IrIsT
August 14th, 2016, 12:11
سلام و درود.
یک اسکریپت میذارم برای دوستان عزیز monitoring website on php
که این اسکرپیت جهت چک کردن افلاین یا انلاین بودن سایت و ایمیل دادن به صاحب سایت کاربرد داره
<?php
function checkURL($url) {
//array of emails to send warning
$adminEmails=array("admin1@t-zones.sk","admin2@vodafonemail.cz");
//email of sender
$senderEmail="monitoring@domain.tld";
//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/");
?>
یک اسکریپت میذارم برای دوستان عزیز monitoring website on php
که این اسکرپیت جهت چک کردن افلاین یا انلاین بودن سایت و ایمیل دادن به صاحب سایت کاربرد داره
<?php
function checkURL($url) {
//array of emails to send warning
$adminEmails=array("admin1@t-zones.sk","admin2@vodafonemail.cz");
//email of sender
$senderEmail="monitoring@domain.tld";
//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/");
?>