Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat > kimsufi.php <<EOF
- <?php
- $path = "/root/your_scripts_path/";
- $host = "smtp.gmail.com";
- $username = "your@email";
- $password = "password";
- $api_key = "apikey";
- $api_secret = "apipwd";
- $url = "http://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2";
- if (!file_exists("/tmp/kimsufi")) {
- $f = file_get_contents($url);
- $a = json_decode($f);
- $avail = $a->answer->availability;
- foreach($avail as $s) {
- if($s->reference==='142sk1') {
- $z = $s->zones;
- foreach($z as $zone) {
- if($zone->availability!=='unavailable') {
- //echo $s->reference . " is " . $zone->availability . " in " . $zone->zone . "\n";
- $from = "Kimsufi daemon <your@email>";
- $to = "Your name <your@email>";
- $subject = "Disponibilidad en Kimsufi KS-1 zona ".$zone->zone;
- $body = "Disponibilidad en zona ".$zone->zone." http://www.kimsufi.com/ie/#servers";
- $para = "phone#including_country_code";
- $de = $para;
- $mensaje = $body;
- include($path."manda_email.php");
- include($path."manda_sms.php");
- //echo "Se fue email.";
- touch("/tmp/kimsufi");
- }
- //else { echo "No availability"; }
- }
- break;
- }
- }
- }
- EOF
- cat > manda_email.php <<EOF
- <?php
- require_once "Mail.php";
- $headers = array ('From' => $from,
- 'To' => $to,
- 'Subject' => $subject);
- $smtp = Mail::factory('smtp',
- array ('host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password));
- $mail = $smtp->send($to, $headers, $body);
- //file_put_contents($log_email,date("Y-m-d-H:i:s | ").$mensaje."\n",FILE_APPEND);
- ?>
- EOF
- cat > manda_sms.php <<EOF
- <?php
- $postUrl = "http://rest.innovativetxt.com/smsapi/index.php";
- $fields = "to=".$para."&from=".$de."&text=".$mensaje."&api_key=".$api_key."&api_secret=".$api_secret;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $postUrl);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
- //Response of the POST request
- $response = curl_exec($ch);
- curl_close($ch);
- //file_put_contents($log_sms,date("Y-m-d-H:i:s | ").$response."\n",FILE_APPEND);
- ?>
- EOF
- cat >> /etc/crontab <<EOF
- */1 * * * * root /usr/bin/php /your_scripts_path/kimsufi.php
- EOF
- service cron restart
Advertisement
Add Comment
Please, Sign In to add comment