-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.php
191 lines (161 loc) · 4.13 KB
/
admin.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
require "config.php";
require_once "hvp-playlist.class.php";
require_once "hvp-file-browser.class.php";
require_once "hvp-settings.class.php";
$settings = new Hvp\Settings ();
$playlist = new Hvp\Playlist ();
/* add a new item into the playlist or remove one */
if (isset ($_GET['path']) && is_file ($_GET['path'])) {
$path = urldecode ($_GET['path']);
$playlist->add_item ($path);
}
else if (isset ($_GET['hash'])) {
$playlist->remove_item ($_GET['hash']);
}
/* update settings */
if (isset ($_GET['action']) && $_GET['action'] == "configuration" && !empty ($_POST)) {
if (isset ($_POST['title']) && !empty ($_POST['title'])) {
$settings->set_value ("/general/title", $_POST['title']);
}
if (isset ($_POST['interface'])) {
$settings->set_value ("/general/interface", $_POST['interface']);
}
if (isset ($_POST['video-backend'])) {
$settings->set_value ("/general/video-backend", $_POST['video-backend']);
}
$value = (!isset ($_POST['autoplay'])) ? "false" : "true";
$settings->set_value ("/general/autoplay", $value);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Administration - <?php echo $settings->title; ?></title>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="style-admin.css" />
</head>
<body>
<header>
<h1>Home Video Player Administration</h1>
</header>
<div id="content-wrapper">
<div id="main-content">
<div id="admin">
<div id="admin-tabs">
<ul>
<li><a href="./">← Back</a></li>
<li><a href="?action=file-browser">File Browser</a></li>
<li><a href="?action=configuration">Configuration</a></li>
</ul>
</div>
<div id="admin-content">
<?php
/* $_GET['action'] */
$action = (isset ($_GET['action'])) ? $_GET['action'] : "";
switch ($action) {
case "file-browser":
default:
?>
<?php
/* ========== File browser ========== */
echo "<ul id=\"file-browser\">";
if (!isset ($directories)) {
echo "<li>File directories.php not set</li>";
}
else {
foreach ($directories as $directory) {
echo "<li><strong>$directory</strong></li>";
echo "<ul>";
Hvp\FileBrowser::read_dir ($directory);
echo "</ul>";
}
}
echo "</ul>";
?>
<?php
break;
case "configuration":
?>
<?php
/* ========== Configuration ========== */
?>
<h1>General Settings</h1>
<form method="post" action="admin.php?action=configuration">
<ul>
<li>
Title:
<input type="text" name="title" value="<?php echo $settings->title; ?>" />
</li>
<?php
$interface = $settings->interface;
?>
<li>
Interface:
<select name="interface">
<option <?php echo ($interface == "index") ? "selected" : "" ?> value="index">Index</option>
<option <?php echo ($interface == "playlist") ? "selected" : "" ?> value="playlist">Playlist</option>
</select>
</li>
<?php
$video_backend = $settings->get_value ("/general/video-backend");
?>
<li>
Video backend:
<select name="video-backend">
<option <?php echo ($video_backend == "HTML5") ? "selected" : "" ?>>HTML5</option>
<option <?php echo ($video_backend == "VLC") ? "selected" : "" ?>>VLC</option>
<option <?php echo ($video_backend == "WMP") ? "selected" : "" ?>>WMP</option>
</select>
</li>
<li>
<input <?php echo ($settings->autoplay == "true") ? "checked" : "" ?> type="checkbox" name="autoplay" id="autoplay" value="true" />
<label for="autoplay">Autoplay</label>
</li>
</ul>
<div>
<input type="submit" value="Update" />
</div>
</form>
<h1>Directories</h1>
<ul id="directories">
<?php
foreach ($directories as $directory) {
echo "<li>$directory</li>";
}
?>
</ul>
<div>
<input type="button" value="Edit" />
</div>
<?php
/* !$_GET['action'] */
break;
}
?>
</div>
</div>
</div>
<div id="side-panel-wrapper"><div id="side-panel-inner"><div id="playlist">
<ul>
<?php
$items = $playlist->get_playlist ();
foreach ($items as $item) {
if (isset ($_GET['hash']) && $_GET['hash'] == $item['hash'])
$li = 'li class="selected"';
else
$li = 'li';
echo "<$li><a href=\"admin.php?hash=${item['hash']}\">${item['name']}</a></li>";
}
?>
</ul>
</div></div></div>
</div>
<footer>
<?php
require "footer.php";
?>
</footer>
</body>
</html>