Newer
Older
SmartAlarm / alarm.php
root on 7 May 2019 1 KB Initial commit
  1. #!/usr/bin/php
  2. <?php
  3. include('config.php');
  4.  
  5. // quote
  6. $category = "life"; // inspire, management, sports, life, funny, love, art, students
  7.  
  8. $tosay = "beep beep beep beep beep?\n
  9. beep beep beep beep beep.\n
  10. wake up, wake up, wake up, wake up, wake up.\n
  11. It's time to start the day!\n";
  12.  
  13. /* Get Weather Data */
  14. if($weatherenabled == 1){
  15. $json=file_get_contents($weatherurl);
  16. $data=json_decode($json,true);
  17.  
  18. $tosay .= "... weather ...\n";
  19. $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n";
  20. $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n";
  21. $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n";
  22. $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n";
  23. }
  24.  
  25. if($gmailenabled == 1){
  26. $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error());
  27. $status=imap_status($mbox,$hostname,SA_ALL);
  28. if ($status) {
  29. $tosay .= "... email ...\n";
  30. $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n";
  31. } else {
  32. echo "imap_status failed: " . imap_last_error() . "\n";
  33. }
  34. imap_close($mbox);
  35. }
  36.  
  37. if($dateenabled == 1){
  38. $week = date('W');
  39. $fulldate = date('l \t\h\e jS \of F Y');
  40. $tosay .= "... date and time ...\n";
  41. $tosay .= "today is ".$fulldate.".\n";
  42. $tosay .= "it is week number ".$week.".\n";
  43. }
  44.  
  45. if($quoteenabled == 1){
  46. $json=file_get_contents('https://quotes.rest/qod?category='.$category);
  47. $data=json_decode($json,true);
  48. $author = $data['contents']['quotes'][0]['author'];
  49. $quote = $data['contents']['quotes'][0]['quote'];
  50. $tosay .= "... quote of the day ...\n";
  51. $tosay .= $author." once said... ".$quote.".\n";
  52. }
  53.  
  54. echo $tosay;
  55.  
  56. ?>
Buy Me A Coffee