1 | <?php |
---|
2 | $html .= "<div id=comments-wrap>"; |
---|
3 | |
---|
4 | function bbencode($string) |
---|
5 | { |
---|
6 | $string = strip_tags(&$string); |
---|
7 | $string = str_replace(array('[b]','[/b]','[i]','[/i]','[u]','[/u]'), |
---|
8 | array('<b>','</b>','<i>','</i>','<u>','</u>'), $string); |
---|
9 | $string = preg_replace('^\[color=(.*?)](.*?)\[/color]^', '<font color="\1">\2</font>', $string); |
---|
10 | $string = preg_replace('^\[kill=(.*?)](.*?)\[/kill]^', '<a href="\?a=kill_detail&kll_id=\1">\2</a>', $string); |
---|
11 | $string = preg_replace('^\[pilot=(.*?)](.*?)\[/pilot]^', '<a href="\?a=pilot_detail&plt_id=\1">\2</a>', $string); |
---|
12 | return nl2br($string); |
---|
13 | } |
---|
14 | |
---|
15 | $kll_id = $_GET['kll_id']; |
---|
16 | $qry = new DBQuery(); |
---|
17 | if (isset($_POST['comment'])) |
---|
18 | { |
---|
19 | $kb = new Killboard(KB_SITE); |
---|
20 | $config = $kb->getConfig(); |
---|
21 | |
---|
22 | $pw = false; |
---|
23 | if (!$config->getConfig('comments_pw')) |
---|
24 | { |
---|
25 | $pw = true; |
---|
26 | } |
---|
27 | if ($_POST['password'] == $config->getPostPassword() || $pw) |
---|
28 | { |
---|
29 | if ($_POST['comment'] == null) |
---|
30 | { |
---|
31 | $html .= "Error: Sillent type hey? good for you, bad for a comment."; |
---|
32 | } |
---|
33 | else |
---|
34 | { |
---|
35 | $comment = $_POST['comment']; |
---|
36 | $comment = bbencode($comment); |
---|
37 | |
---|
38 | $name = $_POST['name']; |
---|
39 | if ($name == null) |
---|
40 | { |
---|
41 | $name = "Anonymous"; |
---|
42 | } |
---|
43 | $name = strip_tags($name); |
---|
44 | // Password if right so insert the comment. |
---|
45 | $qry->execute("INSERT INTO kb3_comments (`kll_id`,`comment`,`name`) |
---|
46 | VALUES ('$kll_id','$comment','$name')"); |
---|
47 | } |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | // Password is wrong |
---|
52 | $html .= "Error: Wrong Password"; |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | $qry = new DBQuery(); |
---|
57 | $qry->execute("SELECT id, name, comment FROM kb3_comments WHERE `kll_id` = $kll_id"); |
---|
58 | if ($qry->recordCount() == 0) |
---|
59 | { |
---|
60 | // no commments |
---|
61 | // $html .= "No Comments yet."; |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | while ($data = $qry->getRow()) |
---|
66 | { |
---|
67 | $name = $data['name']; |
---|
68 | $comment = $data['comment']; |
---|
69 | $html .= "<div class=\"comment-text\"><a href=\"?a=search&searchtype=pilot&searchphrase=".$name."\">".$name."</a>:<p>".$comment."</p>"; |
---|
70 | if ($page->isAdmin()) |
---|
71 | { |
---|
72 | $html .= "<a href=\"javascript:openWindow('?a=comments_delete&c_id=".$data['id']."', null, 480, 350, '' );\">Delete Comment</a>"; |
---|
73 | } |
---|
74 | $html .= "</div><br/>"; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | $html .= "<div><form id=\"postform\" name=\"postform\" method=\"post\" action=\"?a=kill_detail&kll_id=".$kill->getID()."\">"; |
---|
79 | $html .= "<br><b>Add Comment:</b><br><textarea class=\"comment\" name=\"comment\" cols=\"55\" rows=\"5\" wrap=\"PHYSICAL\" onKeypress=\"limitText(this.form.comment,this.form.countdown,200);\"></textarea><br>"; |
---|
80 | $html .= "<input readonly type=\"text\" name=\"countdown\" id=\"countdown\" size=\"1\" value=\"200\">Letters left<br/>"; |
---|
81 | $html .= "<b>Name:</b>"; |
---|
82 | $html .= "<input style=\"position:relative; right:-3px;\" class=\"comment-button\" name=\"name\" type=\"text\" size=\"24\" maxlength=\"24\"> "; |
---|
83 | if ($config->getConfig('comments_pw')) |
---|
84 | { |
---|
85 | $html .= "<br><b>Password:</b>"; |
---|
86 | $html .= "<input type=\"password\" name=\"password\" size=\"19\" class=comment-button> "; |
---|
87 | } |
---|
88 | $html .= "<input class=\"comment-button\" name=\"submit\" type=\"submit\" value=\"Add Comment\">"; |
---|
89 | $html .= "</form></div></div>"; |
---|
90 | ?> |
---|