Author |
Message |
technocrat
Life Cycles Becoming CPU Cycles
![](modules/Forums/images/avatars/d867b24b43a1b71491557.jpg)
Joined: Jul 07, 2005
Posts: 511
|
Posted:
Thu Mar 15, 2007 11:25 pm |
|
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. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! / Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kguske
Site Admin
![](modules/Forums/images/avatars/41f0b40a419280935f3a0.gif)
Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Fri Mar 16, 2007 5:50 am |
|
Thanks - definitely great suggestions! Have you looked at performance impact of using freeresult? |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Fri Mar 16, 2007 8:19 am |
|
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, http://us3.php.net/manual/en/function.mysql-free-result.php
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Mar 16, 2007 8:51 am |
|
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? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Fri Mar 16, 2007 9:10 am |
|
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. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Gremmie
Former Moderator in Good Standing
![](modules/Forums/images/avatars/0cd76dcf45da5de2cf864.jpg)
Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Fri Mar 16, 2007 9:33 am |
|
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](modules/Forums/images/smiles/icon_confused.gif) |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
technocrat
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Mar 16, 2007 9:40 am |
|
Sure you "inadvertently" deleted it
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Mar 16, 2007 9:55 am |
|
technocrat,
Yes, in PHP 5 it seems it does make a difference. Especially if you use mysqlI |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
Site Admin
![](modules/Forums/images/avatars/125904890252d880f79f312.png)
Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Sat Mar 17, 2007 8:02 am |
|
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? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 17, 2007 8:23 am |
|
Actually, it would be easier to just do an internal test rather than add another setting ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
gotcha
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/blank.gif)
Joined: Mar 14, 2005
Posts: 91
|
Posted:
Sat Mar 17, 2007 1:36 pm |
|
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](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Mar 18, 2007 9:57 am |
|
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](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
gotcha
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Mar 18, 2007 4:25 pm |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|