|
10.02.2006, 23:21
9. Облегчим функции, отвечающие за Ultramode (вывод заголовков новостей), информацию о пользователе по cookie и информация о пользователе из БД, находим:
PHP код:
function ultramode() { global $prefix, $db; $ultra = "ultramode.txt"; $file = fopen("$ultra", "w"); fwrite($file, "General purpose self-explanatory file with news headlines\n"); $result = $db->sql_query("SELECT sid, aid, title, time, comments, topic FROM ".$prefix."_stories ORDER BY time DESC LIMIT 0,10"); while ($row = $db->sql_fetchrow($result)) { $rsid = intval($row['sid']); $raid = filter($row['aid'], nohtml); $rtitle = filter($row['title'], nohtml); $rtime = $row['time']; $rcomments = intval($row['comments']); $rtopic = intval($row['topic']); $row2 = $db->sql_fetchrow($db->sql_query("select topictext, topicimage from ".$prefix."_topics where topicid='$rtopic'")); $topictext = filter($row2['topictext'], nohtml); $topicimage = filter($row2['topicimage'], nohtml); $content = "%%\n$rtitle\n/modules.php?name=News&file=article&sid=$rsid\n$rtime\n$raid\n$topictext\n$rcomments\n $topicimage\n"; fwrite($file, $content); } fclose($file); } function cookiedecode($user) { global $cookie, $prefix, $db, $user_prefix; $user = base64_decode($user); $user = addslashes($user); // $user = htmlentities($user, ENT_QUOTES); $cookie = explode(":", $user); $result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE username='$cookie[1]'"); $row = $db->sql_fetchrow($result); $pass = $row['user_password']; if ($cookie[2] == $pass && $pass != "") { return $cookie; } else { unset($user); unset($cookie); } } function getusrinfo($user) { global $userinfo, $user_prefix, $db; $user2 = base64_decode($user); $user2 = addslashes($user2); $user3 = explode(":", $user2); $result = $db->sql_query("SELECT * FROM ".$user_prefix."_users WHERE username='$user3[1]' AND user_password='$user3[2]'"); if ($db->sql_numrows($result) == 1) { $userinfo = $db->sql_fetchrow($result); } return $userinfo; }
Заменяем на:
PHP код:
// Copyright Soniks http://mynuke.ru function ultramode() { global $prefix, $db; $ultra = "ultramode.txt"; $file = fopen("$ultra", "w"); fwrite($file, "General purpose self-explanatory file with news headlines\n"); $result = $db->sql_query("SELECT s.sid, s.aid, s.title, s.time, s.comments, t.topictext, t.topicimage FROM ".$prefix."_stories AS s LEFT JOIN ".$prefix."_topics AS t ON(t.topicid=s.topic) ORDER BY s.time DESC LIMIT 0,10"); while ($row = $db->sql_fetchrow($result)) { $rsid = intval($row['sid']); $raid = filter($row['aid'], nohtml); $rtitle = filter($row['title'], nohtml); $rtime = $row['time']; $rcomments = intval($row['comments']); $topictext = filter($row['topictext'], nohtml); $topicimage = filter($row['topicimage'], nohtml); $content = "%%\n$rtitle\n/modules.php?name=News&file=article&sid=$rsid\n$rtime\n$raid\n$topictext\n$rcomments\n $topicimage\n"; fwrite($file, $content); } fclose($file); } //Copyright Soniks http://mynuke.ru function cookiedecode($user) { global $cookie; if(is_user($user)){ $user = base64_decode($user); $user = addslashes($user); $cookie = explode(":", $user); return $cookie; } else { unset($user); unset($cookie); } } //Copyright Soniks http://mynuke.ru function getusrinfo($user) { global $userinfo; return $userinfo; }
10. Немного изменим блок администратора, но по-прежнему он будет производить 7 запросов к БД, такова цена информативности, тем более что это будет только для администратора и поэтому не столь значимо, находим:
PHP код:
function adminblock() { global $admin, $prefix, $db, $admin_file; if (is_admin($admin)) { $result = $db->sql_query("SELECT title, content FROM ".$prefix."_blocks WHERE bkey='admin'"); while ($row = $db->sql_fetchrow($result)) { $row[content] = filter($row[content]); $row[title] = filter($row[title], nohtml); $content = "<font class=\"content\">$row[content]</font>"; themesidebox($row[title], $row[content]); } $title = ""._WAITINGCONT.""; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_queue")); $content = "<font class=\"content\">"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=submissions\">"._SUBMISSIONS."</a>: $num<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_reviews_add")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=reviews\">"._WREVIEWS."</a>: $num<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_newlink")); $brokenl = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='1'")); $modreql = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='0'")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=Links\">"._WLINKS."</a>: $num<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=LinksListModRequests\">"._MODREQLINKS."</a>: $modreql<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=LinksListBrokenLinks\">"._BROKENLINKS."</a>: $brokenl<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_newdownload")); $brokend = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='1'")); $modreqd = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='0'")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=downloads\">"._UDOWNLOADS."</a>: $num<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=DownloadsListModRequests\">"._MODREQDOWN."</a>: $modreqd<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=DownloadsListBrokenDownloads\">"._BROKENDOWN."</a>: $brokend<br></font>"; themesidebox($title, $content); } }
Заменяем на:
PHP код:
//Copyright Soniks http://mynuke.ru function adminblock($blockinfo) { global $admin, $prefix, $db, $admin_file; if (is_admin($admin)) { $content = str_replace("admin.php",$admin_file.".php", $blockinfo['content']); $content = "<font class=\"content\">$content</font>"; themesidebox($blockinfo['title'], $content); $title = ""._WAITINGCONT.""; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_queue")); $content = "<font class=\"content\">"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=submissions\">"._SUBMISSIONS."</a>: $num<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_reviews_add")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=reviews\">"._WREVIEWS."</a>: $num<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_newlink")); $brokenl = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='1'")); $modreql = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='0'")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=Links\">"._WLINKS."</a>: $num<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=LinksListModRequests\">"._MODREQLINKS."</a>: $modreql<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=LinksListBrokenLinks\">"._BROKENLINKS."</a>: $brokenl<br>"; $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_newdownload")); $brokend = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='1'")); $modreqd = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='0'")); $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=downloads\">"._UDOWNLOADS."</a>: $num<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=DownloadsListModRequests\">"._MODREQDOWN."</a>: $modreqd<br>"; $content .= "<strong><big>·</big></strong> <a href=\"".$admin_file.".php?op=DownloadsListBrokenDownloads\">"._BROKENDOWN."</a>: $brokend<br></font>"; themesidebox($title, $content); } }
|
|