-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
314 lines (280 loc) · 10.9 KB
/
index.php
File metadata and controls
314 lines (280 loc) · 10.9 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
include("includes/vars.php");
debuglog("=================****==================","INIT",2);
//
// Check to see if this is a mobile browser
//
if (array_key_exists('mobile', $_REQUEST)) {
$skin = ($_REQUEST['mobile'] == "phone") ? "phone" : "desktop";
debuglog("Request asked for skin: ".$skin,"INIT",6);
} else if(array_key_exists('skin', $_REQUEST)) {
$skin = $_REQUEST['skin'];
debuglog("Request asked for skin: ".$skin,"INIT",6);
} else if (array_key_exists('skin', $_COOKIE)) {
$skin = $_COOKIE['skin'];
debuglog("Using skin as set by Cookie: ".$skin,"INIT",6);
} else {
debuglog("Detecting window size to decide which skin to use....","INIT",4);
include('checkwindowsize.php');
exit(0);
}
$skin = trim($skin);
debuglog("Using skin : ".$skin,"INIT",6);
if (!is_dir('skins/'.$skin)) {
print '<h3>Skin '.$skin.' does not exist!</h3>';
exit(0);
}
if (file_exists('skins/'.$skin.'/skin.requires')) {
debuglog("Loading Skin Requirements File","INIT",9);
$skinrequires = file('skins/'.$skin.'/skin.requires');
} else {
$skinrequires = array();
}
// SVN had composergenrename as a string but it's now an array
if (!is_array($prefs['composergenrename'])) {
$prefs['composergenrename'] = array($prefs['composergenrename']);
}
// Workaround bug where this wasn't initialised to a value, meaning an error could be thrown
// on the first inclusion of connection.php
if ($prefs['player_backend'] == '') {
$prefs['player_backend'] = 'mpd';
}
include("includes/functions.php");
include("international.php");
//
// See if there are any POST values from the setup screen
//
if (array_key_exists('mpd_host', $_POST)) {
foreach ($_POST as $i => $value) {
debuglog("Setting Pref ".$i." to ".$value,"INIT", 3);
$prefs[$i] = $value;
}
setcookie('currenthost',$prefs['currenthost'],time()+365*24*60*60*10);
$prefs['multihosts']->$prefs['currenthost'] = (object) [
'host' => $prefs['mpd_host'],
'port' => $prefs['mpd_port'],
'password' => $prefs['mpd_password'],
'socket' => $prefs['unix_socket']
];
$logger->setLevel($prefs['debug_enabled']);
savePrefs();
}
debuglog($_SERVER['SCRIPT_FILENAME'],"INIT",9);
debuglog($_SERVER['PHP_SELF'],"INIT",9);
//
// Has the user asked for the setup screen?
//
if (array_key_exists('setup', $_REQUEST)) {
$title = get_int_text("setup_request");
include("setupscreen.php");
exit();
}
include("player/mpd/connection.php");
if (!$is_connected) {
debuglog("MPD Connection Failed","INIT",1);
$title = get_int_text("setup_connectfail");
include("setupscreen.php");
exit();
} else {
$mpd_status = do_mpd_command("status", true);
if (array_key_exists('error', $mpd_status)) {
debuglog("MPD Password Failed or other status failure","INIT",1);
close_mpd();
$title = get_int_text("setup_connecterror").$mpd_status['error'];
include("setupscreen.php");
exit();
}
}
// Let's do a test to see if we're running mpd or mopidy
$oldmopidy = false;
debuglog("Probing Player Type....","INIT",4);
$r = do_mpd_command('tagtypes', true, true);
if (is_array($r) && array_key_exists('tagtype', $r)) {
if (in_array('X-AlbumUri', $r['tagtype'])) {
debuglog(" ....tagtypes test says we're running Mopidy","INIT",4);
$prefs['player_backend'] = "mopidy";
} else {
debuglog(" ....tagtypes test says we're running MPD","INIT",4);
$prefs['player_backend'] = "mpd";
}
} else {
debuglog("WARNING! No output for 'tagtypes' - probably an old version of Mopidy. Rompr may not function correctly","INIT",2);
$prefs['player_backend'] = "mopidy";
$oldmopidy = true;
}
if ($prefs['unix_socket'] != '') {
// If we're connected by a local socket we can read the music directory
$arse = do_mpd_command('config', true);
if (array_key_exists('music_directory', $arse)) {
debuglog("Music Directory Is ".$arse['music_directory'],"INIT",9);
$prefs['music_directory'] = $arse['music_directory'];
if (is_link("prefs/MusicFolders")) {
system ("unlink prefs/MusicFolders");
}
system ('ln -s "'.$arse['music_directory'].'" prefs/MusicFolders');
}
}
close_mpd();
//
// See if we can use the SQL backend
//
// XML backend no longer supported. Force switch to SQLite.
if (array_key_exists('collection_type', $prefs) && $prefs['collection_type'] == "xml") {
$prefs['collection_type'] = "sqlite";
}
include( "backends/sql/connect.php");
if (array_key_exists('collection_type', $prefs)) {
connect_to_database();
} else {
probe_database();
include("backends/sql/".$prefs['collection_type']."/specifics.php");
}
if (!$mysqlc) {
sql_init_fail();
}
savePrefs();
list($result, $message) = check_sql_tables();
if ($result == false) {
sql_init_fail($message);
}
//
// Do some initialisation and cleanup of the Apache backend
//
include ("includes/firstrun.php");
debuglog("Initialisation done. Let's Boogie!", "INIT",9);
debuglog("=================****==================","STARTED UP",2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>RompR</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" sizes="196x196" href="newimages/favicon-196.png" />
<link rel="shortcut icon" sizes="128x128" href="newimages/favicon-128.png" />
<link rel="shortcut icon" sizes="16x16" href="newimages/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<?php
print '<link rel="stylesheet" type="text/css" href="skins/'.$skin.'/skin.css" />'."\n";
foreach ($skinrequires as $s) {
$s = trim($s);
$ext = strtolower(pathinfo($s, PATHINFO_EXTENSION));
if ($ext == "css") {
debuglog("Including Skin Requirement ".$s,"INIT",6);
print '<link rel="stylesheet" type="text/css" href="'.$s.'" />'."\n";
}
}
?>
<link rel="stylesheet" id="theme" type="text/css" />
<link rel="stylesheet" id="fontsize" type="text/css" />
<link rel="stylesheet" id="fontfamily" type="text/css" />
<link rel="stylesheet" id="icontheme-theme" type="text/css" />
<link rel="stylesheet" id="icontheme-adjustments" type="text/css" />
<link rel="stylesheet" id="albumcoversize" type="text/css" />
<!-- JQuery : http://jquery.com -->
<script type="text/javascript" src="jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="jquery/jquery-migrate-1.2.1.js"></script>
<!-- JQueryUI is required for $.widget even in the mobile version -->
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
<!-- JQuery AJAX form plugin : http://malsup.com/jquery/form/ -->
<script type="text/javascript" src="jquery/jquery.form.js"></script>
<!-- JQuery JSONP Plugin. My saviour : https://github.com/jaubourg/jquery-jsonp -->
<script type="text/javascript" src="jquery/jquery.jsonp-2.3.1.min.js"></script>
<!-- MD5 hashing algorith : http://pajhome.org.uk/crypt/md5 -->
<script type="text/javascript" src="jshash-2.2/md5-min.js"></script>
<!-- Masonry layout engine : http://masonry.desandro.com/ -->
<script type="text/javascript" src="jquery/imagesloaded.pkgd.min.js"></script>
<script type="text/javascript" src="jquery/masonry.pkgd.min.js"></script>
<script type="text/javascript" src="includes/globals.js"></script>
<script type="text/javascript" src="ui/readyhandlers.js"></script>
<script type="text/javascript" src="ui/debug.js"></script>
<script type="text/javascript" src="ui/functions.js"></script>
<script type="text/javascript" src="ui/uifunctions.js"></script>
<script type="text/javascript" src="ui/clickfunctions.js"></script>
<script type="text/javascript" src="ui/lastfm.js"></script>
<script type="text/javascript" src="ui/nowplaying.js"></script>
<script type="text/javascript" src="ui/infobar2.js"></script>
<script type="text/javascript" src="ui/playlist.js"></script>
<script type="text/javascript" src="ui/coverscraper.js"></script>
<script type="text/javascript" src="ui/favefinder.js"></script>
<?php
$inc = glob("streamplugins/*.js");
foreach($inc as $i) {
print '<script type="text/javascript" src="'.$i.'"></script>'."\n";
}
print'<script type="text/javascript" src="player/mpd/controller.js"></script>'."\n";
?>
<script type="text/javascript" src="player/player.js"></script>
<?php
include('includes/globals.php');
?>
<script language="javascript">
function aADownloadFinished() {
debug.trace("INDEX","Album Art Download Has Finished");
}
var playlist = new Playlist();
var player = new multiProtocolController();
var lastfm = new LastFM(prefs.lastfm_user);
var coverscraper = new coverScraper(0, false, false, prefs.downloadart);
var trackFinder = new faveFinder(false);
</script>
<script type="text/javascript" src="ui/podcasts.js"></script>
<?php
debuglog("Including skins/".$skin.'/skinvars.php',"LAYOUT",5);
include('skins/'.$skin.'/skinvars.php');
$inc = glob("browser/helpers/*.js");
foreach($inc as $i) {
debuglog("Including Browser Helper ".$i,"INIT",5);
print '<script type="text/javascript" src="'.$i.'"></script>'."\n";
}
$inc = glob("browser/plugins/*.js");
ksort($inc);
foreach($inc as $i) {
debuglog("Including Info Panel Plugin ".$i,"INIT",5);
print '<script type="text/javascript" src="'.$i.'"></script>'."\n";
}
if ($use_smartradio) {
$inc = glob("radios/*.js");
ksort($inc);
foreach($inc as $i) {
debuglog("Including Smart Radio Plugin ".$i,"INIT",5);
print '<script type="text/javascript" src="'.$i.'"></script>'."\n";
}
}
if ($use_plugins) {
$inc = glob("plugins/*.js");
foreach($inc as $i) {
debuglog("Including Plugin ".$i,"INIT",5);
print '<script type="text/javascript" src="'.$i.'"></script>'."\n";
}
}
?>
<script type="text/javascript" src="browser/info.js"></script>
<?php
foreach ($skinrequires as $s) {
$s = trim($s);
$ext = strtolower(pathinfo($s, PATHINFO_EXTENSION));
if ($ext == "js") {
debuglog("Including Skin Requirement ".$s,"INIT",5);
print '<script type="text/javascript" src="'.$s.'"></script>'."\n";
}
}
print '<script type="text/javascript" src="skins/'.$skin.'/skin.js"></script>'."\n";
?>
</head>
<?php
debuglog("Including skins/".$skin.'/skin.php',"LAYOUT",5);
include('skins/'.$skin.'/skin.php');
?>
<div id="tagadder" class="funkymusic dropmenu dropshadow">
<div class="configtitle textcentre hound" style="padding-top:4px"><b>
<?php
print get_int_text("lastfm_addtags").'</b><i class="icon-cancel-circled clickicon playlisticonr tright" onclick="tagAdder.close()"></i></div><div>'.get_int_text("lastfm_addtagslabel");
?>
</div>
<div class="containerbox padright dropdown-container tagaddbox"></div>
</div>
</body>
</html>