Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function checkURL($url) {
- //array of emails to send warning
- //email of sender
- //array of valid http codes
- $validStatus=array(200,301,302);
- //minimum filesize in bytes
- $minFileSize=500;
- if(!function_exists('curl_init')) die("Curl PHP package not installed!");
- $ch=curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response=curl_exec($ch);
- $info=curl_getinfo($ch);
- $statusCode=intval($info['http_code']);
- $filesize=$info['size_download'];
- if(!in_array($statusCode,$validStatus) || $filesize<$minFileSize) {
- $message = "Web ERROR ($url) - Status Code: $statusCode, Filesize: $filesize\r\n";
- foreach($adminEmails as $email) {
- mail($email, "Web Monitoring ERROR", $message, "From: $senderEmail\r\nReply-To: $senderEmail\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n");
- }
- }
- }
- checkURL("http://google.com/");
- ?>
Add Comment
Please, Sign In to add comment