FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Changing GLOBAL.php VAR_NAMES
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Changing GLOBAL.php VAR_NAMES [message #11152] Thu, 19 June 2003 18:59 Go to next message
mogilla is currently offline  mogilla   United States
Messages: 5
Registered: June 2003
Location: New York, USA
Karma: 0
Junior Member
Excuse me, but I am relatively new to php.

While attempting to integrate FUDforum into my existing site, I found that a few global variables are the same as what I am currently using.

Changing WWW_ROOT_DIR to FUD_WWW_ROOT_DISK forum-wide appears to work correctly until I attempt to enter the administration section. I receive the following two errors:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\forum\include\glob.inc on line 35

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\forum\include\core.inc on line 24

This occurs on both windows and linux boxes. This even persists after I change FUD_WWW_ROOT_DISK back to WWW_ROOT_DISK forum-wide. I thought that the FUD_WWW_ROOT_DISK may have been saved into memory, but a reboot of either box did not resolve the errors. So, one by one, I replaced each file that had the variable changed and attempted to open the administration pages after each change. Alas, when replacing the GLOBALS_HELP with the original, I could access the administration pages. I opened both the altered GLOBALS_HELP and the original GLOBALS_HELP. I found no difference between the two other than a file size difference. All hidden characters appeared to be the same also.

Altered GLOBALS_HELP: 13.2kb
Original GLOBALS_HELP: 12.8kb

This is not my major concern, but an explanation might help in with problems which may arise in the future. Knowing the reason behind why adding and then removing 4 characters would leave a file wih two different sizes?

My major concern is understanding the following:

function read_help() in glob.inc has trouble with my prepending "FUD_" to any GLOBAL variables. I have studied this function and have the basics of what it does, but am having a bit of trouble deciphering it in it's entirety. Might someone with more knowledge than I aid me in understanding it more?

function read_help()
{
	/* retrieve GLOBALS_HELP file and set data to contents */
	$data = file_get_contents($GLOBALS['INCLUDE'].'GLOBALS_HELP');
	
	/* $len is number of characters of $data */
	$len = strlen($data);
	
	/* set $p to 0 as a starting position  */
	$p = 0;
	
	/* while $p (position) has a real value  */
	while (($p = strpos($data, "\n", $p)) !== FALSE) {
		
		/* if $p (position) +1 is greater than or equal
                      to $len, break from loop  */
		if (++$p >= $len) {
			break;
		}
		
		/* ?????????????  */
		if ($data[$p] < 'A' || $data[$p] > 'Z') {
			continue;
		}
		
		/* $ke is position of the next new line  */
		$ke = strpos($data, "\n", $p);
		
		/* $key is the string (var_name) from position
                     $ke to $p  */
		$key = substr($data, $p, ($ke - $p));
		
		/* $ke + 1  */
		++$ke;
		
		/* $e is position of end of GLOBALS variable 
                      definition signified by a period and 
                      double new line  */
		$e = strpos($data, ".\n\n", $ke);
		
		/* definine array $key's value by using 
                      information between end of GLOBALS 
                      var_name value and end of GLOBALS 
                      var_name */
		$help_ar[$key] = nl2br(htmlspecialchars(substr($data, $ke, ($e - $ke))));
		
		/* ?????????????  */
		$p = $e + 2;
		
		/* if $p (position) is greater than or equal to
                     $len, break from loop  */
		if ($p >= $len) {
			break;
		}
	}
	
	/* add to $help_ar  */
	return (isset($help_ar) ? $help_ar : NULL);
}


I appreciate any help. I do enjoy different code and learning new ways to accomplish a task, but time is a commodity I cannot afford at this time.

[Updated on: Thu, 19 June 2003 20:17]

Report message to a moderator

Re: Changing GLOBAL.php VAR_NAMES [message #11162 is a reply to message #11152] Thu, 19 June 2003 22:35 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Your text editor probably changed \n to \r\n, which would explain the size increase.

That is also the reason why the code gets stuck inside an infinite loop.
<?php
$e
= strpos($data, ".\n\n", $ke);
?>


looks for the end of the explanation for each option. Since your file's line endings are now \r\n, it cannot find this and sets $e to 0. Which what causes the ends loop. I'll add a check for value of $e in CVS, but that would simply prevent the loop. The solution is to make sure you GLOBALS_HELP does not have \r in it.


FUDforum Core Developer
Re: Changing GLOBAL.php VAR_NAMES [message #11212 is a reply to message #11162] Sun, 22 June 2003 00:25 Go to previous message
mogilla is currently offline  mogilla   United States
Messages: 5
Registered: June 2003
Location: New York, USA
Karma: 0
Junior Member
Thanks for the explanation.

I used ColdFusion Studio 5 to do the forum-wide changes of var_names. I find it odd that only one file was affected. Anyhow, what you said does make sense.

Since my original post I picked up my book on php and have found that I should have been working with php all along instead of ColdFusion. I can't say that I wasted my money on ColdFusion, but if I started with php I wouldn't have had to part with as much to begin with.

Happy Programming! Smile
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Timeout units
Next Topic: How to allow users to delete their posts?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 19:57:42 GMT 2024

Total time taken to generate the page: 0.02822 seconds