source: aowow/latest.php

Last change on this file was 170, checked in by maron, 16 years ago
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1<?php
2
3require_once ('includes/game.php');
4
5switch($_GET['latest'])
6{
7 case 'comments':
8 $comments = array();
9 $rows = $DB->select('
10 SELECT `id`, `type`, `typeID`, LEFT(`commentbody`, 120) as `preview`, `userID` as `user`, `post_date` as `date`, (NOW()-`post_date`) as `elapsed`
11 FROM ?_comments
12 WHERE 1
13 ORDER BY post_date DESC
14 LIMIT 300');
15 foreach($rows as $i => $row)
16 {
17 $comments[$i] = array();
18 $comments[$i] = $row;
19 switch($row['type'])
20 {
21 case 1: // NPC
22 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM creature_template WHERE entry=?d LIMIT 1', $row['typeID']);
23 break;
24 case 2: // GO
25 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM gameobject_template WHERE entry=?d LIMIT 1', $row['typeID']);
26 break;
27 case 3: // Item
28 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM item_template WHERE entry=?d LIMIT 1', $row['typeID']);
29 break;
30 case 4: // Item Set
31 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_itemset WHERE itemsetID=?d LIMIT 1', $row['typeID']);
32 break;
33 case 5: // Quest
34 $comments[$i]['subject'] = $DB->selectCell('SELECT Title FROM quest_template WHERE entry=?d LIMIT 1', $row['typeID']);
35 break;
36 case 6: // Spell
37 $comments[$i]['subject'] = $DB->selectCell('SELECT spellname FROM ?_spell WHERE spellID=?d LIMIT 1', $row['typeID']);
38 break;
39 case 7: // Zone
40 // TODO
41 break;
42 case 8: // Faction
43 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM ?_factions WHERE factionID=?d LIMIT 1', $row['typeID']);
44 break;
45 default:
46 $comments[$i]['subject'] = $DB->selectCell('SELECT name FROM '.$types[$row['type']].'_template WHERE entry=?d LIMIT 1', $row['typeID']);
47 break;
48 }
49 $comments[$i]['user'] = $rDB->selectCell('SELECT username FROM account WHERE id=?d LIMIT 1', $row['user']);
50 if(empty($comments[$i]['user']))
51 $comments[$i]['user'] = 'Anonymous';
52 $comments[$i]['rating'] = array_sum($DB->selectCol('SELECT rate FROM ?_comments_rates WHERE commentid=?d', $row['id']));
53 $comments[$i]['purged'] = ($comments[$i]['rating'] <= -50)? 1: 0;
54 $comments[$i]['deleted'] = 0;
55 }
56 $smarty->assign('comments', $comments);
57 break;
58 default: break;
59}
60
61global $page;
62$page = array(
63 'Mapper' => false,
64 'Book' => false,
65 'Title' => '',
66 'tab' => 0,
67 'type' => 0,
68 'typeid' => 0,
69 'path' => '[0, 30]'
70);
71
72$smarty->assign('page', $page);
73$smarty->display('latest_comments.tpl');
74
75?>
Note: See TracBrowser for help on using the repository browser.