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
/
Copy pathreviewsByActiveDJs.php
executable file
·191 lines (149 loc) · 8.56 KB
/
reviewsByActiveDJs.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
<html>
<head>
<title>WSBF: DJ Album Review Index</title>
<meta name="author" content="Edward Sullivan" />
<link rel="stylesheet" href="/jqui/css/smoothness/jquery-ui-1.8.16.custom.css">
<script type="text/javascript" src="/jqui/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/jqui/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/jqui/other_jq/timeentry/jquery.timeentry.min.js"> </script>
<script type="text/javascript" src="/jqui/development-bundle/ui/jquery.ui.widget.js"> </script>
<script type="text/javascript" src="/jqui/development-bundle/ui/jquery.ui.datepicker.js"> </script>
<script>
$(function() {
$( "#datepicker1" ).datepicker();
$( "#datepicker2" ).datepicker();
});
</script>
<link rel='stylesheet' type='text/css' href='style.css' />
<script type="text/javascript" src="/jqui/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/jqui/js/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="/jqui/css/smoothness/jquery-ui-1.8.16.custom.css" />
</head>
<body>
<div id="container">
<h1><a href="http://new.wsbf.net">WSBF-FM Clemson</a></h1>
<h2>Albums Reviewed By DJs</h2>
<hr />
<!-- Form to get start date and end date with Javascript. GETs back to itself -->
<form name=frmTest action="reviewsByActiveDJs.php" method=GET>
<table>
<tr>
<td>Start Date:</td>
<td><input type="text" class="required ui-state-default ui-corner-all" id="datepicker1" name="start_date" /></td>
</tr>
<tr>
<td>End Date:</td>
<td><input type="text" class="required ui-state-default ui-corner-all" id="datepicker2" name="end_date" /></td>
</tr>
<tr>
<td>Apply filter:</td>
<td><input type='submit' value='Submit' name='submit' class='ui-state-default ui-corner-all' /></td>
</tr>
</table>
</form>
<hr />
<?php
/* Connecting to the database */
require_once("connect.php");
/* Default start date/time */
$start_english = "1974-12-31 19:00:00";
$start_english_default = "1974-12-31 19:00:00";
/* Default end date/time */
$now_unix = strtotime("now");
$now_english = date("Y-m-d H:i:s", $now_unix);
$end_english = $now_english;
$end_english_default = $now_english;
/* Getting the start date from the Javascrip input calendar*/
if(isset($_GET['start_date'])){
$start_date = $_GET['start_date'];
/* Getting the start time in English for MySQL */
$start_Y = date('Y', strtotime($start_date)); // year
$start_m = date('m', strtotime($start_date)); // month
$start_d = date('d', strtotime($start_date)); // day
// $start_H = date('H', strtotime($start_time)); // hour
// $start_i = date('i', strtotime($start_time)); // minute
// $start_s = date('s', strtotime($start_time)); // second
$start_H = date('H', strtotime("00:00:00")); // hour
$start_i = date('i', strtotime("00:00:00")); // minute
$start_s = date('s', strtotime("00:00:00")); // second
// Format for mktime is (hour, min, sec, month, day, year, day light savings)
$start_unix = mktime($start_H, $start_i, $start_s, $start_m, $start_d, $start_Y);
$start_english = date("Y-m-d H:i:s", $start_unix);
}
/* Getting the end date from the Javascrip input calendar */
if(isset($_GET['end_date'])){
$end_date = $_GET['end_date'];
/* Getting the end time in English for MySQL */
$end_Y = date('Y', strtotime($end_date)); // year
$end_m = date('m', strtotime($end_date)); // month
$end_d = date('d', strtotime($end_date)); // day
//$end_H = date('H', strtotime($end_time)); // hour
//$end_i = date('i', strtotime($end_time)); // minute
//$end_s = date('s', strtotime($end_time)); // second
$end_H = date('H', strtotime("00:00:00")); // hour
$end_i = date('i', strtotime("00:00:00")); // minute
$end_s = date('s', strtotime("00:00:00")); // second
// Format for mktime is (hour, min, sec, month, day, year, day light savings)
$end_unix = mktime($end_H, $end_i, $end_s, $end_m, $end_d, $end_Y);
$end_english = date("Y-m-d H:i:s", $end_unix);
}
/* Setting date range (seeing if values from calendar do not match default values) */
if ($start_english == "1969-12-31 00:00:00"){
$start_english = $start_english_default;
}
if ($end_english == "1969-12-31 00:00:00"){
$end_english = $end_english_default;
}
echo "<h4>Albums reviewed between $start_english and $end_english </h4><br>";
/* For each active user, query to count all their CD reviews within the selected date range */
$cd_count_query = sprintf("SELECT u.*, p.*,
(IFNULL( COUNT( p.`albumID` ) , 0 )) AS reviewCount
FROM `users` u
LEFT JOIN `libreview` p
ON u.`username` = p.`username`
AND p.`review_date` >= \"%s\"
AND p.`review_date` <= \"%s\"
WHERE `statusID` = 0
GROUP BY u.`username`
ORDER BY `last_name`, `first_name`, p.`username`",$start_english, $end_english);
/* For each active user, query to list their reviewed album IDs for the selected date range */
$cd_id_query = sprintf("SELECT u.*, p.*,
(IFNULL( COUNT( p.`albumID` ) , 0 )) AS reviewCount
FROM `users` u
LEFT JOIN `libreview` p
ON u.`username` = p.`username`
AND p.`review_date` >= \"%s\"
AND p.`review_date` <= \"%s\"
WHERE `statusID` = 0
GROUP BY p.`albumID`
ORDER BY `last_name`, `first_name`, p.`username`",$start_english, $end_english);
/* Submitting the queries */
$cd_count_query_result = mysql_query($cd_count_query,$link) or die("MySQL error [". __FILE__ ."] near line " . __LINE__ . ": " .mysql_error());
$cd_id_query_result = mysql_query($cd_id_query,$link) or die("MySQL error [". __FILE__ ."] near line " . __LINE__ . ": " .mysql_error());
/* Getting the first row for the query of albumIDs (so we can match the first one's username) */
$cd_id_query_row = mysql_fetch_assoc($cd_id_query_result);
/* Displaying output in simple table*/
echo "<table>";
/* Table header row */
echo "<tr><td><i>First</i></td><td><i>Last</i></td><td><i>#</i></td><td align='center'><i>Albums</i></td></tr>";
/* Spacer row */
echo "<tr><td>.</td><td></td><td></td><td></td></tr>";
/* For each active user, printing the first and last name and the count of CDs reviews with given date range */
while ($cd_count_query_row = mysql_fetch_assoc($cd_count_query_result)){
echo "<tr><td>$cd_count_query_row[first_name]</td>
<td>$cd_count_query_row[last_name]</td>
<td>$cd_count_query_row[reviewCount]</td>
<td>";
/* For each active user, printing all the IDs (links) for the CDs that the user reviewed in the date range */
while (strtoupper($cd_id_query_row['username']) == strtoupper ($cd_count_query_row['username']) && $cd_id_query_row != FALSE ) {
echo "<a href=\"http://new.wsbf.net/wizbif/read_review.php?albumID=$cd_id_query_row[albumID]\">$cd_id_query_row[albumID] </a>";
$cd_id_query_row = mysql_fetch_assoc($cd_id_query_result);
}
echo "<td>
</tr>";
}
echo "</table>";
?>
</div>
</body>
</html>