Toko baju super murah

www.bajusupermurah.com menjual pakaian berkwalitas dan termurah

php script cara tes sebuah website sedang up atau down


males basa-basi,, ,,cek bekicot

cara 1:

<?php

if (isDomainAvailible(“http://www.bajusupermurah.com&#8221;))

{

echo “Up and running!”;

}

else

{

echo “Woops, nothing found there.”;

}

//returns true, if domain is availible, false if not

function isDomainAvailible($domain)

{

//check, if a valid url is provided

if(!filter_var($domain, FILTER_VALIDATE_URL))

{

return false;

}

//initialize curl

$curlInit = curl_init($domain);

curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);

curl_setopt($curlInit,CURLOPT_HEADER,true);

curl_setopt($curlInit,CURLOPT_NOBODY,true);

curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);

//get answer

$response = curl_exec($curlInit);

curl_close($curlInit);

if ($response) return true;

return false;

}

?>

cara 2:

<?php

function Visit($url){

$agent = “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”;$ch=curl_init();

curl_setopt ($ch, CURLOPT_URL,$url );

curl_setopt($ch, CURLOPT_USERAGENT, $agent);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch,CURLOPT_VERBOSE,false);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch,CURLOPT_SSLVERSION,3);

curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);

$page=curl_exec($ch);

//echo curl_error($ch);

$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

if($httpcode>=200 && $httpcode<300) return true;

else return false;

}

if (Visit(‘http://www.bajusupermurah.com&#8217;))

echo “Website OK”.”n”;

else

echo “Website DOWN”;

?>

cara ke 3:

<?php

ini_set(“default_socket_timeout”,”05″);

set_time_limit(5);

$f=fopen(‘http://www.bajusupermurah.com&#8217;,”r”);

$r=fread($f,1000);

fclose($f);

if(strlen($r)>1) {

echo(“<span class=’online’>Online</span>”);

}

else {

echo(“<span class=’offline’>Offline</span>”);

}

?>

source:http://css-tricks.com/snippets/php/check-if-website-is-available/
Iklan

1 Juni 2013 - Posted by | Cuap cuap, Tutorial PHP | ,

Belum ada komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: