Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel(tm)
Author Message
menelaos61
Worker
Worker



Joined: Nov 10, 2004
Posts: 110

PostPosted: Sat Nov 20, 2004 9:17 am Reply with quote

Hi Raven,
In /includes/sentinel.php
you use:
Code:
$checkrow = $db->sql_fetchrow($db->sql_query("CHECK TABLE ".$prefix."_nsnst_ip2country"));
to see is the IP2Country module is installed.
Also it checks if the table has been proberly closed.

I discovered that this is a rather slow query. Faster would be:
Code:
$checkrow = $db->sql_fetchrow($db->sql_query("CHECK TABLE ".$prefix."_nsnst_ip2country QUICK"));
In this way not the entire the table would be checked, enough to see if it exists.

But even faster would be to use:
Code:
$checkrow = $db->sql_fetchrow($db->sql_query("SHOW TABLES LIKE '".$prefix."_nsnst_ip2country%'"));


Or is it that you want to build in a complete table check on purpose?
What do you think of these ideas?

Cheers,
Richard
 
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Nov 20, 2004 10:33 am Reply with quote

Quote:
Or is it that you want to build in a complete table check on purpose?

I don't believe so. I'll pass this by Bob Marion (the chief developer) and make sure. Thanks so much for the suggestion!
 
View user's profile Send private message
BobMarion
Former Admin in Good Standing



Joined: Oct 30, 2002
Posts: 1037
Location: RedNeck Land (known as Kentucky)

PostPosted: Sat Nov 20, 2004 3:45 pm Reply with quote

I'll update the codes to use the fastest one. We're just checking to see if the table is there as if it's not then IP2C ins't installed Smile

_________________
Bob Marion
Codito Ergo Sum
http://www.nukescripts.net 
View user's profile Send private message Send e-mail Visit poster's website
Raven







PostPosted: Sat Nov 20, 2004 6:12 pm Reply with quote

Take the % (wildcard) of the end. Improves the chance that the index will be used.
 
menelaos61







PostPosted: Mon Nov 22, 2004 9:29 am Reply with quote

The 'slow' query is actually used in:
\admin\modules\sentinel\ABDBOptimize.php
\admin\modules\sentinel\ABDBRepair.php
\admin\modules\sentinel\ABDBStructure.php
\admin\modules\sentinel\ABSearchUsers.php
\admin\modules\sentinel\functions.php
\includes\sentinel.php

But of course the most important place to improve it would be in sentinel.php

Cheers,
Richard Smile
 
menelaos61







PostPosted: Mon Nov 22, 2004 10:55 am Reply with quote

further on (to reduce querytime of sentinel.php)

The get_ip() is called by the proxy blocker as well as in the 'Basic Value Setup'
This results in the in_range() function to be called twice and thus the query:
Code:
SELECT * FROM nuke_nsnst_reserved_ranges WHERE ip_lo<='1234567890' AND ip_hi>='1234567890'

to be run twice.

I'm not that much into sentinel.php to oversee the concequenses of the following change right now, but it should be possible to move the proxy-section to after the 'basic value'-section
and change:
Code:
$proxy0 = get_ip();

to
Code:
$proxy0 = $remote;


If this is too drastically, another change would undoubtly be possible Smile

Cheers!
Richard Wink
 
menelaos61







PostPosted: Mon Nov 22, 2004 3:43 pm Reply with quote

It just doesn't stop. But as long as I'm in the flow I guess I'll keep on posting on this. (Maybe this topic should move to enhancement requests)

Anyway, I found another way to reduce the ammount of queries that sentinel.php executes (this time quite drastically).

in sentinel.php
[FIND]
Code:
// AUTHOR Protection

[BEFORE ADD:]
Code:
$result = $db->sql_query("SELECT * FROM ".$prefix."_nsnst_blockers");

$num_rows = $db->sql_numrows($result);
for ($i = 0; $i < $num_rows; $i++) {
$array[$i] = mysql_fetch_array($result);
}
$arrayother = $array[0];
$arrayunion = $array[1];
$arrayclike = $array[2];
$arrayharvester = $array[3];
$arrayscript   = $array[4];
$arrayauthor   = $array[5];
$arrayreferer = $array[6];
$arrayfilter   = $array[7];
$arrayrequest = $array[8];
$arraystring   = $array[9];
$arrayadmin = $array[10];


aditionally, change the folowing line in the different blocker-sections from:
Code:
$blocker_row = abget_blocker("author");
to:
Code:
$blocker_row = $arrayauthor;


(for example, change:
Code:
$blocker_row = abget_blocker("admin");
to:
Code:
$blocker_row = $arrayadmin;


The identifier-names $arrayadmin,$arrayauthors, etcetera are only used for ease of use here. The code could also be changed to:
Code:
$blocker_row = $array[10];
instead of:
Code:
$blocker_row = $arrayadmin;
.

The result of these changes is that instead of the folowing queries:
Quote:

SELECT * FROM nuke_nsnst_blockers WHERE block_name='author'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='admin'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='union'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='clike'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='filter'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='script'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='referer'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='harvester'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='string'
SELECT * FROM nuke_nsnst_blockers WHERE block_name='request'
only the folowing is executed:
Quote:
SELECT * FROM nuke_nsnst_blockers


Raven & Bob, I wonder if this is interesting for Sentinel or if there were explicit (security) reasons to code otherwise.

Cheers from a cloudy & wet Holland,
Richard Smile
 
BobMarion







PostPosted: Mon Nov 22, 2004 5:23 pm Reply with quote

Great ideas Smile
 
Raven







PostPosted: Mon Nov 22, 2004 7:40 pm Reply with quote

Would you please send me (email) your 'enhanced' sentinel.php file? I want to test your changes. Thanks!
 
menelaos61







PostPosted: Tue Nov 23, 2004 5:20 pm Reply with quote

Hi Raven,
Did you check my sentinel.php in you pm-box?
I wonder if you checked it out.

cheers,
Richard Smile
 
Raven







PostPosted: Tue Nov 23, 2004 5:55 pm Reply with quote

I am testing it as I have time Smile
 
menelaos61







PostPosted: Tue Nov 23, 2004 6:07 pm Reply with quote

you win SmileWinkSmile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel(tm)

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©