Author |
Message |
Mesum
Useless
![](modules/Forums/images/avatars/180c055e41aaf0a475312.gif)
Joined: Aug 23, 2002
Posts: 213
Location: Chicago
|
Posted:
Fri Mar 04, 2005 4:25 pm |
|
Let's face it, if you run a busy website, you don't upgrade your PHP-Nuke powered site every month. You may apply the security and bugs fix files by chatserv from http://www.nukeresouces.com but that's about it.
How server intense is your website? How many members? How many members? How many % of your members are active? Do you have an active forum? What have you done to make your website run a little or a lot faster? Does your site ever crashes because of load? If it does, for what reasons? Are you on a dedicated server or a shared (a webhosting account)?
I want to make this thread with all the information I found over the internet and personally and make it a documetation for future.
2 Version will be used for example in this thread:
7.4, because I believe all the site running for 6.5 to 7.4 can use those hacks without breaking anything.
7.6, because of new structure of PHP-Nuke to handle admins and modules.
First thing first: The oldest and most popular speed hacks in mainfile.php by DJMaze, Steven111, Telli and others seems to work well for many site owners.
Please see my next post.
Please note that I am trying to make an How-To type of thread so please don't post stuff like "I can't get this thing to work", "What files need to get edited?" or "I can't find line XXXX in file XXXX" as all of these codes I and others are going to post have proven to speed up PHP-Nuke powered website and are being used by many.
Thank you. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Mesum
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 05, 2005 3:49 am |
|
Sorry for the late follow-up post, my fiance had a little fever.
Anyways, here is the first speed hack by Steven111: http://www.windowsforumz.com , DJMaze: http://www.cpgnuke.com , Raven: http://www.ravenphpscripts.com and Telli: http://www.codezwiz.com
This hack can be applied to all PHP-Nuke versions 6.5 and above.
Open root/mainfile.php and replace these functions:
(Note: Above code is the actual code you can find in mainfile.php and bottom one is replacement. I am posting it as actual code, code to replace, actual code, code to replace to keep it as easy as possible for everyone)
Code:function is_admin($admin) {
global $prefix, $db;
if(!is_array($admin)) {
$admin = base64_decode($admin);
$admin = addslashes($admin);
$admin = explode(":", $admin);
$aid = addslashes($admin[0]);
$pwd = "$admin[1]";
} else {
$aid = addslashes($admin[0]);
$pwd = "$admin[1]";
}
if ($aid != "" AND $pwd != "") {
$aid = substr("$aid", 0,25);
$result = $db->sql_query("SELECT pwd FROM ".$prefix."_authors WHERE aid='$aid'");
$row = $db->sql_fetchrow($result);
$pass = $row['pwd'];
if($pass == $pwd && $pass != "") {
return 1;
}
}
return 0;
}
|
Code: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;
}
|
Code:function is_user($user) {
global $prefix, $db, $user_prefix;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
$uid = "$user[0]";
$pwd = "$user[2]";
} else {
$uid = "$user[0]";
$pwd = "$user[2]";
}
$uid = addslashes($uid);
$uid = intval($uid);
if ($uid != "" AND $pwd != "") {
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if($pass == $pwd && $pass != "") {
return 1;
}
}
return 0;
}
|
Code: 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;
}
|
Code: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;
}
}
|
Code: 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;
}
|
Code: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);
}
}
|
Code: 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);
}
|
Code: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;
}
|
Code: 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);
}
|
2 functions
Code:function formatAidHeader($aid) {
global $prefix, $db;
$result = $db->sql_query("SELECT url, email FROM ".$prefix."_authors WHERE aid='$aid'");
$row = $db->sql_fetchrow($result);
$url = stripslashes($row['url']);
$email = stripslashes($row['email']);
if ((isset($url)) && ($url != "http://")) {
$aid = "<a href=\"$url\">$aid</a>";
} elseif (isset($email)) {
$aid = "<a href=\"mailto:$email\">$aid</a>";
} else {
$aid = $aid;
}
echo "$aid";
}
function get_author($aid) {
global $prefix, $db;
$result = $db->sql_query("SELECT url, email FROM ".$prefix."_authors WHERE aid='$aid'");
$row = $db->sql_fetchrow($result);
$url = stripslashes($row['url']);
$email = stripslashes($row['email']);
if ((isset($url)) && ($url != "http://")) {
$aid = "<a href=\"$url\">$aid</a>";
} elseif (isset($email)) {
$aid = "<a href=\"mailto:$email\">$aid</a>";
} else {
$aid = $aid;
}
return($aid);
}
|
Are being replaced by one:
Code: 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;
}
|
Code:function get_theme() {
global $user, $cookie, $Default_Theme;
if(is_user($user)) {
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$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;
}
return($ThemeSel);
}
|
Code: 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);
}
|
Next, I will post speed tweaks made by Bob from NSN and were included in chatserv's bugs and seurity patch series 2.8 and above. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Mesum
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 19, 2005 4:24 pm |
|
Hmm, it seems that I forgot about this topic.
Anyways, back to the topic:
Credits: Bob Marion: http://www.nukescripts.net , Raven: http://www.ravenphpscripts.com and chatserv: http://www.nukeresources.com
Admin Files:
Nuke 7.6:
Find:
Code:if (!eregi("".$admin_file.".php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied"); }
|
Change it to:
Code:if (!stristr($_SERVER['SCRIPT_NAME'], "".$admin_file.".php")) { die ("Access Denied"); }
|
Previous Nuke Versions:
Find:
Code:if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied"); }
|
Change it to:
Code:if (!stristr($_SERVER['SCRIPT_NAME'], "admin.php")) { die ("Access Denied"); }
|
***************************************************
The rest of this tweak can be applied to ALL PHP-Nuke versions. If you are using chatserv's patches, you do not need to apply these patches, only to those modules, add-ons or blocks that didn't come with core of PHP-Nuke.
***************************************************
Blocks:
Find:
Code:if (eregi("block-BLOCK_NAME.php", $_SERVER['SCRIPT_NAME'])) {
|
Chage it to:
Code:if (stristr($_SERVER['SCRIPT_NAME'], "block-BLOCK_NAME.php")) {
|
Includes:
(counter.php - javascript.php - meta.php and sql_layer.php)
Find:
Code:if (eregi("FILE_NAME.php", $_SERVER['SCRIPT_NAME'])) {
|
Chage it to:
Code:if (stristr($_SERVER['SCRIPT_NAME'], "FILE_NAME.php")) {
|
Modules
(All php files as long as they include the line described below)
Find:
Code:if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
|
Chage it to:
Code:if (!stristr($_SERVER['SCRIPT_NAME'], "modules.php")) {
|
Main files:
(auth.php - config.php - footer.php - header.php and mainfile.php)
Find:
Code:if (eregi("FILE_NAME.php", $_SERVER['SCRIPT_NAME'])) {
|
Change it to:
Code:if (stristr($_SERVER['SCRIPT_NAME'], "FILE_NAME.php")) {
|
This tweak does speedup your PHP-Nuke but you won't see a whole a lot of difference unless you are running a busy site, From what it seems that it did help me reduce server load a bit but can't say that for sure as I am on a shared server with some people messing up with their website and code all the time.
Up Next:
Working with core files, use them with your needs. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Mesum
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 19, 2005 6:59 pm |
|
Points System: If you don't use it, disable it and save some queries and server load!
UPDATE!!! This tweak is still under progress!!!
I couldn't helping noticing that since 7.0 PHP-Nuke uses a point system to reward users points on different things they do on site. Great, if you actually use that system but if you are not using it, PHP-Nuke still tries to record the points every time a user moves from page A to B (correction is needed if I am wrong)
What we do? We add a swtich to disable this function completely when not using it.
Files that need to change: 3 (config.php, mainfile.php and includes/counter.php)
Credits: chatserv: http://www.nukeresources.com , unknown: http://www.scriptsheaven.com and Me: http://www.chicagobase.com
Open config.php:
Find:
Add right under it:
Code://Points System Swtich. (1 = On, 0 = Off)
$pswitch = 0;
|
Open mainfile.php and find these 2 functions (They both are next to each other)
Code:function is_group($user, $name) {
global $prefix, $db, $user_prefix;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
$uid = "$user[0]";
$pwd = "$user[2]";
} else {
$uid = "$user[0]";
$uid = intval($uid);
$pwd = "$user[2]";
}
if ($uid != "" AND $pwd != "") {
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if($pass == $pwd && $pass != "") {
$result2 = $db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row2 = $db->sql_fetchrow($result2);
$points = intval($row2['points']);
$result3 = $db->sql_query("SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'");
$row3 = $db->sql_fetchrow($result3);
$mod_group = $row3['mod_group'];
$result4 = $db->sql_query("SELECT points FROM ".$prefix."_groups WHERE id='$mod_group'");
$row4 = $db->sql_fetchrow($result4);
$grp = intval($row4['points']);
if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
return 1;
}
}
}
return 0;
}
function update_points($id) {
global $user_prefix, $prefix, $db, $user;
if (is_user($user)) {
if(!is_array($user)) {
$user1 = base64_decode($user);
$user1 = addslashes($user1);
$user1 = explode(":", $user1);
$username = "$user1[1]";
} else {
$username = "$user1[1]";
}
if ($db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_groups")) > '0') {
$id = intval($id);
$result = $db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='$id'");
$row = $db->sql_fetchrow($result);
$rpoints = intval($row['points']);
$db->sql_query("UPDATE ".$user_prefix."_users SET points=points+" . $rpoints . " WHERE username='$username'");
}
}
}
|
And change them to:
Code:global $pswitch;
if ($pswitch == '1') {
function is_group($user, $name) {
global $prefix, $db, $user_prefix;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
$uid = "$user[0]";
$pwd = "$user[2]";
} else {
$uid = "$user[0]";
$uid = intval($uid);
$pwd = "$user[2]";
}
if ($uid != "" AND $pwd != "") {
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if($pass == $pwd && $pass != "") {
$result2 = $db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row2 = $db->sql_fetchrow($result2);
$points = intval($row2['points']);
$result3 = $db->sql_query("SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'");
$row3 = $db->sql_fetchrow($result3);
$mod_group = $row3['mod_group'];
$result4 = $db->sql_query("SELECT points FROM ".$prefix."_groups WHERE id='$mod_group'");
$row4 = $db->sql_fetchrow($result4);
$grp = intval($row4['points']);
if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
return 1;
}
}
}
return 0;
}
function update_points($id) {
global $user_prefix, $prefix, $db, $user;
if (is_user($user)) {
if(!is_array($user)) {
$user1 = base64_decode($user);
$user1 = explode(":", $user1);
$username = "$user1[1]";
} else {
$username = "$user1[1]";
}
if ($db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_groups")) > '0') {
$row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='$id'"));
$rpoints = $row['points'];
$db->sql_query("UPDATE ".$user_prefix."_users SET points=points+" . $rpoints . " WHERE username='$username'");
}
}
}
}
|
Open includes/counter.php
Find:
Code:global $prefix, $db;
|
Chage it to:
Code:global $prefix, $db, $pswitch;
|
Find:
Code:/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
update_points(13);
/* Start Detailed Statistics */
|
Change it to:
Code:/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
if ($pswitch == '1') {
update_points(13);
}
/* Start Detailed Statistics */
|
Savings: One less query per page and less server load (I think) |
Last edited by Mesum on Sat Mar 19, 2005 7:41 pm; edited 2 times in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Mesum
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 19, 2005 7:27 pm |
|
Did you know that default PHP-Nuke Survey block takes 29 queries and Does not check if a person has already vote or not?
2 solutions:
A: Use Forums Survey module by Jeff (AKA JRSweets) from http://www.jeffrusso.net.
Pros: The block takes only 3 queries.
You can pick random surveys from Forums.
Permissions can be set from admin panel.
GPL.
Works with any 6.5+ version of PHP-Nuke.
Cons: Still in Beta.
You going to apply few fixes from his site's forums.
Too many files to upload.
Few optional edits into core files.
B: Use CZ Enhanced Survey Block by Telli from http://www.codezwiz.com.
Pros: 4 queries also works like it is supposed to.
Stores the ip and doesnt allow them to vote for a set amount of time (configurable in the block)
Can be set to run random polls (configurable in the block).
Will work in any Nuke Version that is using the Survey Module.
Cons: You can not configure from admin panel.
Not GPL but free.
Savings: 26 to 25 queries per page where block is visible. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Isaiah
Hangin' Around
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Nov 09, 2004
Posts: 32
|
Posted:
Tue Dec 13, 2005 8:41 am |
|
Mesum wrote: | Points System: If you don't use it, disable it and save some queries and server load!
UPDATE!!! This tweak is still under progress!!!
I couldn't helping noticing that since 7.0 PHP-Nuke uses a point system to reward users points on different things they do on site. Great, if you actually use that system but if you are not using it, PHP-Nuke still tries to record the points every time a user moves from page A to B (correction is needed if I am wrong)
What we do? We add a swtich to disable this function completely when not using it.
Files that need to change: 3 (config.php, mainfile.php and includes/counter.php)
Credits: chatserv: http://www.nukeresources.com , unknown: http://www.scriptsheaven.com and Me: http://www.chicagobase.com
Open config.php:
Find:
Add right under it:
Code://Points System Swtich. (1 = On, 0 = Off)
$pswitch = 0;
|
Open mainfile.php and find these 2 functions (They both are next to each other)
Code:function is_group($user, $name) {
global $prefix, $db, $user_prefix;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
$uid = "$user[0]";
$pwd = "$user[2]";
} else {
$uid = "$user[0]";
$uid = intval($uid);
$pwd = "$user[2]";
}
if ($uid != "" AND $pwd != "") {
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if($pass == $pwd && $pass != "") {
$result2 = $db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row2 = $db->sql_fetchrow($result2);
$points = intval($row2['points']);
$result3 = $db->sql_query("SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'");
$row3 = $db->sql_fetchrow($result3);
$mod_group = $row3['mod_group'];
$result4 = $db->sql_query("SELECT points FROM ".$prefix."_groups WHERE id='$mod_group'");
$row4 = $db->sql_fetchrow($result4);
$grp = intval($row4['points']);
if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
return 1;
}
}
}
return 0;
}
function update_points($id) {
global $user_prefix, $prefix, $db, $user;
if (is_user($user)) {
if(!is_array($user)) {
$user1 = base64_decode($user);
$user1 = addslashes($user1);
$user1 = explode(":", $user1);
$username = "$user1[1]";
} else {
$username = "$user1[1]";
}
if ($db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_groups")) > '0') {
$id = intval($id);
$result = $db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='$id'");
$row = $db->sql_fetchrow($result);
$rpoints = intval($row['points']);
$db->sql_query("UPDATE ".$user_prefix."_users SET points=points+" . $rpoints . " WHERE username='$username'");
}
}
}
|
And change them to:
Code:global $pswitch;
if ($pswitch == '1') {
function is_group($user, $name) {
global $prefix, $db, $user_prefix;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
$uid = "$user[0]";
$pwd = "$user[2]";
} else {
$uid = "$user[0]";
$uid = intval($uid);
$pwd = "$user[2]";
}
if ($uid != "" AND $pwd != "") {
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row = $db->sql_fetchrow($result);
$pass = $row['user_password'];
if($pass == $pwd && $pass != "") {
$result2 = $db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE user_id='$uid'");
$row2 = $db->sql_fetchrow($result2);
$points = intval($row2['points']);
$result3 = $db->sql_query("SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'");
$row3 = $db->sql_fetchrow($result3);
$mod_group = $row3['mod_group'];
$result4 = $db->sql_query("SELECT points FROM ".$prefix."_groups WHERE id='$mod_group'");
$row4 = $db->sql_fetchrow($result4);
$grp = intval($row4['points']);
if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
return 1;
}
}
}
return 0;
}
function update_points($id) {
global $user_prefix, $prefix, $db, $user;
if (is_user($user)) {
if(!is_array($user)) {
$user1 = base64_decode($user);
$user1 = explode(":", $user1);
$username = "$user1[1]";
} else {
$username = "$user1[1]";
}
if ($db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_groups")) > '0') {
$row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='$id'"));
$rpoints = $row['points'];
$db->sql_query("UPDATE ".$user_prefix."_users SET points=points+" . $rpoints . " WHERE username='$username'");
}
}
}
}
|
Open includes/counter.php
Find:
Code:global $prefix, $db;
|
Chage it to:
Code:global $prefix, $db, $pswitch;
|
Find:
Code:/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
update_points(13);
/* Start Detailed Statistics */
|
Change it to:
Code:/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
if ($pswitch == '1') {
update_points(13);
}
/* Start Detailed Statistics */
|
Savings: One less query per page and less server load (I think) |
What about to remove even the Counter?
It will be faster i think, and it is not such important, as you can see the sites hits/etc... from your cpanel... |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|