0){ good_message( $url ); }else{ mail('david58cypher@gmail.com', 'site Error!', $url . " position Copyright"); } } } function monitor_sites_content( $url ){ $result = get_web_page( $url ); if ( $result == null ) { mail('david58cypher@gmail.com', 'site Error!', $url . 'Error! timeout'); }elseif ( $result['http_code'] != 200 ){ mail('david58cypher@gmail.com', 'site Error!', $url . 'Error! Httpd Code Error!'); }else{ if (strpos($result['content'], "here")!==3){ mail('david58cypher@gmail.com', 'site Error!', $url . " position here"); }else{ good_message( $url ); } } } function good_message( $url ){ $myFile = "testFile.txt"; $time1 = mktime (21, 10, 0, date("m"), date("d"), date("Y") ); $time2 = mktime (21, 15, 0, date("m"), date("d"), date("Y") ); $time3 = mktime (9, 10, 0, date("m"), date("d"), date("Y") ); $time4 = mktime (9, 15, 0, date("m"), date("d"), date("Y") ); $time = mktime (date('H'), date('i'), 0, date("m"), date("d"), date("Y") ); if (($time > $time1) && ($time<$time2)){ mail('david@cyphermedia.com', 'Site Work!!', " Site: " . $url . " working Good! "); } if (($time > $time3) && ($time<$time4)){ mail('david@cyphermedia.com', 'Site Work!!', " site: " . $url . " working Good! "); if ($s_file == 0 ){ $fh = fopen($myFile, 'w') or die("can't open file"); }else{ $fh = fopen($myFile, 'a') or die("can't open file"); } }else{ $fh = fopen($myFile, 'a') or die("can't open file"); } $stringData = date("c") . " " . $url . " Working! \n"; fwrite($fh, $stringData); fclose($fh); } function get_web_page( $url ) { $options = array( 'http' => array( 'user_agent' => 'spider', // who am i 'max_redirects' => 2, // stop after 10 redirects 'timeout' => 60, // timeout on response ) ); $context = stream_context_create( $options ); $page = @file_get_contents( $url, false, $context ); $result = array( ); if ( $page != false ) $result['content'] = $page; else if ( !isset( $http_response_header ) ) return null; // Bad url, timeout // Save the header $result['header'] = $http_response_header; // Get the *last* HTTP status code $nLines = count( $http_response_header ); for ( $i = $nLines-1; $i >= 0; $i-- ) { $line = $http_response_header[$i]; if ( strncasecmp( "HTTP", $line, 4 ) == 0 ) { $response = explode( ' ', $line ); $result['http_code'] = $response[1]; break; } } return $result; } ?>