root/dev/common/class.comments.php @ 149

Revision 149, 2.2 KB (checked in by exi, 16 years ago)

Changed custom ship values to also display unknown types.
Changed comment class to allow html code insertion.
Added pullout of externalids on killlists.
Fixed next week link.
Small change to the sql-inserter to remove the ';'.
Fixed the double http-link on rss feeds.
Fixed VictimAllianceURL on kill_details.
Fixed wrong links on standings page.

Line 
1<?php
2
3class Comments
4{
5
6    function Comments($kll_id)
7    {
8        $this->id_ = $kll_id;
9        $this->raw_ = false;
10
11        $this->comments_ = array();
12        $qry = new DBQuery();
13        $qry->execute("SELECT *,id FROM kb3_comments WHERE `kll_id` = '".$kll_id."' order by posttime asc");
14        while ($row = $qry->getRow())
15        {
16            $this->comments_[] = array('time' => $row['posttime'], 'name' => $row['name'], 'comment' => stripslashes($row['comment']), 'id' => $row['id']);
17        }
18    }
19
20    function getComments()
21    {
22        global $smarty;
23
24        $smarty->assign_by_ref('comments', $this->comments_);
25        return $smarty->fetch(get_tpl('block_comments'));
26    }
27
28    function addComment($name, $text)
29    {
30        $comment = $this->bbencode($text);
31
32        $name = slashfix(strip_tags($name));
33        $qry = new DBQuery();
34        $qry->execute("INSERT INTO kb3_comments (`kll_id`,`comment`,`name`,`posttime`)
35                       VALUES ('".$this->id_."','".$comment."','".$name."','".date('Y-m-d H:i:s')."')");
36        $id = $qry->getInsertID();
37        $this->comments_[] = array('time' => date('Y-m-d H:i:s'), 'name' => $name, 'comment' => stripslashes($comment), 'id' => $id);
38    }
39
40    function delComment($c_id)
41    {
42        $qry = new DBQuery();
43        $qry->execute("DELETE FROM kb3_comments WHERE id='".$c_id."' LIMIT 1");
44    }
45
46    function postRaw($bool)
47    {
48        $this->raw_ = $bool;
49    }
50
51    function bbencode($string)
52    {
53        if (!$this->raw_)
54        {
55            $string = strip_tags(stripslashes($string));
56        }
57        $string = str_replace(array('[b]','[/b]','[i]','[/i]','[u]','[/u]'),
58                              array('<b>','</b>','<i>','</i>','<u>','</u>'), $string);
59        $string = preg_replace('^\[color=(.*?)](.*?)\[/color]^', '<font color="\1">\2</font>', $string);
60        $string = preg_replace('^\[kill=(.*?)](.*?)\[/kill]^', '<a href="\?a=kill_detail&kll_id=\1">\2</a>', $string);
61        $string = preg_replace('^\[pilot=(.*?)](.*?)\[/pilot]^', '<a href="\?a=pilot_detail&plt_id=\1">\2</a>', $string);
62        return nl2br(addslashes($string));
63    }
64}
65?>
Note: See TracBrowser for help on using the browser.