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 -> RN Not Bugs
Author Message
technocrat
Life Cycles Becoming CPU Cycles



Joined: Jul 07, 2005
Posts: 511

PostPosted: Thu Mar 15, 2007 11:25 pm Reply with quote

No it will work, but thats because registered globals are turned on. But I would get in the habit of declaring all your globals in included files, just to make sure that something unexpected doesnt happen.

Like I said they are suggestions nothing else. I am just happy you guys secured it. You could hack this really easily in it's original state.

_________________
Nuke-Evolution
phpBB-Evolution / phpBB-Evolution Blog 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Fri Mar 16, 2007 5:50 am Reply with quote

Thanks - definitely great suggestions! Have you looked at performance impact of using freeresult?

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Mar 16, 2007 8:19 am Reply with quote

I don't run register_globals on, as a host, and I add register_globals off to my .htaccess just as added insurance.

technocrat wrote:
Second add $db->sql_freeresult();


According to this post, [ Only registered users can see links on this board! Get registered or login! ]
Using this function may actually increase the amount of memory used. In my case, the script used 208 bytes less memory when *not* using mysql_free_result().
Check for yourself: call memory_get_usage() at the end of the script.

It is not recommended to use this with PHP 4.x
 
View user's profile Send private message
Raven







PostPosted: Fri Mar 16, 2007 8:51 am Reply with quote

Mad I inadvertently deleted the first 2 posts of this thread! Rather than try to put them back in order, I'll just repost them here.
-----------------------------------------------------------------------------------------

Technocrat
Posted: Thu Mar 15, 2007 9:47 am
These are just a few suggestions, so you can do what ever with them.

First I would change all the if statements to else if. There is no reason to parse all the other if statements when its not possible to be in two areas at once.

Second add $db->sql_freeresult(); to your queries or add an unbuffered fetch to your db class. It will help keep down the memory usage. You should probably get in the habit of adding it everywhere.

Third $newpagetitle = $slogan; you do not have it globally declared except in the if news statement.
-----------------------------------------------------------------------------------------
KGuske
Posted: Thu Mar 15, 2007 8:39 pm
Interesting ideas. I haven't tested the dynamic titles, really, but I did look at the code and I'm not sure the variables need to be globally declared. Did you verify a problem, technocrat?
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Mar 16, 2007 9:10 am Reply with quote

Yeah, I don't have register globals on either and I am running 2.10. Odd.

I"ll take a look at your suggestions, especially the else if. I agree with you that from an execution point (rather than parse), it would be quicker.

I have added this to my "to-do" as I have also released this to the public so the non-RN'ers could benefit.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Fri Mar 16, 2007 9:33 am Reply with quote

I'm confused about something. You guys may not have register globals turned on, but Nuke essentially overrides you with import_request_variables(). Unless you guys rewrote all of Nuke to use $_POST, $_GET, etc. Confused

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
technocrat







PostPosted: Fri Mar 16, 2007 9:40 am Reply with quote

Rolling Eyes Sure you "inadvertently" deleted it ROTFL

Well if it doesn't make a difference in 4 then it does in 5. I took the memory usage down 1/3 by adding freeresults in a lot of places, like mainfile, and sentinel. Plus if you look at the code for phpbb v3 db class they free all the db queries. Not that they are the perfect coders but they generally do good work.
 
Raven







PostPosted: Fri Mar 16, 2007 9:55 am Reply with quote

technocrat,

Yes, in PHP 5 it seems it does make a difference. Especially if you use mysqlI
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Sat Mar 17, 2007 8:02 am Reply with quote

So there would be some future benefit by perhaps setting a constant in rnconfig.php to indicate whether the user was utilising PHP 5.x.x and then wrapping the freeresult in an if isset so it only gets execute the constant is set?
 
View user's profile Send private message Send e-mail
Raven







PostPosted: Sat Mar 17, 2007 8:23 am Reply with quote

Actually, it would be easier to just do an internal test rather than add another setting Smile
 
gotcha
Regular
Regular



Joined: Mar 14, 2005
Posts: 91

PostPosted: Sat Mar 17, 2007 1:36 pm Reply with quote

I think it would be nice to make it work similar to the way GT includes the url rewrites.
So if there is a file "dynamic_titles/DT-Forums.php" include it and make a $GLOBAL variable that contains the dynamic title... if the $GLOBAL is empty have it revert to the default $sitename $pagetitle.
Not sure if it will be much faster than using a bunch of if else statements, but it will certainly be alot cleaner and would give developers a chance to include it in their modules Smile
 
View user's profile Send private message Visit poster's website
montego







PostPosted: Sun Mar 18, 2007 9:57 am Reply with quote

gotcha, the concept is a sound one. We would have to run some tests to see if the If-elseif length is really too long to warrant the additional disk reads. My gut tells me that there is probably some "breaking point", where it might start being the more efficient approach... but, to quote a famous Quality guru Deming: "In God I trust, everyone else, show me the data..." Smile
 
gotcha







PostPosted: Sun Mar 18, 2007 4:25 pm Reply with quote

Maybe if the dynamic title code was included in the GoogleTap/GT-*.php file it would save the extra disk read and eliminate the if $name ==. I know in GT-nextgen(haven't tried yours yet) the GT-*.php file is included before the head(); function is called. I am actually using the method from my last post but I haven't really done any speed comparisons yet.
 
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 -> RN Not Bugs

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 ©