This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_library.php
executable file
·328 lines (268 loc) · 8.54 KB
/
p_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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<?php
require_once("connect.php");
require_once("header.php");
require_once("hash_functions.php");
require_once("position_check.php");
$rot;
$bUnreviewed;
$sTrackID;
$sArtistID;
$sAlbumID;
if (isset($_GET['trackID'])) {
$sTrackID = $_GET['trackID'];
}
if (isset($_GET['albumID'])) {
$sAlbumID = $_GET['albumID'];
}
if (isset($_GET['artistID'])) {
$sArtistID = $_GET['artistID'];
}
if (isset($_GET['rot'])) {
$rot = $_GET['rot'];
}
$md_ret_value = MD_check();
echo "
<div id = 'filters'>
<table><tr>
<td><div id = 'search'><input id = 'searchInput' type='text' value='Search: '></div></td>
<td><div id = 'centerlab'><a href='p_library.php?'>Bilbotheque</a></div></td>
<td></td>
<td><div id = 'reviewlabel'><a href='p_library.php?rot=0'>To Be Reviewed</a></div></td>
<td></td>
<td><div id = 'rotationlabel'>
<div id='rotationButton'><a href=' '>Rotation</a></div>
<div id='rotationtypes' style='display:none'>
<a href=''>: </a>
<a href = 'p_library.php?rot=1'>N</a>
<a href = 'p_library.php?rot=2'>H</a>
<a href = 'p_library.php?rot=3'>M</a>
<a href = 'p_library.php?rot=4'>L</a>
<a href = 'p_library.php?rot=6'>J</a>
</div>
</div>
</td>
</tr></table>
</div>";
// Album Detail, muy important
if(!empty($sAlbumID)) {
$tracksquery = "
SELECT DISTINCT t.track_num, t.track_name, d.airability, t.disc_num
FROM libartist b
JOIN libalbum a on a.ArtistID = b.ArtistID
JOIN libtrack t on t.AlbumID = a.AlbumID
JOIN def_airability d on d.airabilityID = t.airabilityID
WHERE a.albumID = ".$sAlbumID."
";
$detailquery = "
SELECT a.album_name, a.albumID, b.artist_name, b.artistID, r.username, r.reviewer, r.review, r.review_date
FROM libartist b
JOIN libalbum a on a.ArtistID = b.ArtistID
JOIN libtrack t on t.AlbumID = a.AlbumID
LEFT JOIN libreview r on r.albumID = a.albumID
WHERE a.albumID = ".$sAlbumID."
LIMIT 1";
//Submit Queries
$details = mysql_query($detailquery, $link);
$list = mysql_query($tracksquery, $link);
//If query returns FALSE, no albums were returned. Die with error
if (!$list) die ('No Tracks returned, this album is fucked up: ' . mysql_error());
$deet = mysql_fetch_assoc($details);
echo "<div id='results'>
<div id='detail'>
<strong>".$deet['album_name']."</strong><br>
by <a href= 'p_library.php?artistID=".$deet['artistID']."'>".$deet['artist_name']." </a> <br>";
if( $deet['reviewer']) echo "<p>".$deet['review']." - <a href = 'p_profiles.php?dj=".$deet['username']."'>".$deet['reviewer']."</a> ".$deet['review_date']."</p>";
else echo "<a href='p_review.php?albumID=".$deet['albumID']."'>Review this album</a>";
echo "</div>
<div id='list'>
<table>
<tr>
<th>Tracks</th>
<th></th>
<th></th>
</tr>";
//Get row from SQL Query, populate tables with tracks
while($row = mysql_fetch_assoc($list)) {
echo "<tr>
<td>".$row['track_num'].". ".$row['track_name']."</td>
<td>".$row['airability']."</td>
<td><img src='crystal2.png'> 13 <a href = ''>+</a></td>
</tr> ";
}
echo "
</table>
</div>
</div>";
}
else if(!empty($sArtistID)) {
$albumsquery = "
SELECT a.albumID, a.album_name, a.artistID, r.reviewer, r.username
FROM libalbum a
LEFT JOIN libartist b on b.artistID = a.artistID
LEFT JOIN libreview r on r.albumID = a.albumID
LEFT JOIN def_rotations d on d.rotationID = a.rotationID
WHERE a.artistID = ".$sArtistID;
/*
LEFT JOIN libreview r on r.albumID = a.albumID
LEFT JOIN def_rotations d on d.rotationID = a.rotationID
*/
$detailquery = "
SELECT b.artist_name, b.artistID
FROM libartist b
JOIN libalbum a on a.ArtistID = b.ArtistID
WHERE b.artistID = ".$sArtistID." LIMIT 1";
//Submit Query
$details = mysql_query($detailquery, $link);
$list = mysql_query($albumsquery, $link);
//If query returns FALSE, no albums were returned. Die with error
if (!$list) die ('No Tracks returned, this artist aint got shit: ' . mysql_error());
$deet = mysql_fetch_assoc($details);
echo "
<div id='results'>
<div id='detail'>
<strong>".$deet['artist_name']."</strong><br>
</div>
<div id='list'>
<table>
<tr>
<th>Album</th>
<th>Reviewer</th>
</tr> ";
//Get row from SQL Query, populate tables with Albums
while($row = mysql_fetch_assoc($list)) {
echo "
<tr>
<td><a href = 'p_library.php?albumID=".$row['albumID']."'>".$row['album_name']."</a></td>";
if ( $row['reviewer']){
echo " <td><a href = 'p_profiles.php?dj=".$row['username']."'>".$row['reviewer']."</a></td>";
} else {
echo " <td><a href = 'p_library.php?albumID=".$row['albumID']."'>review this! </a></td>";
}
echo" <td>".$row['binAbbr']."</td>
<td><img src='crystal2.png'> 13</td>
</tr> ";
}
echo " </table>
</div>
</div>";
}
else { //nothing set
$query = "
SELECT a.album_name, a.albumID, b.artist_name, b.artistID, r.reviewer, r.review_date, r.username, a.rotationID
FROM libalbum a
JOIN libartist b on a.artistID = b.artistID
LEFT JOIN libreview r on a.albumID = r.albumID
LEFT JOIN def_rotations d on d.rotationID = a.rotationID";
//unreviewed or rotation
if ( isset($rot) ) {
$query.=" WHERE a.rotationID = ";
$query.=$rot;
$query.=" ORDER BY r.review_date ASC";
}
else { // default to new, recently reviewed rotation
$query.=" WHERE a.rotationID = 1
ORDER BY r.review_date DESC";
}
$query.=" LIMIT 50";
//Submit Query
$list = mysql_query($query, $link);
//If query returns FALSE, no albums were returned. Die with error
if (!$list) die ('No albums returned: ' . mysql_error());
echo "
<div id = 'results'>
<div id = 'list'>
<table>
<tr>
<th>Artist</th>
<th>Album</th>
<th>Reviewer</th>
<th><a href = ''></a></th>
<th></td>
</tr> ";
//Get row from SQL Query, populate tables with albums
while($row = mysql_fetch_assoc($list)) {
$albumID = $row['albumID'];
$album_code = $row['album_code'];
$album_name = $row['album_name'];
$artist_name = $row['artist_name'];
$artistID = $row['artistID'];
/*
if ($rot != 0) {
$review_date = $row['review_date'];
$last_name = $row['last_name'];
$first_name = $row['first_name'];
}
if($album_code == $albumID){
$a_code = "<a href=\"review.php?albumID=$albumID\">REVIEW THIS!</a>";
}
else{
$a_code = "<a href=\"read_review.php?albumID=$albumID\">$album_code</a>";
//If user is music director, show extra link to edit a review
if($md_ret_value)
$a_code .= "<br><a href=\"review.php?albumID=$albumID&edit=1\">Edit Review</a>";
}
*/
echo " <tr>
<td><a href = 'p_library.php?artistID=".$row['artistID']."'>".$row['artist_name']."</a></td>
<td><a href = 'p_library.php?albumID=".$row['albumID']."'>".$row['album_name']."</a></td>";
if ( $row['reviewer']){
echo " <td><a href = 'p_profiles.php?dj=".$row['username']."'>".$row['reviewer']."</a></td>";
} else {
echo " <td><a href = 'p_review.php?albumID=".$row['albumID']."'>review this! </a></td>";
}
echo " <td>".$row['binAbbr']."</td>
<td><img src='crystal2.png'> 13</td>
</tr>";
}
echo " </table>
</div>
</div>";
}
echo "
<script type = 'text/javascript'>
$('#search').click(function(event) {
$('#results').hide();
if ( $('#searchInput').attr('value') == 'Search: ' ) {
$('#searchInput').attr('value','');
$.post('p_search.php', function(data) {
$('#center').append(data);
});
}
$('#searchresults').show();
});
$('#centerlab a').click(function(event){
event.preventDefault();
var qs = $(this).attr('href');
$.post(qs, function(data) {
$('#center').html(data);
});
});
$('#reviewlabel a').click(function(event) {
event.preventDefault();
var qs = $(this).attr('href');
$.post(qs, function(data) {
$('#center').html(data);
});
});
$('#rotationButton a').click(function(event) {
event.preventDefault();
$('#rotationtypes').toggle();
});
$('#rotationtypes a').click(function(event) {
event.preventDefault();
$('#')
var qs = $(this).attr('href');
$.post(qs, function(data) {
$('#center').html(data);
});
});
$('#results a').click(function(event){
event.preventDefault();
var qs = $(this).attr('href');
$.post( qs, function(data) {
$('#center').html(data);
});
});
</script>
";
?>