|
10.02.2006, 23:07
7. Обновим функцию проверки на активность модуля и функции, работающие с блоками, находим:
PHP код:
function is_active($module) { global $prefix, $db; $module = trim($module); $result = $db->sql_query("SELECT active FROM ".$prefix."_modules WHERE title='$module'"); $row = $db->sql_fetchrow($result); $act = intval($row['active']); if (!$result OR $act == 0) { return 0; } else { return 1; } } function render_blocks($side, $blockfile, $title, $content, $bid, $url) { if ($url == "") { if ($blockfile == "") { if ($side == "c") { themecenterbox($title, $content); } elseif ($side == "d") { themecenterbox($title, $content); } else { themesidebox($title, $content); } } else { if ($side == "c") { blockfileinc($title, $blockfile, 1); } elseif ($side == "d") { blockfileinc($title, $blockfile, 1); } else { blockfileinc($title, $blockfile); } } } else { if ($side == "c" OR $side == "d") { headlines($bid,1); } else { headlines($bid); } } } function blocks($side) { global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user; 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; $sql = "SELECT bid, bkey, title, content, url, blockfile, view, expire, action, subscription FROM ".$prefix."_blocks WHERE bposition='$pos' AND active='1' $querylang ORDER BY weight ASC"; $result = $db->sql_query($sql); while($row = $db->sql_fetchrow($result)) { $bid = intval($row['bid']); $title = filter($row['title'], nohtml); $content = $row['content']; $url = filter($row['url'], nohtml); $blockfile = filter($row['blockfile'], nohtml); $view = intval($row['view']); $expire = intval($row['expire']); $action = filter($row['action'], nohtml); $action = substr("$action", 0,1); $now = time(); $sub = intval($row['subscription']); 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 ($row[bkey] == admin) { adminblock(); } elseif ($row[bkey] == userbox) { userblock(); } elseif ($row[bkey] == "") { 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); } } } } }
Заменяем на:
PHP код:
// Copyright Soniks http://mynuke.ru function is_active($module) { global $modules_info; $module = trim($module); $act = intval($modules_info[$module]['active']); if ($act == 1) { return 1; } else { return 0; } } // Copyright Soniks http://mynuke.ru function render_blocks($side, $blockinfo) { if ($blockinfo['url'] == "") { if ($blockinfo['blockfile'] == "") { if ($side == "c") { themecenterbox($blockinfo['title'], $blockinfo['content']); } elseif ($side == "d") { themecenterbox($blockinfo['title'], $blockinfo['content']); } else { themesidebox($blockinfo['title'], $blockinfo['content']); } } else { if ($side == "c") { blockfileinc($blockinfo['title'], $blockinfo['blockfile'], 1); } elseif ($side == "d") { blockfileinc($blockinfo['title'], $blockinfo['blockfile'], 1); } else { blockfileinc($blockinfo['title'], $blockinfo['blockfile']); } } } else { if ($side == "c" OR $side == "d") { headlines($blockinfo,1); } else { headlines($blockinfo); } } } // Copyright Soniks http://mynuke.ru function blocks($side) { global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user, $block_info; if(!is_array($block_info) or empty($block_info)){ $block_info = array(); if ($multilingual == 1) { $querylang = "AND (blanguage='$currentlang' OR blanguage='')"; } else { $querylang = ""; } $result = $db->sql_query("SELECT bid, bkey, title, content, url, bposition, weight, blockfile, view, expire, action, subscription, refresh, time FROM ".$prefix."_blocks WHERE active='1' $querylang ORDER BY bposition, weight ASC"); while($row = $db->sql_fetchrow($result)) { $bid = intval($row['bid']); $bkey = filter($row['bkey'], nohtml); $title = filter($row['title'], nohtml); $content = $row['content']; $url = filter($row['url'], nohtml); $blockfile = filter($row['blockfile'], nohtml); $view = intval($row['view']); $expire = intval($row['expire']); $action = filter($row['action'], nohtml); $action = substr("$action", 0,1); $sub = intval($row['subscription']); $refresh = intval($row['refresh']); $time = intval($row['time']); $block_info[$row['bposition']][] = array('bid'=>$bid, 'bkey'=>$bkey, 'title'=>$title, 'content'=>$content, 'url'=>$url, 'blockfile'=>$blockfile, 'view'=>$view, 'expire'=>$expire, 'action'=>$action, 'subscription'=>$sub, 'refresh'=>$refresh, 'time'=>$time); } } 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($block_info[$side]){ foreach($block_info[$side] as $value) { $bid = $value['bid']; $bkey = $value['bkey']; $view = $value['view']; $expire = $value['expire']; $action = $value['action']; $now = time(); $sub = $value['subscription']; 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 ($bkey == "admin") { adminblock($value); } elseif ($bkey == "userbox") { userblock(); } elseif ($bkey == "") { if ($view == 0) { render_blocks($side, $value); } elseif ($view == 1 AND is_user($user) || is_admin($admin)) { render_blocks($side, $value); } elseif ($view == 2 AND is_admin($admin)) { render_blocks($side, $value); } elseif ($view == 3 AND !is_user($user) || is_admin($admin)) { render_blocks($side, $value); } } } } } }
8. Облегчим функцию, отвечающая за сессии, находим:
PHP код:
function online() { global $user, $cookie, $prefix, $db; cookiedecode($user); $ip = $_SERVER["REMOTE_ADDR"]; $uname = $cookie[1]; if (!isset($uname)) { $uname = "$ip"; $guest = 1; } $past = time()-300; $db->sql_query("DELETE FROM ".$prefix."_session WHERE time < '$past'"); $result = $db->sql_query("SELECT time FROM ".$prefix."_session WHERE uname='$uname'"); $ctime = time(); if ($uname!="") { $uname = substr("$uname", 0,25); if ($row = $db->sql_fetchrow($result)) { $db->sql_query("UPDATE ".$prefix."_session SET uname='$uname', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$uname'"); } else { $db->sql_query("INSERT INTO ".$prefix."_session (uname, time, host_addr, guest) VALUES ('$uname', '$ctime', '$ip', '$guest')"); } } }
Заменяем на:
PHP код:
// Copyright Soniks http://mynuke.ru function online() { global $user, $prefix, $db, $userinfo; $ip = $_SERVER["REMOTE_ADDR"]; $guest = 0; $uname = $userinfo['username']; if (!$uname) { $uname = "$ip"; $guest = 1; } $past = time()-300; $db->sql_query("DELETE FROM ".$prefix."_session WHERE time < '$past' OR uname='".addslashes($uname)."'"); $ctime = time(); if ($uname!="") { $uname = substr("$uname", 0,25); $db->sql_query("INSERT INTO ".$prefix."_session (uname, time, host_addr, guest) VALUES ('$uname', '$ctime', '$ip', '$guest')"); } }
Так же выполняем SQL-запрос в phpMyAdmin:
Код:
DROP TABLE IF EXISTS `nuke_session`;
CREATE TABLE `nuke_session` (
`uname` varchar(25) NOT NULL default '',
`time` varchar(14) NOT NULL default '',
`host_addr` varchar(48) NOT NULL default '',
`guest` int(1) NOT NULL default '0',
KEY `time` (`time`),
KEY `guest` (`guest`)
) TYPE=HEAP;
не забываем в запросе заменить префиксы nuke_ на свои!
|
|