This repository has been archived by the owner on Jan 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
64 lines (54 loc) · 1.46 KB
/
api.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
<?php
if (!$_GET) echo getServers();
if ($_GET['control'])
{
file_put_contents("ctl", "{$_GET['control']}\n");
if ($_GET['control'] == "n") file_put_contents("msg", "Skipped");
}
function getServers() {
$return = "";
$servers = file_get_contents("servers");
unlink("servers");
$array = explode("\n", $servers);
foreach ($array as $server) {
$entry = explode("|", $server);
$name = $entry[0];
$address = $entry[1];
$href = "server.php?address=$address";
$return .= "<h1><a href=$href >$name</a></h1>";
}
return $return;
}
function getSong() {
$return = "";
if (!file_exists("curSong"))
{
$return = "
<img src=imgs/pandora.png class=albumart alt=\"Pandora logo\" />
<h1>Hello There</h1>
<h2>Pianobar is starting up...</h2>";
die($return);
}
if (file_exists("msg"))
{
$msg = file_get_contents("msg");
unlink("msg");
die("<h1 class=msg>$msg</h1>");
}
$songInfo = file_get_contents("curSong");
$arraySong = explode("|", $songInfo);
$title = $arraySong[0];
$artist = $arraySong[1];
$album = $arraySong[2];
$coverart = $arraySong[3];
if (!$coverart) $coverart = "imgs/pandora.png";
$love = $arraySong[4];
if ($love==1) $return .= "<img src=imgs/love.png class=love width=20 />";
$return .= "
<img src=$coverart class=albumart alt=\"Artwork for $album\" />
<h1>$title</h1>
<h2>$artist</h2>
<h2 class=album>$album</h2>";
return $return;
}
?>