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