-
Notifications
You must be signed in to change notification settings - Fork 5
/
latest.php
84 lines (79 loc) · 2.73 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
<?php
/*
* UDWBase: WOWDB Web Interface
*
* © UDW 2009-2011
*
* Released under the terms and conditions of the
* GNU General Public License (http://gnu.org).
*
*/
require_once ('includes/game.php');
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 ?_udwbase_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 FROM ?_creature_template WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 2: // GO
$comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_gameobject_template WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 3: // Item
$comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_item_template WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 4: // Item Set
$comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_udwbase_itemset WHERE itemsetID=?d LIMIT 1', $row['typeID']);
break;
case 5: // Quest
$comments[$i]['subject'] = $DB->selectCell('SELECT Title FROM ?_quest_template WHERE entry=?d LIMIT 1', $row['typeID']);
break;
case 6: // Spell
$comments[$i]['subject'] = $DB->selectCell('SELECT spellname_loc'.$_SESSION['locale'].' FROM ?_udwbase_spell WHERE spellID=?d LIMIT 1', $row['typeID']);
break;
case 7: // Zone
// TODO
break;
case 8: // Faction
$comments[$i]['subject'] = $DB->selectCell('SELECT name_loc'.$_SESSION['locale'].' FROM ?_udwbase_factions WHERE factionID=?d LIMIT 1', $row['typeID']);
break;
default:
$comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_'.$types[$row['type']].'_template WHERE entry=?d LIMIT 1', $row['typeID']);
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 ?_udwbase_comments_rates WHERE commentid=?d', $row['id']));
$comments[$i]['purged'] = ($comments[$i]['rating'] <= -50)? 1: 0;
$comments[$i]['deleted'] = 0;
}
$smarty->assign('comments', $comments);
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);
$smarty->display('latest_comments.tpl');
?>