-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_report.php
316 lines (286 loc) · 10.7 KB
/
session_report.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
<?php require("verify.php");
#### User has logged in and been verified ####
settype ($xperpage, "integer");
//echo "Date:$xdate";
if ($xdate == "") $xdate = date("Y-m-d");
if ($xdate2 == "") $xdate2 = date ("Y-m-d");
if ($xperpage < 5) $xperpage = 200;
if ($xperpage > 200) $xperpage = 200;
if ($sdate =="") $sdate=mod;
####Get username
if (!$xname) { $xname = $user[username]; }
$xname = htmlentities($xname);
//echo $xname;
?>
<HTML>
<head>
<TITLE>ThreeD - MusicDB Session Report</TITLE>
<LINK REL="StyleSheet" HREF="style.css" TYPE="text/css">
</head>
<BODY onload="document.forms[0].xdate.focus()">
<B>MUSIC CATALOGUE - SESSION REPORT</B>
<form action=session_report.php method=post>
<input type=hidden name=xdosearch value=1>
<p><table border=0 cellspacing=0 cellpadding=5>
<tr>
<td>
<font color=red>The session report now has added functionality - the default settings are the same as before, except it only shows your items - replace your name with * to see everyone's items </font>
</td>
<td></td>
</tr>
<tr bgcolor="#CCCCCC">
<td align=left><b>Enter dates to check (yyyy-mm-dd) From: </b><input type=text name=xdate value="<?php echo htmlentities(stripslashes($xdate))?>" size=25 maxlength=50>
<b> To: </b><input type=text name=xdate2 value="<?php echo htmlentities(stripslashes($xdate2))?>" size=25 maxlength=50>
</td>
<td></td>
</tr>
<tr bgcolor="#CCCCCC">
<td align=left><b>Show items for this user only: </b>
<input type=text name=xname value="<?php echo "$xname" ?>" size=25 maxlength=50><b> (use * to view all users)</b>
</td>
<td></td>
</tr>
<tr bgcolor="#CCCCCC">
<td align=left><b>Date to search: </b>
<select name=sdate>
<!--<option value="any"<?php //if ($sdate == "any") { echo " selected"; } ?>>Any Type</option>-->
<option value="mod"<?php if ($sdate == "mod") { echo " selected"; } ?>>Date Modified</option>
<option value="cre"<?php if ($sdate == "cre") { echo " selected"; } ?>>Date Created</option>
<option value="arr"<?php if ($sdate == "arr") { echo " selected"; } ?>>Date Arrived</option>
</select>
<b> Matches per Page: </b>
<select name=xperpage>
<option value=200<?php if ($xperpage == 200) { echo " selected"; } ?>>200</option>
<option value=100<?php if ($xperpage == 100) { echo " selected"; } ?>>100</option>
<option value=50<?php if ($xperpage == 50) { echo " selected"; } ?>>50</option>
<option value=25<?php if ($xperpage == 25) { echo " selected"; } ?>>25</option>
<option value=10<?php if ($xperpage == 10) { echo " selected"; } ?>>10</option>
<option value=5<?php if ($xperpage == 5) { echo " selected"; } ?>>5</option>
</select>
</td>
<td align=right><input type=submit name=xbutton value=Search>
</td>
</tr>
<!--<tr bgcolor="#CCCCCC">
<td>
<font color=red> NB Date Arrived will only work if the Arrival Date is filled out correctly for each CD!! </font>
</td>
<td></td>
</tr>-->
</table>
<?php
$xwords = addslashes($xwords); #################
$pieces = explode("-", $xdate2); //0=year,1=month,2=day
//echo "Year:",$pieces[0], " Month:",$pieces[1], " Day:",$pieces[2], "<br>";
$nextday = mktime(0, 0, 0, $pieces[1], $pieces[2]+1, $pieces[0]);
$enddate = date ("Y-m-d", $nextday);
//echo "<br>xdate2:", $xdate2, ":<br> date :",$xdate,":<br><br>";*/
//Type of date to use:
if ($sdate=="any")
{$when="any";
echo " using any ";
$who = "cd.createwho";
$head = "Created By";}
else if ($sdate=="mod")
{$when = "modifywhen";
$who = "cd.modifywho";
$head = "Modified By";}
else if ($sdate=="cre")
{$when = "createwhen";
$who = "cd.createwho";
$head = "Created By";}
else if ($sdate=="arr")
{$when = "arrivaldate";
$who = "cd.createwho";
$head = "Created By";}
//echo " when is $when ";
if ($xdosearch) {
$qsort = "cd.id";
if ($when=="arrivaldate") {
//Use arrivaldate (field type is date)
$where="WHERE (cd.$when>=date'$xdate'
AND cd.$when<=date'$enddate')
AND $who = users.id ";
}
else {
//use either modifydate or createdate (field type is bigint)
$where="WHERE ('1970-01-01 00:00:00 GMT'::timestamp +
((cd.$when::bigint)::text)::interval>=date'$xdate'
AND '1970-01-01 00:00:00 GMT'::timestamp +
((cd.$when::bigint)::text)::interval<=date'$enddate')
AND $who = users.id ";
}
if ($xname!="*") {
$where = $where."AND users.username = '$xname' ";
}
//modified here---------->
$query ="SELECT cd.id, cd.artist, cd.title, cd.local, cd.format, users.username, cd.$when FROM cd, users ";
// $query ="SELECT cd.id, cd.artist, cd.title, cd.local, cd.format, users.username, cd.arrivaldate, cd.createwhen, cd.modifywhen FROM cd, users ";
$query=$query.$where;
// $query = $query."GROUP BY $who, cd.id, cd.artist, cd.title, cd.local, cd.format, users.username, cd.$when, cd.arrivaldate, cd.createwhen, cd.modifywhen ORDER BY cd.id;";
$query = $query."GROUP BY $who, cd.id, cd.artist, cd.title, cd.local, cd.format, users.username, cd.$when ORDER BY cd.id;";
// echo "<p>" . htmlentities($query) . "<p>";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
//Check for existance of mp3 files
echo "<p><table border=0 cellspacing=0 cellpadding=3>\n";
echo "<tr><td><b>$num match";
if ($num != 1) { echo "es"; }
echo " found</b></td>";
echo '<tr bgcolor="#CCCCCC">';
echo "<td>If you catalogue a CD with a data track (eg a video etc) and you include that track in the catalogue, make sure you put <b>[data]</b> at the begining of the track title, otherwise this page will show that the CD was not successfully MP3ed.</td></tr>";
echo "<br> If a CD shows up as <i>Not MP3ed successfully</i>, click on the <i>Show</i> link to see which track(s) are missing.";
if (!$xmore && !$xless) { $xcursor = 1; }
if ($xcursor < 1) $xcursor = 1;
if ($xless) { $xcursor = $xcursor - $xperpage; }
if ($xmore) { $xcursor = $xcursor + $xperpage; }
if ($xcursor < 1) $xcursor = 1;
if ($xcursor > $num) $xcursor = $num;
$start = $xcursor;
$end = $start + $xperpage - 1;
if ($end > $num) { $end = $num; }
if ($num > $xperpage) {
echo "<td><b>Showing matches $start to $end</b></td>";
}
if ($start > 1) { echo "<td><input type=submit name=xless value=Previous></td>"; }
if ($num > $end) { echo "<td><input type=submit name=xmore value=Next></td>"; }
echo "</tr></table>";
if ($num) {
echo "<input type=hidden name=xcursor value=$xcursor>";
echo "<p>\n";
echo "<p><TABLE border=1 cellpadding=2 cellspacing=0 bgcolor=#CCCCCC width=100%>\n";
echo "<tr><th align=left>ID Number</th><th align=left>Artist</th><th align=left>Album Title</th><th align=left>$head</th><th align=left>Date</th><th align=left>MP3</th><th align=left>Local</th><th align=left>Format</th><th align=center>Action</th></tr>\n";
// echo "<tr><th align=left>ID Number</th><th align=left>Artist</th><th align=left>Album Title</th><th align=left>$head</th><th align=left>ArrivalDate</th><th align=left>CreateDate</th><th align=left>ModifyDate</th><th align=left>Date</th><th align=left>MP3</th><th align=left>Local</th><th align=left>Format</th><th align=center>Action</th></tr>\n";
for ($i=$start-1;$i<$end;$i++) {
echo "<TR valign=top bgcolor=#";
if ($i % 2 == 0) { echo "CCFFCC"; } else { echo "CCCCFF"; }
echo ">";
$r = pg_Fetch_array($result, $i, PGSQL_ASSOC);
$a = htmlentities($r[id]);
echo "<td>";
if ($a) { echo sprintf("%07.0f", $a); }
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[artist]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[title]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[username]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
//selected
$a = htmlentities($r[$when]);
if ($when!=arrivaldate) {$a=date("Y-m-d", $a);}
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
/*
//arrival
$a = htmlentities($r[cd.arrivaldate]);
$a=date("Y-m-d", $a);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
//create
/* $a = htmlentities($r[('1970-01-01 00:00:00 GMT'::timestamp +
((cd.createwhen::bigint)::text)::interval]);
{$a=date("Y-m-d", $a);}
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
//modify
$a = htmlentities($r[('1970-01-01 00:00:00 GMT'::timestamp +
((cd.modifywhen::bigint)::text)::interval]);
echo "<td>";
if ($when!=createdate) {$a=date("Y-m-d", $a);}
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
*/
$a = htmlentities($r[id]);
$a=wave_files_present($a,$db);
echo "<td>";
if ($a==0) { echo "OK"; }
else if ($a==1) { echo "<font color=red>$a track not MP3ed successfully</font>"; }
else { echo "<font color=red>$a tracks not MP3ed successfully</font>"; }
echo "</td>\n";
$a = htmlentities($r[local]);
echo "<td>";
if ($a) {
if ($a==2 or $a==3) { echo "L"; }
else { echo " "; }
}
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[format]);
echo "<td>";
if ($a) {
if ($a==1) { echo "CD"; }
if ($a == 2) { echo '7" Vinyl'; }
if ($a == 3) { echo '12" Vinyl'; }
if ($a == 4) { echo "Cassette"; }
if ($a == 5) { echo "Reel"; }
if ($a == 6) { echo "Minidisc"; }
if ($a == 7) { echo "MP3"; }
else { echo " "; }
}
else { echo " "; }
echo "</td>\n";
echo "<td width=1 align=center>";
echo "<a HREF=cdshow.php?";
echo "xref=" . $r[id] . ">Show<a>";
echo "</td></TR>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
#else { echo "<p><b><font color=red>NO MATCHES FOUND</font></b>\n"; }
}
?>
</form>
</BODY>
</HTML>
<?php
function wave_files_present($cdid,$dbname) {
//Check wither wave or mp3 files are present
$wavepath = "/data/wavein";
$mp3pathhi = "/data/music/hi";
$mp3pathlo = "/data/music/lo";
$trackquery = "SELECT * FROM cdtrack WHERE cdid = $q$cdid$q ORDER by tracknum;";
$result = pg_query($dbname, $trackquery);
$num = pg_num_rows($result);
$cdnum = sprintf("%07.0f", $cdid);
//echo "<br>$cdid:";
$wavethere = 0;
for ($i=0;$i<$num;$i++) {
$istitle = 0;
$r = pg_Fetch_array($result, $i, PGSQL_ASSOC);
$tracknum[$i] = $r[tracknum];
$trackartist[$i] = $r[trackartist];
if ($trackartist[$i]) { $isartist = 1; }
$tracktitle[$i] = $r[tracktitle];
$thetracknum = sprintf("%02.0f", $r[tracknum]);
$data=strtolower($tracktitle[$i]);
$data=strpos($tracktitle[$i],"[data");
if (strpos(strtolower ($tracktitle[$i]),"[data") === false) {
if (is_readable("$wavepath/$cdnum/$cdnum-$thetracknum.wav")) {}
else if ((is_readable("$mp3pathhi/$cdnum/$cdnum-$thetracknum.mp3"))
and (is_readable("$mp3pathlo/$cdnum/$cdnum-$thetracknum.mp3"))) {}
else {$wavethere = $wavethere + 1;}
$playname[$i] = "$cdnum-$thetracknum";
}
}
return $wavethere;
}
?>