boemboem Posted January 13, 2009 Share Posted January 13, 2009 After some testing also from this phpfreaks (thank you for that), there are some problems wich accur when people submit a url with a /subdirectory in it. The sit is alive, but it shows not alive because it can't find a index.* page I believe. This is the output page and the code: http://keurmerk.coldcharlie.nl/multi.php <?php //Fill this in with the list of servers $servers = file('./text.txt'); // Function to check response time function pingDomain($domain){ $starttime = microtime(true); $file = @fsockopen ($domain, 80, $errno, $errstr, 10); $stoptime = microtime(true); $status = 0; if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } return $status; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <table> <?php foreach($servers as $domainbase){ $status = pingDomain(trim($domainbase)); if ($status != -1) echo "<tr><td><img src=\"images/status/alive.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; else echo "<tr><td><img src=\"images/status/dead.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; } ?> </table> </body> </html> This is the form handler: http://keurmerk.coldcharlie.nl/form.html <?PHP ###################### Set up the following variables ###################### # # $filename = "text.txt"; #CHMOD to 666 $forward = 0; # redirect? 1 : yes || 0 : no $location = "thankyou.htm"; #set page to redirect to, if 1 is above # # ##################### No need to edit below this line ###################### $msg .= $_POST['url'] . "\n"; $fp = fopen ($filename, "a"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $msg); fclose ($fp); } else { $forward = 2; } if ($forward == 1) { //header ("Location:$location"); header("Location: " . $_SERVER['HTTP_REFERER']); } else if ($forward == 0) { echo ("Thank you for submitting our form. We will get back to you as soon as possible."); } else { "Error processing form. Please contact the webmaster"; } ?> Any help would be great I found something here: http://www.webmasterworld.com/forum88/77.htm I dont understand ehat they mean Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/ Share on other sites More sharing options...
rhodesa Posted January 13, 2009 Share Posted January 13, 2009 you can get just the hostname out with parseurl() Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736194 Share on other sites More sharing options...
boemboem Posted January 13, 2009 Author Share Posted January 13, 2009 ??? where do I put that function then? Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736204 Share on other sites More sharing options...
rhodesa Posted January 13, 2009 Share Posted January 13, 2009 try this: <?php //Fill this in with the list of servers $servers = file('./text.txt'); // Function to check response time function pingDomain($domain){ $host = parseurl($domain,PHP_URL_HOST); $starttime = microtime(true); $file = @fsockopen ($host, 80, $errno, $errstr, 10); $stoptime = microtime(true); $status = 0; if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } return $status; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <table> <?php foreach($servers as $domainbase){ $status = pingDomain(trim($domainbase)); if ($status != -1) echo "<tr><td><img src=\"images/status/alive.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; else echo "<tr><td><img src=\"images/status/dead.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; } ?> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736230 Share on other sites More sharing options...
boemboem Posted January 13, 2009 Author Share Posted January 13, 2009 :-X Fatal error: Call to undefined function parseurl() in /var/www/g35003/coldcharlie.nl/subdomains/keurmerk/multi.php on line 8 Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736290 Share on other sites More sharing options...
rhodesa Posted January 13, 2009 Share Posted January 13, 2009 sorry...it's parse_url() Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736295 Share on other sites More sharing options...
boemboem Posted January 13, 2009 Author Share Posted January 13, 2009 ok, that worked, only the ouput is all negative now http://keurmerk.coldcharlie.nl/multi.php <?php //Fill this in with the list of servers $servers = file('./text.txt'); // Function to check response time function pingDomain($domain){ $host = parse_url($domain,PHP_URL_HOST); $starttime = microtime(true); $file = @fsockopen ($host, 80, $errno, $errstr, 10); $stoptime = microtime(true); $status = 0; if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } return $status; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <table> <?php foreach($servers as $domainbase){ $status = pingDomain(trim($domainbase)); if ($status != -1) echo "<tr><td><img src=\"images/status/alive.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; else echo "<tr><td><img src=\"images/status/dead.gif\" /> <b><a href=\"http://$domainbase\" target=\"_blank\">http://$domainbase</a></td><tr>"; } ?> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736302 Share on other sites More sharing options...
rhodesa Posted January 13, 2009 Share Posted January 13, 2009 ok...this should work now: <?php //Fill this in with the list of servers $servers = file('./text.txt'); // Function to check response time function pingDomain($host){ $starttime = microtime(true); $file = @fsockopen ($host, 80, $errno, $errstr, 10); $stoptime = microtime(true); $status = 0; if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } return $status; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <table> <?php foreach($servers as $domainbase){ $host = parse_url(trim($domainbase),PHP_URL_HOST); $status = pingDomain($host); if ($status != -1) echo "<tr><td><img src=\"images/status/alive.gif\" /> <b><a href=\"$domainbase\" target=\"_blank\">$domainbase</a></td><tr>"; else echo "<tr><td><img src=\"images/status/dead.gif\" /> <b><a href=\"$domainbase\" target=\"_blank\">$domainbase</a></td><tr>"; } ?> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736320 Share on other sites More sharing options...
boemboem Posted January 13, 2009 Author Share Posted January 13, 2009 I'm sorry but it isn't http://keurmerk.coldcharlie.nl/multi.php Also the links are not working because the http:// not pressent in the<a href Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736352 Share on other sites More sharing options...
rhodesa Posted January 13, 2009 Share Posted January 13, 2009 what is the contents of the text file then....cus clearly mine must be different Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736377 Share on other sites More sharing options...
boemboem Posted January 13, 2009 Author Share Posted January 13, 2009 My bad! I didnt supply the http:// When I submit a url with http://www.google.nl for example it works fine and http://www.phpfreaks.com/forums too! Quote Link to comment https://forums.phpfreaks.com/topic/140672-solved-fsockopen-and-subdirectories/#findComment-736383 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.