Loading

CURL check website 2

  1. <?php
  2. function Visit($url){
  3.        $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";$ch=curl_init();
  4.        curl_setopt ($ch, CURLOPT_URL,$url );
  5.        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
  6.        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  7.        curl_setopt ($ch,CURLOPT_VERBOSE,false);
  8.        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  9.        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
  10.        curl_setopt($ch,CURLOPT_SSLVERSION,3);
  11.        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
  12.        $page=curl_exec($ch);
  13.        //echo curl_error($ch);
  14.        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  15.        curl_close($ch);
  16.        if($httpcode>=200 && $httpcode<300) return true;
  17.        else return false;
  18. }
  19. if (Visit("http://www.google.com"))
  20.        echo "Website OK"."n";
  21. else
  22.        echo "Website DOWN";
  23. ?>

Comments