home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / pollcomments.php < prev    next >
PHP Script  |  2000-12-05  |  27KB  |  563 lines

  1. <?php
  2.  
  3. ######################################################################
  4. # PHP-NUKE: Web Portal System
  5. # ===========================
  6. #
  7. # Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
  8. # http://phpnuke.org
  9. #
  10. # This modules is to manage all user's comments in the site
  11. #
  12. # This program is free software. You can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License.
  15. ######################################################################
  16.  
  17. function modone() {
  18.     global $admin, $moderate;
  19.     if(((isset($admin)) && ($moderate == 1)) || ($moderate==2)) echo "<form action=\"pollcomments.php\" method=\"post\">";
  20. }
  21.  
  22. function modtwo($tid, $score, $reason) {
  23.     global $admin, $user, $moderate, $reasons;
  24.     if((((isset($admin)) && ($moderate == 1)) || ($moderate == 2)) && ($user)) {
  25.         echo " | <select name=dkn$tid>";
  26.         for($i=0; $i<sizeof($reasons); $i++) {
  27.             echo "<option value=\"$score:$i\">$reasons[$i]</option>\n";
  28.         }
  29.         echo "</select>";
  30.     }
  31. }
  32.  
  33. function modthree($pollID, $mode, $order, $thold=0) {
  34.     global $admin, $user, $moderate;
  35.     if((((isset($admin)) && ($moderate == 1)) || ($moderate==2)) && ($user)) echo "<center><input type=hidden name=pollID value=$pollID><input type=hidden name=mode value=$mode><input type=hidden name=order value=$order><input type=hidden name=thold value=$thold>
  36.     <input type=hidden name=op value=moderate>
  37.     <input type=image src=$uimages/moderate.gif border=0></form></center>";
  38. }
  39.  
  40. function navbar($pollID, $title, $thold, $mode, $order) {
  41.     global $user, $bgcolor1, $bgcolor2, $textcolor1, $textcolor2;
  42.     $query = mysql_query("select pollID FROM pollcomments where sid=$sid");
  43.     if(!$query) $count = 0; else $count = mysql_num_rows($query);
  44.     $result = mysql_query("select pollTitle from poll_desc where pollID=$pollID");
  45.     list($title) = mysql_fetch_row($result);
  46.     if(!isset($thold)) $thold=0; ?>
  47.     <table width=99% border=0 cellspacing=1 cellpadding=2>
  48.     <?php if($title) {
  49.         echo "<tr><td bgcolor=\"$bgcolor2\" align=center><font size=2 color=\"$textcolor1\">\"$title\" | ";
  50.         if($user) {
  51.             echo "<a href=\"user.php\"><font color=\"$textcolor1\">".translate("Configure")."</font></a>";
  52.         } else {
  53.             echo "<a href=\"user.php\"><font color=\"$textcolor1\">".translate("Login/Create Account")."</font></a>";
  54.         }
  55.         if(($count==1)) {
  56.         echo " | <B>$count</B> ".translate("comment")."</font></td></tr>";
  57.         } else {
  58.         echo " | <B>$count</B> ".translate("comments")."</font></td></tr>";
  59.         }
  60.     } ?>
  61.     <tr><td bgcolor="<?php echo"$bgcolor1"; ?>" align="center"><font size=2>
  62.     <form method=get action=pollcomments.php>
  63.     <font color="<?php echo"$textcolor2"; ?>"><?php echo translate("Threshold"); ?></font> <select name=thold>
  64.     <option value="-1" <?PHP if ($thold == -1) { echo "selected"; } ?>>-1
  65.     <option value="0" <?PHP if ($thold == 0) { echo "selected"; } ?>>0
  66.     <option value="1" <?PHP if ($thold == 1) { echo "selected"; } ?>>1
  67.     <option value="2" <?PHP if ($thold == 2) { echo "selected"; } ?>>2
  68.     <option value="3" <?PHP if ($thold == 3) { echo "selected"; } ?>>3
  69.     <option value="4" <?PHP if ($thold == 4) { echo "selected"; } ?>>4
  70.     <option value="5" <?PHP if ($thold == 5) { echo "selected"; } ?>>5
  71.     </select> <select name=mode>
  72.     <option value="nocomments" <?PHP if ($mode == 'nocomments') { echo "selected"; } ?>><?php echo translate("No Comments"); ?>
  73.     <option value="nested" <?PHP if ($mode == 'nested') { echo "selected"; } ?>><?php echo translate("Nested"); ?>
  74.     <option value="flat" <?PHP if ($mode == 'flat') { echo "selected"; } ?>><?php echo translate("Flat"); ?>
  75.     <option value="thread" <?PHP if (!isset($mode) || $mode=='thread' || $mode=="") { echo "selected"; } ?>><?php echo translate("Thread"); ?>
  76.     </select> <select name=order>
  77.     <option value="0" <?PHP if (!$order) { echo "selected"; } ?>><?php echo translate("Oldest First"); ?>
  78.     <option value="1" <?PHP if ($order==1) { echo "selected"; } ?>><?php echo translate("Newest First"); ?>
  79.     <option value="2" <?PHP if ($order==2) { echo "selected"; } ?>><?php echo translate("Highest Scores First"); ?>
  80.     </select>
  81.     <input type=submit value=<?php echo translate("Refresh"); ?>></font>
  82.     <input type=hidden name=pollID value=<?PHP echo "$pollID"; ?>>
  83.     </td></tr></form>
  84.     <tr><td bgcolor="<?php echo"$bgcolor2"; ?>" align=center><font size=1 color="#FFFFFF"><?php echo translate("The comments are owned by the poster. We aren't responsible for their content."); ?></td></tr>
  85.     </table>
  86. <?php
  87. }
  88.  
  89. function DisplayKids ($tid, $mode, $order=0, $thold=0, $level=0, $dummy=0, $tblwidth=99) {
  90.     global $datetime, $user, $cookie, $bgcolor1, $reasons, $anonymous, $anonpost, $commentlimit;
  91.     $comments = 0;
  92.     cookiedecode($user);
  93.     $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");
  94.     if ($mode == 'nested') {
  95.         /* without the tblwidth variable, the tables run of the screen with netscape
  96.            in nested mode in long threads so the text can't be read. */
  97.         while (list($r_tid, $r_pid, $r_pollID, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {
  98.             if($r_score >= $thold) {
  99.                 if (!isset($level)) {
  100.                 } else {
  101.                     if (!$comments) {
  102.                         echo "<ul>";
  103.                         $tblwidth -= 5;
  104.                     }
  105.                 }
  106.                 $comments++;
  107.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  108.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";
  109.             // enter hex color between first two appostrophe for second alt bgcolor
  110.                 $r_bgcolor = ($dummy%2)?"":"#E6E6D2";
  111.                 echo "<a name=\"$r_tid\">";
  112.                 echo "<table width=90% border=0><tr bgcolor=\"$r_bgcolor\"><td>";
  113.                 formatTimestamp($r_date);
  114.                 if ($r_email) {
  115.                     echo "<p><b>$r_subject</b> <font size=2>";
  116.                     if(!$cookie[7]) {
  117.                         echo "(".translate("Score: ")."$r_score";
  118.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  119.                         echo ")";
  120.                     }
  121.                     echo "<br>".translate("by")." <a href=\"mailto:$r_email\">$r_name</a> <font size=2><b>($r_email)</b></font> ".translate("on")." $datetime";
  122.                 } else {
  123.                     echo "<p><b>$r_subject</b> <font size=2>";
  124.                     if(!$cookie[7]) {
  125.                         echo "(".translate("Score: ")."$r_score";
  126.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  127.                         echo ")";
  128.                     }
  129.                     echo "<br>".translate("by")." $r_name ".translate("on")." $datetime";
  130.                 }            
  131.                 if ($r_name != $anonymous) { echo "<BR>(<a href=\"user.php?op=userinfo&uname=$r_name\">".translate("User Info")."</a>) "; }
  132.                 if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }
  133.                 echo "</font></td></tr><tr><td>";
  134.                 if(($cookie[10]) && (strlen($r_comment) > $cookie[10])) echo substr("$r_comment", 0, $cookie[10])."<br><br><b><a href=\"pollcomments.php?pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  135.                 elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"pollcomments.php?pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  136.                 else echo $r_comment;
  137.                 echo "</td></tr></table><br><p><font size=2 color=\"$bgcolor2\"> [ <a href=\"pollcomments.php?op=Reply&pid=$r_tid&pollID=$r_pollID&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
  138.                 modtwo($r_tid, $r_score, $r_reason);
  139.                 echo " ]</font><p>";
  140.                 DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
  141.             }
  142.         }
  143.     } elseif ($mode == 'flat') {
  144.         while (list($r_tid, $r_pid, $r_pollID, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {
  145.             if($r_score >= $thold) {
  146.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  147.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";
  148.                 echo "<a name=\"$r_tid\">";
  149.                 echo "<hr><table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td>";
  150.                 formatTimestamp($r_date);
  151.                 if ($r_email) {
  152.                     echo "<p><b>$r_subject</b> <font size=2>";
  153.                     if(!$cookie[7]) {
  154.                         echo "(".translate("Score: ")."$r_score";
  155.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  156.                         echo ")";
  157.                     }
  158.                     echo "<br>".translate("by")." <a href=\"mailto:$r_email\">$r_name</a> <font size=2><b>($r_email)</b></font> ".translate("on")." $datetime";
  159.                  } else {
  160.                     echo "<p><b>$r_subject</b> <font size=2>";
  161.                     if(!$cookie[7]) {
  162.                         echo "(".translate("Score: ")."$r_score";
  163.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  164.                         echo ")";
  165.                     }
  166.                     echo "<br>".translate("by")." $r_name ".translate("on")." $datetime";
  167.                 }            
  168.                 if ($r_name != $anonymous) { echo "<BR>(<a href=\"user.php?op=userinfo&uname=$r_name\">".translate("User Info")."</a>) "; }
  169.                 if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }
  170.                 echo "</font></td></tr><tr><td>";
  171.                 if(($cookie[10]) && (strlen($r_comment) > $cookie[10])) echo substr("$r_comment", 0, $cookie[10])."<br><br><b><a href=\"pollcomments.php?pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  172.                 elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"pollcomments.php?pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  173.                 else echo $r_comment;
  174.                 echo "</td></tr></table><br><p><font size=2 color=\"$bgcolor2\"> [ <a href=\"pollcomments.php?op=Reply&pid=$r_tid&pollID=$r_pollID&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
  175.                 modtwo($r_tid, $r_score, $r_reason);
  176.                 echo " ]</font><p>";
  177.                 DisplayKids($r_tid, $mode, $order, $thold);
  178.             }
  179.         }
  180.     } else {
  181.         while (list($r_tid, $r_pid, $r_pollID, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {
  182.             if($r_score >= $thold) {
  183.                 if (!isset($level)) {
  184.                 } else {
  185.                     if (!$comments) {
  186.                         echo "<ul>";
  187.                     }
  188.                 }
  189.                 $comments++;
  190.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  191.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";
  192.                 formatTimestamp($r_date);
  193.                 echo "<li><a href=\"pollcomments.php?op=showreply&tid=$r_tid&pollID=$r_pollID&pid=$r_pid&mode=$mode&order=$order&thold=$thold#$r_tid\">$r_subject</a> ".translate("by")." $r_name <font size=2>".translate("on")." $datetime</font><br>";
  194.  
  195.                 DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1);
  196.             } 
  197.         }
  198.     }
  199.     if ($level && $comments) {
  200.         echo "</ul>";
  201.     }
  202.  
  203. }
  204.  
  205. function DisplayBabies ($tid, $level=0, $dummy=0) {
  206.     global $datetime, $anonymous;
  207.     $comments = 0;
  208.     $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");
  209.     while (list($r_tid, $r_pid, $r_pollID, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result))
  210.     {
  211.         if (!isset($level)) {
  212.         } else {
  213.             if (!$comments) {
  214.                 echo "<ul>";
  215.             }
  216.         }
  217.         $comments++;
  218.         if (!eregi("[a-z0-9]",$r_name)) { $r_name = $anonymous; }
  219.         if (!eregi("[a-z0-9]",$r_subject)) { $r_subject = "[".translate("No Subject")."]"; }
  220.  
  221.         formatTimestamp($r_date);
  222.         echo "<a href=\"pollcomments.php?op=showreply&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">$r_subject</a> ".translate("by")." $r_name <font size=2>".translate("on")." $datetime</font><br>";
  223.         DisplayBabies($r_tid, $level+1, $dummy+1);
  224.     } 
  225.     if ($level && $comments) {
  226.         echo "</ul>";
  227.     }
  228. }
  229.  
  230. function DisplayTopic ($pollID, $pid=0, $tid=0, $mode="thread", $order=0, $thold=0, $level=0, $nokids=0) {
  231.     global $hr, $user, $datetime, $cookie, $mainfile, $admin, $commentlimit, $anonymous, $reasons, $anonpost;
  232.     if($mainfile) {
  233.         global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  234.     } else {
  235.         global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  236.         include("mainfile.php");
  237.         include("header.php");
  238.     }
  239.     $count_times = 0;
  240.     cookiedecode($user);
  241.     $q = "select tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason from pollcomments where pollID=$pollID and pid=$pid";
  242.     if($thold != "") {
  243.         $q .= " and score>=$thold";
  244.     } else {
  245.         $q .= " and score>=0";
  246.     }
  247.     if ($order==1) $q .= " order by date desc";
  248.     if ($order==2) $q .= " order by score desc";
  249.     $something = mysql_query("$q");
  250.     $num_tid = mysql_num_rows($something);
  251.     navbar($pollID, $title, $thold, $mode, $order);
  252.     modone();
  253.     while ($count_times < $num_tid) {
  254.         list($tid, $pid, $pollID, $date, $name, $email, $url, $host_name, $subject, $comment, $score, $reason) = mysql_fetch_row($something);
  255.         if ($name == "") { $name = $anonymous; }
  256.         if ($subject == "") { $subject = "[".translate("No Subject")."]"; }    
  257.  
  258.         echo "<a name=\"$tid\">";
  259.         echo "<table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td width=500>";
  260.         formatTimestamp($date);
  261.         if ($email) {
  262.             echo "<p><b>$subject</b> <font size=2>";
  263.             if(!$cookie[7]) {
  264.                 echo "(".translate("Score: ")."$score";
  265.                 if($reason>0) echo ", $reasons[$reason]";
  266.                 echo ")";
  267.             }
  268.             echo "<br>".translate("by")." <a href=\"mailto:$email\">$name</a> <b>($email)</b> ".translate("on")." $datetime"; 
  269.         } else {
  270.             echo "<p><b>$subject</b> <font size=2>";
  271.             if(!$cookie[7]) {
  272.                 echo "(".translate("Score: ")."$score";
  273.                 if($reason>0) echo ", $reasons[$reason]";
  274.                 echo ")";
  275.             }
  276.             echo "<br>".translate("by")." $name ".translate("on")." $datetime";
  277.         }            
  278.         
  279.     // If you are admin you can see the Poster IP address (you have this right, no?)
  280.     // with this you can see who is flaming you... ha-ha-ha
  281.         
  282.         if ($name != $anonymous) { echo "<br>(<a href=\"user.php?op=userinfo&uname=$name\">".translate("User Info")."</a>) "; }
  283.         if (eregi("http://",$url)) { echo "<a href=\"$url\" target=\"window\">$url</a> "; }
  284.         
  285.         if($admin) {
  286.             $result= mysql_query("select host_name from pollcomments where tid='$tid'");
  287.             list($host_name) = mysql_fetch_row($result);
  288.             echo "<br><b>(IP: $host_name)</b>";
  289.         }
  290.         
  291.         echo "</font></td></tr><tr><td>";
  292.         if(($cookie[10]) && (strlen($comment) > $cookie[10])) echo substr("$comment", 0, $cookie[10])."<br><br><b><a href=\"pollcomments.php?pollID=$pollID&tid=$tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  293.         elseif(strlen($comment) > $commentlimit) echo substr("$comment", 0, $commentlimit)."<br><br><b><a href=\"pollcomments.php?pollID=$pollID&tid=$tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
  294.         else echo $comment;
  295.         echo "</td></tr></table><br><p><font size=2 color=000000> [ <a href=\"pollcomments.php?op=Reply&pid=$tid&pollID=$pollID&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
  296.         
  297.         if ($pid != 0) {
  298.             list($erin) = mysql_fetch_row(mysql_query("select pid from pollcomments where tid=$pid"));
  299.             echo "| <a href=\"pollcomments.php?pollID=$pollID&pid=$erin&mode=$mode&order=$order&thold=$thold\">".translate("Parent")."</a>";
  300.         }
  301.         modtwo($tid, $score, $reason);
  302.         
  303.         if($admin) {
  304.         echo " | <a href=\"admin.php?op=RemovePollComment&tid=$tid&pollID=$pollID\">".translate("Delete")."</a> ]</font><p>";
  305.         } else {
  306.             echo " ]</font><p>";
  307.         }
  308.         
  309.         DisplayKids($tid, $mode, $order, $thold, $level);
  310.         echo "</ul>";
  311.         if($hr) echo "<hr noshade size=1>";
  312.         echo "</p>";
  313.         $count_times += 1;
  314.     }
  315.     modthree($pollID, $mode, $order, $thold);
  316.     if($pid==0) return array($pollID, $pid, $subject);
  317.     else include("footer.php");
  318. }
  319.  
  320. function singlecomment($tid, $pollID, $mode, $order, $thold) {
  321.     include("mainfile.php");
  322.     include("header.php");
  323.     global $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $anonpost, $admin, $anonymous;
  324.     $deekayen = mysql_query("select date, name, email, url, subject, comment, score, reason from pollcomments where tid=$tid and pollID=$pollID");
  325.     list($date, $name, $email, $url, $subject, $comment, $score, $reason) = mysql_fetch_row($deekayen);
  326.     $titlebar = "<b>$subject</b>";
  327.     if($name == "") $name = $anonymous;
  328.     if($subject == "") $subject = "[".translate("No Subject")."]";
  329.     modone();
  330.     echo "<table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td width=500>";
  331.     formatTimestamp($date);
  332.     if($email) echo "<p><b>$subject</b> <font size=2>(".translate("Score: ")."$score)<br>".translate("by")." <a href=\"mailto:$email\"><font color=\"$bgcolor2\">$name</font></a> <font size=2><b>($email)</b></font> ".translate("on")." $datetime";
  333.     else echo "<p><b>$subject</b> <font size=2>(".translate("Score: ")."$score)<br>".translate("by")." $name ".translate("on")." $datetime";
  334.     echo "</td></tr><tr><td>$comment</td></tr></table><br><p><font size=2 color=\"$bgcolor2\"> [ <a href=\"pollcomments.php?op=Reply&pid=$tid&pollID=$pollID&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a> | <a href=\"pollBooth.php?pollID=$pollID\">Root</a>";
  335.     modtwo($tid, $score, $reason);
  336.     echo " ]";
  337.     modthree($pollID, $mode, $order, $thold);
  338.     include("footer.php");
  339. }
  340.  
  341. function reply ($pid, $pollID, $mode, $order, $thold) {
  342.     include("mainfile.php");
  343.     include("header.php");
  344.     global $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $anonymous;
  345.     if($pid!=0) {
  346.         list($date, $name, $email, $url, $subject, $comment, $score) = mysql_fetch_row(mysql_query("select date, name, email, url, subject, comment, score from pollcomments where tid=$pid"));
  347.     } else {
  348.         list($subject) = mysql_fetch_row(mysql_query("select pollTitle FROM poll_desc where pollID=$pollID"));
  349.     }
  350.     if($comment == "") $comment = $temp_comment;
  351.     $titlebar = "<b>$subject</b>";
  352.     if($name == "") $name = $anonymous;
  353.     if($subject == "") $subject = "[".translate("No Subject")."]";
  354.     echo "<table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td width=500>";
  355.     formatTimestamp($date);
  356.     echo "<p><b>$subject</b> <font size=2>";
  357.     echo "</td></tr><tr><td>$comment $notes</td></tr></table><hr>";
  358.  
  359.     if(!isset($pid) || !isset($pollID)) { echo "Something is not right. This message is just to keep things from messing up down the road"; exit(); }
  360.     if($pid == 0) {
  361.         list($subject) = mysql_fetch_row(mysql_query("select pollTitle from poll_desc where pollID=$pollID"));
  362.     } else {
  363.         list($subject) = mysql_fetch_row(mysql_query("select subject from pollcomments where tid=$pid"));
  364.     }
  365.  
  366.     echo "<form action=\"pollcomments.php\" method=post>";
  367.     echo "<P><FONT color=\"$bgcolor2\"><B>".translate("Your Name")."</B></FONT> ";
  368.     if ($user) {
  369.         cookiedecode($user);
  370.         echo "<a href=\"user.php\">$cookie[1]</a> <font size=2>[ <a href=\"user.php?op=logout\">".translate("Logout")."</a> ]</font>";
  371.     } else {
  372.         echo "$anonymous"; $anonpost=2;
  373.     }
  374.     echo "<P><FONT color=\"$bgcolor2\"><B>".translate("Subject")."</B></FONT><BR>";
  375.     if (!eregi("Re:",$subject)) $subject = "Re: $subject";
  376.     echo "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=50 maxlength=60 value=\"$subject\"><BR>";
  377.     echo "<P><FONT color=\"$bgcolor2\"><B>".translate("Comment")."</B></FONT><BR>"
  378.         ."<TEXTAREA wrap=virtual cols=50 rows=10 name=comment></TEXTAREA><br>
  379.         <font size=2>".translate("Allowed HTML:")."<br>";
  380.         while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
  381.         echo "<br>";
  382.     if ($user) { echo "<INPUT type=checkbox name=anonpost> ".translate("Post Anonymously")."<br>"; }
  383.     echo "<INPUT type=\"hidden\" name=\"pid\" value=\"$pid\">"
  384.         ."<INPUT type=\"hidden\" name=\"pollID\" value=\"$pollID\"><INPUT type=\"hidden\" name=\"mode\" value=\"$mode\">"
  385.         ."<INPUT type=\"hidden\" name=\"order\" value=\"$order\"><INPUT type=\"hidden\" name=\"thold\" value=\"$thold\">"
  386.         ."<INPUT type=submit name=op value=\"Preview\">"
  387.         ."<INPUT type=submit name=op value=\"Ok!\"> <SELECT name=\"posttype\"><OPTION value=\"exttrans\">".translate("Extrans (html tags to text)")."<OPTION value=\"html\" >".translate("HTML Formatted")."<OPTION value=\"plaintext\" SELECTED>".translate("Plain Old Text")."</SELECT></FORM><br>";
  388.         
  389.     include("footer.php");
  390. }
  391.  
  392. function replyPreview ($pid, $pollID, $subject, $comment, $anonpost, $mode, $order, $thold, $posttype) {
  393.     include("mainfile.php");
  394.     include("header.php");
  395.     global $user, $cookie, $anonymous;
  396.     cookiedecode($user);
  397.     $subject = stripslashes($subject);
  398.     $comment = stripslashes($comment);
  399.     if (!isset($pid) || !isset($pollID)) { echo "Something is not right with passing a variable to this function. This message is just to keep things from messing up down the road"; exit(); }
  400.  
  401.     echo "<table width=99% border=0><tr><td>";
  402.     echo "<p><b>$subject</b>";
  403.     echo "<br><font size=2>".translate("by")." ";
  404.     if ($user) echo "$cookie[1]";
  405.     else echo "$anonymous";
  406.     echo "".translate(" on...")."</font></td></tr><tr><td>";
  407.     if($posttype=="exttrans") echo nl2br(htmlspecialchars($comment));
  408.     elseif($posttype=="plaintext") echo nl2br($comment);
  409.     else echo $comment;
  410.     echo "</td></tr></table><br>";
  411.  
  412.     echo "<hr>";
  413.  
  414.     echo "<form action=\"pollcomments.php\" method=post><P><FONT color=\"$bgcolor2\"><B>".translate("Your Name")."</B></FONT> ";
  415.     if ($user) echo "<a href=\"user.php\">$cookie[1]</a> <font size=2>[ <a href=\"user.php?op=logout\">".translate("Logout")."</a> ]</font>";
  416.     else echo "$anonymous";
  417.     echo "<P><FONT color=\"$bgcolor2\"><B>".translate("Subject")."</B></FONT><BR>"
  418.         ."<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=50 maxlength=60 value=\"$subject\"><br>"
  419.         ."<P><FONT color=\"$bgcolor2\"><B>".translate("Comment")."</B></FONT><BR>"
  420.         ."<TEXTAREA wrap=virtual cols=50 rows=10 name=comment>$comment</TEXTAREA><br>";
  421.         echo"<font size=2>".translate("Allowed HTML:")."<br>";
  422.         while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
  423.         echo "<br>";        
  424.     if ($anonpost) { echo "<INPUT type=checkbox name=anonpost checked> ".translate("Post Anonymously")."<br>"; } elseif($user) { echo "<INPUT type=checkbox name=anonpost> ".translate("Post Anonymously")."<br>"; }
  425.     echo "<INPUT type=\"hidden\" name=\"pid\" value=\"$pid\">"
  426.         ."<INPUT type=\"hidden\" name=\"pollID\" value=\"$pollID\"><INPUT type=\"hidden\" name=\"mode\" value=\"$mode\">"
  427.         ."<INPUT type=\"hidden\" name=\"order\" value=\"$order\"><INPUT type=\"hidden\" name=\"thold\" value=\"$thold\">"
  428.         ."<INPUT type=submit name=op value=\"Preview\">"
  429.         ."<INPUT type=submit name=op value=\"Ok!\"> <SELECT name=\"posttype\"><OPTION value=\"exttrans\"";
  430.         if($posttype=="exttrans") echo" SELECTED";
  431.         echo  ">".translate("Extrans (html tags to text)")."<OPTION value=\"html\"";;
  432.         if($posttype=="html") echo" SELECTED";
  433.         echo ">".translate("HTML Formatted")."<OPTION value=\"plaintext\"";
  434.         if(($posttype!="exttrans") && ($posttype!="html")) echo" SELECTED";
  435.         echo ">".translate("Plain Old Text")."</SELECT></FORM><br>";
  436.  
  437.     include("footer.php");
  438. }
  439.  
  440. function CreateTopic ($anonpost, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype) {
  441.     global $user, $userinfo, $EditedMessage, $cookie;
  442.     include("mainfile.php");
  443.     $author = FixQuotes($author);
  444.     $subject = FixQuotes(filter_text($subject, "nohtml"));
  445.     if($posttype=="exttrans")
  446.         $comment = FixQuotes(nl2br(htmlspecialchars(check_words($comment))));
  447.     elseif($posttype=="plaintext")
  448.         $comment = FixQuotes(nl2br(filter_text($comment)));
  449.     else
  450.         $comment = FixQuotes(filter_text($comment));
  451.     if($user) getusrinfo($user);
  452.     if (($user) && (!$anonpost)) {
  453.         getusrinfo($user);
  454.         $name = $userinfo[uname];
  455.         $email = $userinfo[femail];
  456.         $url = $userinfo[url];
  457.         $score = 1;
  458.     } else {
  459.         $name = ""; $email = ""; $url = "";
  460.         $score = 0;
  461.     }
  462.     $ip = getenv("REMOTE_HOST");
  463.     if (empty($ip)) {
  464.         $ip = getenv("REMOTE_ADDR");
  465.     }
  466. //begin fake thread control
  467.     list($fake) = mysql_fetch_row(mysql_query("select count(*) from poll_desc where pollID=$pollID"));
  468.     mysql_query("LOCK TABLES pollcomments WRITE");
  469. //begin duplicate control
  470.     list($tia) = mysql_fetch_row(mysql_query("select count(*) from pollcomments where pid='$pid' and pollID='$pollID' and subject='$subject' and comment='$comment'"));
  471. //begin troll control
  472.     if($user) {
  473.         list($troll) = mysql_fetch_row(mysql_query("select count(*) from pollcomments where (score=-1) and (name='$userinfo[uname]') and (to_days(now()) - to_days(date) < 3)"));
  474.     } elseif(!$score) {
  475.         list($troll) = mysql_fetch_row(mysql_query("select count(*) from pollcomments where (score=-1) and (host_name='$ip') and (to_days(now()) - to_days(date) < 3)"));
  476.     }
  477.     if((!$tia) && ($fake == 1) && ($troll < 6)) {
  478.         mysql_query("insert into pollcomments values (NULL, '$pid', '$pollID', now(), '$name', '$email', '$url', '$ip', '$subject', '$comment', '$score', '0')");
  479.     } else {
  480.         mysql_query("UNLOCK TABLES");
  481.         include("header.php");
  482.         if($tia) echo "Duplicate.  Did you submit twice?<br><br><a href=\"pollBooth.php?op=results&pollID=$pollID\">Back to Poll</a>";
  483.         elseif($troll > 5) echo "This account or IP has been temporarily disabled.
  484.                 This means that either this IP, or
  485.                 user account has been moderated down more than 5 times in
  486.                 the last few hours.  If you think this is unfair,
  487.                 you should contact the admin.  If you
  488.                 are being a troll, now is the time for you to either
  489.                 grow up, or change your IP.<br><br><a href=\"pollBooth.php?pollID=$pollID\">Back to Poll</a>";
  490.         elseif($fake == 0) echo "According to my records, the topic you are trying 
  491.                 to reply to does not exist. If you're just trying to be 
  492.                 annoying, well then too bad.";
  493.         include("footer.php");
  494.         exit;
  495.     }
  496.     mysql_query("UNLOCK TABLES");
  497.     Header("Location: pollBooth.php?op=results&pollID=$pollID");
  498. }
  499.  
  500. switch($op) {
  501.  
  502.     case "Reply":
  503.         reply($pid, $pollID, $mode, $order, $thold);
  504.         break;
  505.  
  506.     case "Preview":
  507.         replyPreview ($pid, $pollID, $subject, $comment, $anonpost, $mode, $order, $thold, $posttype);
  508.         break;
  509.  
  510.     case "Ok!":
  511.         CreateTopic($anonpost, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype);
  512.         break;
  513.  
  514.     case "moderate":
  515.         if(isset($admin)) {
  516.             include("auth.inc.php");
  517.         } else {
  518.             include("mainfile.php");    
  519.         }
  520.         if(($admintest==1) || ($moderate==2)) {
  521.             while(list($tdw, $emp) = each($HTTP_POST_VARS)) {
  522.                 if (eregi("dkn",$tdw)) {
  523.                     $emp = explode(":", $emp);
  524.                     if($emp[1] != 0) {
  525.                         $tdw = ereg_replace("dkn", "", $tdw);
  526.                         $q = "UPDATE pollcomments SET";
  527.                         if(($emp[1] == 9) && ($emp[0]>=0)) { # Overrated
  528.                             $q .= " score=score-1 where tid=$tdw";
  529.                         } elseif (($emp[1] == 10) && ($emp[0]<=4)) { # Underrated
  530.                             $q .= " score=score+1 where tid=$tdw";
  531.                         } elseif (($emp[1] > 4) && ($emp[0]<=4)) {
  532.                             $q .= " score=score+1, reason=$emp[1] where tid=$tdw";
  533.                         } elseif (($emp[1] < 5) && ($emp[0] > -1)) {
  534.                             $q .= " score=score-1, reason=$emp[1] where tid=$tdw";
  535.                         } elseif (($emp[0] == -1) || ($emp[0] == 5)) {
  536.                             $q .= " reason=$emp[1] where tid=$tdw";
  537.                         }
  538.                         if(strlen($q) > 20) mysql_query("$q");
  539.                     }
  540.                 }
  541.             }
  542.         }
  543.         Header("Location: pollBooth.php?op=results&pollID=$pollID");
  544.         break;
  545.  
  546.     case "showreply":
  547.         DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);
  548.         break;
  549.  
  550.     default:
  551.         if ((isset($tid)) && (!isset($pid))) {
  552.             singlecomment($tid, $pollID, $mode, $order, $thold);
  553.         } elseif (($mainfile) xor (($pid==0) || (!isset($pid)))) {
  554.             Header("Location: pollBooth.php?op=results&pollID=$pollID&mode=$mode&order=$order&thold=$thold");
  555.         } else {
  556.             if(!isset($pid)) $pid=0;
  557.             DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);
  558.         }
  559.         break;
  560. }
  561.  
  562. ?>
  563.