Looping code while function loads
Posted: Tue Sep 20, 2005 2:16 pm
Ok, I'm not sure if this is even possible... But I want to output dots the the browser for as long as one of the functions (whois lookup) keeps loading (which is usually over 30 seconds).
Here is my code:
I've been scrapping and re-coding all day and I just can't figure it out... What happens now is this:
Gelieve te wachten terwijl we de beschikbaarheid van uw domein controleren ...LOOP #0 LOOP #1
So it loops until the function starts loading, and then it waits until the loading is complete before doing anything else instead of repeating the loop until the buffer can be sent (which is when the WHOIS is done).
Any help would be greatly appreciated.
Here is my code:
Code: Select all
// Reset counters
$timeoutcounter = 0;
$retrycounter = 0;
while (empty($isavail)) // If isavail is empty, the WHOIS has not yet been completed
{
echo "LOOP #$timeoutcounter ";//REMOVE - FOR TESTING ONLY
// If 5 seconds elapsed, send a dot (or any other character)
if ($timeoutcounter == 5)
{
echo ". <br>Available: $isavail <br>Retry: $retrycounter <br>Domain: $fulldomain<br>";
$timeoutcounter = 0;
}
// Send the WHOIS after x seconds
if ($retrycounter == 1)
{
// start buffering the output
ob_start();
include ("whois.inc");
$whoisresult = lookup($fulldomain);
while (empty($isavail))
{
// Check if domain is available
$isavail = $whoisresult[0]; // Contains "1" is it's available, blank if it's registered
echo "<br>CHECK COMPLETE: $isavail <br> Result: $whoisresult[0]<br>";//REMOVE - FOR TESTING ONLY
}
// Flush buffer once loop has been broken
ob_flush();
flush();
}
// Get WHOIS result
$isavail = $whoisresult[0]; // Contains "1" is it's available, blank if it's registered
// Timeout executing
sleep(1);
// Increase counter
$timeoutcounter++;
$retrycounter++;
}I've been scrapping and re-coding all day and I just can't figure it out... What happens now is this:
Gelieve te wachten terwijl we de beschikbaarheid van uw domein controleren ...LOOP #0 LOOP #1
So it loops until the function starts loading, and then it waits until the loading is complete before doing anything else instead of repeating the loop until the buffer can be sent (which is when the WHOIS is done).
Any help would be greatly appreciated.