-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
109 lines (85 loc) · 2.09 KB
/
Copy pathindex.php
File metadata and controls
109 lines (85 loc) · 2.09 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
require('top.php');
if (isset($_GET['v'])) {
$_SESSION['volume'] = intval($_GET['v']);
}
$radio = new Lib_Radio();
$stations = $radio->stations();
foreach ($stations as $group_name => &$group_stations) {
foreach ($group_stations as &$station) {
$s = Lib_Station_Factory::create($group_name, $station);
$station = array(
'id' => $s->id(),
'name' => $s->name(),
'playing' => $s->playing()
);
if (isset($_GET['v']) && $station['playing']) {
$s->stop();
$s->play($_SESSION['volume']);
}
}
// Destroy reference
unset($station);
}
// Destroy reference
unset($group_stations);
if (isset($_GET['v'])) {
header('Location: ./');
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Music Web Remote</title>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="refresh" content="30" />
<link href="resource/css/main.css" rel="stylesheet" media="all" />
</head>
<body>
<h2>Radio</h2>
<form action="./" method="get">
<label>
Volume:
<select name="v">
<? foreach (array_fill(0, 10, '') as $i => $t): ?>
<? $v = 100 - $i * 10 ?>
<? if (isset($_SESSION['volume']) && $_SESSION['volume'] === $v): ?>
<option selected="selected" value="<?= $v ?>"><?= $v ?></option>
<? else: ?>
<option value="<?= $v ?>"><?= $v ?></option>
<? endif ?>
<? endforeach ?>
</select>
</label>
<input type="submit" value="Set" />
</form>
<? foreach ($stations as $group => $group_stations): ?>
<h3><?= ucfirst($group) ?></h3>
<ul>
<? foreach ($group_stations as $station): ?>
<li>
<?= $station['name'] ?>
<?
if ($station['playing']) {
$command = 'stop';
} else {
$command = 'play';
}
$href = "command.php?c={$command}&g={$group}&s={$station['id']}";
if (isset($_SESSION['volume'])) {
$href .= "&v={$_SESSION['volume']}";
}
?>
<? if ($command === 'play'): ?>
(<a href="<?= $href ?>">Start</a>)
<? else: ?>
(Playing... <a href="<?= $href ?>">Stop</a>)
<? endif ?>
</li>
<? endforeach ?>
</ul>
<? endforeach ?>
</body>
</html>