home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / surveys / comments.php next >
Encoding:
PHP Script  |  2002-09-16  |  32.4 KB  |  756 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (!eregi("modules.php", $PHP_SELF)) {
  16.     die ("You can't access this file directly...");
  17. }
  18. require_once("mainfile.php");
  19. $module_name = basename(dirname(__FILE__));
  20. get_lang($module_name);
  21. $pagetitle = "- "._SURVEYS."";
  22.  
  23. function format_url($comment) {
  24.     global $nukeurl;
  25.     unset($location);
  26.     $comment = $comment;
  27.     $links = array();
  28.     $hrefs = array();
  29.     $pos = 0;
  30.     while (!(($pos = strpos($comment,"<",$pos)) === false)) {
  31.     $pos++;
  32.     $endpos = strpos($comment,">",$pos);
  33.     $tag = substr($comment,$pos,$endpos-$pos);
  34.     $tag = trim($tag);
  35.     if (isset($location)) {
  36.             if (!strcasecmp(strtok($tag," "),"/A")) {
  37.             $link = substr($comment,$linkpos,$pos-1-$linkpos);
  38.             $links[] = $link;
  39.             $hrefs[] = $location;
  40.             unset($location);
  41.             }
  42.         $pos = $endpos+1;
  43.     } else {
  44.         if (!strcasecmp(strtok($tag," "),"A")) {
  45.         if (eregi("HREF[ \t\n\r\v]*=[ \t\n\r\v]*\"([^\"]*)\"",$tag,$regs));
  46.         else if (eregi("HREF[ \t\n\r\v]*=[ \t\n\r\v]*([^ \t\n\r\v]*)",$tag,$regs));
  47.         else $regs[1] = "";
  48.         if ($regs[1]) {
  49.                 $location = $regs[1];
  50.         }
  51.         $pos = $endpos+1;
  52.         $linkpos = $pos;
  53.         } else {
  54.         $pos = $endpos+1;
  55.         }
  56.     }
  57.     }
  58.     for ($i=0; $i<sizeof($links); $i++) {
  59.     if (!eregi("://", $hrefs[$i])) {
  60.         $hrefs[$i] = $nukeurl;
  61.     } elseif (!eregi("mailto://", $hrefs[$i])) {
  62.         $href = explode("/",$hrefs[$i]);
  63.         $href = " [$href[2]]";
  64.         $comment = ereg_replace(">$links[$i]</a>", "title='$hrefs[$i]'> $links[$i]</a>$href", $comment);
  65.     }
  66.     }
  67.     return($comment);
  68. }
  69.  
  70. function modone() {
  71.     global $admin, $moderate, $module_name;
  72.     if(((isset($admin)) && ($moderate == 1)) || ($moderate==2)) echo "<form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">";
  73. }
  74.  
  75. function modtwo($tid, $score, $reason) {
  76.     global $admin, $user, $moderate, $reasons;
  77.     if((((isset($admin)) && ($moderate == 1)) || ($moderate == 2)) && ($user)) {
  78.         echo " | <select name=dkn$tid>";
  79.         for($i=0; $i<sizeof($reasons); $i++) {
  80.             echo "<option value=\"$score:$i\">$reasons[$i]</option>\n";
  81.         }
  82.         echo "</select>";
  83.     }
  84. }
  85.  
  86. function modthree($pollID, $mode, $order, $thold=0) {
  87.     global $admin, $user, $moderate;
  88.     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>
  89.     <input type=hidden name=op value=moderate>
  90.     <input type=image src=images/menu/moderate.gif border=0></form></center>";
  91. }
  92.  
  93. function navbar($pollID, $title, $thold, $mode, $order) {
  94.     global $user, $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $anonpost, $pollcomm, $prefix, $dbi, $module_name;
  95.     OpenTable();
  96.     $query = sql_query("select pollID FROM ".$prefix."_pollcomments where pollID=$pollID", $dbi);
  97.     if(!$query) $count = 0; else $count = sql_num_rows($query, $dbi);
  98.     $result = sql_query("select pollTitle from ".$prefix."_poll_desc where pollID=$pollID", $dbi);
  99.     list($title) = sql_fetch_row($result, $dbi);
  100.     if(!isset($thold)) $thold=0;
  101.     echo "\n\n<!-- COMMENTS NAVIGATION BAR START -->\n\n";
  102.     echo "<table width=\"99%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">\n";
  103.     if($title) {
  104.     echo "<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><font class=\"content\" color=\"$textcolor1\">\"$title\" | ";
  105.         if(is_user($user)) {
  106.         echo "<a href=\"modules.php?name=Your_Account&op=editcomm\"><font color=\"$textcolor1\">"._CONFIGURE."</font></a>";
  107.         } else {
  108.         echo "<a href=\"modules.php?name=Your_Account\"><font color=\"$textcolor1\">"._LOGINCREATE."</font></a>";
  109.         }
  110.         if(($count==1)) {
  111.             echo " | <B>$count</B> "._COMMENT."</font></td></tr>\n";
  112.         } else {
  113.             echo " | <B>$count</B> "._COMMENTS."</font></td></tr>\n";
  114.         }
  115.     }
  116.     echo "<tr><td bgcolor=\"$bgcolor1\" align=\"center\" width=\"100%\">\n"
  117.     ."<table border=\"0\"><tr><td><font class=\"content\">\n"
  118.     ."<form method=\"post\" action=\"modules.php?name=$module_name&op=results&pollID=$pollID\">\n"
  119.     ."<font color=\"$textcolor2\">"._THRESHOLD."</font> <select name=\"thold\">\n"
  120.     ."<option value=\"-1\"";
  121.     if ($thold == -1) {
  122.     echo " selected";
  123.     }
  124.     echo ">-1</option>\n"
  125.          ."<option value=\"0\"";
  126.     if ($thold == 0) {
  127.     echo " selected";
  128.     }
  129.     echo ">0</option>\n"
  130.      ."<option value=\"1\"";
  131.     if ($thold == 1) {
  132.     echo " selected";
  133.     }
  134.     echo ">1</option>\n"
  135.      ."<option value=\"2\"";
  136.     if ($thold == 2) {
  137.     echo " selected";
  138.     }
  139.     echo ">2</option>\n"
  140.      ."<option value=\"3\"";
  141.     if ($thold == 3) {
  142.     echo " selected";
  143.     }
  144.     echo ">3</option>\n"
  145.      ."<option value=\"4\"";
  146.     if ($thold == 4) {
  147.     echo " selected";
  148.     }
  149.     echo ">4</option>\n"
  150.      ."<option value=\"5\"";
  151.     if ($thold == 5) {
  152.     echo " selected";
  153.     }
  154.     echo ">5</option>\n"
  155.      ."</select> <select name=mode>"
  156.      ."<option value=\"nocomments\"";
  157.     if ($mode == 'nocomments') {
  158.     echo " selected";
  159.     }
  160.     echo ">"._NOCOMMENTS."</option>\n"
  161.      ."<option value=\"nested\"";
  162.     if ($mode == 'nested') {
  163.     echo " selected";
  164.     }
  165.     echo ">"._NESTED."</option>\n"
  166.      ."<option value=\"flat\"";
  167.     if ($mode == 'flat') {
  168.     echo " selected";
  169.     }
  170.     echo ">"._FLAT."</option>\n"
  171.      ."<option value=\"thread\"";
  172.     if (!isset($mode) || $mode=='thread' || $mode=="") {
  173.     echo " selected";
  174.     }
  175.     echo ">"._THREAD."</option>\n"
  176.      ."</select> <select name=\"order\">"
  177.      ."<option value=\"0\"";
  178.     if (!$order) {
  179.     echo " selected";
  180.     }
  181.     echo ">"._OLDEST."</option>\n"
  182.      ."<option value=\"1\"";
  183.     if ($order==1) {
  184.     echo " selected";
  185.     }
  186.     echo ">"._NEWEST."</option>\n"
  187.          ."<option value=\"2\"";
  188.     if ($order==2) {
  189.     echo " selected";
  190.     }
  191.     echo ">"._HIGHEST."</option>\n"
  192.      ."</select>\n"
  193.      ."<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n"
  194.      ."<input type=\"submit\" value=\""._REFRESH."\"></form>\n";
  195.     cookiedecode($user);
  196.     if (($pollcomm) AND ($mode != "nocomments")) {
  197.     if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  198.         echo "</font></td><td bgcolor=\"$bgcolor1\" valign=\"top\"><font class=\"content\"><form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">"
  199.         ."<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
  200.         ."<input type=\"hidden\" name=\"pollID\" value=\"$pollID\">"
  201.         ."<input type=\"hidden\" name=\"op\" value=\"Reply\">"
  202.         ."  <input type=\"submit\" value=\""._REPLYMAIN."\">";
  203.     }
  204.     }
  205.     echo "</form></font></td></tr></table>\n"
  206.     ."</td></tr>"
  207.     ."<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><font class=\"tiny\">"._COMMENTSWARNING."</font></td></tr>\n"
  208.     ."</table>"
  209.     ."\n\n<!-- COMMENTS NAVIGATION BAR END -->\n\n";
  210.     CloseTable();
  211.     if ($anonpost == 0 AND !is_user($user)) {
  212.         echo "<br>";
  213.     OpenTable();
  214.     echo "<center>"._NOANONCOMMENTS."</center>";
  215.     CloseTable();
  216.     }
  217.     echo "<br>";
  218. }
  219.  
  220. function DisplayKids ($tid, $mode, $order=0, $thold=0, $level=0, $dummy=0, $tblwidth=99) {
  221.     global $datetime, $user, $cookie, $bgcolor1, $reasons, $anonymous, $anonpost, $commentlimit, $prefix, $dbi, $module_name;
  222.     $comments = 0;
  223.     cookiedecode($user);
  224.     $result = sql_query("select tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason from ".$prefix."_pollcomments where pid = $tid order by date, tid", $dbi);
  225.     if ($mode == 'nested') {
  226.         /* without the tblwidth variable, the tables run of the screen with netscape
  227.            in nested mode in long threads so the text can't be read. */
  228.         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) = sql_fetch_row($result, $dbi)) {
  229.             if($r_score >= $thold) {
  230.                 if (!isset($level)) {
  231.                 } else {
  232.                     if (!$comments) {
  233.                         echo "<ul>";
  234.                         $tblwidth -= 5;
  235.                     }
  236.                 }
  237.                 $comments++;
  238.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  239.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  240.             // enter hex color between first two appostrophe for second alt bgcolor
  241.                 $r_bgcolor = ($dummy%2)?"":"#E6E6D2";
  242.                 echo "<a name=\"$r_tid\">";
  243.                 echo "<table width=90% border=0><tr bgcolor=\"$r_bgcolor\"><td>";
  244.                 formatTimestamp($r_date);
  245.                 if ($r_email) {
  246.                     echo "<p><b>$r_subject</b> <font class=content>";
  247.                     if(!$cookie[7]) {
  248.                         echo "("._SCORE." $r_score";
  249.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  250.                         echo ")";
  251.                     }
  252.                     echo "<br>"._BY." <a href=\"mailto:$r_email\">$r_name</a> <font class=content><b>($r_email)</b></font> "._ON." $datetime";
  253.                 } else {
  254.                     echo "<p><b>$r_subject</b> <font class=content>";
  255.                     if(!$cookie[7]) {
  256.                         echo "("._SCORE." $r_score";
  257.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  258.                         echo ")";
  259.                     }
  260.                     echo "<br>"._BY." $r_name "._ON." $datetime";
  261.                 }            
  262.                 if ($r_name != $anonymous) { echo "<BR>(<a href=\"modules.php?name=Your_Account&op=userinfo&uname=$r_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$r_name\">"._SENDAMSG."</a>) "; }
  263.                 if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }
  264.                 echo "</font></td></tr><tr><td>";
  265.                 $r_comment = format_url($r_comment);
  266.                 if(($cookie[10]) && (strlen($r_comment) > $cookie[10])) echo substr("$r_comment", 0, $cookie[10])."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  267.                 elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  268.                 else echo $r_comment;
  269.                 echo "</td></tr></table><br><p>";
  270.                 if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  271.                     echo "<font class=content color=\"$bgcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$r_tid&pollID=$r_pollID&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a>";
  272.                 }
  273.                 modtwo($r_tid, $r_score, $r_reason);
  274.                 echo " ]</font><p>";
  275.                 DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
  276.             }
  277.         }
  278.     } elseif ($mode == 'flat') {
  279.         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) = sql_fetch_row($result, $dbi)) {
  280.             if($r_score >= $thold) {
  281.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  282.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  283.                 echo "<a name=\"$r_tid\">";
  284.                 echo "<hr><table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td>";
  285.                 formatTimestamp($r_date);
  286.                 if ($r_email) {
  287.                     echo "<p><b>$r_subject</b> <font class=content>";
  288.                     if(!$cookie[7]) {
  289.                         echo "("._SCORE." $r_score";
  290.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  291.                         echo ")";
  292.                     }
  293.                     echo "<br>"._BY." <a href=\"mailto:$r_email\">$r_name</a> <font class=content><b>($r_email)</b></font> "._ON." $datetime";
  294.                  } else {
  295.                     echo "<p><b>$r_subject</b> <font class=content>";
  296.                     if(!$cookie[7]) {
  297.                         echo "("._SCORE." $r_score";
  298.                         if($r_reason>0) echo ", $reasons[$r_reason]";
  299.                         echo ")";
  300.                     }
  301.                     echo "<br>"._BY." $r_name "._ON." $datetime";
  302.                 }            
  303.                 if ($r_name != $anonymous) { echo "<BR>(<a href=\"modules.php?name=Your_Account&op=userinfo&uname=$r_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$r_name\">"._SENDAMSG."</a>) "; }
  304.                 if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }
  305.                 echo "</font></td></tr><tr><td>";
  306.                 $r_comment = format_url($r_comment);
  307.                 if(($cookie[10]) && (strlen($r_comment) > $cookie[10])) echo substr("$r_comment", 0, $cookie[10])."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  308.                 elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$r_pollID&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  309.                 else echo $r_comment;
  310.                 echo "</td></tr></table><br><p><font class=content color=\"$bgcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$r_tid&pollID=$r_pollID&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a>";
  311.                 modtwo($r_tid, $r_score, $r_reason);
  312.                 echo " ]</font><p>";
  313.                 DisplayKids($r_tid, $mode, $order, $thold);
  314.             }
  315.         }
  316.     } else {
  317.         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) = sql_fetch_row($result, $dbi)) {
  318.             if($r_score >= $thold) {
  319.                 if (!isset($level)) {
  320.                 } else {
  321.                     if (!$comments) {
  322.                         echo "<ul>";
  323.                     }
  324.                 }
  325.                 $comments++;
  326.                 if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  327.                 if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  328.                 formatTimestamp($r_date);
  329.                 echo "<li><font class=\"content\"><a href=\"modules.php?name=$module_name&file=comments&op=showreply&tid=$r_tid&pollID=$r_pollID&pid=$r_pid&mode=$mode&order=$order&thold=$thold#$r_tid\">$r_subject</a> "._BY." $r_name "._ON." $datetime</font><br>";
  330.                 DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1);
  331.             } 
  332.         }
  333.     }
  334.     if ($level && $comments) {
  335.         echo "</ul>";
  336.     }
  337.  
  338. }
  339.  
  340. function DisplayBabies ($tid, $level=0, $dummy=0) {
  341.     global $datetime, $anonymous, $prefix, $dbi, $module_name;
  342.     $comments = 0;
  343.     $result = sql_query("select tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason from ".$prefix."_pollcomments where pid = $tid order by date, tid", $dbi);
  344.     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) = sql_fetch_row($result, $dbi))
  345.     {
  346.         if (!isset($level)) {
  347.         } else {
  348.             if (!$comments) {
  349.                 echo "<ul>";
  350.             }
  351.         }
  352.         $comments++;
  353.         if (!eregi("[a-z0-9]",$r_name)) { $r_name = $anonymous; }
  354.         if (!eregi("[a-z0-9]",$r_subject)) { $r_subject = "["._NOSUBJECT."]"; }
  355.         formatTimestamp($r_date);
  356.         echo "<a href=\"modules.php?name=$module_name&file=comments&op=showreply&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">$r_subject</a><font class=\"content\"> "._BY." $r_name "._ON." $datetime<br>";
  357.         DisplayBabies($r_tid, $level+1, $dummy+1);
  358.     } 
  359.     if ($level && $comments) {
  360.         echo "</ul>";
  361.     }
  362. }
  363.  
  364. function DisplayTopic ($pollID, $pid=0, $tid=0, $mode="thread", $order=0, $thold=0, $level=0, $nokids=0) {
  365.     global $hr, $user, $datetime, $cookie, $mainfile, $admin, $commentlimit, $anonymous, $reasons, $anonpost, $foot1, $foot2, $foot3, $foot4, $prefix, $dbi, $module_name;
  366.     if($mainfile) {
  367.         global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  368.     } else {
  369.         global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  370.         include("mainfile.php");
  371.         include("header.php");
  372.     }
  373.     if ($pid!=0) {
  374.         include("header.php");
  375.     }
  376.     $count_times = 0;
  377.     cookiedecode($user);
  378.     $q = "select tid, pid, pollID, date, name, email, url, host_name, subject, comment, score, reason from ".$prefix."_pollcomments where pollID=$pollID and pid=$pid";
  379.     if($thold != "") {
  380.         $q .= " and score>=$thold";
  381.     } else {
  382.         $q .= " and score>=0";
  383.     }
  384.     if ($order==1) $q .= " order by date desc";
  385.     if ($order==2) $q .= " order by score desc";
  386.     $something = sql_query($q, $dbi);
  387.     $num_tid = sql_num_rows($something, $dbi);
  388.     navbar($pollID, $title, $thold, $mode, $order);
  389.     modone();
  390.     while ($count_times < $num_tid) {
  391.         list($tid, $pid, $pollID, $date, $name, $email, $url, $host_name, $subject, $comment, $score, $reason) = sql_fetch_row($something, $dbi);
  392.         if ($name == "") { $name = $anonymous; }
  393.         if ($subject == "") { $subject = "["._NOSUBJECT."]"; }    
  394.  
  395.         echo "<a name=\"$tid\">";
  396.         echo "<table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td width=500>";
  397.         formatTimestamp($date);
  398.         if ($email) {
  399.             echo "<p><b>$subject</b> <font class=content>";
  400.             if(!$cookie[7]) {
  401.                 echo "("._SCORE." $score";
  402.                 if($reason>0) echo ", $reasons[$reason]";
  403.                 echo ")";
  404.             }
  405.             echo "<br>"._BY." <a href=\"mailto:$email\">$name</a> <b>($email)</b> "._ON." $datetime"; 
  406.         } else {
  407.             echo "<p><b>$subject</b> <font class=content>";
  408.             if(!$cookie[7]) {
  409.                 echo "("._SCORE." $score";
  410.                 if($reason>0) echo ", $reasons[$reason]";
  411.                 echo ")";
  412.             }
  413.             echo "<br>"._BY." $name "._ON." $datetime";
  414.         }            
  415.         
  416.     // If you are admin you can see the Poster IP address (you have this right, no?)
  417.     // with this you can see who is flaming you... ha-ha-ha
  418.  
  419.     if (is_active("Journal")) {
  420.         $result = sql_query("select jid from ".$prefix."_journal where aid='$name' AND status='yes' order by pdate,jid DESC limit 0,1", $dbi);
  421.         list($jid) = sql_fetch_row($result, $dbi);
  422.         if ($jid != "" AND isset($jid)) {
  423.         $journal = " | <a href=\"modules.php?name=Journal&file=display&jid=$jid\">"._JOURNAL."</a>";
  424.         } else {
  425.         $journal = "";
  426.         }
  427.     }
  428.         if ($name != $anonymous) { echo "<br>(<a href=\"modules.php?name=Your_Account&op=userinfo&uname=$name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$name\">"._SENDAMSG."</a>$journal) "; }
  429.         if ($url != "http://" AND $url != "") { echo "<a href=\"$url\" target=\"window\">$url</a> "; }
  430.         
  431.         if(is_admin($admin)) {
  432.             $result= sql_query("select host_name from ".$prefix."_pollcomments where tid='$tid'", $dbi);
  433.             list($host_name) = sql_fetch_row($result, $dbi);
  434.             echo "<br><b>(IP: $host_name)</b>";
  435.         }
  436.         
  437.         echo "</font></td></tr><tr><td>";
  438.         $comment = format_url($comment);
  439.         if(($cookie[10]) && (strlen($comment) > $cookie[10])) echo substr("$comment", 0, $cookie[10])."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$pollID&tid=$tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  440.         elseif(strlen($comment) > $commentlimit) echo substr("$comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&pollID=$pollID&tid=$tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  441.         else echo $comment;
  442.         echo "</td></tr></table><br><p>";
  443.         if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  444.             echo "<font class=\"content\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$tid&pollID=$pollID&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a>";
  445.         }
  446.         if ($pid != 0) {
  447.             list($erin) = sql_fetch_row(sql_query("select pid from ".$prefix."_pollcomments where tid=$pid", $dbi), $dbi);
  448.             echo "| <a href=\"modules.php?name=$module_name&file=comments&pollID=$pollID&pid=$erin&mode=$mode&order=$order&thold=$thold\">"._PARENT."</a>";
  449.         }
  450.         modtwo($tid, $score, $reason);
  451.         
  452.         if(is_admin($admin)) {
  453.             echo " | <a href=\"admin.php?op=RemovePollComment&tid=$tid&pollID=$pollID\">"._DELETE."</a> ]</font><p>";
  454.         } elseif ($anonpost != 0 OR is_admin($admin) OR is_user($user)) {
  455.             echo " ]</font><p>";
  456.         }
  457.         
  458.         DisplayKids($tid, $mode, $order, $thold, $level);
  459.         echo "</ul>";
  460.         if($hr) echo "<hr noshade size=1>";
  461.         echo "</p>";
  462.         $count_times += 1;
  463.     }
  464.     modthree($pollID, $mode, $order, $thold);
  465.     if($pid==0) return array($pollID, $pid, $subject);
  466.     else include("footer.php");
  467. }
  468.  
  469. function singlecomment($tid, $pollID, $mode, $order, $thold) {
  470.     include("header.php");
  471.     global $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $anonpost, $admin, $anonymous, $prefix, $dbi, $module_name;
  472.     $result = sql_query("select date, name, email, url, subject, comment, score, reason from ".$prefix."_pollcomments where tid=$tid and pollID=$pollID", $dbi);
  473.     list($date, $name, $email, $url, $subject, $comment, $score, $reason) = sql_fetch_row($result, $dbi);
  474.     $titlebar = "<b>$subject</b>";
  475.     if($name == "") $name = $anonymous;
  476.     if($subject == "") $subject = "["._NOSUBJECT."]";
  477.     modone();
  478.     echo "<table width=99% border=0><tr bgcolor=\"$bgcolor1\"><td width=500>";
  479.     formatTimestamp($date);
  480.     $comment = format_url($comment);
  481.     if($email) echo "<p><b>$subject</b> <font class=content>("._SCORE." $score)<br>"._BY." <a href=\"mailto:$email\"><font color=\"$bgcolor2\">$name</font></a> <font class=content><b>($email)</b></font> "._ON." $datetime";
  482.     else echo "<p><b>$subject</b> <font class=content>("._SCORE." $score)<br>"._BY." $name "._ON." $datetime";
  483.     echo "</td></tr><tr><td>$comment</td></tr></table><br><p><font class=content color=\"$bgcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$tid&pollID=$pollID&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a> | <a href=\"modules.php?name=$module_name&pollID=$pollID\">"._ROOT."</a>";
  484.     modtwo($tid, $score, $reason);
  485.     echo " ]";
  486.     modthree($pollID, $mode, $order, $thold);
  487.     include("footer.php");
  488. }
  489.  
  490. function reply ($pid, $pollID, $mode, $order, $thold) {
  491.     include("header.php");
  492.     global $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $AllowableHTML, $anonymous, $prefix, $anonpost, $dbi, $module_name;
  493.     if ($anonpost == 0 AND !is_user($user)) {
  494.     OpenTable();
  495.     echo "<center><font class=title><b>"._SURVEYCOM."</b></font></center>";
  496.     CloseTable();
  497.     echo "<br>";
  498.     OpenTable();
  499.     echo "<center>"._NOANONCOMMENTS."<br><br>"._GOBACK."</center>";
  500.     CloseTable();
  501.     } else {
  502.     if($pid!=0) {
  503.         list($date, $name, $email, $url, $subject, $comment, $score) = sql_fetch_row(sql_query("select date, name, email, url, subject, comment, score from ".$prefix."_pollcomments where tid=$pid", $dbi), $dbi);
  504.     } else {
  505.         list($subject) = sql_fetch_row(sql_query("select pollTitle FROM ".$prefix."_poll_desc where pollID=$pollID", $dbi), $dbi);
  506.     }
  507.     if($comment == "") {
  508.         $comment = $temp_comment;
  509.     }
  510.     $titlebar = "<b>$subject</b>";
  511.     if($name == "") $name = $anonymous;
  512.     if($subject == "") $subject = "["._NOSUBJECT."]";
  513.     formatTimestamp($date);
  514.     OpenTable();
  515.     echo "<center><font class=\"title\"><b>"._SURVEYCOM."</b></font></center>";
  516.     CloseTable();
  517.     echo "<br>";
  518.     OpenTable();
  519.     echo "<center><font class=\"content\"><b>$subject</b></center><br>";
  520.     if ($comment == "") {
  521.         echo "<center><i>"._DIRECTCOM."</i></font></center><br>";
  522.     } else {
  523.         echo "<br>$comment</font>";
  524.     }
  525.     CloseTable();
  526.     if(!isset($pid) || !isset($pollID)) { echo "Something is not right. This message is just to keep things from messing up down the road"; exit(); }
  527.     if($pid == 0) {
  528.         list($subject) = sql_fetch_row(sql_query("select pollTitle from ".$prefix."_poll_desc where pollID=$pollID", $dbi), $dbi);
  529.     } else {
  530.         list($subject) = sql_fetch_row(sql_query("select subject from ".$prefix."_pollcomments where tid=$pid", $dbi), $dbi);
  531.     }
  532.     echo "<br>";
  533.     OpenTable();
  534.     echo "<form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">";
  535.     echo "<font class=\"content\"><b>"._YOURNAME.":</b></font> ";
  536.     if (is_user($user)) {
  537.         cookiedecode($user);
  538.         echo "<font class=\"content\"><a href=\"modules.php?name=Your_Account\">$cookie[1]</a> [ <a href=\"modules.php?name=Your_Account&op=logout\">"._LOGOUT."</a> ]</font>";
  539.     } else {
  540.         echo "<font class=\"content\">$anonymous</font>";
  541.         $xanonpost=1;
  542.     }
  543.     echo "<br><br><font class=\"content\"><B>"._SUBJECT.":</B></FONT><BR>";
  544.     if (!eregi("Re:",$subject)) $subject = "Re: ".substr($subject,0,81)."";
  545.     echo "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=50 maxlength=85 value=\"$subject\"><BR>";
  546.     echo "<br><br><font class=\"content\"><B>"._UCOMMENT.":</B></FONT><BR>"
  547.         ."<TEXTAREA wrap=virtual cols=50 rows=10 name=comment></TEXTAREA><br>
  548.         <font class=\"content\">"._ALLOWEDHTML."<br>";
  549.         while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
  550.         echo "<br>";
  551.     if (is_user($user) AND ($anonpost == 1)) { echo "<INPUT type=checkbox name=xanonpost> "._POSTANON."<br>"; }
  552.     echo "<INPUT type=\"hidden\" name=\"pid\" value=\"$pid\">"
  553.         ."<INPUT type=\"hidden\" name=\"pollID\" value=\"$pollID\">"
  554.         ."<INPUT type=\"hidden\" name=\"mode\" value=\"$mode\">"
  555.         ."<INPUT type=\"hidden\" name=\"order\" value=\"$order\">"
  556.         ."<INPUT type=\"hidden\" name=\"thold\" value=\"$thold\">"
  557.         ."<br><INPUT type=submit name=op value=\""._PREVIEW."\"> "
  558.         ."<INPUT type=submit name=op value=\""._OK."\"> "
  559.         ."<SELECT name=\"posttype\">"
  560.         ."<OPTION value=\"exttrans\">"._EXTRANS."</option>"
  561.         ."<OPTION value=\"html\" >"._HTMLFORMATED."</option>"
  562.         ."<OPTION value=\"plaintext\" SELECTED>"._PLAINTEXT."</option>"
  563.         ."</SELECT>"
  564.         ."</FORM>";
  565.     CloseTable();
  566.     }
  567.     include("footer.php");
  568. }
  569.  
  570. function replyPreview ($pid, $pollID, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype) {
  571.     include("header.php");
  572.     global $user, $cookie, $AllowableHTML, $anonymous, $module_name;
  573.     cookiedecode($user);
  574.     $subject = stripslashes($subject);
  575.     $comment = stripslashes($comment);
  576.     if (!isset($pid) || !isset($pollID)) {
  577.         echo ""._NOTRIGHT."";
  578.         exit();
  579.     }
  580.     OpenTable();
  581.     echo "<center><font class=\"title\"><b>"._SURVEYCOMPRE."</b></font></center>";
  582.     CloseTable();
  583.     echo "<br>";
  584.     OpenTable();
  585.     echo "<b>$subject</b><br>";
  586.     echo "<font class=content>"._BY." ";
  587.     if (is_user($user)) {
  588.         echo "$cookie[1]";
  589.     } else {
  590.         echo "$anonymous ";
  591.     }
  592.     echo ""._ONN."</font><br><br>";
  593.     if ($posttype=="exttrans") {
  594.         echo nl2br(htmlspecialchars($comment));
  595.     } elseif ($posttype=="plaintext") {
  596.         echo nl2br($comment);
  597.     } else {
  598.         echo $comment;
  599.     }
  600.     CloseTable();
  601.     echo "<br>";
  602.     OpenTable();
  603.     echo "<form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">"
  604.         ."<font class=\"content\"><B>"._YOURNAME.":</B></FONT> ";
  605.     if (is_user($user)) {
  606.         echo "<font class=\"content\"><a href=\"modules.php?name=Your_Account\">$cookie[1]</a> <font class=\"content\">[ <a href=\"modules.php?name=Your_Account&op=logout\">"._LOGOUT."</a> ]</font>";
  607.     } else {
  608.         echo "<font class=\"content\">$anonymous</font>";
  609.     }
  610.     echo "<br><br><font class=\"content\"><B>"._SUBJECT.":</B></FONT><BR>"
  611.         ."<INPUT TYPE=\"text\" name=\"subject\" size=\"50\" maxlength=\"85\" value=\"$subject\"><br><br>"
  612.         ."<P><font class=\"content\"><B>"._UCOMMENT.":</B></FONT><BR>"
  613.         ."<TEXTAREA wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"comment\">$comment</TEXTAREA><br>";
  614.         echo"<font class=\"content\">"._ALLOWEDHTML."<br>";
  615.         while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
  616.         echo "<br>";        
  617.     if (($xanonpost) AND ($anonpost == 1)) { 
  618.         echo "<INPUT type=\"checkbox\" name=\"xanonpost\" checked> "._POSTANON."<br>"; 
  619.     } elseif ((is_user($user)) AND ($anonpost == 1)) {
  620.         echo "<INPUT type=\"checkbox\" name=\"xanonpost\"> "._POSTANON."<br>";
  621.     }
  622.     echo "<INPUT type=\"hidden\" name=\"pid\" value=\"$pid\">"
  623.         ."<INPUT type=\"hidden\" name=\"pollID\" value=\"$pollID\"><INPUT type=\"hidden\" name=\"mode\" value=\"$mode\">"
  624.         ."<INPUT type=\"hidden\" name=\"order\" value=\"$order\"><INPUT type=\"hidden\" name=\"thold\" value=\"$thold\">"
  625.         ."<br><INPUT type=submit name=op value=\""._PREVIEW."\"> "
  626.         ."<INPUT type=submit name=op value=\""._OK."\"> <SELECT name=\"posttype\"><OPTION value=\"exttrans\"";
  627.         if($posttype=="exttrans") echo" SELECTED";
  628.         echo  ">"._EXTRANS."<OPTION value=\"html\"";;
  629.         if($posttype=="html") echo" SELECTED";
  630.         echo ">"._HTMLFORMATED."<OPTION value=\"plaintext\"";
  631.         if(($posttype!="exttrans") && ($posttype!="html")) echo" SELECTED";
  632.         echo ">"._PLAINTEXT."</SELECT></FORM>";
  633.     CloseTable();
  634.     include("footer.php");
  635. }
  636.  
  637. function CreateTopic ($xanonpost, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype) {
  638.     global $user, $userinfo, $EditedMessage, $cookie, $prefix, $pollcomm, $anonpost, $dbi, $module_name;
  639.     $author = FixQuotes($author);
  640.     $subject = FixQuotes(filter_text($subject, "nohtml"));
  641.     if ($posttype=="exttrans") {
  642.         $comment = FixQuotes(nl2br(htmlspecialchars(check_words($comment))));
  643.     } elseif ($posttype=="plaintext") {
  644.         $comment = FixQuotes(nl2br(filter_text($comment)));
  645.     } else {
  646.         $comment = FixQuotes(filter_text($comment));
  647.     }
  648.     if(is_user($user)) {
  649.     getusrinfo($user);
  650.     }
  651.     if ((is_user($user)) && (!$xanonpost)) {
  652.         getusrinfo($user);
  653.     $name = $userinfo[uname];
  654.     $email = $userinfo[femail];
  655.     $url = $userinfo[url];
  656.     $score = 1;
  657.     } else {
  658.     $name = ""; $email = ""; $url = "";
  659.     $score = 0;
  660.     }
  661.     $ip = getenv("REMOTE_HOST");
  662.     if (empty($ip)) {
  663.         $ip = getenv("REMOTE_ADDR");
  664.     }
  665.     $result = sql_query("select count(*) from ".$prefix."_poll_desc where pollID='$pollID'", $dbi);
  666.     $fake = sql_num_rows($result, $dbi);
  667.     if ($fake == 1) {
  668.     if ((($anonpost == 0) AND (is_user($user))) OR ($anonpost == 1)) {
  669.         sql_query("insert into ".$prefix."_pollcomments values (NULL, '$pid', '$pollID', now(), '$name', '$email', '$url', '$ip', '$subject', '$comment', '$score', '0')", $dbi);
  670.     } else {
  671.         echo "Nice try...";
  672.         die();
  673.     }
  674.     } else {
  675.     include("header.php");
  676.     echo "According to my records, the topic you are trying "
  677.         ."to reply to does not exist. If you're just trying to be "
  678.         ."annoying, well then too bad.";
  679.     include("footer.php");
  680.     die();
  681.     }
  682.     if ($pollcomm == 1) {
  683.     if (isset($cookie[4])) { $options .= "&mode=$cookie[4]"; } else { $options .= "&mode=thread"; }
  684.     if (isset($cookie[5])) { $options .= "&order=$cookie[5]"; } else { $options .= "&order=0"; }
  685.     if (isset($cookie[6])) { $options .= "&thold=$cookie[6]"; } else { $options .= "&thold=0"; }
  686.     } else {
  687.     $options = "";
  688.     }
  689.     Header("Location: modules.php?name=$module_name&op=results&pollID=$pollID$options");
  690. }
  691.  
  692. switch($op) {
  693.  
  694.     case "Reply":
  695.         reply($pid, $pollID, $mode, $order, $thold);
  696.         break;
  697.  
  698.     case ""._PREVIEW."":
  699.         replyPreview ($pid, $pollID, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype);
  700.         break;
  701.  
  702.     case ""._OK."":
  703.         CreateTopic($xanonpost, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype);
  704.         break;
  705.  
  706.     case "moderate":
  707.         global $module_name;
  708.         if(isset($admin)) {
  709.             include("auth.php");
  710.         } else {
  711.             include("mainfile.php");    
  712.         }
  713.         if(($admintest==1) || ($moderate==2)) {
  714.             while(list($tdw, $emp) = each($HTTP_POST_VARS)) {
  715.                 if (eregi("dkn",$tdw)) {
  716.                     $emp = explode(":", $emp);
  717.                     if($emp[1] != 0) {
  718.                         $tdw = ereg_replace("dkn", "", $tdw);
  719.                         $q = "UPDATE ".$prefix."_pollcomments SET";
  720.                         if(($emp[1] == 9) && ($emp[0]>=0)) { # Overrated
  721.                             $q .= " score=score-1 where tid=$tdw";
  722.                         } elseif (($emp[1] == 10) && ($emp[0]<=4)) { # Underrated
  723.                             $q .= " score=score+1 where tid=$tdw";
  724.                         } elseif (($emp[1] > 4) && ($emp[0]<=4)) {
  725.                             $q .= " score=score+1, reason=$emp[1] where tid=$tdw";
  726.                         } elseif (($emp[1] < 5) && ($emp[0] > -1)) {
  727.                             $q .= " score=score-1, reason=$emp[1] where tid=$tdw";
  728.                         } elseif (($emp[0] == -1) || ($emp[0] == 5)) {
  729.                             $q .= " reason=$emp[1] where tid=$tdw";
  730.                         }
  731.                         if(strlen($q) > 20) sql_query("$q", $dbi);
  732.                     }
  733.                 }
  734.             }
  735.         }
  736.         Header("Location: modules.php?name=$module_name&op=results&pollID=$pollID");
  737.         break;
  738.  
  739.     case "showreply":
  740.         DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);
  741.         break;
  742.  
  743.     default:
  744.         global $module_name;
  745.         if ((isset($tid)) && (!isset($pid))) {
  746.             singlecomment($tid, $pollID, $mode, $order, $thold);
  747.         } elseif (($mainfile) xor (($pid==0) AND (!isset($pid)))) {
  748.             Header("Location: modules.php?name=$module_name&op=results&pollID=$pollID&mode=$mode&order=$order&thold=$thold");
  749.         } else {
  750.             if(!isset($pid)) $pid=0;
  751.             DisplayTopic($pollID, $pid, $tid, $mode, $order, $thold);
  752.         }
  753.         break;
  754. }
  755.  
  756. ?>