To test a remote PHP hosted site feel free to use our test script here: http://www.ispcloud.co.uk/ping.php?url=www.my-website.com
(Replace www.my-website.com with your website)
If you want to adapt this test then feel free to copy the source code below:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .console { font-family:Courier; font-size: 12pt; color: #CCCCCC; background: #000000; border: 3px double #CCCCCC; padding: 10px; } </style> <?php // check responsetime for a webbserver function pingDomain($domain){ $starttime = microtime(true); // supress error messages with @ $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; } ?> <? /** * Get a web file (HTML, XHTML, XML, image, etc.) from a URL. Return an * array containing the HTTP server response header fields and content. */ function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } ?> <title></title> </head> <body> <?php echo '<div class="console">'; if (isset($_GET['url'])) { $u=$_GET["url"]; } if (empty($u)) { echo 'Usage: ?url=www.website-to=test.com'; } else { echo 'URL being tested: '; echo $u; echo'</br>'; echo 'Ping response time: '; echo (pingDomain($u) / 1000); echo ' s'; //Attempt to scrape HTML from remote webpage $result = get_web_page($u); if ( $result['errno'] != 0 ) { //... error: bad url, timeout, redirect loop ... echo '<br/>Error: '; echo $result['errno']; } if ( $result['http_code'] != 200 ) { //... error: no page, no permissions, no service ... echo '<br/>Response header code: '; echo $result['http_code']; echo '</div>'; } else { echo '<br/>(Webpage raw HTML below returned from remote server)<br/><br/><hr/></div><div>'; $output = $result['content']; // account for images $replace = '<img src="http://'.$u.'/'; $output = str_replace('<img src="/',$replace,$output); // account for scripts $replace = '<script type="text/javascript" src="http://'.$u.'/'; $output = str_replace('<script type="text/javascript" src="/',$replace,$output); // account for links $replace = '<link href="http://'.$u.'/'; $output = str_replace('<link href="/',$replace,$output); //show remote content locally echo $output; echo '</div>'; } }; ?> </body> </html>
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article