-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlatest.php
executable file
·137 lines (130 loc) · 5.3 KB
/
latest.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
<?php
require_once('includes/game.php');
$smarty->config_load($conf_file);
switch($_GET['latest'])
{
case 'comments':
$comments = array();
$rows = $DB->select('
SELECT `id`, `type`, `typeID`, LEFT(`commentbody`, 120) as `preview`, `userID` as `user`, `post_date` as `date`, (NOW()-`post_date`) as `elapsed`
FROM ?_comments
WHERE 1
ORDER BY post_date DESC
LIMIT 300
');
foreach($rows as $i => $row)
{
$comments[$i] = array();
$comments[$i] = $row;
switch($row['type'])
{
case 1: // NPC
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_creature WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 2: // GO
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_gameobject WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 3: // Item
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_item WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 4: // Item Set
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_itemset WHERE itemsetID=?d LIMIT 1', $row['typeID']);
break;
case 5: // Quest
$comments[$i]['subject'] = $DB->selectCell('SELECT Title_loc'.$_SESSION['locale'].' FROM locales_quest WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 6: // Spell
$comments[$i]['subject'] = $DB->selectCell('SELECT spellname_loc'.$_SESSION['locale'].' FROM ?_spell WHERE spellID=?d LIMIT 1', $row['typeID']);
break;
case 7: // Zone
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_zones WHERE areatableID=?d LIMIT 1', $row['typeID']);
break;
case 8: // Faction
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_factions WHERE factionID=?d LIMIT 1', $row['typeID']);
break;
default:
$comments[$i]['subject'] = 'Unknown';
break;;
}
$comments[$i]['user'] = $rDB->selectCell('SELECT username FROM account WHERE id=?d LIMIT 1', $row['user']);
if(empty($comments[$i]['user']))
$comments[$i]['user'] = 'Anonymous';
$comments[$i]['rating'] = array_sum($DB->selectCol('SELECT rate FROM ?_comments_rates WHERE commentid=?d', $row['id']));
$comments[$i]['purged'] = ($comments[$i]['rating'] <= -50)? 1: 0;
$comments[$i]['deleted'] = 0;
}
$smarty->assign('comments', $comments);
$smarty->display('latest_comments.tpl');
break;
case 'screenshots':
$screenshots = array();
$rows = $DB->select('
SELECT `id`, `type`, `typeID`, `body`, `username`, `width`, `height`, `date` as `date`, (NOW()-`date`) as `elapsed`
FROM ?_screenshots
WHERE 1
ORDER BY date DESC
LIMIT 300
');
foreach($rows as $i => $row)
{
$screenshots[$i] = array();
$screenshots[$i] = $row;
$screenshots[$i]['number'] = $i;
switch($row['type'])
{
case 1: // NPC
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_creature WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 2: // GO
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_gameobject WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 3: // Item
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM locales_item WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 4: // Item Set
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_itemset WHERE itemsetID=?d LIMIT 1', $row['typeID']);
break;
case 5: // Quest
$screenshots[$i]['subject'] = $DB->selectCell('SELECT Title_loc'.$_SESSION['locale'].' FROM locales_quest WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 6: // Spell
$screenshots[$i]['subject'] = $DB->selectCell('SELECT spellname_loc'.$_SESSION['locale'].' FROM ?_spell WHERE spellID=?d LIMIT 1', $row['typeID']);
break;
case 7: // Zone
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_zones WHERE areatableID=?d LIMIT 1', $row['typeID']);
break;
case 8: // Faction
$screenshots[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_factions WHERE factionID=?d LIMIT 1', $row['typeID']);
break;
default:
$screenshots[$i]['subject'] = 'Unknown';
break;;
}
$screenshots[$i]['user'] = $row['username'];
$screenshots[$i]['body'] = $row['body'];
$screenshots[$i]['width'] = $row['width'];
$screenshots[$i]['height'] = $row['height'];
$screenshots[$i]['typeId']= $row['typeID'];
$screenshots[$i]['type']= $row['type'];
$screenshots[$i]['id']= $row['id'];
/*$screenshots[$i]['purged'] = ($comments[$i]['rating'] <= -50)? 1: 0;
$screenshots[$i]['deleted'] = 0;*/
}
$smarty->assign('screenshots', $screenshots);
$smarty->display('latest_screenshots.tpl');
break;
default:
break;
}
global $page;
$page = array(
'Mapper' => false,
'Book' => false,
'Title' => '',
'tab' => 0,
'type' => 0,
'typeid' => 0,
'path' => '[0, 30]'
);
$smarty->assign('page', $page);
?>