-
Notifications
You must be signed in to change notification settings - Fork 1
/
library.php
133 lines (124 loc) · 4.88 KB
/
library.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
<?php
require_once('session.php');
require_once('global.php');
?>
<?php
$view = "artist";
if (isset($_GET['view']))
$view = $_GET['view'];
$scrollto_active = false;
if (isset($_GET['scrollto_active']) && $_GET['scrollto_active'] != "")
$scrollto_active = true;
$addtoplaylistparameter = "";
if (isset($_GET['addtoplaylist']))
$addtoplaylistparameter = "&addtoplaylist=" . $_GET['addtoplaylist'];
?>
<div id="containerContainer">
<!-- Context Menu -->
<div id="libraryContextMenu" style="display:none;">
<div>
<select id="libraryContextMenuAddToPlaylist" onchange="addToPlaylist(this.value)">
<option value="-1" selected disabled>Add to playlist</option>
<?php
require_once('database.php');
$sql = "SELECT * FROM playlist";
$result = $mysqli->query($sql);
while($row = $result->fetch_object()) {
echo "<option value=".$row->id.">".$row->title."</option>";
}
?>
</select>
</div>
<div>
<button onclick="closeContextMenu()">Close</button>
</div>
</div>
<!-- End Context Menu -->
<table id="libraryViewModeBar" cellspacing="0">
<tr>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=artist<?php echo $addtoplaylistparameter; ?>');" class="<?php $imgadd=""; if ($view =='artist') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/artist<?php echo $imgadd; ?>.svg" height="30"><br>Artists
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=album<?php echo $addtoplaylistparameter; ?>');" class="<?php $imgadd=""; if ($view =='album') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/album<?php echo $imgadd; ?>.svg" height="30"><br>Albums
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=track<?php echo $addtoplaylistparameter; ?>');" class="<?php $imgadd=""; if ($view =='track') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/track<?php echo $imgadd; ?>.svg" height="30"><br>Tracks
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=playlist');" class="<?php $imgadd=""; if ($view =='playlist') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/currentplaylist<?php echo $imgadd; ?>.svg" height="30"><br>Playlists
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=files');" class="<?php $imgadd=""; if ($view =='files') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/dir<?php echo $imgadd; ?>.svg" height="30"><br>Files
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=more');" class="<?php $imgadd=""; if ($view =='more') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/more<?php echo $imgadd; ?>.svg" height="30"><br>More
</a>
</td>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=options');" class="<?php $imgadd=""; if ($view =='options') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/menu<?php echo $imgadd; ?>.svg" height="30"><br>Options
</a>
</td>
<?php if(isUpdateAvail()) { ?>
<td>
<a href='#' onclick="ajaxRequest('content','library.php?view=update');" class="<?php $imgadd=""; if ($view =='update') { echo 'active'; $imgadd="_b"; } ?>">
<img src="img/update<?php echo $imgadd; ?>.svg" height="30"><br>Update
</a>
</td>
<?php } ?>
</tr>
</table>
<div id="searchContainer" class="inputwithimg">
<img src="img/search.svg">
<input type="text" id="search" onkeyup="searchList('search', 'mainlist');" placeholder="" <?php if(!$scrollto_active) echo "autofocus='true'"; ?> title="search current library view" onfocus="controlButton_onFocus();" onblur="controlButton_lostFocus();">
</div>
<ul id="mainlist" class="list">
<?php
require_once('database.php');
// add track to playlist if parameter is given
if (isset($_GET['addtoplaylist'])) {
$sql = "SELECT title FROM playlist WHERE id = ?;";
$statement = $mysqli->prepare($sql);
if (!$statement)
die("<b>PREPARE FAILED:</b> $file<br>$sql<br>");
if (!$statement->bind_param('i', $_GET['addtoplaylist']))
die("<b>BIND FAILED:</b> $file<br>$sql<br>");
if (!$statement->execute())
die("<b>EXEC FAILED:</b> $file<br>$sql<br>");
$statement->bind_result($title);
while ($statement->fetch()) {
echo "<div class='playlistOptions'>";
echo "<div class='infobox'>";
echo "Add tracks to playlist <span class='playlist_title'>$title</span>";
echo "<a href='#' onclick='ajaxRequest(\"content\",\"library.php?view=artist\");' class='playlist_abort'>✖ Abort</a>";
echo "</div>";
echo "</div><br>";
break;
}
$statement->close();
}
// open library view
if(file_exists("php/library-views/$view.php")) {
require("php/library-views/$view.php");
} elseif ($view == "license") {
echo "<div id='license'>";
echo file_get_contents("LICENSE.txt");
echo "</div>";
} else {
echo "invalid library call :-(";
}
?>
</ul>
</div>