Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- 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);
- }
- if ($status <> -1) {
- return true;
- }
- return false;
- }
- //llamando a la funcion
- if (pingDomain('www.dominio.com')) {
- echo 'ON';
- } else {
- echo 'OFF';
- }
Add Comment
Please, Sign In to add comment