|
16.02.2006, 03:06
Оптимизируем блок: Навигация
Открываем blocks/block-Modules.php
И заменяем весь текст, который находиться в том файле на:
PHP код:
<?php if (eregi("block-Modules.php", $_SERVER['PHP_SELF'])) { Header("Location: index.php"); die(); } global $prefix, $db, $admin, $main_module, $modules_info; //Copyright Soniks http://mynuke.ru if(!isset($main_module)){ if(file_exists("./cache/main")){ include_once("./cache/main"); }else{ $row = $db->sql_fetchrow($db->sql_query("SELECT main_module from ".$prefix."_main")); $name = $row['main_module']; $sett ="<?php\n\n"; $sett .="if(!defined('NUKE_FILE'))\n{\n die();\n}\n"; $sett .= '$main_module = "'.$row['main_module'].'";'; $sett .="\n?>"; $fp = fopen ("./cache/main", "wb"); fwrite($fp, $sett); fclose($fp); if(!file_exists("./cache/.htaccess")){ $sett2 ="deny from all"; $fp2 = fopen ("./cache/.htaccess", "wb"); fwrite($fp2, $sett2); fclose($fp2); } } } /* If you're Admin you and only you can see Inactive modules and test it */ /* If the module doesn't exist, it will be removed from the database automaticaly */ /* If you copied a new module is the /modules/ directory, it will be added to the database */ if(is_admin($admin)){ $handle=opendir('modules'); $modlist = array(); while ($file = readdir($handle)) { if ( (!ereg("[.]",$file)) ) $modlist[$file]= "$file"; } closedir($handle); foreach ($modules_info as $title=>$modules_itm) { if($modlist[$title]) unset($modlist[$title]); else { $db->sql_query("DELETE FROM ".$prefix."_modules WHERE title='$title'"); unset($modules_info[$title]); } } if(!empty($modlist)){ foreach($modlist as $modlist_name){ $db->sql_query("INSERT INTO ".$prefix."_modules (mid, title, custom_title, active, view, inmenu, mod_group) VALUES (NULL, '".addslashes($modlist_name)."', '".ereg_replace("_", " ", addslashes($modlist_name))."', '0', '0', '1', '0')"); $modules_info[addslashes($modlist_name)] = array('custom_title' =>ereg_replace("_", " ", addslashes($modlist_name)), 'active'=>0, 'view'=>0, 'inmenu'=>1, 'mod_group'=>0); } } asort($modules_info); $content_admin = "<br><center><b>"._INVISIBLEMODULES."</b><br>"; $content_admin .= "<font class=\"tiny\">"._ACTIVEBUTNOTSEE."</font></center><br>"; $a = 0; $dummy = 0; foreach ($modules_info as $mn_title=>$modules_itms) { if($modules_itms['active'] ==1 and $modules_itms['inmenu']=0 and $m_title != $main_module){ if ($modules_itms['custom_title'] !="") $mn_title2 = $modules_itms['custom_title']; else $mn_title2 = ereg_replace("_", " ", $mn_title); if ($mn_title2 != "") { $content_admin .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n"; $dummy = 1; } else { $a = 1; } } } if ($a == 1 AND $dummy != 1) $content_admin .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n"; $content_admin .= "<br><center><b>"._NOACTIVEMODULES."</b><br>"; $content_admin .= "<font class=\"tiny\">"._FORADMINTESTS."</font></center><br>"; foreach ($modules_info as $mn_title=>$modules_itms) { if($modules_itms['active'] ==0 ){ if ($modules_itms['custom_title'] !="") $mn_title2 = $modules_itms['custom_title']; else $mn_title2 = ereg_replace("_", " ", $mn_title); if ($mn_title2 != "") { $content_admin .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n"; $dummy = 1; } else { $a = 1; } } } if ($a == 1 AND $dummy != 1) $content_admin .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n"; } /* Now we make the Modules block with the correspondent links */ asort($modules_info); $content .= "<strong><big>·</big></strong> <a href=\"index.php\">"._HOME."</a><br>\n"; foreach ($modules_info as $m_title=>$modules_itms) { if($modules_itms['active'] ==1 and $modules_itms['inmenu']=1 and $m_title != $main_module and ((is_admin($admin) and $modules_itms['view'] == 2) or $modules_itms['view'] != 2)){ $m_title2 = ereg_replace("_", " ", $m_title); if ($modules_itms['custom_title'] !="") $m_title2 = $modules_itms['custom_title']; else $m_title2 = ereg_replace("_", " ", $m_title); $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$m_title\">$m_title2</a><br>\n"; } } $content .= $content_admin; ?>
В результате чего, данный блок под пользователем не совершает ни одного запроса.
|
|