Knowledge Base Navigation
Articles: 51 Categories: 8
KB Article: SpeedUp mainfile.php functions
Article: | SpeedUp mainfile.php functions |
Submitted By: | Telli |
Date Added: | 11-25-2004 3:09:42 |
Hits: | 9,435 |
How to drop seconds off your PHP Nuke site load times.
Find and replace these functions in your mainfile.php. Make a backup incase of any problems. This was tested on PHP Nuke up to 7.6. If your using CZEnhanced 7.0 these are allready applied.
function is_active($module) {
global $prefix, $db; static $save; if (is_array($save)) { if (isset($save[$module])) return ($save[$module]); return 0; } $sql = "SELECT title FROM ".$prefix."_modules WHERE active=1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $save[$row[0]] = 1; } if (isset($save[$module])) return ($save[$module]); return 0; }
function getusrinfo($user) {
global $user_prefix, $db, $userinfo; static $userrow; if (!$user || $user == '') { return NULL; } if(!is_array($user)) { $user = base64_decode($user); $user = explode(":", $user); } if (is_array($userrow)) { if ($userrow['username'] == $user[1] && $userrow['user_password'] = $user[2]) { return $userrow; } } $sql = "SELECT * FROM ".$user_prefix."_users WHERE username='$user[1]' AND user_password='$user[2]'"; $result = $db->sql_query($sql); if ($db->sql_numrows($result) == 1) { $userrow = $db->sql_fetchrow($result); return $userinfo = $userrow; } unset($userinfo); }
function cookiedecode($user) {
global $cookie, $db, $user_prefix; static $pass; if(!is_array($user)) { $user = base64_decode($user); $cookie = explode(":", $user); } else { $cookie = $user; } if (!isset($pass)) { $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE username='$cookie[1]'"; $result = $db->sql_query($sql); list($pass) = $db->sql_fetchrow($result); } if ($cookie[2] == $pass && $pass != "") { return $cookie; } unset($user); unset($cookie); }
function get_theme() {
global $user, $cookie, $Default_Theme; static $ThemeSelSave; if (isset($ThemeSelSave)) return ($ThemeSelSave); if(is_user($user)) { $user2 = base64_decode($user); $t_cookie = explode(":", $user2); if($t_cookie[9]=="") $t_cookie[9]=$Default_Theme; if(isset($theme)) $t_cookie[9]=$theme; if(!$tfile=@opendir("themes/$t_cookie[9]")) { $ThemeSel = $Default_Theme; } else { $ThemeSel = $t_cookie[9]; } } else { $ThemeSel = $Default_Theme; } $ThemeSelSave = $ThemeSel; return($ThemeSel); }
function is_admin($admin) {
global $prefix, $db; static $adminSave; if (isset($adminSave)) return ($adminSave); //steve 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; }
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; }
function formatAidHeader($aid) {
echo get_author($aid); } function get_author($aid) { global $prefix, $db; static $users; if (is_array($users[$aid])) { $row = $users[$aid]; } else { $sql = "SELECT url, email FROM ".$prefix."_authors WHERE aid='$aid'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $users[$aid] = $row; } if (isset($row['url'])) { $aid = "<a href=\"$row[url]\">$aid</a>"; } elseif (isset($row['email'])) { $aid = "<a href=\"mailto:$row[email]\">$aid</a>"; } else { $aid = $aid; } return $aid; } |
Current rating: 9.60 by 407 users
Please take one second and rate this article... |
Not a Chance | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Absolutely |
Please register or sign-in to post comments.