This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.php
executable file
·124 lines (100 loc) · 2.92 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
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
<?php
/* Settings */
$mpdServer = 'localhost';
$mpdPort = '6600';
$mpdPassword = NULL;
$volDownSteps = 10;
$volUpSteps = 10;
/* Do not change */
ob_start();
include 'inc/mpd.class.php';
include 'inc/functions.php';
$mpd = new mpd($mpdServer, $mpdPort, $mpdPassword);
define('CURRENTARTIST', $mpd->playlist[$mpd->current_track_id]['Artist']);
define('CURRENTTRACK', $mpd->playlist[$mpd->current_track_id]['Title']);
define('CURRENTID', $mpd->playlist[$mpd->current_track_id]['Id']);
include 'tpl/header.tpl.php';
if($mpd->connected == FALSE) {
echo "Error: " .$mpd->errStr;
} else {
$statusrow = explode("\n", $mpd->SendCommand('status'));
foreach($statusrow as $row) {
$get = explode(': ', $row);
$status[$get[0]] = $get[1];
}
$times = explode(':', $status['time']);
$CURRENTLENGTH = convertSecs($times[1]);
$CURRENTTIME = convertSecs($times[0]);
// fucking dirty
if($mpd->state != 'stop') {
$refresh = ((($times[1]-$times[0])*1000)+500);
if($refresh < 1) { $refresh = 30500; }
echo '<script type="text/javascript">setTimeout("location.reload(true);", ' . $refresh . ');</script>'."\n";
}
if(isset($_POST['toadd'])) {
$object = $_POST['toadd'];
$files = explode("\n", $mpd->SendCommand('lsinfo'));
foreach($files as $row) {
$file = explode(':', $row);
$thefiles[][$file[0]] = ltrim($file[1]);
}
foreach($thefiles as $search) {
if(array_search($object, $search) == 'directory') {
$dir = $mpd->GetDir($object);
foreach($dir as $addRow) {
$addArr[] = $addRow['file'];
}
$mpd->PLAddBulk($addArr);
break;
} else {
$songs = explode(',', $object);
$mpd->PLAddBulk($songs);
break;
}
}
$mpd->SendCommand('update');
header('Location: ./#current');
}
switch($_GET['a']) {
case 'volup':
$mpd->AdjustVolume($volUpSteps); break;
case 'voldown':
$mpd->AdjustVolume('-'.$volDownSteps); break;
case 'play':
$mpd->Play(); header('Location: ./#current'); break;
case 'pause':
$mpd->Pause(); header('Location: ./#current'); break;
case 'prev':
$mpd->Previous(); header('Location: ./#current'); break;
case 'next':
$mpd->Next(); header('Location: ./#current'); break;
case 'stop':
$mpd->Stop(); header('Location: ./#current'); break;
case 'start':
$songID = (int) $_GET['id'];
$mpd->SkipTo($songID);
header('Location: ./#current');
break;
case 'clearpl':
$mpd->PLClear();
header('Location: ./');
break;
case 'remove':
$songID = (int) $_GET['id'];
$mpd->SendCommand('deleteid', $songID);
$mpd->RefreshInfo();
header('Location: ./#current');
break;
}
switch($mpd->state) {
case 'play':
$status = 'playing'; break;
case 'pause':
$status = 'paused'; break;
default:
$status = 'stopped'; break;
}
include 'tpl/main.tpl.php';
}
include 'tpl/footer.tpl.php';
?>