Setting the date back on Linux machine causes page to hang?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Setting the date back on Linux machine causes page to hang?

Post by Nemesis »

Hey all,

I can set the time forward no problem. However, when I use the same code to set the date back, the page hangs, seemingly IN the exit(); statement.

Here is the code snipet:

Code: Select all

$date = $month.$day.$hour.$min.$year.".".$sec;
$date = trim($date);
		
echo "<pre>Date: ";	// DEBUG
print_r($date);		// DEBUG
echo "</pre>";		// DEBUG
		
mtsiExecuteCommand("date $date",$linearray);
sleep(2);

mtsiExecuteCommand("hwclock --systohc &",$linearray2);
sleep(2);
		
echo "<pre>linearray: ";// DEBUG
print_r($linearray);	// DEBUG
echo "</pre>";		// DEBUG
echo "<pre>linearray2: ";// DEBUG
print_r($linearray2);	// DEBUG
echo "</pre>";		// DEBUG
		
$msg = "Date and Time changed successfully";
$msg = str_replace(" ",":",$msg);
header("HTTP/1.0 302 Redirection");
header("Location:date.php3?mode=$mode&msg=$msg");

echo "exit<br>";	// DEBUG
exit();
This code changes the date correctly on the system, because when I return to the date page after the setting page hangs, the date has been changed back correctly.

The code displays all the correct information, and the last thing that shows up is "exit".
Then, the exit(); doesnt seem to work because the page keeps loading indefinitely.

Nemesis.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

exit is never reached, because you redirect to whatever.php (header:location)
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

so why doesnt the redirect work?

It works fine when I set the time forward instead of backwards.

It just doesnt seem to load the page.....it tries, but it doesnt.
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

Furthermore, if I call the exit(); before the Redirection, the same thing happens.....it's like the redirection gets ignored:

Code: Select all

$date = $month.$day.$hour.$min.$year.".".$sec;
$date = trim($date);
      
echo "<pre>Date: ";   // DEBUG
print_r($date);      // DEBUG
echo "</pre>";      // DEBUG
      
mtsiExecuteCommand("date $date",$linearray);
sleep(2);

mtsiExecuteCommand("hwclock --systohc &",$linearray2);
sleep(2);
      
echo "<pre>linearray: ";// DEBUG
print_r($linearray);   // DEBUG
echo "</pre>";      // DEBUG
echo "<pre>linearray2: ";// DEBUG
print_r($linearray2);   // DEBUG
echo "</pre>";      // DEBUG

echo "exit<br>";   // DEBUG
exit();
produces the same page "hanging" where the page loads forever, and nothing happens.

is there something funky with changing the date back in time that would produce this kind of strange behaviour?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the redirect will not work while you have debug prints unless you are using output buffering (band-aid)
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

I know, I added the debug because it was not working.
The code behaves as I described it without the debug, sorry if I was not specific enough.
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

Weirdest thing:

I changed the exit(); function for:

Code: Select all

exit("Date and Time changed successfully");
and it now works in Mozilla, however, not in IE.

Any ideas?
Post Reply