-
Notifications
You must be signed in to change notification settings - Fork 0
/
siteup.php
executable file
·84 lines (69 loc) · 1.96 KB
/
siteup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
function siteup($url=NULL) {
if ($url == NULL) {
return FALSE;
}
$ch = curl_init($url);
$options = array(
CURLOPT_NOBODY => true,
CURLOPT_FOLLOWLOCATION => true,
);
curl_setopt_array($ch, $options);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($retcode == 200) {
$return = array(
'status' => TRUE,
'retcode' => $retcode,
'error' => '',
);
return $return;
} else {
$return = array(
'status' => FALSE,
'retcode' => $retcode,
'error' => curl_error($ch),
);
return $return;
}
curl_close($ch);
}
$date = date("d M Y G:i:s");
echo "Date: " . $date . "<br /><br />";
$urls = array(
'c4u' => 'www.customs4u.com',
'glam' => 'www.glamworship.com',
'PN' => 'www.propertynetwork.net',
'PN API' => 'www.propertynetworkapi.net',
);
foreach ($urls as $name => $url) {
echo '<b>' . $name . ' (' . $url . ') </b>';
echo "<br />";
$siteup = siteup($url);
if ($siteup['status']) {
echo 'UP';
}
else{
echo $siteup['retcode'] . '-' . $siteup['error'] . "<br />";
echo 'DOWN';
// site is DOWN - send an email
$message = $name . ' - ' . $url;
$message .= "\n\n";
$message .= 'Site is down.';
$message .= "\n\n";
$message .= 'Return code:';
$message .= "\n\n";
$message .= $siteup['retcode'];
$message .= "\n\n";
$message .= 'Error:';
$message .= "\n\n";
$message .= $siteup['error'];
$email = 'titi@zoocha.com';
$subject = $name . ' - DOWN';
$body = $message;
$headers = "From: Zoocha Monitor <no-reply@zoocha.com>" . "\r\n" . "Reply-To: " . $email . "\r\n" . "X-Mailer: PHP/" . phpversion();
// mail($email,$subject,$body,$headers);
}
echo "<br />";
echo "<br />";
}