Changeset 348

Show
Ignore:
Timestamp:
10/19/08 01:24:28 (12 years ago)
Author:
beans
Message:

Updated comments class without IP

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dev/common/includes/class.comments.php

    r343 r348  
    1 <?php 
     1<?php  
    22 
    3 class Comments 
    4 { 
     3class Comments  
     4{  
    55 
    6     function Comments($kll_id) 
    7     { 
    8         $this->id_ = $kll_id; 
    9         $this->raw_ = false; 
     6    function Comments($kll_id)  
     7    {  
     8        $this->id_ = $kll_id;  
     9        $this->raw_ = false;  
    1010 
    11         $this->comments_ = array(); 
    12         $qry = new DBQuery(true); 
    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'], 'ip' => $row['ip']);  
    17         } 
    18     } 
     11        $this->comments_ = array();  
     12        $qry = new DBQuery(true);  
     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    }  
    1919 
    20     function getComments() 
    21     { 
    22         global $smarty; 
     20    function getComments()  
     21    {  
     22        global $smarty;  
    2323 
    24         $smarty->assign_by_ref('comments', $this->comments_); 
    25         return $smarty->fetch(get_tpl('block_comments')); 
    26     } 
     24        $smarty->assign_by_ref('comments', $this->comments_);  
     25        return $smarty->fetch(get_tpl('block_comments'));  
     26    }  
    2727 
    28     function addComment($name, $text) 
    29     { 
    30         $comment = $this->bbencode($text); 
     28    function addComment($name, $text)  
     29    {  
     30        $comment = $this->bbencode($text);  
    3131 
    32         $name = slashfix(strip_tags($name)); 
    33         $qry = new DBQuery(); 
    34         $qry->execute("INSERT INTO kb3_comments (`kll_id`,`comment`,`name`,`posttime`,`ip`) 
    35 VALUES ('".$this->id_."','".$comment."','".$name."','".kbdate('Y-m-d H:i:s')."','".$_SERVER["REMOTE_ADDR"]."')"); 
     32        $name = slashfix(strip_tags($name));  
     33        $qry = new DBQuery(true);  
     34        $qry->execute("INSERT INTO kb3_comments (`kll_id`,`comment`,`name`,`posttime`)  
     35                       VALUES ('".$this->id_."','".$comment."','".$name."','".kbdate('Y-m-d H:i:s')."')");  
     36        $id = $qry->getInsertID();  
     37        $this->comments_[] = array('time' => kbdate('Y-m-d H:i:s'), 'name' => $name, 'comment' => stripslashes($comment), 'id' => $id);  
    3638 
    37 $id = $qry->getInsertID(); 
    38 $this->comments_[] = array('time' => kbdate('Y-m-d H:i:s'), 'name' => $name, 'comment' => stripslashes($comment), 'id' => $id, 'ip' => $row['ip']);  
     39        // create comment_added event  
     40        event::call('comment_added', $this);  
     41    }  
    3942 
    40         // create comment_added event 
    41         event::call('comment_added', $this); 
    42     } 
     43    function delComment($c_id)  
     44    {  
     45        $qry = new DBQuery(true);  
     46        $qry->execute("DELETE FROM kb3_comments WHERE id='".$c_id."' LIMIT 1");  
     47    }  
    4348 
    44     function delComment($c_id) 
    45     { 
    46         $qry = new DBQuery(); 
    47         $qry->execute("DELETE FROM kb3_comments WHERE id='".$c_id."' LIMIT 1"); 
    48     } 
     49    function postRaw($bool)  
     50    {  
     51        $this->raw_ = $bool;  
     52    }  
    4953 
    50     function postRaw($bool) 
    51     { 
    52         $this->raw_ = $bool; 
    53     } 
    54  
    55     function bbencode($string) 
    56     { 
    57         if (!$this->raw_) 
    58         { 
    59             $string = strip_tags(stripslashes($string)); 
    60         } 
    61         $string = str_replace(array('[b]','[/b]','[i]','[/i]','[u]','[/u]'), 
    62                               array('<b>','</b>','<i>','</i>','<u>','</u>'), $string); 
    63         $string = preg_replace('^\[color=(.*?)](.*?)\[/color]^', '<font color="\1">\2</font>', $string); 
    64         $string = preg_replace('^\[kill=(.*?)](.*?)\[/kill]^', '<a href="\?a=kill_detail&kll_id=\1">\2</a>', $string); 
    65         $string = preg_replace('^\[pilot=(.*?)](.*?)\[/pilot]^', '<a href="\?a=pilot_detail&plt_id=\1">\2</a>', $string); 
    66         return nl2br(addslashes($string)); 
    67     } 
    68 } 
    69 ?> 
     54    function bbencode($string)  
     55    {  
     56        if (!$this->raw_)  
     57        {  
     58            $string = strip_tags(stripslashes($string));  
     59        }  
     60        $string = str_replace(array('[b]','[/b]','[i]','[/i]','[u]','[/u]'),  
     61                              array('<b>','</b>','<i>','</i>','<u>','</u>'), $string);  
     62        $string = preg_replace('^\[color=(.*?)](.*?)\[/color]^', '<font color="\1">\2</font>', $string);  
     63        $string = preg_replace('^\[kill=(.*?)](.*?)\[/kill]^', '<a href="\?a=kill_detail&kll_id=\1">\2</a>', $string);  
     64        $string = preg_replace('^\[pilot=(.*?)](.*?)\[/pilot]^', '<a href="\?a=pilot_detail&plt_id=\1">\2</a>', $string);  
     65        return nl2br(addslashes($string));  
     66    }  
     67}  
     68?>