home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / News / comments.php < prev    next >
PHP Script  |  2004-10-13  |  42KB  |  1,001 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", $_SERVER["PHP_SELF"])) {
  16.     die("You can't access this file directly...");
  17. }
  18.  
  19. require_once("mainfile.php");
  20. $module_name = basename(dirname(__FILE__));
  21. get_lang($module_name);
  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("http://", $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($sid, $mode, $order, $thold=0) {
  87.     global $admin, $user, $moderate;
  88.     if((((isset($admin)) && ($moderate == 1)) || ($moderate==2)) && ($user)) echo "<center><input type=hidden name=sid value=$sid><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 nocomm() {
  94.     OpenTable();
  95.     echo "<center><font class=\"content\">"._NOCOMMENTSACT."</font></center>";
  96.     CloseTable();
  97. }
  98.  
  99. function navbar($sid, $title, $thold, $mode, $order) {
  100.     global $user, $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $anonpost, $prefix, $db, $module_name;
  101.     $sql = "SELECT * FROM ".$prefix."_comments WHERE sid='$sid'";
  102.     $query = $db->sql_query($sql);
  103.     if(!$query) {
  104.     $count = 0;
  105.     } else {
  106.     $count = $db->sql_numrows($query);
  107.     }
  108.     $sql = "select title from ".$prefix."_stories where sid='$sid'";
  109.     $query = $db->sql_query($sql);
  110.     list($title) = $db->sql_fetchrow($query);
  111.     if(!isset($thold)) {
  112.     $thold=0;
  113.     }
  114.     echo "\n\n<!-- COMMENTS NAVIGATION BAR START -->\n\n";
  115.     OpenTable();
  116.     echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  117.     if($title) {
  118.     echo "<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><font class=\"content\" color=\"$textcolor1\">\"$title\" | ";
  119.     if(is_user($user)) {
  120.         echo "<a href=\"modules.php?name=Your_Account&op=editcomm\"><font color=\"$textcolor1\">"._CONFIGURE."</font></a>";
  121.     } else {
  122.         echo "<a href=\"modules.php?name=Your_Account\"><font color=\"$textcolor1\">"._LOGINCREATE."</font></a>";
  123.     }
  124.     if(($count==1)) {
  125.         echo " | <B>$count</B> "._COMMENT."";
  126.     } else {
  127.         echo " | <B>$count</B> "._NEWSPOLLCOMENTSLOWERCASE."";
  128.     }
  129.     if ($count > 0 AND is_active("Search")) {
  130.         echo " | <a href='modules.php?name=Search&type=comments&sid=$sid'>"._SEARCHDIS."</a>";
  131.     }
  132.     echo "</font></td></tr>\n";
  133.     }
  134.     echo "<tr><td bgcolor=\"$bgcolor1\" align=\"center\" width=\"100%\">\n"
  135.     ."<table border=\"0\"><tr><td><font class=\"content\">\n"
  136.     ."<form method=\"post\" action=\"modules.php?name=$module_name&file=article\">\n"
  137.     ."<font color=\"$textcolor2\">"._THRESHOLD."</font> <select name=\"thold\">\n"
  138.     ."<option value=\"-1\"";
  139.     if ($thold == -1) {
  140.     echo " selected";
  141.     }
  142.     echo ">-1</option>\n"
  143.          ."<option value=\"0\"";
  144.     if ($thold == 0) {
  145.     echo " selected";
  146.     }
  147.     echo ">0</option>\n"
  148.      ."<option value=\"1\"";
  149.     if ($thold == 1) {
  150.     echo " selected";
  151.     }
  152.     echo ">1</option>\n"
  153.      ."<option value=\"2\"";
  154.     if ($thold == 2) {
  155.     echo " selected";
  156.     }
  157.     echo ">2</option>\n"
  158.      ."<option value=\"3\"";
  159.     if ($thold == 3) {
  160.     echo " selected";
  161.     }
  162.     echo ">3</option>\n"
  163.      ."<option value=\"4\"";
  164.     if ($thold == 4) {
  165.     echo " selected";
  166.     }
  167.     echo ">4</option>\n"
  168.      ."<option value=\"5\"";
  169.     if ($thold == 5) {
  170.     echo " selected";
  171.     }
  172.     echo ">5</option>\n"
  173.      ."</select> <select name=mode>"
  174.      ."<option value=\"nocomments\"";
  175.     if ($mode == 'nocomments') {
  176.     echo " selected";
  177.     }
  178.     echo ">"._NOCOMMENTS."</option>\n"
  179.      ."<option value=\"nested\"";
  180.     if (!isset($mode) || $mode == 'nested' || $mode=="") {
  181.     echo " selected";
  182.     }
  183.     echo ">"._NESTED."</option>\n"
  184.      ."<option value=\"flat\"";
  185.     if ($mode == 'flat') {
  186.     echo " selected";
  187.     }
  188.     echo ">"._FLAT."</option>\n"
  189.      ."<option value=\"thread\"";
  190.     if ($mode=='thread') {
  191.     echo " selected";
  192.     }
  193.     echo ">"._THREAD."</option>\n"
  194.      ."</select> <select name=\"order\">"
  195.      ."<option value=\"0\"";
  196.     if (!$order) {
  197.     echo " selected";
  198.     }
  199.     echo ">"._OLDEST."</option>\n"
  200.      ."<option value=\"1\"";
  201.     if ($order==1) {
  202.     echo " selected";
  203.     }
  204.     echo ">"._NEWEST."</option>\n"
  205.          ."<option value=\"2\"";
  206.     if ($order==2) {
  207.     echo " selected";
  208.     }
  209.     echo ">"._HIGHEST."</option>\n"
  210.      ."</select>\n"
  211.      ."<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n"
  212.      ."<input type=\"submit\" value=\""._REFRESH."\"></form>\n";
  213.     if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  214.     echo "</font></td><td bgcolor=\"$bgcolor1\" valign=\"top\"><font class=\"content\"><form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">"
  215.         ."<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
  216.         ."<input type=\"hidden\" name=\"sid\" value=\"$sid\">"
  217.         ."<input type=\"hidden\" name=\"op\" value=\"Reply\">"
  218.         ."  <input type=\"submit\" value=\""._REPLYMAIN."\">";
  219.     }
  220.     echo "</font></form></td></tr></table>"
  221.     ."</td></tr><tr><td bgcolor=\"$bgcolor2\" align=\"center\"><font class=\"tiny\">"._COMMENTSWARNING."</font></td></tr></table>"
  222.     ."\n\n<!-- COMMENTS NAVIGATION BAR END -->\n\n";
  223.     CloseTable();
  224.     if ($anonpost == 0 AND !is_user($user)) {
  225.         echo "<br>";
  226.     OpenTable();
  227.     echo "<center>"._NOANONCOMMENTS."</center>";
  228.     CloseTable();
  229.     }
  230. }
  231.  
  232. function DisplayKids ($tid, $mode, $order=0, $thold=0, $level=0, $dummy=0, $tblwidth=99) {
  233.     global $datetime, $user, $cookie, $bgcolor1, $reasons, $anonymous, $anonpost, $commentlimit, $prefix, $textcolor2, $db, $module_name;
  234.     $comments = 0;
  235.     cookiedecode($user);
  236.     $sql = "SELECT tid, pid, sid, date, name, email, host_name, subject, comment, score, reason FROM ".$prefix."_comments WHERE pid='$tid' ORDER BY date, tid";
  237.     $result = $db->sql_query($sql);
  238.     if ($mode == 'nested') {
  239.     /* without the tblwidth variable, the tables run of the screen with netscape */
  240.     /* in nested mode in long threads so the text can't be read. */
  241.     while ($row = $db->sql_fetchrow($result)) {
  242.         $r_tid = intval($row['tid']);
  243.         $r_pid = intval($row['pid']);
  244.         $r_sid = intval($row['sid']);
  245.         $r_date = $row['date'];
  246.         $r_name = $row['name'];
  247.         $r_email = $row['email'];
  248.         $r_host_name = $row['host_name'];
  249.         $r_subject = $row['subject'];
  250.         $r_comment = $row['comment'];
  251.         $r_score = intval($row['score']);
  252.         $r_reason = $row['reason'];
  253.         if($r_score >= $thold) {
  254.         if (!isset($level)) {
  255.         } else {
  256.             if (!$comments) {
  257.             echo "<ul>";
  258.             $tblwidth -= 5;
  259.             }
  260.         }
  261.         $comments++;
  262.         if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  263.         if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  264.         // HIJO enter hex color between first two appostrophe for second alt bgcolor
  265.         $r_bgcolor = ($dummy%2)?"":"#E6E6D2";
  266.         echo "<a name=\"$r_tid\">";
  267.         echo "<table border=\"0\"><tr bgcolor=\"$bgcolor1\"><td>";
  268.         formatTimestamp($r_date);
  269.         if ($r_email) {
  270.             echo "<b>$r_subject</b> <font class=\"content\">";
  271.             if(!$cookie[7]) {
  272.             echo "("._SCORE." $r_score";
  273.             if($r_reason>0) echo ", $reasons[$r_reason]";
  274.             echo ")";
  275.             }
  276.             echo "<br>"._BY." <a href=\"mailto:$r_email\">$r_name</a> <font class=\"content\"><b>($r_email)</b></font> "._ON." $datetime";
  277.         } else {
  278.             echo "<b>$r_subject</b> <font class=\"content\">";
  279.             if(!$cookie[7]) {
  280.             echo "("._SCORE." $r_score";
  281.             if($r_reason>0) echo ", $reasons[$r_reason]";
  282.             echo ")";
  283.             }
  284.             echo "<br>"._BY." $r_name "._ON." $datetime";
  285.         }            
  286.         if ($r_name != $anonymous) { 
  287.             $sql2 = "SELECT user_id FROM ".$prefix."_users WHERE username='$r_name'";
  288.             $result2 = $db->sql_query($sql2);
  289.             $row2 = $db->sql_fetchrow($result2);
  290.             $r_uid = intval($row2['user_id']);
  291.             echo "<br>(<a href=\"modules.php?name=Your_Account&op=userinfo&username=$r_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&mode=post&u=$r_uid\">"._SENDAMSG."</a>) ";
  292.         }
  293.         $sql_url = "SELECT user_website FROM ".$prefix."_users WHERE username='$r_name'";
  294.         $result_url = $db->sql_query($sql_url);
  295.         $row_url = $db->sql_fetchrow($result_url);
  296.         $url = $row_url['user_website'];
  297.         if ($url != "http://" AND $url != "" AND eregi("http://", $url)) { echo "<a href=\"$url\" target=\"new\">$url</a> "; }
  298.         echo "</font></td></tr><tr><td>";
  299.         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&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  300.         elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  301.         else echo $r_comment;
  302.         echo "</td></tr></table><br><br>";
  303.         if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  304.             echo "<font class=\"content\" color=\"$textcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$r_tid&sid=$r_sid&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a> ]";
  305.         }
  306.         modtwo($r_tid, $r_score, $r_reason);
  307.         echo "</font><br><br>";
  308.         DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
  309.         }
  310.     }
  311.     } elseif ($mode == 'flat') {
  312.         while ($row = $db->sql_fetchrow($result)) {
  313.         $r_tid = intval($row['tid']);
  314.         $r_pid = intval($row['pid']);
  315.         $r_sid = intval($row['sid']);
  316.         $r_date = $row['date'];
  317.         $r_name = $row['name'];
  318.         $r_email = $row['email'];
  319.         $r_host_name = $row['host_name'];
  320.         $r_subject = $row['subject'];
  321.         $r_comment = $row['comment'];
  322.         $r_score = intval($row['score']);
  323.         $r_reason = $row['reason'];
  324.         if($r_score >= $thold) {
  325.             if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  326.             if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  327.             echo "<a name=\"$r_tid\">";
  328.             echo "<hr><table width=\"99%\" border=\"0\"><tr bgcolor=\"$bgcolor1\"><td>";
  329.             formatTimestamp($r_date);
  330.             if ($r_email) {
  331.             echo "<b>$r_subject</b> <font class=\"content\">";
  332.             if(!$cookie[7]) {
  333.                 echo "("._SCORE." $r_score";
  334.                 if($r_reason>0) echo ", $reasons[$r_reason]";
  335.                 echo ")";
  336.             }
  337.             echo "<br>"._BY." <a href=\"mailto:$r_email\">$r_name</a> <font class=\"content\"><b>($r_email)</b></font> "._ON." $datetime";
  338.              } else {
  339.             echo "<b>$r_subject</b> <font class=\"content\">";
  340.             if(!$cookie[7]) {
  341.                 echo "("._SCORE." $r_score";
  342.                 if($r_reason>0) echo ", $reasons[$r_reason]";
  343.                 echo ")";
  344.             }
  345.             echo "<br>"._BY." $r_name "._ON." $datetime";
  346.             }            
  347.             if ($r_name != $anonymous) {
  348.             $sql2 = "SELECT user_id FROM ".$prefix."_users WHERE username='$r_name'";
  349.             $result2 = $db->sql_query($sql2);
  350.             $row2 = $db->sql_fetchrow($result2);
  351.             $ruid = intval($row3['user_id']);
  352.             echo "<br>(<a href=\"modules.php?name=Your_Account&op=userinfo&username=$r_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&mode=post&u=$ruid\">"._SENDAMSG."</a>) ";
  353.             }
  354.             $sql_url = "SELECT user_website FROM ".$prefix."_users WHERE username='$r_name'";
  355.             $result_url = $db->sql_query($sql_url);
  356.             $row_url = $db->sql_fetchrow($result_url);
  357.             $url = $row_url['user_website'];
  358.             if ($url != "http://" AND $url != "" AND eregi("http://", $url)) { echo "<a href=\"$url\" target=\"new\">$url</a> "; }
  359.             echo "</font></td></tr><tr><td>";
  360.             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&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  361.             elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  362.             else echo $r_comment;
  363.             echo "</td></tr></table><br><br>";
  364.             if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  365.             echo "<font class=\"content\" color=\"$textcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$r_tid&sid=$r_sid&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a> ]";
  366.             }
  367.             modtwo($r_tid, $r_score, $r_reason);
  368.             echo "</font><br><br>";
  369.             DisplayKids($r_tid, $mode, $order, $thold);
  370.         }
  371.         }
  372.     } elseif ($mode == 'thread') {
  373.             while ($row = $db->sql_fetchrow($result)) {
  374.         $r_tid = intval($row['tid']);
  375.         $r_pid = intval($row['pid']);
  376.         $r_sid = intval($row['sid']);
  377.         $r_date = $row['date'];
  378.         $r_name = $row['name'];
  379.         $r_email = $row['email'];
  380.         $r_host_name = $row['host_name'];
  381.         $r_subject = $row['subject'];
  382.         $r_comment = $row['comment'];
  383.         $r_score = intval($row['score']);
  384.         $r_reason = $row['reason'];
  385.         if($r_score >= $thold) {
  386.             if (!isset($level)) {
  387.             } else {
  388.             if (!$comments) {
  389.                 echo "<ul>";
  390.             }
  391.             }
  392.             $comments++;
  393.             if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  394.             if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  395.             formatTimestamp($r_date);
  396.             echo "<li><font class=\"content\" color=\"$textcolor2\"><a href=\"modules.php?name=$module_name&file=comments&op=showreply&tid=$r_tid&sid=$r_sid&pid=$r_pid&mode=$mode&order=$order&thold=$thold#$r_tid\">$r_subject</a> "._BY." $r_name "._ON." $datetime</font><br>";
  397.             DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1);
  398.         }
  399.         }
  400.     } else {
  401.     /* without the tblwidth variable, the tables run of the screen with netscape */
  402.     /* in nested mode in long threads so the text can't be read. */
  403.     while ($row = $db->sql_fetchrow($result)) {
  404.         $r_tid = intval($row['tid']);
  405.         $r_pid = intval($row['pid']);
  406.         $r_sid = intval($row['sid']);
  407.         $r_date = $row['date'];
  408.         $r_name = $row['name'];
  409.         $r_email = $row['email'];
  410.         $r_host_name = $row['host_name'];
  411.         $r_subject = $row['subject'];
  412.         $r_comment = $row['comment'];
  413.         $r_score = intval($row['score']);
  414.         $r_reason = $row['reason'];
  415.         if($r_score >= $thold) {
  416.         if (!isset($level)) {
  417.         } else {
  418.             if (!$comments) {
  419.             echo "<ul>";
  420.             $tblwidth -= 5;
  421.             }
  422.         }
  423.         $comments++;
  424.         if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
  425.         if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
  426.         // HIJO enter hex color between first two appostrophe for second alt bgcolor
  427.         $r_bgcolor = ($dummy%2)?"":"#E6E6D2";
  428.         echo "<a name=\"$r_tid\">";
  429.         echo "<table border=\"0\"><tr bgcolor=\"$bgcolor1\"><td>";
  430.         formatTimestamp($r_date);
  431.         if ($r_email) {
  432.             echo "<b>$r_subject</b> <font class=\"content\">";
  433.             if(!$cookie[7]) {
  434.             echo "("._SCORE." $r_score";
  435.             if($r_reason>0) echo ", $reasons[$r_reason]";
  436.             echo ")";
  437.             }
  438.             echo "<br>"._BY." <a href=\"mailto:$r_email\">$r_name</a> <font class=\"content\"><b>($r_email)</b></font> "._ON." $datetime";
  439.         } else {
  440.             echo "<b>$r_subject</b> <font class=\"content\">";
  441.             if(!$cookie[7]) {
  442.             echo "("._SCORE." $r_score";
  443.             if($r_reason>0) echo ", $reasons[$r_reason]";
  444.             echo ")";
  445.             }
  446.             echo "<br>"._BY." $r_name "._ON." $datetime";
  447.         }            
  448.         if ($r_name != $anonymous) { 
  449.             $sql2 = "SELECT user_id FROM ".$prefix."_users WHERE username='$r_name'";
  450.             $result2 = $db->sql_query($sql2);
  451.             $row2 = $db->sql_fetchrow($result2);
  452.             $ruid2 = $row2['user_id'];
  453.             echo "<br>(<a href=\"modules.php?name=Your_Account&op=userinfo&username=$r_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&mode=post&u=$ruid2\">"._SENDAMSG."</a>) ";
  454.         }
  455.         $sql_url = "SELECT user_website FROM ".$prefix."_users WHERE username='$r_name'";
  456.         $result_url = $db->sql_query($sql_url);
  457.         $row_url = $db->sql_fetchrow($result_url);
  458.         $url = $row_url['user_website'];
  459.         if ($url != "http://" AND $url != "" AND eregi("http://", $url)) { echo "<a href=\"$url\" target=\"new\">$url</a> "; }
  460.         echo "</font></td></tr><tr><td>";
  461.         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&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  462.         elseif(strlen($r_comment) > $commentlimit) echo substr("$r_comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  463.         else echo $r_comment;
  464.         echo "</td></tr></table><br><br>";
  465.         if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  466.             echo "<font class=\"content\" color=\"$textcolor2\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$r_tid&sid=$r_sid&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a> ]";
  467.         }
  468.         modtwo($r_tid, $r_score, $r_reason);
  469.         echo "</font><br><br>";
  470.         DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
  471.         }
  472.         }
  473.         }
  474.     if ($level && $comments) {
  475.         echo "</ul>";
  476.     }
  477. }
  478.  
  479. function DisplayBabies ($tid, $level=0, $dummy=0) {
  480.     global $datetime, $anonymous, $prefix, $db, $module_name;
  481.     $comments = 0;
  482.     $sql = "SELECT tid, pid, sid, date, name, email, host_name, subject, comment, score, reason FROM ".$prefix."_comments WHERE pid='$tid' ORDER BY date, tid";
  483.     $result = $db->sql_query($sql);
  484.     while ($row = $db->sql_fetchrow($result)) {
  485.         $r_tid = intval($row['tid']);
  486.         $r_pid = intval($row['pid']);
  487.         $r_sid = intval($row['sid']);
  488.         $r_date = $row['date'];
  489.         $r_name = $row['name'];
  490.         $r_email = $row['email'];
  491.         $r_host_name = $row['host_name'];
  492.         $r_subject = $row['subject'];
  493.         $r_comment = $row['comment'];
  494.         $r_score = intval($row['score']);
  495.         $r_reason = $row['reason'];
  496.     if (!isset($level)) {
  497.     } else {
  498.         if (!$comments) {
  499.         echo "<ul>";
  500.         }
  501.     }
  502.     $comments++;
  503.     if (!eregi("[a-z0-9]",$r_name)) { $r_name = $anonymous; }
  504.     if (!eregi("[a-z0-9]",$r_subject)) { $r_subject = "["._NOSUBJECT."]"; }
  505.     formatTimestamp($r_date);
  506.     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><font class=\"content\"> "._BY." $r_name "._ON." $datetime<br>";
  507.     DisplayBabies($r_tid, $level+1, $dummy+1);
  508.     } 
  509.     if ($level && $comments) {
  510.         echo "</ul>";
  511.     }
  512. }
  513.  
  514. function DisplayTopic ($sid, $pid=0, $tid=0, $mode="nested", $order=0, $thold=0, $level=0, $nokids=0) {
  515.     global $hr, $user, $datetime, $cookie, $mainfile, $admin, $commentlimit, $anonymous, $reasons, $anonpost, $foot1, $foot2, $foot3, $foot4, $prefix, $acomm, $articlecomm, $db, $module_name, $nukeurl;
  516.     if($mainfile) {
  517.     global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  518.     } else {
  519.     global $title, $bgcolor1, $bgcolor2, $bgcolor3;
  520.     include("mainfile.php");
  521.     include("header.php");
  522.     }
  523.     if ($pid!=0) {
  524.     include("header.php");
  525.     }
  526.     $count_times = 0;
  527.     cookiedecode($user);
  528.     $q = "SELECT tid, pid, sid, date, name, email, host_name, subject, comment, score, reason FROM ".$prefix."_comments WHERE sid='$sid' and pid='$pid'";
  529.     if($thold != "") {
  530.     $q .= " AND score>='$thold'";
  531.     } else {
  532.     $q .= " AND score>='0'";
  533.     }
  534.     if ($order==1) $q .= " ORDER BY date DESC";
  535.     if ($order==2) $q .= " ORDER BY score DESC";
  536.     $something = $db->sql_query($q);
  537.     $num_tid = $db->sql_numrows($something);
  538.     if ($acomm == 1) {
  539.     nocomm();
  540.     }
  541.     if (($acomm == 0) AND ($articlecomm == 1)) {
  542.     navbar($sid, $title, $thold, $mode, $order);
  543.     }
  544.     modone();
  545.     while ($count_times < $num_tid) {
  546.     echo "<br>";
  547.     OpenTable();
  548.     $row = $db->sql_fetchrow($something);
  549.     $tid = $row['tid'];
  550.     $pid = $row['pid'];
  551.     $sid = $row['sid'];
  552.     $date = $row['date'];
  553.     $c_name = $row['name'];
  554.     $email = $row['email'];
  555.     $host_name = $row['host_name'];
  556.     $subject = $row['subject'];
  557.     $comment = $row['comment'];
  558.     $score = $row['score'];
  559.     $reason = $row['reason'];
  560.     if ($c_name == "") { $c_name = $anonymous; }
  561.     if ($subject == "") { $subject = "["._NOSUBJECT."]"; }    
  562.     echo "<a name=\"$tid\"></a>";
  563.     echo "<table width=\"99%\" border=\"0\"><tr bgcolor=\"$bgcolor1\"><td width=\"500\">";
  564.     formatTimestamp($date);
  565.     if ($email) {
  566.         echo "<b>$subject</b> <font class=\"content\">";
  567.         if(!$cookie[7]) {
  568.         echo "("._SCORE." $score";
  569.         if($reason>0) echo ", $reasons[$reason]";
  570.         echo ")";
  571.         }
  572.         echo "<br>"._BY." <a href=\"mailto:$email\">$c_name</a> <b>($email)</b> "._ON." $datetime"; 
  573.     } else {
  574.         echo "<b>$subject</b> <font class=\"content\">";
  575.         if(!$cookie[7]) {
  576.         echo "("._SCORE." $score";
  577.         if($reason>0) echo ", $reasons[$reason]";
  578.         echo ")";
  579.         }
  580.         echo "<br>"._BY." $c_name "._ON." $datetime";
  581.     }            
  582.         
  583.     /* If you are admin you can see the Poster IP address */
  584.     /* with this you can see who is flaming you...*/
  585.  
  586.     if (is_active("Journal")) {
  587.         $sql = "SELECT jid FROM ".$prefix."_journal WHERE aid='$c_name' AND status='yes' ORDER BY pdate,jid DESC LIMIT 0,1";
  588.         $result = $db->sql_query($sql);
  589.         $row = $db->sql_fetchrow($result);
  590.         $jid = intval($row['jid']);
  591.         if ($jid != "" AND isset($jid)) {
  592.         $journal = " | <a href=\"modules.php?name=Journal&file=display&jid=$jid\">"._JOURNAL."</a>";
  593.         } else {
  594.         $journal = "";
  595.         }
  596.     }
  597.     if ($c_name != $anonymous) {
  598.         $sql2 = "SELECT user_id FROM ".$prefix."_users WHERE username='$c_name'";
  599.         $result2 = $db->sql_query($sql2);
  600.         $row2 = $db->sql_fetchrow($result2);
  601.         $r_uid = intval($row2['user_id']);
  602.         echo "<br>(<a href=\"modules.php?name=Your_Account&op=userinfo&username=$c_name\">"._USERINFO."</a> | <a href=\"modules.php?name=Private_Messages&mode=post&u=$r_uid\">"._SENDAMSG."</a>$journal) ";
  603.     }
  604.     $sql_url = "SELECT user_website FROM ".$prefix."_users WHERE username='$c_name'";
  605.     $result_url = $db->sql_query($sql_url);
  606.     $row_url = $db->sql_fetchrow($result_url);
  607.     $url = $row_url['user_website'];
  608.     if ($url != "http://" AND $url != "" AND eregi("http://", $url)) { echo "<a href=\"$url\" target=\"new\">$url</a> "; }
  609.  
  610.     if(is_admin($admin)) {
  611.         $sql = "SELECT host_name FROM ".$prefix."_comments WHERE tid='$tid'";
  612.         $result = $db->sql_query($sql);
  613.         $row = $db->sql_fetchrow($result);
  614.         $host_name = $row['host_name'];
  615.         echo "<br><b>(IP: $host_name)</b>";
  616.     }
  617.     echo "</font></td></tr><tr><td>";
  618.     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&sid=$sid&tid=$tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  619.     elseif(strlen($comment) > $commentlimit) echo substr("$comment", 0, $commentlimit)."<br><br><b><a href=\"modules.php?name=$module_name&file=comments&sid=$sid&tid=$tid&mode=$mode&order=$order&thold=$thold\">"._READREST."</a></b>";
  620.     else echo $comment;
  621.     echo "</td></tr></table><br><br>";
  622.     if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  623.         echo "<font class=\"content\"> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a>";
  624.     }
  625.     if ($pid != 0) {
  626.         $sql = "SELECT pid FROM ".$prefix."_comments WHERE tid='$pid'";
  627.         $result = $db->sql_query($sql);
  628.         $row = $db->sql_fetchrow($result);
  629.         $erin = intval($row['pid']);
  630.         echo " | <a href=\"modules.php?name=$module_name&file=comments&sid=$sid&pid=$erin&mode=$mode&order=$order&thold=$thold\">"._PARENT."</a>";
  631.     }
  632.     modtwo($tid, $score, $reason);
  633.         
  634.     if(is_admin($admin)) {
  635.         echo " | <a href=\"admin.php?op=RemoveComment&tid=$tid&sid=$sid\">"._DELETE."</a> ]</font><br><br>";
  636.     } elseif ($anonpost != 0 OR is_admin($admin) OR is_user($user)) {
  637.         echo " ]</font><br><br>";
  638.     }
  639.         
  640.     DisplayKids($tid, $mode, $order, $thold, $level);
  641.     echo "</ul>";
  642.     if($hr) echo "<hr noshade size=\"1\">";
  643.     $count_times += 1;
  644.     CloseTable();
  645.     }
  646.     modthree($sid, $mode, $order, $thold);
  647.     if ($pid==0) {
  648.     return array($sid, $pid, $subject);
  649.  
  650.     } else {
  651.     include("footer.php");
  652.     }
  653. }
  654.  
  655. function singlecomment($tid, $sid, $mode, $order, $thold) {
  656.     global $module_name, $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $admin, $anonpost, $prefix, $textcolor2, $db;
  657.     include("header.php");
  658.     $sql = "SELECT date, name, email, subject, comment, score, reason FROM ".$prefix."_comments WHERE tid='$tid' AND sid='$sid'";
  659.     $result = $db->sql_query($sql);
  660.     $row = $db->sql_fetchrow($result);
  661.     $date = $row['date'];
  662.     $name = $row['name'];
  663.     $email = $row['email'];
  664.     $subject = $row['subject'];
  665.     $comment = $row['comment'];
  666.     $score = intval($row['score']);
  667.     $reason = $row['reason'];
  668.     $titlebar = "<b>$subject</b>";
  669.     if($name == "") $name = $anonymous;
  670.     if($subject == "") $subject = "["._NOSUBJECT."]";
  671.     modone();
  672.     OpenTable();
  673.     echo "<table width=\"99%\" border=\"0\"><tr bgcolor=\"$bgcolor1\"><td width=\"500\">";
  674.     formatTimestamp($date);
  675.     if($email) echo "<b>$subject</b> <font class=\"content\" color=\"$textcolor2\">("._SCORE." $score)<br>"._BY." <a href=\"mailto:$email\"><font color=\"$bgcolor2\">$name</font></a> <font class=content><b>($email)</b></font> "._ON." $datetime";
  676.     else echo "<b>$subject</b> <font class=content>("._SCORE." $score)<br>"._BY." $name "._ON." $datetime";
  677.     echo "</td></tr><tr><td>$comment</td></tr></table><br><br>";
  678.     if ($anonpost==1 OR is_admin($admin) OR is_user($user)) {
  679.     echo "<font class=content> [ <a href=\"modules.php?name=$module_name&file=comments&op=Reply&pid=$tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">"._REPLY."</a> | <a href=\"modules.php?name=$module_name&file=article&sid=$sid&mode=$mode&order=$order&thold=$thold\">"._ROOT."</a> ]";
  680.     }
  681.     modtwo($tid, $score, $reason);
  682.     echo "";
  683.     modthree($sid, $mode, $order, $thold);
  684.     CloseTable();
  685.     include("footer.php");
  686. }
  687.  
  688. function reply($pid, $sid, $mode, $order, $thold) {
  689.     include("config.php");
  690.     include("header.php");
  691.     global $anonymous, $module_name, $user, $cookie, $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $db, $anonpost;
  692.     if ($anonpost == 0 AND !is_user($user)) {
  693.     OpenTable();
  694.     echo "<center><font class=title><b>"._COMMENTREPLY."</b></font></center>";
  695.     CloseTable();
  696.     echo "<br>";
  697.     OpenTable();
  698.     echo "<center>"._NOANONCOMMENTS."<br><br>"._GOBACK."</center>";
  699.     CloseTable();
  700.     } else {
  701.     if ($pid != 0) {
  702.         $sql = "SELECT date, name, email, subject, comment, score FROM ".$prefix."_comments WHERE tid='$pid'";
  703.         $result = $db->sql_query($sql);
  704.         $row = $db->sql_fetchrow($result);
  705.             $date = $row['date'];
  706.         $name = $row['name'];
  707.         $email = $row['email'];
  708.         $subject = $row['subject'];
  709.         $comment = $row['comment'];
  710.         $score = intval($row['score']);
  711.     } else {
  712.         $sql2 = "SELECT time, title, hometext, bodytext, informant, notes FROM ".$prefix."_stories WHERE sid='$sid'";
  713.         $result2 = $db->sql_query($sql2);
  714.         $row2 = $db->sql_fetchrow($result2);
  715.             $date = $row2['time'];
  716.         $subject = $row2['title'];
  717.         $temp_comment = $row2['hometext'];
  718.         $comment2 = $row2['bodytext'];
  719.         $name = $row2['informant'];
  720.         $notes = $row2['notes'];
  721.     }
  722.     if($comment == "") {
  723.         $comment = "$temp_comment<br><br>$comment2";
  724.     }
  725.     OpenTable();
  726.     echo "<center><font class=title><b>"._COMMENTREPLY."</b></font></center>";
  727.     CloseTable();
  728.     echo "<br>";
  729.     OpenTable();
  730.     if ($name == "") $name = $anonymous;
  731.     if ($subject == "") $subject = "["._NOSUBJECT."]";
  732.     formatTimestamp($date);
  733.     echo "<b>$subject</b> <font class=\"content\">";
  734.     if (!$temp_comment) echo"("._SCORE." $score)";
  735.     if ($email) {
  736.         echo "<br>"._BY." <a href=\"mailto:$email\">$name</a> <font class=\"content\"><b>($email)</b></font> "._ON." $datetime";
  737.     } else {
  738.         echo "<br>"._BY." $name "._ON." $datetime";
  739.     }
  740.     echo "<br><br>$comment<br><br>";
  741.     if ($pid == 0) {
  742.         if ($notes != "") {
  743.         echo "<b>"._NOTE."</b> <i>$notes</i><br><br>";
  744.         } else {
  745.         echo "";
  746.         }
  747.     }
  748.     if (!isset($pid) || !isset($sid)) { echo "Something is not right. This message is just to keep things from messing up down the road"; exit(); }
  749.     if ($pid == 0) {
  750.         $sql3 = "SELECT title FROM ".$prefix."_stories WHERE sid='$sid'";
  751.         $result3 = $db->sql_query($sql3);
  752.         $row3 = $db->sql_fetchrow($result3);
  753.         $subject = $row3['title'];
  754.     } else {
  755.         $sql4 = "SELECT subject FROM ".$prefix."_comments WHERE tid='$pid'";
  756.         $result4 = $db->sql_query($sql4);
  757.         $row4 = $db->sql_fetchrow($result4);
  758.         $subject = $row4['subject'];
  759.     }
  760.     CloseTable();
  761.     echo "<br>";
  762.     OpenTable();
  763.     echo "<form action=\"modules.php?name=$module_name&file=comments\" method=\"post\">";
  764.     echo "<font class=option><b>"._YOURNAME.":</b></font> ";
  765.     if (is_user($user)) {
  766.         cookiedecode($user);
  767.         echo "<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><br><br>";
  768.     } else {
  769.             echo "<font class=\"content\">$anonymous";
  770.         echo " [ <a href=\"modules.php?name=Your_Account\">"._NEWUSER."</a> ]<br><br>";
  771.     }
  772.     echo "<font class=\"option\"><b>"._SUBJECT.":</b></font><br>";
  773.     if (!eregi("Re:",$subject)) $subject = "Re: ".substr($subject,0,81)."";
  774.     echo "<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"85\" value=\"$subject\"><br><br>";
  775.     echo "<font class=\"option\"><b>"._UCOMMENT.":</b></font><br>"
  776.         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"comment\"></textarea><br>"
  777.         ."<font class=\"content\">"._ALLOWEDHTML."<br>";
  778.     while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
  779.     echo "<br>";
  780.     if (is_user($user) AND ($anonpost == 1)) { echo "<input type=\"checkbox\" name=\"xanonpost\"> "._POSTANON."<br>"; }
  781.     echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\">\n"
  782.             ."<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n"
  783.         ."<input type=\"hidden\" name=\"mode\" value=\"$mode\">\n"
  784.         ."<input type=\"hidden\" name=\"order\" value=\"$order\">\n"
  785.         ."<input type=\"hidden\" name=\"thold\" value=\"$thold\">\n"
  786.         ."<input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">\n"
  787.         ."<input type=\"submit\" name=\"op\" value=\""._OK."\">\n"
  788.         ."<select name=\"posttype\">\n"
  789.         ."<option value=\"exttrans\">"._EXTRANS."</option>\n"
  790.         ."<option value=\"html\" >"._HTMLFORMATED."</option>\n"
  791.         ."<option value=\"plaintext\" selected>"._PLAINTEXT."</option>\n"
  792.         ."</select></font></form>\n";
  793.     CloseTable();
  794.     }
  795.     include("footer.php");
  796. }
  797.  
  798. function replyPreview ($pid, $sid, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype) {
  799.     include("header.php");
  800.     global $module_name, $user, $cookie, $AllowableHTML, $anonymous, $anonpost;
  801.     OpenTable();
  802.     echo "<center><font class=\"title\"><b>"._COMREPLYPRE."</b></font></center>";
  803.     CloseTable();
  804.     echo "<br>";
  805.     OpenTable();
  806.     cookiedecode($user);
  807.     $subject = stripslashes($subject);
  808.     $comment = stripslashes($comment);
  809.     if (!isset($pid) || !isset($sid)) {
  810.         echo ""._NOTRIGHT."";
  811.         exit();
  812.     }
  813.     echo "<b>$subject</b>";
  814.     echo "<br><font class=\"content\">"._BY." ";
  815.     if (is_user($user)) {
  816.     echo "$cookie[1]";
  817.     } else {
  818.         echo "$anonymous";
  819.     }
  820.     echo " "._ONN."</font><br><br>";
  821.     if ($posttype=="exttrans") {
  822.         echo nl2br(htmlspecialchars($comment));
  823.     } elseif ($posttype=="plaintext") {
  824.         echo nl2br($comment);
  825.     } else {
  826.         echo $comment;
  827.     }
  828.     CloseTable();
  829.     echo "<br>";
  830.     OpenTable();
  831.     echo "<form action=\"modules.php?name=$module_name&file=comments\" method=\"post\"><font class=\"option\"><b>"._YOURNAME.":</b></font> ";
  832.     if (is_user($user)) {
  833.         echo "<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><br><br>";
  834.     } else {
  835.         echo "<font class=\"content\">$anonymous<br><br>";
  836.     }
  837.     echo "<font class=\"option\"><b>"._SUBJECT.":</b></font><br>"
  838.     ."<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"85\" value=\"$subject\"><br><br>"
  839.     ."<font class=\"option\"><b>"._UCOMMENT.":</b></font><br>"
  840.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"comment\">$comment</textarea><br>"
  841.     ."<font class=\"content\">"._ALLOWEDHTML."<br>";
  842.     while (list($key,) = each($AllowableHTML)) echo " <".$key.">";
  843.     echo "<br>";
  844.     if (($xanonpost) AND ($anonpost == 1)){
  845.         echo "<input type=\"checkbox\" name=\"xanonpost\" checked> "._POSTANON."<br>";
  846.     } elseif ((is_user($user)) AND ($anonpost == 1)) {
  847.         echo "<input type=\"checkbox\" name=\"xanonpost\"> "._POSTANON."<br>";
  848.     }
  849.     echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
  850.         ."<input type=\"hidden\" name=\"sid\" value=\"$sid\">"
  851.     ."<input type=\"hidden\" name=\"mode\" value=\"$mode\">"
  852.         ."<input type=\"hidden\" name=\"order\" value=\"$order\">"
  853.     ."<input type=\"hidden\" name=\"thold\" value=\"$thold\">"
  854.         ."<input type=submit name=op value=\""._PREVIEW."\">"
  855.         ."<input type=submit name=op value=\""._OK."\">\n"
  856.     ."<select name=\"posttype\"><option value=\"exttrans\"";
  857.     if ($posttype=="exttrans") {
  858.         echo " selected";
  859.     }
  860.     echo ">"._EXTRANS."</option>\n"
  861.     ."<OPTION value=\"html\"";;
  862.     if ($posttype=="html") {
  863.         echo " selected";
  864.     }
  865.     echo ">"._HTMLFORMATED."</option>\n"
  866.     ."<OPTION value=\"plaintext\"";
  867.     if (($posttype!="exttrans") && ($posttype!="html")) {
  868.         echo " selected";
  869.     }
  870.     echo ">"._PLAINTEXT."</option></select></font></form>";
  871.     CloseTable();
  872.     include("footer.php");
  873. }
  874.  
  875. function CreateTopic ($xanonpost, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype) {
  876.     global $module_name, $user, $userinfo, $EditedMessage, $cookie, $AllowableHTML, $ultramode, $prefix, $anonpost, $articlecomm, $db;
  877.     cookiedecode($user);
  878.     $author = FixQuotes($author);
  879.     $subject = FixQuotes(filter_text($subject, "nohtml"));
  880.     $comment = format_url($comment);
  881.     if($posttype=="exttrans") {
  882.         $comment = FixQuotes(nl2br(htmlspecialchars(check_words($comment))));
  883.     } elseif($posttype=="plaintext") {
  884.         $comment = FixQuotes(nl2br(filter_text($comment)));
  885.     } else {
  886.     $comment = FixQuotes(filter_text($comment));
  887.     }
  888.     if(is_user($user)) {
  889.         getusrinfo($user);
  890.     }
  891.     if ((is_user($user)) && (!$xanonpost)) {
  892.     getusrinfo($user);
  893.     $name = $userinfo['username'];
  894.     $email = $userinfo['femail'];
  895.     $url = $userinfo['user_website'];
  896.     $score = 1;
  897.     } else {
  898.     $name = ""; $email = ""; $url = "";
  899.     $score = 0;
  900.     }
  901.     $ip = $_SERVER["REMOTE_HOST"];
  902.     if (empty($ip)) {
  903.         $ip = $_SERVER["REMOTE_ADDR"];
  904.     }
  905.     $sql = "SELECT * FROM ".$prefix."_stories WHERE sid='$sid'";
  906.     $result = $db->sql_query($sql);
  907.     $fake = $db->sql_numrows($result);
  908.     $un_fix1 = $db->sql_fetchrow($db->sql_query("SELECT acomm FROM ".$prefix."_stories WHERE sid='$sid'"));
  909.     $acomm = $un_fix1['acomm'];  
  910.     if (($fake == 1) AND ($articlecomm == 1)) {
  911.     if (((($anonpost == 0) AND (is_user($user))) OR ($anonpost == 1)) AND $acomm == "0") { 
  912.         $sql = "INSERT INTO ".$prefix."_comments VALUES (NULL, '$pid', '$sid', now(), '$name', '$email', '$url', '$ip', '$subject', '$comment', '$score', '0')";
  913.         $db->sql_query($sql);
  914.         $sql = "UPDATE ".$prefix."_stories SET comments=comments+1 WHERE sid='$sid'";
  915.         $db->sql_query($sql);
  916.         if ($ultramode) {
  917.             ultramode();
  918.         }
  919.     } else {
  920.         echo "Nice try...";
  921.         die();
  922.     }
  923.     } else {
  924.     include("header.php");
  925.     Opentable();
  926.     echo ""._COMMENTSWARNINGS."";
  927.     Closetable();
  928.     include("footer.php");
  929.     die();
  930.     }
  931.     if (isset($cookie[4])) { $options .= "&mode=$cookie[4]"; } else { $options .= "&mode=nested"; }
  932.     if (isset($cookie[5])) { $options .= "&order=$cookie[5]"; } else { $options .= "&order=0"; }
  933.     if (isset($cookie[6])) { $options .= "&thold=$cookie[6]"; } else { $options .= "&thold=0"; }
  934.     Header("Location: modules.php?name=$module_name&file=article&sid=$sid$options");
  935. }
  936.  
  937. switch($op) {
  938.  
  939.     case "Reply":
  940.     reply($pid, $sid, $mode, $order, $thold);
  941.     break;
  942.  
  943.     case ""._PREVIEW."":
  944.     replyPreview ($pid, $sid, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype);
  945.     break;
  946.  
  947.     case ""._OK."":
  948.     CreateTopic($xanonpost, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype);
  949.     break;
  950.  
  951.     case "moderate":
  952.     if(isset($admin)) {
  953.         include("auth.php");
  954.     } else {
  955.         include("mainfile.php");    
  956.     }
  957.     if(($admintest==1) || ($moderate==2)) {
  958.         while(list($tdw, $emp) = each($HTTP_POST_VARS)) {
  959.         if (eregi("dkn",$tdw)) {
  960.             $emp = explode(":", $emp);
  961.             if($emp[1] != 0) {
  962.             $tdw = ereg_replace("dkn", "", $tdw);
  963.             $tdw = intval($tdw);
  964.             $q = "UPDATE ".$prefix."_comments SET";
  965.             if(($emp[1] == 9) && ($emp[0]>=0)) { # Overrated
  966.                 $q .= " score=score-1 where tid='$tdw'";
  967.             } elseif (($emp[1] == 10) && ($emp[0]<=4)) { # Underrated
  968.                 $q .= " score=score+1 where tid='$tdw'";
  969.             } elseif (($emp[1] > 4) && ($emp[0]<=4)) {
  970.                 $q .= " score=score+1, reason='$emp[1]' where tid='$tdw'";
  971.             } elseif (($emp[1] < 5) && ($emp[0] > -1)) {
  972.                 $q .= " score=score-1, reason='$emp[1]' where tid='$tdw'";
  973.             } elseif (($emp[0] == -1) || ($emp[0] == 5)) {
  974.                 $q .= " reason='$emp[1]' where tid='$tdw'";
  975.             }
  976.             if(strlen($q) > 20) $db->sql_query($q);
  977.             }
  978.         }
  979.         }
  980.     }
  981.     Header("Location: modules.php?name=$module_name&file=article&sid=$sid&mode=$mode&order=$order&thold=$thold");
  982.     break;
  983.  
  984.     case "showreply":
  985.     DisplayTopic($sid, $pid, $tid, $mode, $order, $thold);
  986.     break;
  987.  
  988.     default:
  989.     if ((isset($tid)) && (!isset($pid))) {
  990.         singlecomment($tid, $sid, $mode, $order, $thold);
  991.     } elseif (($mainfile) xor (($pid==0) AND (!isset($pid)))) {
  992.         Header("Location: modules.php?name=$module_name&file=article&sid=$sid&mode=$mode&order=$order&thold=$thold");
  993.     } else {
  994.         if(!isset($pid)) $pid=0;
  995.         DisplayTopic($sid, $pid, $tid, $mode, $order, $thold);
  996.     }
  997.     break;
  998.  
  999. }
  1000.  
  1001. ?>