forked from MarkusNemesis/VanillaWoWDB2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
latest.php
79 lines (73 loc) · 2.47 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
<?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 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_loc'.$_SESSION['locale'].' FROM ?_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 ?_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 ?_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);
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');
?>