Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Making Nuke Efficient
Author Message
BobMarion
Former Admin in Good Standing



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

PostPosted: Sun Dec 05, 2004 11:51 pm Reply with quote

While we were building NukeSentinel 1.0 Raven and I talked about speed for and using stristr where ever possible instead of eregi. Well open every one of your block files and you will see a line like:
Code:
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {


Now take those lines and change them to:
Code:
if (!stristr($_SERVER['PHP_SELF'], "modules.php")) {


On NukeScripts this (from the blocks being changed) account for a .7 sec speed increase on the load time. I talked to Raven about earlier today and told him to give it a try and he loved the speed increase.

Now, if ChatServ reads this I hope he does this in his 2.8 patch, I don't care if he mentions it came from here or there but this would go a long way to bringing PHP-Nuke back into line Smile

I'll be updating all of the PHP-Nuke downloads on my site to reflect this change in all files that use that type of line as well as on my own site its self.

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



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Mon Dec 06, 2004 1:32 pm Reply with quote

2.8 patch? Bang Head
 
View user's profile Send private message Visit poster's website
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Mon Dec 06, 2004 1:36 pm Reply with quote

Pretty big undertaking I was checking what it would take to completely convert osc2nuke74x this way and decided I'd wait and see if they did it in a future release.

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
Mesum
Useless



Joined: Aug 23, 2002
Posts: 213
Location: Chicago

PostPosted: Mon Dec 06, 2004 2:02 pm Reply with quote

Bob, by any chance, you use "Speedup Hacks" by DJMaze and Steve, post a while ago?
 
View user's profile Send private message Visit poster's website
BobMarion







PostPosted: Thu Dec 09, 2004 12:44 am Reply with quote

No, I keep meaning to add those but never get around to it Sad DJMaze gave me permission to use them though.
 
Mesum







PostPosted: Thu Dec 09, 2004 7:33 am Reply with quote

I asked this question because I noticed a major slow down in forums if it's a busy website, maybe there is a glitch in the code and then was corrected later on by the CPG staff.
 
RTS-Bone
New Member
New Member



Joined: Jun 20, 2004
Posts: 9

PostPosted: Wed Feb 23, 2005 3:25 pm Reply with quote

What about if we have
Code:
if (eregi("block-Welcome.php",$PHP_SELF)) {
instead ?

Theres no "!" before eregi...
 
View user's profile Send private message
MarkyBear
Hangin' Around



Joined: Mar 27, 2005
Posts: 39

PostPosted: Sun Jul 10, 2005 6:35 pm Reply with quote

I have a quick question about this, for the lines that read:

Code:
if (!eregi("modules.php", $PHP_SELF)) { 


Would I change them to?:

Code:
if (!stristr($_SERVER['PHP_SELF'], "modules.php")) { 



Thanks in advance for whomevers time and any help given!
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Sun Jul 10, 2005 6:55 pm Reply with quote

Assuming $PHP_SELF is previously set to $_SERVER['PHP_SELF'], and hopefully it is, that should work.

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
MarkyBear







PostPosted: Sun Jul 10, 2005 7:19 pm Reply with quote

kguske wrote:
Assuming $PHP_SELF is previously set to $_SERVER['PHP_SELF'], and hopefully it is, that should work.



Thanks for the reply!

I'm not sure what you mean by "previously set"?

If you mean that they once had that code in there, then no, I haven't edited any of these files at all...Like the Bank, Lottery and Shop files, they all contain that line in them...

Would I notice an error right off the bat if I changed it???

Thanks again! Very Happy
 
kguske







PostPosted: Sun Jul 10, 2005 7:28 pm Reply with quote

$PHP_SELF is not a reserved name, so if there isn't a line somewhere before this code like
Code:
$PHP_SELF = $_SERVER['PHP_SELF'];

this approach might not be the same code. Most likely, that line exists somewhere, so most likely you will be ok. In fact, using the approach Bob recommended is more secure than assuming that $PHP_SELF is set previously.

If it wasn't, you wouldn't notice an error either way. Using the prior approach, if the $PHP_SELF line wasn't properly set, you would be less secure...
 
chatserv







PostPosted: Sun Jul 10, 2005 7:44 pm Reply with quote

You will find that line in mainfile.php as:
Code:
if ($phpver >= 41) {

    $PHP_SELF = $_SERVER['PHP_SELF'];
}


While you're checking it you might also want to change it to:
Code:
if ($phpver >= 41) {

   $PHP_SELF = htmlentities($_SERVER["PHP_SELF"]);
}
 
kguske







PostPosted: Sun Jul 10, 2005 7:52 pm Reply with quote

Thanks, Chatserv. Your suggested change will make it MORE secure, and, under those circumstances, wouldn't MarkyBear want to use
Code:
if (!stristr($PHP_SELF, "modules.php")) {

instead?
 
MarkyBear







PostPosted: Sun Jul 10, 2005 7:54 pm Reply with quote

kguske wrote:
$PHP_SELF is not a reserved name, so if there isn't a line somewhere before this code like
Code:
$PHP_SELF = $_SERVER['PHP_SELF'];

this approach might not be the same code. Most likely, that line exists somewhere, so most likely you will be ok. In fact, using the approach Bob recommended is more secure than assuming that $PHP_SELF is set previously.

If it wasn't, you wouldn't notice an error either way. Using the prior approach, if the $PHP_SELF line wasn't properly set, you would be less secure...


Ok, I'm kind of starting to understand what you're meaning here and thank you for taking the time to not only help, but to help me learn this!

So, for example the Bank mod, I searched the file and that line you posted is no where in there, so I just changed it from:

Code:
if (!eregi("modules.php", $PHP_SELF)) {


to

Code:
if (!stristr($_SERVER['PHP_SELF'], "modules.php")) {


Correct???

Sorry to be a pain, I'm trying here LOL

And thanks again!!
 
kguske







PostPosted: Sun Jul 10, 2005 7:59 pm Reply with quote

That should work, yes.
 
MarkyBear







PostPosted: Sun Jul 10, 2005 8:00 pm Reply with quote

kguske wrote:
That should work, yes.


Will do and thanks again for all your time and help!!!

chatserv wrote:
You will find that line in mainfile.php as:
Code:
if ($phpver >= 41) {

    $PHP_SELF = $_SERVER['PHP_SELF'];
}


While you're checking it you might also want to change it to:
Code:
if ($phpver >= 41) {

   $PHP_SELF = htmlentities($_SERVER["PHP_SELF"]);
}


Had it and changed it as suggested, thank you for your help too!!!
 
Isaiah
Hangin' Around



Joined: Nov 09, 2004
Posts: 32

PostPosted: Thu Mar 23, 2006 6:26 am Reply with quote

Another one tweak,
i think most of the php freaks allready know this Smile

More than 86% faster site loading to the sites i used this.
Just have in mind that if you have a very busy site with lot of traffic,
it can make the server load go at high levels.

Tip:

Edit your .htaccess file,
and place those lines at the start of the file :

php_flag zlib.output_compression on
php_value zlib.output_compression_level 1


Don't adjust the compression_level value to 9 (max),
as there is nearly no difference, and level 9 can push the server to the limit.

After this, all pages are compressed using the gzip php library,
result in super fast loading of your pages.

Cheers!
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu Mar 23, 2006 11:54 pm Reply with quote

Be careful! It increased my initial load time by over .2 second. I'm sure there are other factors involved. Remember that your browser must be able to negotiate compressed input or it won't work at all. It could also be the mainfile code routine is conflicting with this code. I'm just saying that you need to test it very carefully. Thanks.
 
View user's profile Send private message
Raven







PostPosted: Fri Mar 24, 2006 12:00 am Reply with quote

And it definitely conflicts and errors out with the mainfile.php code. Repeated attempts showed an increase of up to just over a second, even with the mainfile code adjusted.
 
Isaiah







PostPosted: Fri Mar 24, 2006 2:06 am Reply with quote

Well, i use this code at two very crowded sites i own,
and these 20 days i use it, i didn't experienced any problem at all,
either at the browsers i tested, seems that everything is working so fast.

By the way, about mainfile.php, in case of any conflict or error mismatch,
normally i should expect an error message, am i right?
 
Raven







PostPosted: Fri Mar 24, 2006 8:38 am Reply with quote

If you have error display turned on you should see a gzip conflict.
 
Isaiah







PostPosted: Fri Mar 24, 2006 8:47 am Reply with quote

I understood. But there is this message (conflict) only if you place the
ozhandler command at index.php.

By placing the code i wrote above at .htaccess, there is no conflict,
although at mainfile.php there is reference to ogzhadler.
 
Raven







PostPosted: Fri Mar 24, 2006 8:59 am Reply with quote

My point is that each person needs to test this carefully. Even after I removed the mainfile code conflict my page generation times for my home page increased by up to 2 seconds longer. And I ran the test multiple times. This is not an attack on you so please don't take on a defensive posture Smile. As with all changes and modifications, environmental factors can and will affect results.
 
Isaiah







PostPosted: Fri Mar 24, 2006 9:33 am Reply with quote

Raven wrote:
This is not an attack on you so please don't take on a defensive posture Smile. As with all changes and modifications, environmental factors can and will affect results.


lol Smile sure mate Smile of course i didn't feel it like attack Smile

By the way,
you made me search for this further Smile ,
and when i remove all references of this compression feature from mainfile.php, the page loading is too sloooooow.

I think that even without modifying .htaccess, and having the code at mainfile.php, like this one you have to the latest raven package,
it is allready a speed tweak finally Smile
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Making Nuke Efficient

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 ©