/[gnuheter]/gnuheter/pollcomments.php
ViewVC logotype

Diff of /gnuheter/pollcomments.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by pawal, Mon Dec 16 21:24:29 2002 UTC revision 1.17 by pawal, Sun Feb 2 16:07:40 2003 UTC
# Line 1  Line 1 
1  <?php  <?php
2  # pollcomments.php - Poll comments  # comments.php - comments throughout the entire site
3  #  #
4  # Written by  # Written by
 #  Francisco Burzi  
5  #  Patrik Wallström <pawal@blipp.com>  #  Patrik Wallström <pawal@blipp.com>
6  #  #
7  # This file is part of Gnuheter.  # This file is part of Gnuheter.
# Line 25  Line 24 
24  #  #
25  # $Id$  # $Id$
26    
27  if (!isset($config)) include('config.php');  # /* check comments */
28    $pid = (int) $_GET['pid'];
29  $savemainfile = $mainfile;  $sid = (int) $_GET['sid'];
30  if (ereg('/pollcomments\.php$', $SCRIPT_NAME))  $tid = (int) $_GET['tid'];
31          include('mainfile.php');  $mode = urlencode($_GET['mode']);
32  $mainfile = $savemainfile;  $op = urlencode($_GET['op']);
33    $order = (int) $_GET['order'];
34  isRealUser($HTTP_COOKIE_VARS['user']);  $thold = (int) $_GET['thold'];
35    
36    # /* redirect to real comments */
37  function modone() {  $redir = "comments.php?op=$op&typ=1&tid=$tid&pid=$pid&sid=$sid&mode=$mode&order=$order&thold=$thold";
38          global $admin,$moderate,$REQUEST_URI;  header("Location: $redir");
39          if (((isset($admin)) && ($moderate == 1)) || ($moderate == 2)) {  ?>
                 echo "<form method=\"POST\" action=\"pollcomments.php\" name=\"mod_form\">\n";  
         }  
 }  
   
 function modtwo($tid, $score, $reason) {  
         global $admin, $user, $moderate, $reasons;  
         $modder = "";  
         if ((((isset($admin)) && ($moderate == 1)) || ($moderate == 2)) && ($user)) {  
                 $modder.= " | <select name=\"dkn$tid\">";  
                 for ($i=0; $i<sizeof($reasons); $i++) {  
                         $modder.= "<option value=\"$score:$i\">$reasons[$i]</option>\n";  
                 }  
                 $modder.= "</select>\n";  
         }  
         return $modder;  
 }  
   
 function modthree($sid, $mode, $order, $thold=0) {  
         global $admin, $user, $moderate, $uimages;  
         if ((((isset($admin)) && ($moderate == 1)) || ($moderate==2)) && ($user)) {  
                 echo "<div align=\"center\">";  
                 echo "<input class=\"textbox\" type=\"hidden\" name=\"pollID\" value=\"$sid\">";  
                 echo "<input class=\"textbox\" type=\"hidden\" name=\"mode\" value=\"$mode\">";  
                 echo "<input class=\"textbox\" type=\"hidden\" name=\"order\" value=\"$order\">";  
                 echo "<input class=\"textbox\" type=\"hidden\" name=\"thold\" value=\"$thold\">";  
                 echo "<input class=\"textbox\" type=\"hidden\" name=\"op\" value=\"moderate\">";  
                 echo "<input type=\"image\" src=\"$uimages/moderate.png\" border=\"0\"></div></form>\n";  
         }  
 }  
   
 function format_short_comment($name,$subject,$date,$tid,$sid,$pid,$mode,$order,$thold) {  
         global $anonymous;  
         if (!eregi("[a-z0-9]",$name)) $name = $anonymous;  
         if (!eregi("[a-z0-9]",$subject)) $subject = "[Inget ärende]";  
         $subject = nowordlinkshtml($subject);  
         $datetime = formatTimestamp($date);  
         if ($name != $anonymous)  
                 $name = "<a href=\"user.php?op=userinfo&amp;uname=$name\">$name</a>";  
         return "&middot; <a href=\"pollcomments.php?op=showreply&amp;tid=$tid&amp;pollID=$sid&amp;pid=$pid&amp;mode=$mode&amp;order=$order&amp;thold=$thold#$r_tid\">$subject</a> av $name den $datetime<br>\n";  
 }  
   
   
 function format_comment_header($name,$subject,$tid,$date,$reason,$email,$score) {  
         global $anonymous,$reasons,$cookie,$admin;  
         if (!eregi("[a-z0-9]",$name)) $name = $anonymous;  
         if (!eregi("[a-z0-9]",$subject)) $subject = "[Inget ärende]";  
         $subject = wordlinks($subject);  
         $header = "<a name=\"$tid\" />";  
         $header.= "<table width=\"400\" border=\"0\"><tr><td class=\"commentheader\">"; # fix stylesheet  
         $datetime = formatTimestamp($date);  
         $header.= "<p><b>$subject</b>\n";  
         $this_reason = $reason ? ", {$reasons[$reason]}" : "";  
         if (!$cookie[7])  
                 $header.= "(Poäng: $score$this_reason)";  
         if ($name != $anonymous)  
                 $header.= "<br>av <a href=\"user.php?op=userinfo&amp;uname=$name\">$name</a> ";  
         else  
                 $header.= "<br>av $name";  
         if ($email)  
                 $header.= " (<a href=\"mailto:$email\">$email</a>)";  
         if ($datetime) $header.= " den $datetime\n";  
   
         # visa URL till riktig hemsida här?  
   
         if ($admin and $tid) {  
                 $result = mysql_query("SELECT host_name FROM pollcomments WHERE tid='$tid'");  
                 list($host_name) = mysql_fetch_row($result);  
                 $header.= "<br><b>(IP: $host_name)</b>\n";  
         }  
   
         $header.= "</td></tr>\n";  
         return $header;  
 }  
   
 function format_comment_body($comment,$sid,$tid,$thold,$order,$maxlength) {  
         global $commentlimit; # from config.php  
         if ($maxlength) $commentlimit = $maxlength;  
         $morecomment = "<br><br><b><a href=\"pollcomments.php?pollID=$sid&amp;tid=$tid&amp;mode=$mode&amp;order=$order&amp;thold=$thold\">Läs resten av den här kommentaren...</a></b>\n";  
         $body = "<tr><td><div class=\"commentbody\">\n";  
         if (($maxlength) && (strlen($comment) > $maxlength))  
                 $body.= substr("$comment", 0, $maxlength).$morecomment;  
         elseif (strlen($comment) > $commentlimit)  
                 $body.= substr("$comment", 0, $commentlimit).$morecomment;  
         else $body.= $comment;  
         $body.= "</div>\n";  
         $body.= "</td></tr></table><br>\n";  
         $body = wordlinks($body);  
         return $body;  
 }  
   
 function format_comment_footer($tid,$sid,$pid,$mode,$order,$thold,$score,$reason) {  
         global $admin, $user, $anompost;  
         if ($anompost or $admin or $user)  
                 $footer = "[ <a href=\"pollcomments.php?op=Reply&amp;pid=$tid&amp;pollID=$sid&amp;mode=$mode&amp;order=$order&amp;thold=$thold\">Svara</a>\n";  
         else  
                 $footer = "[ <i>Du får inte kommentera anonymt, var vänlig <a href=\"user.php\">registera dig</a></i>";  
         if ($pid != 0) {  
                 list($erin) = mysql_fetch_row(mysql_query("SELECT pid FROM pollcomments WHERE tid='$pid'"));  
                 $footer.= " | <a href=\"pollcomments.php?op=results&amp;pollID=$sid&amp;pid=$erin&amp;mode=$mode&amp;order=$order&amp;thold=$thold\">Uppåt</a>\n";  
         }  
         $footer.= modtwo($tid, $score, $reason);  
         if ($admin)  
                 $footer.= " | <a href=\"admin.php?op=RemoveComment&amp;tid=$tid&amp;pollID=$sid\">Radera</a> ]<br><br>\n";  
         else  
                 $footer.= " ]<br><br>\n";  
         return $footer;  
 }  
   
 function navbar($sid, $thold, $mode, $order) {  
         global $user, $REQUEST_URI;  
         $tholds = array(-1,0,1,2,3,4,5);  
         if (!isset($thold)) $thold = 0; ?>  
   
         <table width="99%" border="0" cellspacing="1" cellpadding="2">  
         <tr><td align="center">  
         <form method="GET" action="<?= $REQUEST_URI; ?>">  
                 Gräns:  
                 <select name="thold">  
 <? for ($i = 0; $i < count($tholds); $i++) { ?>  
                 <option value="<?= $tholds[$i]; ?>" <? if ($thold == $tholds[$i]) { echo "selected"; } ?>><?= $tholds[$i]; ?></option>  
 <? } ?>  
                 </select>  
                 <select name="mode">  
                         <option value="nocomments" <?php if ($mode == 'nocomments') { echo "selected"; } ?>>Utan kommentarer</option>  
                         <option value="nested" <?php if ($mode == 'nested') { echo "selected"; } ?>>Nästlad</option>  
                         <option value="flat" <?php if ($mode == 'flat') { echo "selected"; } ?>>Platt</option>  
                         <option value="thread" <?php if (!isset($mode) || $mode=='thread' || $mode=="") { echo "selected"; } ?>>Trådad</option>  
                 </select>  
                 <select name="order">  
                         <option value="0" <?php if (!$order) { echo "selected"; } ?>>Äldre först</option>  
                         <option value="1" <?php if ($order==1) { echo "selected"; } ?>>Nyare först</option>  
                         <option value="2" <?php if ($order==2) { echo "selected"; } ?>>Högre poäng först</option>  
                 </select>  
                 <input type="submit" value="Uppdatera" class="button">  
                 <input type="hidden" name="pollID" value="<?= $sid; ?>">  
                 <input type="hidden" name="op" value="results">  
         </form></td></tr>  
         <tr class="commentwarning"><td>Kommentarerna tillhör de som postade dem. Vi ansvarar ej för dess innehåll.</td></tr>  
         </table>  
 <?php  
 }  
   
 function DisplayKids ($tid, $mode, $order=0, $thold=0, $level=0) {  
         global $datetime, $user, $cookie;  
         if (!isset($config)) include('config.php');  
         $comments = 0;  
         cookiedecode($user);  
         $result = mysql_query("SELECT tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason FROM pollcomments WHERE pid='$tid' ORDER BY date, tid");  
         if ($mode == 'nested') {  
                 while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {  
                         if ($r_score >= $thold) {  
                                 if (isset($level) and !$comments)  
                                         echo '<div class="commentbox">';  
                                 $comments++;  
   
                                 echo format_comment_header($r_name,$r_subject,$r_tid,$r_date,$r_reason,$r_email,$r_score);  
                                 echo format_comment_body($r_comment,$r_sid,$r_tid,$thold,$order,$cookie[10]);  
                                 echo format_comment_footer($r_tid,$r_sid,0,$mode,$order,$thold,$r_score,$r_reason);  
                                 DisplayKids($r_tid, $mode, $order, $thold, $level+1);  
                         }  
                 }  
         } elseif ($mode == 'flat') {  
                 while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {  
                         if ($r_score >= $thold) {  
                                 echo format_comment_header($r_name,$r_subject,$r_tid,$r_date,$r_reason,$r_email,$r_score);  
                                 echo format_comment_body($r_comment,$r_sid,$r_tid,$thold,$order,$cookie[10]);  
                                 echo format_comment_footer($r_tid,$r_sid,0,$mode,$order,$thold,$r_score,$r_reason);  
                                 DisplayKids($r_tid, $mode, $order, $thold);  
                         }  
                 }  
         } else {  
                 while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {  
                         if ($r_score >= $thold) {  
                                 if (isset($level) and !$comments)  
                                         echo '<div class="commentbox">';  
                                 $comments++;  
                                 echo format_short_comment($r_name,$r_subject,$r_date,$r_tid,$r_sid,$r_pid,$mode,$order,$thold);  
                                 DisplayKids($r_tid, $mode, $order, $thold, $level+1);  
                         }  
                 }  
         }  
         if ($comments)  
                 echo "</div>\n";  
 }  
   
 function DisplayTopic ($sid, $pid=0, $tid=0, $mode="thread", $order=0, $thold=0, $level=0, $nokids=0) {  
         global $user, $datetime, $cookie, $mainfile, $admin;  
         global $bgcolor1, $bgcolor2, $bgcolor3;  
         global $dbhost,$dbuname,$dbpass,$dbname;  
         if (!@$mainfile)  
                 include('header.php');  
         else {  
                 if (!isset($config)) include('config.php');  
         }  
         dbconnect();  
         $count_times = 0;  
         cookiedecode($user);  
         $q = "SELECT tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason FROM pollcomments WHERE pollID='$sid' AND pid='$pid'";  
         if ($thold != '') {  
                 $q .= " AND score >= '$thold'";  
         } else {  
                 $q .= " AND score >= '0'";  
         }  
         if ($order == 1) $q .= ' order by date desc';  
         if ($order == 2) $q .= ' order by score desc';  
         $something = mysql_query($q);  
         $num_tid = mysql_num_rows($something);  
         navbar($sid, $thold, $mode, $order);  
         modone();  
         while ($count_times < $num_tid) {  
                 list($tid, $pid, $sid, $date, $name, $email, $url, $host_name, $subject, $comment, $score, $reason) = mysql_fetch_row($something);  
   
                 echo format_comment_header($name,$subject,$tid,$date,$reason,$email,$score);  
                 echo format_comment_body($comment,$sid,$tid,$thold,$order,$cookie[10]);  
                 echo format_comment_footer($tid,$sid,$pid,$mode,$order,$thold,$score,$reason);  
   
                 DisplayKids($tid, $mode, $order, $thold, $level);  
                 $count_times += 1;  
         }  
         modthree($sid, $mode, $order, $thold);  
         if ($pid == 0) return array($sid, $pid, $subject);  
         else include('footer.php');  
 }  
   
 function singlecomment($tid, $sid, $mode, $order, $thold) {  
         include('header.php');  
         global $user, $cookie;  
         dbconnect();  
         $result = mysql_query("SELECT date, name, email, url, subject, comment, score, reason FROM pollcomments WHERE tid='$tid' AND pollID='$sid'");  
         list($date, $name, $email, $url, $subject, $comment, $score, $reason) = mysql_fetch_row($result);  
   
         echo format_comment_header($name,$subject,$tid,$date,$reason,$email,$score);  
         echo format_comment_body($comment,$sid,$tid,$thold,$order,65535);  
         echo format_comment_footer($tid,$sid,0,$mode,$order,$thold,$score,$reason);  
         echo "<a href=\"pollBooth.php?op=results&amp;pollID=$sid".rmflags()."\">Tillbaks till undersökningen</a>\n";  
         modthree($sid, $mode, $order, $thold);  
         include('footer.php');  
 }  
   
 function reply($pid, $sid, $mode, $order, $thold) {  
         global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI;  
         if (!@$mainfile)  
                 include('header.php');  
         else {  
                 if (!isset($config)) include('config.php');  
         }  
         global $user, $cookie, $bgcolor1, $bgcolor2, $bgcolor3;  
         $reason = ""; $score = 0;  
         dbconnect();  
         if ($pid!=0) {  
                 list($date, $name, $email, $url, $subject, $comment, $score,  
                      $reason) = mysql_fetch_row(mysql_query("SELECT date, ".  
                                  "name, email, url, subject, comment, score, ".  
                                  "reason FROM pollcomments WHERE tid='$pid'"));  
         } else {  
                 list($date, $subject, $temp_comment, $comment, $name,  
                      $notes) = mysql_fetch_row(mysql_query("SELECT NOW(), ".  
                                 "pollTitle, NULL, NULL, NULL, NULL FROM ".  
                                 "poll_desc WHERE pollID='$sid'"));  
         }  
         if ($comment == "") $comment = $temp_comment;  
   
         echo format_comment_header($name,$subject,$pid,$date,$reason,$email,$score);  
         echo format_comment_body("$comment $notes",$sid,$pid,-1,"",0);  
   
         if (!isset($pid) || !isset($sid)) { echo "<img src=\"images/warning.png\">Någonting är väldigt fel."; exit(); }  
         if (!@$pid) {  
                 list($subject) = mysql_fetch_row(mysql_query("SELECT pollTitle FROM poll_desc WHERE pollID='$sid'"));  
         } else {  
                 list($subject) = mysql_fetch_row(mysql_query("SELECT subject FROM pollcomments WHERE tid='$pid'"));  
         }  
   
         echo "<form method=\"POST\" action=\"$REQUEST_URI\">\n";  
         echo "<p><font color=\"$bgcolor2\"><b>Ditt namn:</b></font>\n";  
         if ($user) {  
                 cookiedecode($user);  
                 echo "<a href=\"user.php\">$cookie[1]</a> <font size=2>[ <a href=\"user.php?op=logout\">Logga ut</a> ]</font>";  
         } else {  
                 echo "<font color=\"Red\">$anonymous</font><font color=\"Black\">\n";  
                 echo "[ <a href=\"user.php\">Ny användare</a> | <a href=\"user.php?op=commentsLogin&passOn=".urlencode($REQUEST_URI)."\">Logga in</a> ]</font>\n";  
         }  
         echo "<p><font color=\"$bgcolor2\"><b>Ärende</b></font><br>\n";  
         if (!eregi("Re:",$subject)) $subject = "Re: $subject";  
         echo "<input class=\"textbox\" type=\"text\" name=\"subject\" size=\"50\" maxlength=\"60\" value=\"".htmlspecialchars($subject)."\"><br>";  
         echo "<p><font color=\"$bgcolor2\"><b>Kommentar</b></font><br>\n";  
         echo "<textarea class=\"textbox\" wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"comment\"></textarea><br>\n";  
         echo "Tillåten HTML:<br>\n";  
         while (list($key,)= each($AllowableHTML)) echo " &lt;".$key."&gt;";  
         echo "<br>\n";  
         if ($user) {  
                 echo "<input type=\"checkbox\" name=\"postanon\"> Posta anonymt<br>\n";  
                 echo "<input type=\"checkbox\" name=\"medsig\" checked> Infoga signatur<br>\n";  
         }  
         if($speling) {    
                 echo "<input type=\"checkbox\" id=\"spell\" name=\"spell\"" . (($spell) ? " checked" : "")  . ">&nbsp;<label for=\"spell\">Kontrollera stavning</label><br>\n";  
         }  
         echo "<input class=\"textbox\" type=\"hidden\" name=\"pid\" value=\"$pid\">\n"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"pollID\" value=\"$sid\">"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"mode\" value=\"$mode\">\n"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"order\" value=\"$order\">"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"thold\" value=\"$thold\">\n"  
             ."<input type=\"submit\" name=\"op\" value=\"Preview\" class=\"button\">\n"  
             ."<input type=\"submit\" name=\"op\" value=\"Ok!\" class=\"button\"> "  
             ."<select name=\"posttype\">"  
             ."<option value=\"source\">Källkod"  
             ."<option value=\"html\">HTML-formatterad"  
             ."<option value=\"plaintext\" selected>Vanlig text"  
             ."</select></form><br>\n";  
   
         include('footer.php');  
 }  
   
 function replyPreview ($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell) {  
         global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI;  
         if(!@$mainfile)  
                 include('header.php');  
         else {  
                 if (!isset($config)) include('config.php');  
         }  
         global $user, $cookie;  
         cookiedecode($user);  
         if ($user && $medsig && ($cookie[11]!="")) $usersig="<br>".stripslashes($cookie[11]);  
         else $usersig="";  
         $subject = stripslashes($subject);  
         $subject = strip_tags($subject);  
         $comment = stripslashes($comment);  
   
         if (!isset($pid) || !isset($sid)) { echo "<img src=\"images/warning.png\">Någonting är väldigt fel."; exit(); }  
   
         if ($user and !$postanon)  
                 $name = $cookie[1];  
         else {  
                 $name = $anonymous; $usersig=""; }  
   
         if ($posttype == "source")  
             $viewcomment = '<pre>'.nowordlinksshow($comment).'</pre>'.$usersig;  
         else {  
           $comment = filter_text($comment);  
           if ($posttype == "plaintext")  
                 $viewcomment = nl2br($comment).$usersig;  
           else  
                 $viewcomment = $comment.$usersig;  
         }  
   
         echo format_comment_header($name,($spell) ? spellcheck(wordlinks($subject)) : $subject,$tid,$date,"","",0);  
         echo format_comment_body(($spell) ? spellcheck(wordlinks($viewcomment)) : $viewcomment,$sid,$tid,$thold,$order,$cookie[10]);  
   
         echo "<hr>\n";  
   
         echo "<form method=\"POST\" action=\"$REQUEST_URI\"><p><font color=\"$bgcolor2\"><b>Ditt namn: </b></font>\n";  
         if ($user) echo "<a href=\"user.php\">$cookie[1]</a> [ <a href=\"user.php?op=logout\">Logga ut</a> ]\n";  
         else echo "$anonymous";  
         echo "<p><font color=\"$bgcolor2\"><b>Ärende</b></font><br>\n"  
                 ."<input class=\"textbox\" type=\"text\" name=\"subject\" size=\"50\" maxlength=\"60\" value=\"".htmlspecialchars($subject)."\"><br>\n"  
                 ."<p><b>Kommentar</b><br>\n"  
                 ."<textarea class=\"textbox\" wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"comment\">".htmlspecialchars($comment)."</textarea><br>\n";  
                 echo "Tillåten HTML:<br>\n";  
                 while (list($key,)= each($AllowableHTML)) echo " &lt;".$key."&gt;";  
                 echo "<br>\n";  
         if ($postanon) $postanon_check = " checked"; else $postanon_check = "";  
         if ($medsig) $medsig_check = " checked"; else $medsig_check = "";  
         if ($user) {  
                 echo "<input type=\"checkbox\" name=\"postanon\" $postanon_check> Posta anonymt<br>\n";  
                 echo "<input type=\"checkbox\" name=\"medsig\" $medsig_check> Infoga signatur<br>\n";  
         }  
         if ($speling) {  
                 echo "<input type=\"checkbox\" id=\"spell\" name=\"spell\"" . (($spell) ? " checked" : "")  . ">&nbsp;<label for=\"spell\">Kontrollera stavning</label><br>\n";  
         }  
         echo "<input class=\"textbox\" type=\"hidden\" name=\"pid\" value=\"$pid\">"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"pollID\" value=\"$sid\">"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"mode\" value=\"$mode\">\n"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"order\" value=\"$order\">"  
             ."<input class=\"textbox\" type=\"hidden\" name=\"thold\" value=\"$thold\">\n"  
             ."<input type=\"submit\" name=\"op\" value=\"Preview\" class=\"button\">\n"  
             ."<input type=\"submit\" name=\"op\" value=\"Ok!\" class=\"button\"> "  
             ."<select name=\"posttype\">"  
             ."<option value=\"source\"";  
         if ($posttype == "source") echo " selected";  
         echo ">Källkod".  
              "<option value=\"html\"";  
         if ($posttype == "html") echo " selected";  
         echo ">HTML-formatterad".  
              "<option value=\"plaintext\"";  
         if (($posttype != "source") && ($posttype != "html"))  
             echo " selected";  
         echo ">Vanlig text".  
              "</select></form><br>\n";  
   
         include('footer.php');  
 }  
   
 function CreateTopic ($medsig, $postanon, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype) {  
         global $dbhost,$dbuname,$dbpass,$dbname;  
         global $user, $userinfo, $EditedMessage, $cookie;  
         dbconnect();  
         $author = FixQuotes($author);  
         $subject = FixQuotes(filter_text($subject, "nohtml"));  
         if ($user && $medsig && ($cookie[11]!="")) $usersig="<br>".stripslashes($cookie[11]);  
         else $usersig="";  
         if ($posttype == "source")  
                 $comment = FixQuotes('<pre>'.nowordlinksshow($comment).'</pre>').$usersig;  
         elseif ($posttype == "plaintext")  
                 $comment = FixQuotes(nl2br(filter_text($comment))).$usersig;  
         else  
                 $comment = FixQuotes(filter_text($comment)).$usersig;  
         if ($user) getusrinfo($user);  
         if (($user) && (!$postanon)) {  
                 getusrinfo($user);  
                 $name = $userinfo[uname];  
                 $email = $userinfo[femail];  
                 $url = $userinfo[url];  
                 $score = 1;  
         } else {  
                 $name = ""; $email = ""; $url = "";  
                 $score = 0;  
         }  
         $ip = getenv("REMOTE_ADDR");  
 //begin fake thread control  
         list($fake) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM poll_desc WHERE pollID='$sid'"));  
         mysql_query("LOCK TABLES pollcomments WRITE");  
 //begin duplicate control  
         list($tia) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM pollcomments WHERE pid='$pid' AND pollID='$sid' AND subject='$subject' AND comment='$comment'"));  
 //begin troll control  
         if ($user) {  
                 $sql = "SELECT COUNT(*) FROM pollcomments WHERE (score=-1) AND (name='$userinfo[uname]') AND (TO_DAYS(NOW()) - TO_DAYS(date) < 3)";  
                 $result = mysql_query($sql);  
                 list($troll) = mysql_fetch_row($result);  
         } elseif(!$score) {  
                 $sql = "SELECT COUNT(*) FROM pollcomments WHERE (score=-1) AND (host_name='$ip') AND (TO_DAYS(NOW()) - TO_DAYS(date) < 3)";  
                 list($troll) = mysql_fetch_row(mysql_query($sql));  
         }  
         if ((!$tia) && ($fake == 1) && ($troll < 6)) {  
                 mysql_query("INSERT INTO pollcomments VALUES (NULL, '$pid', '$sid', now(), '$name', '$email', '$url', '$ip', '$subject', '$comment', '$score', '0')");  
         } else {  
                 mysql_query("UNLOCK TABLES");  
                 include('header.php');  
                 if ($tia) echo "<img src=\"images/warning.png\"><br><br>Det verkar som om du redan postat den här kommentaren...<br><br><a href=\"pollBooth.php?op=results&amp;pollID=$sid&amp;mode=$mode&amp;order=$order&amp;thold=$thold\">Tillbaks till undersökningen</a>";  
                 elseif ($troll > 5) echo "<img src=\"images/warning.png\"><br><br>  
                         Det här kontot eller IP-numret har blivit tillfälligt avstängt.  
                         Detta betyder att du har modererats ner mer än fem gånger de senaste  
                         timmarna.  
                         Om du tycker att det här är orättvist ska du kontakta  
                         administratören. Om du är ett troll är det dags att växa upp  
                         eller ändra din IP-adress.  
                         <br><br><a href=\"article.php?sid=$sid&mode=$mode&order=$order&thold=$thold\">Tillbaks till artikeln</a>";  
                 elseif (!@$fake) echo "<img src=\"images/warning.png\"><br><br>  
                         Enligt protokollet så finns inte det du försöker svara  
                         på. Du är nog på villovägar.";  
                 include('footer.php');  
                 exit;  
         }  
         mysql_query('UNLOCK TABLES');  
         mysql_query("UPDATE stories SET comments=comments+1 WHERE sid='$sid'");  
         Header("Location: pollBooth.php?op=results&pollID=$sid&mode=$mode&order=$order&thold=$thold");  
 }  
   
   
 switch ($op) {  
         case "Reply":  
                 reply($pid, $pollID, $mode, $order, $thold);  
                 break;  
         case "Preview":  
                 replyPreview($medsig, $pid, $pollID, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell);  
                 break;  
         case "Ok!":  
                 CreateTopic($medsig, $postanon, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype);  
                 break;  
         case "moderate":  
                 if (isset($admin)) {  
                         include('auth.inc.php');  
                 } else  
                         dbconnect();  
                 if (($admintest==1) || ($moderate==2)) {  
                         while (list($tdw, $emp) = each($HTTP_POST_VARS)) {  
                                 if (eregi("dkn",$tdw)) {  
                                         $emp = explode(':', $emp);  
                                         if ($emp[1] != 0) {  
                                                 $tdw = ereg_replace('dkn', "", $tdw);  
                                                 $q = "UPDATE pollcomments SET";  
                                                 if (($emp[1] == 9) && ($emp[0]>=0)) { # Overrated  
                                                         $q .= " score=score-1 WHERE tid='$tdw'";  
                                                 } elseif (($emp[1] == 10) && ($emp[0]<=4)) { # Underrated  
                                                         $q .= " score=score+1 WHERE tid='$tdw'";  
                                                 } elseif (($emp[1] > 4) && ($emp[0]<=4)) {  
                                                         $q .= " score=score+1, reason='$emp[1]' WHERE tid=$tdw";  
                                                 } elseif (($emp[1] < 5) && ($emp[0] > -1)) {  
                                                         $q .= " score=score-1, reason='$emp[1]' WHERE tid='$tdw'";  
                                                 } elseif (($emp[0] == -1) || ($emp[0] == 5)) {  
                                                         $q .= " reason='$emp[1]' WHERE tid='$tdw'";  
                                                 }  
                                                 if(strlen($q) > 20) mysql_query("$q");  
                                         }  
                                 }  
                         }  
                 }  
                 Header("Location: pollBooth.php?op=results&pollID=$pollID&mode=$mode&order=$order&thold=$thold");  
                 break;  
         case "showreply":  
                 DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);  
                 break;  
         default:  
                 if ((isset($tid)) && (!isset($pid))) {  
                         singlecomment($tid, $pollID, $mode, $order, $thold);  
                 } elseif (($mainfile) xor (($pid==0) || (!isset($pid)))) {  
                         Header("Location: pollBooth.php?op=results&pollID=$pollID&mode=$mode&order=$order&thold=$thold");  
                 } else {  
                         if (!isset($pid)) $pid=0;  
                         DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);  
                 }  
                 break;  
 }  
   
 ?>  

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26