Advertisement
Guest User

Untitled

a guest
May 27th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. cd /root
  2. cat > kimsufi.php <<EOF
  3. #!/usr/bin/php
  4. <?php
  5.  
  6. $url = "http://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2";
  7. $f = file_get_contents($url);
  8. $a = json_decode($f);
  9. $avail = $a->answer->availability;
  10.  
  11. foreach($avail as $s) {
  12.  if($s->reference==='142sk1') {
  13.   $z = $s->zones;
  14.   foreach($z as $zone) {
  15.     if($zone->availability!=='unavailable') {
  16.         //echo $s->reference . " is " . $zone->availability . " in " . $zone->zone . "\n";
  17.                 $from = "Kimsufi daemon";
  18.                 $to = "your@email.address";
  19.                 $subject = "Disponibilidad en Kimsufi KS-1 zona ".$z;
  20.                 $body = "Disponibilidad en zona ".$z." http://www.kimsufi.com/ie/#servers";
  21.                 include("manda_email.php");
  22.     }
  23.      //else { echo "No availability"; }
  24.     }
  25.    break;
  26.   }
  27. }
  28. ?>
  29. EOF
  30.  
  31. cat > manda_email.php <<EOF
  32. <?php
  33. require_once "Mail.php";
  34.  
  35. $host = "smtp.gmail.com";
  36. $username = "your@mail.com";
  37. $password = "password";
  38.  
  39. $headers = array ('From' => $from,
  40.   'To' => $to,
  41.   'Subject' => $subject);
  42. $smtp = Mail::factory('smtp',
  43.   array ('host' => $host,
  44.     'auth' => true,
  45.     'username' => $username,
  46.     'password' => $password));
  47.  
  48. $mail = $smtp->send($to, $headers, $body);
  49. file_put_contents($log_email,date("Y-m-d-H:i:s | ").$mensaje."\n",FILE_APPEND);
  50. ?>
  51. EOF
  52.  
  53. cat >> /etc/crontab <<EOF
  54. */1  * * * * root       /usr/bin/php /root/kimsufi.php
  55. EOF
  56.  
  57. service cron restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement