forked from CCHits/Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_chart.php
89 lines (88 loc) · 2.89 KB
/
new_chart.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
<?php
require_once('CONFIG/CONFIG_DEFAULT.php');
mysql_connect($RW_HOST, $RW_USER, $RW_PASS);
mysql_select_db($RW_BASE);
$period = 30;
$count = 100;
$aperiod = array('30' => '', '90' => '', '120' => '', '150' => '', '180' => '');
if (isset($_GET['period'])) {
switch ($_GET['period']) {
case '30':
case '90':
case '120':
case '150':
case '180':
$period = $_GET['period'];
break;
default:
$period = 30;
}
}
if (isset($_GET['rows'])) {
$count = $_GET['rows'];
}
$aperiod[$period] = ' selected';
if (isset($_GET['count']) && 0 + $_GET['count'] > 0) {
$count = 0 + $_GET['count'];
}
$date = date("Ymd", strtotime("-1 day"));
$pdate = date("Ymd", strtotime("-{$period} days"));
$sql = "
SELECT t.intTrackID, t.intArtistID, t.strTrackName, strArtistName, t.intChartPlace, count( t.intTrackID ) * ( ( 100 - ( IFNULL( MAX( intShowCount ) , 0 ) *5 ) ) /100 ) AS decVotes
FROM tracks AS t
LEFT JOIN (
SELECT vt.intTrackID
FROM votes AS vt
WHERE vt.datTimeStamp <= '$date'
AND vt.datTimeStamp >= '$pdate'
) AS v ON v.intTrackID = t.intTrackID
LEFT JOIN (
SELECT st.intTrackID, count( st.intTrackID ) AS intShowCount
FROM showtracks AS st, shows AS s
WHERE (
(
s.enumShowType = 'weekly' AND s.intShowUrl <= '" . $date . "'
AND s.intShowUrl > '20000000'
) OR (
s.enumShowType = 'monthly' AND s.intShowUrl <= '" . substr($date, 0, 6) . "'
AND s.intShowUrl > '200000'
)
)
AND s.intShowID = st.intShowID
GROUP BY intTrackID
) AS s ON s.intTrackID = t.intTrackID
LEFT JOIN (
SELECT ar.strArtistName as strArtistName, ar.intArtistID
FROM artists AS ar
) AS a ON a.intArtistID = t.intArtistID
WHERE t.isApproved =1
GROUP BY t.intTrackID
ORDER BY decVotes DESC , intTrackID ASC
LIMIT 0 , " . $count;
//echo $sql . "<br/>";
$qry = mysql_query($sql);
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>New Chart - for review</title></head><body>";
echo '<form action="" method="get">
<select name="period">
<option value=30' . $aperiod['30'] . '>30 days</option>
<option value=90' . $aperiod['90'] . '>90 days</option>
<option value=120' . $aperiod['120'] . '>120 days</option>
<option value=150' . $aperiod['150'] . '>150 days</option>
<option value=180' . $aperiod['180'] . '>180 days</option>
</select>
Rows: <input type="text" name="rows" value="' . $count . '"> <input type="submit" value="Go">
</form>';
if (mysql_errno() > 0 || mysql_num_rows($qry) == 0) {
die("Errors occurred " . mysql_error());
}
echo "<table>";
$row = 0;
while ($data = mysql_fetch_array($qry)) {
if ($row++ % 20 == 0) {
echo "<tr><th>Track name</th><th>Artist Name</th><th>Current Chart Place</th><th>New Chart Place</th><th>Votes</th></tr>\r\n";
}
echo "<tr><td><a href=\"/track/{$data['intTrackID']}\">{$data['strTrackName']}</a></td><td>{$data['strArtistName']}</td><td>{$data['intChartPlace']}</td><td>$row</td><td>{$data['decVotes']}</td></tr>\r\n";
}
echo "</table>
</body>
</html>";