#!/usr/bin/php
<?php
$cccam_url = 'http://localhost:16001'; //CCCam Server
$cccam_username = 'cccam'; //CCCam Benutzername
$cccam_password = 'cccam'; //CCCam Passwort
$smtp_host = 'smtp.blah.com'; //SMTP Server
$smtp_user = 'username'; //SMTP Username
$smtp_password = 'geheim'; //SMTP Passwort
$smtp_recipient = 'email@host.com'; //Empfaengeremail
$smtp_from = 'email@host.com'; //Absenderemail
//--------------------------------------------------------------------------------------------------------------
$context = stream_context_create(array(
'http' => array(
'header' => 'Authorization: Basic ' . base64_encode($cccam_username . ':' . $cccam_password)
)
));
$data = file_get_contents($cccam_url . '/servers', false, $context);
preg_match('/\<PRE\>(.*)\<\/PRE\>/s', $data, $m);
$data = explode("\n", $m[1]);
$down = array();
foreach ($data as $key => $val) {
if (substr($val, 0, 1) == '|' && substr($val, 2, 3) != 'H') {
$row = explode('|', $val);
if (trim($row[1]) != '' && trim($row[2]) == '') {
$down[] = $row[1];
}
}
}
if ($down) {
$message = implode("\n", $down);
$subject = 'CCCam Server down';
exec('sendEmail -f ' . $smtp_from . ' -t ' . $smtp_recipient . ' -u "' . $subject . '" -m "' . $message . '" -s ' . $smtp_host . ' -xu ' . $smtp_user . ' -xp ' . $smtp_password);
}
?>