-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
69 lines (62 loc) · 3.19 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require "alice.php";
if (time()-$u['time'] > 1200) $errors[] = array("danger", "Alice's data is at least 20 minutes old.");
/* Masthead */
if (alice_xbmc_playing())
{
$nowPlaying = alice_xbmc_playing();
if ($nowPlaying[0])
$masthead = "{$nowPlaying[0]} - “{$nowPlaying[1]}”";
else $masthead = $nowPlaying[1];
}
elseif ($e['count'])
if ($e['count'] == 1) $masthead = "{$e['count']} new message";
else $masthead = "{$e['count']} new messages";
else
{
$masthead = "{$w['currTemp']}°F - {$w['currCond']} <img src=./inc/images/weather/{$w['icon']}.png width=100 alt='{$w['currCond']}' />";
}
/* Subhead */
if (alice_xbmc_playing())
{
$subhead = <<<SHEAD
<div class="progress progress-striped active"><div class="progress-bar" style="width: {$nowPlaying[2]}%;"><strong>{$nowPlaying[2]}%</strong></div></div>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"rewind"}});'><span class="glyphicon glyphicon-backward"></span></a>
<a class="btn btn-primary" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"pause"}});'><span class="glyphicon glyphicon-play"></span><span class="glyphicon glyphicon-pause"></span></a>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"stop"}});'><span class="glyphicon glyphicon-stop"></span></a>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"forward"}});'><span class="glyphicon glyphicon-forward"></span></a>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"volumeup"}});'><span class="glyphicon glyphicon-volume-up"></span></a>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"volumedown"}});'><span class="glyphicon glyphicon-volume-down"></span></a>
<a class="btn btn-default" onclick='aliceAPI({"method":"XBMC.Control","params":{"action":"mute"}});'><span class="glyphicon glyphicon-volume-off"></span></a>
SHEAD;
}
else $subhead = "It is ".date("g:i a");
/* XBMC */
/* Get three most recent films */
if (alice_xbmc_isOn())
{
$jsonThreeFilms = json_decode(alice_xbmc_talk(array("jsonrpc" => "2.0", "method" => "VideoLibrary.GetRecentlyAddedMovies", "params" => array("limits" => array("end" => 3), "properties" => array("mpaa", "runtime")), "id" => 1)));
$arrayThreeFilms = $jsonThreeFilms->result->movies;
$films = "";
foreach ($arrayThreeFilms as $movie)
{
$films .= "<a href=\"xbmc.php?movie={$movie->movieid}\"><strong>{$movie->label}</strong></a> - {$movie->mpaa} - " . floor($movie->runtime / 60) . " mins<br />\n";
}
$smarty->assign("xbmcBody", $films);
}
else $errors[] = array("warning", "XBMC is offline.");
$notifications = alice_mysql_get("modules", "notification", "DESC");
foreach($notifications as $id => $value)
{
$value = explode("|", $value);
$notif[] = array("id"=>$id, "title"=>$value[0], "message"=>$value[1]);
}
$smarty->assign("masthead", $masthead);
$smarty->assign("subhead", $subhead);
$smarty->assign("weather", $w);
$smarty->assign("updateTime", date("g:i a", $u['time']));
$smarty->assign("updateCity", $u["city"]);
$smarty->assign("notifications", array_slice($notif, 0, 3));
$smarty->assign("error", $errors);
$smarty->display("index.tpl");
?>