Page 1 of 1

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

Posted: Fri Feb 11, 2005 9:23 am
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.

Posted: Fri Feb 11, 2005 10:21 am
by timvw
exit is never reached, because you redirect to whatever.php (header:location)

Posted: Fri Feb 11, 2005 10:46 am
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.

Posted: Fri Feb 11, 2005 11:04 am
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?

Posted: Fri Feb 11, 2005 11:11 am
by feyd
the redirect will not work while you have debug prints unless you are using output buffering (band-aid)

Posted: Fri Feb 11, 2005 11:16 am
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.

Posted: Fri Feb 11, 2005 1:07 pm
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?