|
14.01.2006, 11:27
Andruha Можно попробывать заменить несколько функций в файле mainfile большого снижения нагрузки не обещаю но всеже!
Открываем mainfile.php
Находим функцию:
PHP код:
function is_admin($admin) {
Заменяем на:
PHP код:
function is_admin($admin) {
global $prefix, $db;
static $adminSave;
if (isset($adminSave)) return ($adminSave);
if(!is_array($admin)) {
$admin = base64_decode($admin);
$admin = explode(":", $admin);
}
$aid = $admin[0];
$pwd = $admin[1];
if ($aid != "" AND $pwd != "") {
$aid = trim($aid);
$sql = "SELECT pwd FROM ".$prefix."_authors WHERE aid='$aid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$pass = $row['pwd'];
if ($pass == $pwd && $pass != "") {
return $adminSave = 1;
}
}
return $adminSave = 0;
}
Далее находим:
PHP код:
function is_user($user) {
Заменяем на:
PHP код:
function is_user($user) {
global $db, $user_prefix;
static $userSave;
if (isset($userSave)) return ($userSave);
if (!is_array($user)) {
$user = base64_decode($user);
$user = explode(":", $user);
}
$uid = $user[0];
$pwd = $user[2];
$uid = intval($uid);
if ($uid != "" AND $pwd != "") {
$sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if ($pass == $pwd && $pass != "") {
return $userSave = 1;
}
}
return $userSave = 0;
}
Далее находим:
Заменяем на:
PHP код:
function blocks($side) {
global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user;
static $barr;
if ($multilingual == 1) {
$querylang = "AND (blanguage='$currentlang' OR blanguage='')";
} else {
$querylang = "";
}
if (strtolower($side[0]) == "l") {
$pos = "l";
} elseif (strtolower($side[0]) == "r") {
$pos = "r";
} elseif (strtolower($side[0]) == "c") {
$pos = "c";
} elseif (strtolower($side[0]) == "d") {
$pos = "d";
}
$side = $pos;
if (!isset($barr)){
$sql = "SELECT bid, bkey, title, content, url, blockfile, view, expire, action, subscription, bposition FROM ".$prefix."_blocks WHERE active='1' $querylang ORDER BY weight ASC";
$result = $db->sql_query($sql);
while(list($bid, $bkey, $title, $content, $url, $blockfile, $view, $expire, $action, $subscription, $bposition) = $db->sql_fetchrow($result)) {
$bid = intval($bid);
$view = intval($view);
$barr[]= array($bid, $bkey, $title, $content, $url, $blockfile, $view, $expire, $action, $subscription, $bposition);
}
}
for ($i=0; $i<sizeof($barr); $i++){
list ($bid, $bkey, $title, $content, $url, $blockfile, $view, $expire, $action, $subscription, $bposition)=$barr[$i];
if ($bposition==$side){
$now = time();
if ($sub == 0 OR ($sub == 1 AND !paid())) {
if ($expire != 0 AND $expire <= $now) {
if ($action == "d") {
$db->sql_query("UPDATE ".$prefix."_blocks SET active='0', expire='0' WHERE bid='$bid'");
return;
} elseif ($action == "r") {
$db->sql_query("DELETE FROM ".$prefix."_blocks WHERE bid='$bid'");
return;
}
}
if ($view == 0) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 2 AND is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
}
}
}
}
}
Вот вобщем это минимум что можно зделать!
|
|