Newer
Older
SmartAlarm / alarm.php
root on 7 May 1 KB Initial commit
#!/usr/bin/php
<?php
include('config.php');

// quote
$category = "life"; // inspire, management, sports, life, funny, love, art, students

$tosay = "beep beep beep beep beep?\n
	beep beep beep beep beep.\n
	wake up, wake up, wake up, wake up, wake up.\n
	It's time to start the day!\n";

/* Get Weather Data */
if($weatherenabled == 1){
	$json=file_get_contents($weatherurl);
	$data=json_decode($json,true);

	$tosay .= "... weather ...\n";
	$tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n";
	$tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n";
	$tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n";
	$tosay .= "this is best described as ".$data['weather'][0]['description'].".\n";
}

if($gmailenabled == 1){
	$mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error());
	$status=imap_status($mbox,$hostname,SA_ALL);
	if ($status) {
		$tosay .= "... email ...\n";
		$tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n";
	} else {
		echo "imap_status failed: " . imap_last_error() . "\n";
	}
	imap_close($mbox);
}

if($dateenabled == 1){
	$week = date('W');
	$fulldate = date('l \t\h\e jS \of F Y');
	$tosay .= "... date and time ...\n";
	$tosay .= "today is ".$fulldate.".\n";
	$tosay .= "it is week number ".$week.".\n";
}

if($quoteenabled == 1){
	$json=file_get_contents('https://quotes.rest/qod?category='.$category);
	$data=json_decode($json,true);
	$author = $data['contents']['quotes'][0]['author'];
	$quote = $data['contents']['quotes'][0]['quote'];
	$tosay .= "... quote of the day ...\n";
	$tosay .= $author." once said... ".$quote.".\n";
}

echo $tosay;

?>