<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: comments.php,v 1.28.2.5 2004/08/27 16:02:54 kirilt Exp $





/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)            */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

/************************************************************************

 MODIFICATIONS

    21 JUN 2001 - Snorter - snorter@genesiscollective.com
        Modified to allow edit and delete of any comment.

        This fixes one of the most annoying aspects of administering
        comments. The old version only allowed you to delete top-level
        comments. The fixes here allow you to edit or delete any
        comment. When a comment is deleted, all children of that
        comment are also correctly deleted.

        You can also edit the text of a comment - don't abuse this!

        Now all we need is a unified comment system so we don't have
        to make these changes to every file that writes comments...
    09-22-2001 - trini0:- trini0@optonline.net
        Make it so that in the preview and posts, muliple / & '
        don't show up.

************************************************************************/

if ( _MPN_USER && $GLOBALS['uinf'][10] > $commentlimit )
{
    $commentlimit = $GLOBALS['uinf'][10];
}

function modone() {
        global $moderate,$phpEx;

        if ((_MPN_ADMIN && $moderate == 1) || (_MPN_USER && $moderate == 2))
        {
            echo "<form action=\"comments.$phpEx\" method=\"post\">";
        }
}

function modtwo($tid, $score, $reason) {
        global $moderate, $reasons;

        if ((_MPN_ADMIN && $moderate == 1) || (_MPN_USER && $moderate == 2))
        {
             echo " | <select name=dkn$tid>";
            for ($i=0; $i < sizeof($reasons); $i++)
             {
                 echo "<option value=\"$score:$i\">$reasons[$i]</option>\n";
             }

             echo "</select>";
        }
}

function modthree($sid, $mode = 'thread', $order = 0, $thold=0) {
        global $moderate, $uimages;


        if ((_MPN_ADMIN && $moderate == 1) || (_MPN_USER && $moderate == 2))
        {
            echo "<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' />
                  <input type='hidden' name='op' value='moderate' />
                  <input class=\"button\" type=\"submit\" value=\"" . translate('Moderate') . "\" />";

            echo "</form>\n";
        }
}


function navbar( $sid, $title, $thold=0, $mode="thread", $order=0 )
{
        global $mpnTables,$phpEx;
        global $bgcolor1, $bgcolor2, $textcolor1, $textcolor2;

        $query = mysql_query("select sid FROM ".$mpnTables['comments']." where sid=$sid");
        if(!$query) $count = 0; else $count = mysql_num_rows($query);

        if(!isset($thold)) $thold=0; ?>

        <table border='0' cellspacing='1' cellpadding='2' summary=''>

        <?php if($title)
        {
            echo "<tr><td bgcolor=\"$bgcolor2\" align='center'><font size=1 color=\"$textcolor1\">\"$title\" | ";

            if( _MPN_USER) {
                    echo "<a href='user.php'>".translate("Configure")."</a>";
            } else {
                    echo "<a href='user.php'>".translate("Login/Create Account")."</a>";
            }

            if(($count==1)) {
            echo " | <B>$count</B> ".translate("comment")."</font>";
            } else {
            echo " | <B>$count</B> ".translate("comment")."s</font>";
            }

            echo "</td></tr>\n";
        } ?>

       <tr><td bgcolor="<?php echo"$bgcolor1"; ?>" align="center">
        <?php echo "<form method=\"get\" action=\"article.$phpEx\">"; ?>        <font color="<?php echo"$textcolor2"; ?>"><?php echo translate("Threshold"); ?></font>
        <select name=thold>
        <option value="-1" <?php if ($thold == -1) { echo "selected=\"selected\""; } ?>>-1</option>
        <option value="0" <?php if ($thold == 0) { echo "selected=\"selected\""; } ?>>0</option>
        <option value="1" <?php if ($thold == 1) { echo "selected=\"selected\""; } ?>>1</option>
        <option value="2" <?php if ($thold == 2) { echo "selected=\"selected\""; } ?>>2</option>
        <option value="3" <?php if ($thold == 3) { echo "selected=\"selected\""; } ?>>3</option>
        <option value="4" <?php if ($thold == 4) { echo "selected=\"selected\""; } ?>>4</option>
        <option value="5" <?php if ($thold == 5) { echo "selected=\"selected\""; } ?>>5</option>
        </select>

        <select name=mode>

        <option value="nocomments" <?php if ($mode == 'nocomments') { echo "selected=\"selected\""; } ?>><?php echo translate("No Comments"); ?></option>
        <option value="nested" <?php if ($mode == 'nested') { echo "selected=\"selected\""; } ?>>
        <?php echo translate("Nested"); ?></option>
        <option value="flat" <?php if ($mode == 'flat') { echo "selected=\"selected\""; } ?>><?php echo translate("Flat"); ?></option>
        <option value="thread" <?php if (!isset($mode) || $mode=='thread' || $mode=="") { echo "selected=\"selected\""; } ?>><?php echo translate("Thread"); ?></option>

        </select>

        <select name=order>

       <option value="0" <?php if (!$order) { echo "selected=\"selected\""; } ?>><?php echo translate("Oldest First"); ?></option>
       <option value="1" <?php if ($order==1) { echo "selected=\"selected\""; } ?>>
       <?php echo translate("Newest First"); ?></option>
       <option value="2" <?php if ($order==2) { echo "selected=\"selected\""; } ?>><?php echo translate("Highest Scores First"); ?></option>

       </select>
        <input class='button' type=submit value=<?php echo translate("Refresh"); ?> />
        <input type=hidden name=sid value=<?php echo "$sid"; ?> />
        </form>

        </td></tr><tr><td bgcolor="<?php echo"$bgcolor2"; ?>" align=center>

        <font size=1><?php echo translate("The comments are owned by the poster. We aren't responsible for their content."); ?>
        </font></td></tr></table><?php

        echo "<br /><br />\n";
}

function DisplayKids ($tid, $mode, $order=0, $thold=0, $level=0, $dummy=0, $tblwidth='95%') {
        global $mpnTables,$phpEx;
        global $datetime, $bgcolor1, $bgcolor2, $reasons, $anonymous, $anonpost, $commentlimit;
        global $sid;
        $comments = 0;

        $result = mysql_query("select tid, pid, sid, date, name, email, url, host_name, subject, comment, score, reason from ".$mpnTables['comments']." where pid = $tid order by date, tid");

        if ($mode == 'nested')
        {
            /* without the tblwidth variable, the tables run of the screen with netscape
               in nested mode in long threads so the text can't be read. */

            while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {

                    // Kiril: New Sanitizer

                    $sanity_ary = compact( 'r_subject', 'r_comment' );
                    $_SERVER['SAN'] -> slashIT( $sanity_ary );
                    extract( $sanity_ary );

                    $_SERVER['SAN'] -> adjustFormat( $r_comment, 3, 10 );
                    unset( $sanity_ary );

                    // End New Saintizer

                    if($r_score >= $thold) {
                            if (!isset($level)) {
                            } else {
                                    if (!$comments) {
                                            //echo "<ul>";
                                            $tblwidth -= 5;
                                    }
                            }
                            $comments++;
                            if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
                            if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";
                    // HIJO enter hex color between first two appostrophe for second alt bgcolor
                            $r_bgcolor = ($dummy%2)?"":$bgcolor2;
                            echo "<a name=\"$r_tid\"></a>";
                            echo "<table border=0><tr bgcolor=\"$bgcolor1\"><td>";

                            formatTimestamp($r_date);

                            if ($r_email && $r_email != '')
                            {
                                echo "<b>$r_subject</b> <font size=1>";

                                if ( ! isset( $GLOBALS['uinf'][7] ) )
                                {
                                        echo "(".translate("Score: ")."$r_score";
                                        if($r_reason>0) echo ", $reasons[$r_reason]";
                                        echo ")";
                                }
                                echo "<br />".translate("by")." <a href=\"mailto:$r_email\">$r_name</a> <b>($r_email)</b> ".translate("on")." $datetime";
                        } else {
                                echo "<b>$r_subject</b> <font size=1>";
                                if(!isset($GLOBALS['uinf'][7])) {
                                        echo "(".translate("Score: ")."$r_score";
                                        if($r_reason>0) echo ", $reasons[$r_reason]";
                                        echo ")";
                                }
                                echo "<br />".translate("by")." $r_name ".translate("on")." $datetime";
                            }

                            if ($r_name != $anonymous) { echo "<br />(<a href=\"user.$phpEx?op=userinfo&uname=$r_name\">".translate("User Info")."</a>) "; }

                            if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }

                            echo "</font></td></tr><tr><td>";

                            if ( strlen( $r_comment ) > $commentlimit )
                            {
                                $c_pos = strpos( $r_comment, '</', $commentlimit );
                                $c_delim = strpos( $r_comment, '>', $c_pos );

                                $endpos = ( (bool)FALSE !== ( $c_delim = strpos( $r_comment, '>', $c_pos ) ) ) ? ( $c_delim ) : ( $commentlimit );

                                 echo substr( $r_comment, 0, $endpos )."<br /><br /><b><a href=\"comments.$phpEx?sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
                            }
                            else
                            {
                                echo $r_comment;
                            }

                            echo "</td></tr></table>";

                            echo "<div class='indent15'>\n";

                                if ($anonpost == 1 OR _MPN_ADMIN OR _MPN_USER) {
                                    echo " [ <a href=\"comments.$phpEx?op=Reply&pid=$r_tid&sid=$r_sid&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
                                }

                                modtwo($r_tid, $r_score, $r_reason);

                                if(_MPN_ADMIN)
                                {
                                    echo " | <a href=\"comments.$phpEx?op=Edit&tid=$r_tid&pid=$r_pid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Edit")."</a>";
                                    echo " | <a href=\"comments.$phpEx?op=RemoveAllComments&tid=$r_tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Delete")."</a>";
                                }

                                echo " ]";

                                echo "<br /><br />\n";

                                DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
                            echo "</div>\n";
                  }
            }
    }
    elseif ($mode == 'flat')
    {
            while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result)) {

                    // Kiril: New Sanitizer

                    $sanity_ary = compact( 'r_subject', 'r_comment' );
                    $_SERVER['SAN'] -> slashIT( $sanity_ary );
                    extract( $sanity_ary );

                    $_SERVER['SAN'] -> adjustFormat( $r_comment, 3, 10 );
                    unset( $sanity_ary );

                    // End New Saintizer

                    if($r_score >= $thold) {
                            if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
                            if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";
                            echo "<a name=\"$r_tid\"></a>";
                            echo "<hr /><table border=0><tr bgcolor=\"$bgcolor1\"><td>";
                            formatTimestamp($r_date);
                            if ($r_email && $r_email != '') {
                                    echo "<b>$r_subject</b> <font size=1>";
                                    if(!isset($GLOBALS['uinf'][7])) {
                                            echo "(".translate("Score: ")."$r_score";
                                            if($r_reason>0) echo ", $reasons[$r_reason]";
                                            echo ")";
                                    }
                                    echo "<br />".translate("by")." <a href=\"mailto:$r_email\">$r_name</a> <b>($r_email)</b> ".translate("on")." $datetime";
                             } else {
                                    echo "<b>$r_subject</b> <font size=1>";
                                    if(!isset($GLOBALS['uinf'][7])) {
                                            echo "(".translate("Score: ")."$r_score";
                                            if($r_reason>0) echo ", $reasons[$r_reason]";
                                            echo ")";
                                    }
                                    echo "<br />".translate("by")." $r_name ".translate("on")." $datetime";
                            }
                            if ($r_name != $anonymous) { echo "<br />(<a href=\"user.$phpEx?op=userinfo&uname=$r_name\">".translate("User Info")."</a>) "; }

                            if (eregi("http://",$r_url)) { echo "<a href=\"$r_url\" target=\"window\">$r_url</a> "; }

                            echo "</font></td></tr><tr><td>";

                            if ( strlen( $r_comment ) > $commentlimit )
                            {
                                $c_pos = strpos( $r_comment, '</', $commentlimit );
                                $c_delim = strpos( $r_comment, '>', $c_pos );

                                $endpos = ( (bool)FALSE !== ( $c_delim = strpos( $r_comment, '>', $c_pos ) ) ) ? ( $c_delim ) : ( $commentlimit );

                                echo substr("$r_comment", 0, $endpos)."<br /><br /><b><a href=\"comments.$phpEx?sid=$r_sid&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
                            }
                            else
                            {
                                echo $r_comment;
                            }

                            echo "</td></tr></table>";

                            echo "<div class='indent15'>\n";

                                if ($anonpost == 1 OR _MPN_ADMIN OR _MPN_USER)
                                {
                                    echo " [ <a href=\"comments.$phpEx?op=Reply&pid=$r_tid&sid=$r_sid&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
                                }
                                modtwo($r_tid, $r_score, $r_reason);

                                if(_MPN_ADMIN) {
                                    echo " | <a href=\"comments.$phpEx?op=Edit&tid=$r_tid&pid=$r_pid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Edit")."</a>";
                                    echo " | <a href=\"comments.$phpEx?op=RemoveAllComments&tid=$r_tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Delete")."</a>";
                                }
                                echo " ]";

                                echo "<br /><br />\n";

                                DisplayKids($r_tid, $mode, $order, $thold);

                            echo "</div>\n";
                    }
            }
        } else {
                while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result))
                {

                        // Kiril: New Sanitizer

                        $sanity_ary = compact( 'r_subject', 'r_comment' );
                        $_SERVER['SAN'] -> slashIT( $sanity_ary );
                        extract( $sanity_ary );

                        $_SERVER['SAN'] -> adjustFormat( $r_comment, 3, 10 );
                        unset( $sanity_ary );

                        // End New Saintizer

                        if($r_score >= $thold)
                        {
                            $comments++;
                            if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
                            if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "[".translate("No Subject")."]";

                            formatTimestamp($r_date);

                            echo "<div class='indent15'>\n";

                                echo "<ul><li><a href=\"comments.$phpEx?op=showreply&tid=$r_tid&sid=$r_sid&pid=$r_pid&mode=$mode&order=$order&thold=$thold#$r_tid\">$r_subject</a> ".translate("by")." $r_name <font size=1>".translate("on")." $datetime</font></li></ul>";
                                echo "<br /><br />\n";



                                DisplayKids($r_tid, $mode, $order, $thold, $level+1, $dummy+1);

                            echo "</div>\n";

                        }
                }
        }
}

function DisplayBabies ($tid, $level=0, $dummy=0) {
    global $mpnTables,$phpEx;
        global $datetime, $anonymous;
        $comments = 0;
        $result = mysql_query("select tid, pid, sid, date, name, email, url, host_name, subject, comment, score, reason from ".$mpnTables['comments']." where pid = $tid order by date, tid");

        while (list($r_tid, $r_pid, $r_sid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason) = mysql_fetch_row($result))
       {
                // Kiril: New Sanitizer

                $sanity_ary = compact( 'r_subject', 'r_comment' );
                $_SERVER['SAN'] -> slashIT( $sanity_ary );
                extract( $sanity_ary );

                $_SERVER['SAN'] -> adjustFormat( $r_comment, 3, 10 );
                unset( $sanity_ary );

                // End New Saintizer

                $comments++;
                if (!eregi("[a-z0-9]",$r_name)) { $r_name = $anonymous; }
                if (!eregi("[a-z0-9]",$r_subject)) { $r_subject = "[".translate("No Subject")."]"; }

                formatTimestamp($r_date);

                echo "<div class='indent15'>\n";

                    echo "<ul><li><a href=\"comments.$phpEx?op=showreply&tid=$r_tid&mode=$mode&order=$order&thold=$thold\">$r_subject</a> ".translate("by")." $r_name ".translate("on")." $datetime</li></ul>";


                    DisplayBabies($r_tid, $level+1, $dummy+1);

                echo "</div>\n";

        }
        /*if ($level && $comments) {
                //echo "</ul>";
        }*/
}

function DisplayTopic ($sid, $pid=0, $tid=0, $mode="thread", $order=0, $thold=0, $level=0, $nokids=0) {
    global $mpnTables,$phpEx, $bgcolor1;
        global $hr, $datetime, $commentlimit, $anonymous, $reasons, $anonpost, $foot1, $foot2, $foot3, $foot4,$title,$bgcolor1, $bgcolor2, $bgcolor3, $textcolor1;

        include_once("header.$phpEx");

        $count_times = 0;

        $q = "select tid, pid, sid, date, name, email, url, host_name, subject, comment, score, reason from ".$mpnTables['comments']." where sid=$sid and pid=$pid";
        if($thold != "") {
                $q .= " and score>=$thold";
        } else {
                $q .= " and score>=0";
        }

        if ($order==1) $q .= " order by date desc";
        if ($order==2) $q .= " order by score desc";
        $something = mysql_query("$q");
        $num_tid = mysql_num_rows($something);

        if (!isset($title))
        {
            $title = null;
        }

        navbar($sid, $title, $thold, $mode, $order);

        //OpenTable();

        modone();

        while ($count_times < $num_tid)
        {
                list($tid, $pid, $sid, $date, $name, $email, $url, $host_name, $subject, $comment, $score, $reason) = mysql_fetch_row($something);
                if ($name == "") { $name = $anonymous; }
                if ($subject == "") { $subject = "[".translate("No Subject")."]"; }

                // Kiril: New Sanitizer

                $sanity_ary = compact( 'subject', 'comment' );
                $_SERVER['SAN'] -> slashIT( $sanity_ary );
                extract( $sanity_ary );

                $_SERVER['SAN'] -> adjustFormat( $comment, 3, 10 );
                unset( $sanity_ary );

                // End New Saintizer

                echo "<a name=\"$tid\"></a>";
                echo "<table border=0><tr bgcolor=\"$bgcolor1\"><td>";

                formatTimestamp($date);

                if ($email && $email != '') {
                        echo "<b>$subject</b>";
                        if(!isset($GLOBALS['uinf'][7]))
                        {
                                echo "(".translate("Score: ")."$score";
                               if($reason>0) echo ", $reasons[$reason]";
                                echo ")";
                        }
                        echo "<br />".translate("by")." <a href=\"mailto:$email\">$name</a> <b>($email)</b> ".translate("on")." $datetime";
                } else {
                        echo "<b>$subject</b>";
                        if(!isset($GLOBALS['uinf'][7]))
                        {
                                echo "(".translate("Score: ")."$score";
                                if($reason>0) echo ", $reasons[$reason]";
                                echo ")";
                        }
                        echo "<br />".translate("by")." $name ".translate("on")." $datetime";
                }

    // If you are admin you can see the Poster IP address (you have this right, no?)
    // with this you can see who is flaming you... ha-ha-ha

                if ($name != $anonymous) { echo "<br />(<a href=\"user.$phpEx?op=userinfo&uname=$name\">".translate("User Info")."</a>) "; }
                if (eregi("http://",$url)) { echo "<a href=\"$url\" target=\"window\">$url</a> "; }

                if(_MPN_ADMIN)
                {
                    $result= mysql_query("select host_name from ".$mpnTables['comments']." where tid='$tid'");
                    list($host_name) = mysql_fetch_row($result);
                    echo "<br /><b>(IP: $host_name)</b>";
                }

                echo "</td></tr><tr><td class='comment_text'>";

                echo "<br /><br />\n";

                if ( strlen( $comment ) > $commentlimit )
                {
                    $c_pos = strpos( $comment, '</', $commentlimit );
                    $c_delim = strpos( $comment, '>', $c_pos );

                    $endpos = ( (bool)FALSE !== ( $c_delim = strpos( $comment, '>', $c_pos ) ) ) ? ( $c_delim ) : ( $commentlimit );

                    echo substr( $comment, 0, $endpos )."<br /><br /><b><a href=\"comments.$phpEx?sid=$sid&tid=$tid&mode=$mode&order=$order&thold=$thold\">".translate("Read the rest of this comment...")."</a></b>";
                }
                else
                {
                    echo $comment;
                }

                echo "</td></tr></table>";

                echo "<div class='indent15'>\n";

                    if ($anonpost == 1 OR _MPN_ADMIN OR _MPN_USER)
                    {
                        echo "[ <a href=\"comments.$phpEx?op=Reply&pid=$tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a>";
                    }
                    else
                    {
                        echo "[ " .translate("No Comments Allowed for Anonymous, please <a href='user.php'>register</a>")." ";
                    }

                    if ($pid != 0) {
                            list($erin) = mysql_fetch_row(mysql_query("select pid from ".$mpnTables['comments']." where tid=$pid"));
                            echo " | <a href=\"comments.$phpEx?sid=$sid&pid=$erin&mode=$mode&order=$order&thold=$thold\">".translate("Parent")."</a>";
                    }

                    modtwo($tid, $score, $reason);

                    if(_MPN_ADMIN)
                    {
                        echo " | <a href=\"comments.$phpEx?op=Edit&tid=$tid&pid=$pid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Edit")."</a>";
                        echo " | <a href=\"comments.$phpEx?op=RemoveAllComments&tid=$tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Delete")."</a>";
                    }
                        echo " ]";

                    echo "<br /><br />\n";

                    DisplayKids($tid, $mode, $order, $thold, $level);



                //echo "</ul>";
                if($hr) echo "<hr noshade size=1>";
                //echo "</p>";
                $count_times += 1;
        }

        modthree($sid, $mode, $order, $thold);
       // CloseTable();

       echo "</div>\n";

        if ( ! isset( $subject ) ) { $subject = ''; }

        if($pid==0)
        {
            return array($sid, $pid, $subject);
        }
        else
        {
            include_once("footer.$phpEx");
        }
}

function singlecomment($tid, $sid, $mode, $order, $thold) {
    global $mpnTables,$phpEx, $anonymous;
        global $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $anonpost, $textcolor1;

        include_once("header.$phpEx");

        $deekayen = mysql_query("select date, name, email, url, subject, comment, score, reason from ".$mpnTables['comments']." where tid=$tid and sid=$sid");
        list($date, $name, $email, $url, $subject, $comment, $score, $reason) = mysql_fetch_row($deekayen);

        // Kiril: New Sanitizer

        $sanity_ary = compact( 'subject', 'comment' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );

        $_SERVER['SAN'] -> adjustFormat( $comment, 3, 10 );
        unset( $sanity_ary );

        // End New Saintizer


        $titlebar = "<b>$subject</b>";
        if($name == "") $name = $anonymous;
        if($subject == "") $subject = "[".translate("No Subject")."]";
        modone();

        echo "<table border=0><tr bgcolor=\"$bgcolor1\"><td>";

        formatTimestamp($date);

        if($email && $email != '') echo "<b>$subject</b> <font size=1>(".translate("Score: ")."$score)<br />".translate("by")." <a href=\"mailto:$email\">$name</a> <font size=1><b>($email)</b></font> ".translate("on")." $datetime";
        else echo "<b>$subject</b> <font size=1>(".translate("Score: ")."$score)<br />".translate("by")." $name ".translate("on")." $datetime";

        echo "</td></tr><tr><td>$comment</td></tr></table><br />";

        if ($anonpost == 1 OR _MPN_ADMIN OR _MPN_USER)
        {
            echo "[ <a href=\"comments.$phpEx?op=Reply&pid=$tid&sid=$sid&mode=$mode&order=$order&thold=$thold\">".translate("Reply")."</a> | <a href=\"article.$phpEx?sid=$sid&mode=$mode&order=$order&thold=$thold&mode=$mode&order=$order&thold=$thold\">Root</a>";
        }

        modtwo($tid, $score, $reason);
        echo " ]";
        modthree($sid, $mode, $order, $thold);

        include_once("footer.$phpEx");
}

function reply ($pid, $sid, $mode, $order, $thold) {
    global $phpEx, $AllowableHTML, $anonymous;
        include_once("header.$phpEx");
    OpenTable();
        global $mpnTables;
        global $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $textcolor1;;
        $bbtext = 1;

        $temp_comment = $notes = null;

        if($pid!=0) {
                list($date, $name, $email, $url, $subject, $comment, $score) = mysql_fetch_row(mysql_query("select date, name, email, url, subject, comment, score from ".$mpnTables['comments']." where tid=$pid"));

                $sanity_ary = compact( 'subject', 'comment' );

        }
        else
        {
                list($date, $subject, $temp_comment, $comment, $name, $notes) = mysql_fetch_row(mysql_query("select time, title, hometext, bodytext, informant, notes FROM ".$mpnTables['stories']." where sid=$sid"));

                $sanity_ary = compact( 'temp_comment', 'comment', 'notes' );

        }

        // Kiril: New Sanitizer

        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );

        // End New Saintizer

        if( $comment == '' )
        {
          $prev_comment = $temp_comment;
          $comment = $temp_comment;
          $bbtext = 0;
        }
        else
        {
            $prev_comment = $comment;
        }

        // Kiril: New Sanitizer

        $prev_ary = compact( 'prev_comment', 'notes' );
        $_SERVER['SAN'] -> adjustFormat( $prev_ary, 3, 10 );
        extract( $prev_ary );

        // End New Saintizer

        $titlebar = "<b>$subject</b>";

        if($name == "") $name = $anonymous;

        if($subject == "") $subject = "[".translate("No Subject")."]";
        echo "<table border=0><tr bgcolor=\"$bgcolor1\"><td>";
        formatTimestamp($date);

        if(isset($email) && $email != '' ) {
                echo "<b>$subject</b> <font size=1>";
                if(!$temp_comment) echo"(".translate("Score: ")."$score)";
                echo "<br />".translate("by")." <a href=\"mailto:$email\">$name</a> <b>($email)</b> ".translate("on")." $datetime";
        } else {
                echo "<b>$subject</b> <font size=1>";
                if(!$temp_comment) echo"(".translate("Score: ")."$score)";
                echo "<br />".translate("by")." $name ".translate("on")." $datetime";
        }

        echo "</td></tr>\n";

        echo $prev_comment;

        echo "<br /><br /><br />\n";

        if ( $notes != '' )
        {
            echo "<tr><td>\n";

            echo "<p class='subtitle1'>\n";

            echo translate( 'Notes' );

            echo "</p>\n";

            echo "<hr /><br />\n";

            echo $notes;
        }

        echo "</td></tr></table><hr />\n";

        if(!isset($pid) || !isset($sid)) { echo "Something is not right. This message is just to keep things from messing up down the road"; exit(); }

        if($pid == 0) {
                list($subject) = mysql_fetch_row(mysql_query("select title from ".$mpnTables['stories']." where sid=$sid"));
        } else {
                list($subject) = mysql_fetch_row(mysql_query("select subject from ".$mpnTables['comments']." where tid=$pid"));
        }

        $subject = stripslashes( $subject );

        echo "<form action=\"comments.$phpEx\" method=post>";
        echo "<FONT color=\"$textcolor1\"><B>".translate("Your Name").":</B></FONT> ";
        if ( _MPN_USER ) {

                echo "<a href='user.php'>" . $GLOBALS['uinf'][1] . "</a> <font size=1>[ <a href=\"user.$phpEx?op=logout\">".translate("Logout")."</a> ]</font>";
        } else {
                echo "<font color=Red>$anonymous<font color=Black>";
                echo " [ <a href='user.php'>".translate("New User")."</a> ] ";
        }

        echo "<br /><br />\n";
        echo "<FONT color=\"$textcolor1\"><B>".translate("Subject")."</B></FONT><br />";
        if (!eregi("Re:",$subject)) $subject = "Re: ".substr($subject,0,56);
        echo "<input type=\"text\" NAME=\"subject\" SIZE=50 maxlength=60 value=\"$subject\"><br /><br />";
        echo "<FONT color=\"$textcolor1\"><B>".translate("Comment")."</B></FONT><br />"
                ."<TEXTAREA wrap=virtual cols=70 rows=20 name=comment></TEXTAREA><br />\n";

                echo "<br />";
        if ( _MPN_USER ) { echo "<input type=checkbox name=xanonpost> ".translate("Post Anonymously")."<br />"; }

        // Kiril: New Sanitizer

        addFormatOption();

        echo "<input type='hidden' name='clickit_form' value='comment' />\n";
        echo "<input type='hidden' name='stripit_form' value='subject' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='1' />\n";

        // End Sanitizer

        echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
                ."<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\">"
                ."<input class='button' type=submit name=op value=\"" . translate("Preview") . "\">"
                ."<input class='button' type=submit name=op value=\"" . translate("Ok!") . "\">\n";

                 echo "</FORM><br />";
    CloseTable();
        include_once("footer.$phpEx");
}

function replyPreview ($pid, $sid, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype) {
        global $phpEx, $AllowableHTML, $anonymous, $bgcolor2, $textcolor1;

        include_once("header.$phpEx");
        OpenTable();

        // Kiril: New Sanitizer

        $prev_comment = $comment;
        $_SERVER['SAN'] -> adjustFormat( $prev_comment, 3, 10 );


        // End New Saintizer

        if (!isset($pid) || !isset($sid)) {
            echo "Something is not right with passing a variable to this function. This message is just to keep things from messing up down the road";
            exit();
        }
        echo "<table border=0><tr><td>";
        echo "<b>$subject</b>";
        echo "<br /><font size=1>".translate("by")." ";

        echo $GLOBALS['uinf']['uname'];

        echo "".translate(" on...")."</font></td></tr><tr><td>";

        echo "$prev_comment\n";

        echo "</td></tr></table><br />";
        echo "<hr>";
        echo "<form action=\"comments.$phpEx\" method=post><FONT color=\"$textcolor1\"><B>".translate("Your Name")."</B></FONT> ";
        if (_MPN_USER)
        {
            echo "<a href='user.php'>" . $GLOBALS['uinf']['uname'] . "</a> [ <a href=\"user.$phpEx?op=logout\">".translate("Logout")."</a> ]";
        } else {
            echo "$anonymous";
        }

        echo "<br /><br />\n";
        echo "<FONT color=\"$textcolor1\"><B>".translate("Subject")."</B></FONT><br />"
                ."<input type=\"text\" NAME=\"subject\" SIZE=50 maxlength=60 value=\"$subject\"><br /><br />"
                ."<FONT color=\"$textcolor1\"><B>".translate("Comment")."</B></FONT><br />"
                ."<TEXTAREA wrap=virtual cols=70 rows=20 name=comment>$comment</TEXTAREA><br />";


        if ($xanonpost) {
            echo "<input type=checkbox name=xanonpost checked> ".translate("Post Anonymously")."<br />";
        } elseif( _MPN_USER) {
            echo "<input type=checkbox name=xanonpost> ".translate("Post Anonymously")."<br />";
        }

        // Kiril: New Sanitizer

        addFormatOption();

        echo "<input type='hidden' name='clickit_form' value='comment' />\n";
        echo "<input type='hidden' name='stripit_form' value='subject' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='1' />\n";

        // End Sanitizer

        echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
        ."<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\">"
        ."<input class='button' type=submit name=op value=\"" . translate("Preview") . "\">"
        ."<input class='button' type=submit name=op value=\"" . translate("Ok!") . "\">\n";

        echo "</FORM><br />";

    CloseTable();
        include_once("footer.$phpEx");
}

function edit ($tid, $pid, $sid, $mode, $order, $thold) {
    global $phpEx,$AllowableHTML, $anonymous;

        include_once("header.$phpEx");
    OpenTable();
        global $mpnTables;
        global $datetime, $bgcolor1, $bgcolor2, $bgcolor3, $textcolor1;
        $bbtext = 1;
        list($date, $name, $email, $url, $subject, $comment, $score) = mysql_fetch_row(mysql_query("select date, name, email, url, subject, comment, score from ".$mpnTables['comments']." where tid=$tid"));

        // Kiril: New Sanitizer

        $sanity_ary = compact( 'subject', 'comment' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );
        $prev_comment = $comment;
        $_SERVER['SAN'] -> adjustFormat( $prev_comment, 3, 10 );
        unset( $sanity_ary );

        // End New Saintizer

        $temp_comment = $notes = null;

        if($comment == "") {
          $comment = $temp_comment;
          $bbtext =0;
        }
        $titlebar = "<b>$subject</b>";

        if($name == "") $name = $anonymous;
        if($subject == "") $subject = "[".translate("No Subject")."]";

        echo "<table border=0><tr bgcolor=\"$bgcolor1\"><td>";

        formatTimestamp($date);

        if($email && $email != '') {
                echo "<b>$subject</b> <font size=1>";
                echo"(".translate("Score: ")."$score)";
                echo "<br />".translate("by")." <a href=\"mailto:$email\">$name</a> <font size=1><b>($email)</b></font> ".translate("on")." $datetime";
        } else {
                echo "<b>$subject</b> <font size=1>";
                echo"(".translate("Score: ")."$score)";
                echo "<br />".translate("by")." $name ".translate("on")." $datetime";
        }

        echo "</td></tr><tr><td>\n";

        if ($bbtext != 0) {
          echo "$temp_comment $prev_comment $notes";
        } else {
          echo "$prev_comment $notes";
        }

        echo "</td></tr></table><hr>\n";

        if(!isset($pid) || !isset($sid)) { echo "Something is not right. This message is just to keep things from messing up down the road"; exit(); }

        echo "<form action=\"comments.$phpEx\" method=post>";
        echo "<FONT color=\"$textcolor1\"><B>".translate("Comment")."</B></FONT><br />"
                ."<TEXTAREA wrap=virtual cols=70 rows=20 name=comment>$comment</TEXTAREA><br />\n";

        // Kiril: New Sanitizer

        addFormatOption();

        echo "<input type='hidden' name='clickit_form' value='comment' />\n";
        echo "<input type='hidden' name='stripit_form' value='subject' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End New Saintizer

        echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\">"
                ."<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
                ."<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\">"

                ."<input class='button' type=submit name=op value=\"" . translate("Accept") . "\">\n";

                 echo "</FORM><br />";


    CloseTable();
        include_once("footer.$phpEx");
}

function UpdateEdit ($tid, $pid, $sid, $comment, $posttype) {
    global $mpnTables,$phpEx;

    $comment = addslashes( $comment );

    // update this record

    mysql_query("UPDATE ".$mpnTables['comments']." SET comment='$comment' WHERE tid=$tid and pid=$pid and sid=$sid");


}

function CreateTopic ($xanonpost, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype) {
        global $EditedMessage, $AllowableHTML, $ultramode, $adminmail, $mpn_new_comment_notify;
        global $sitename, $mpnTables,$phpEx, $smtp, $mailmethod;

        // Kiril: Start Sanitizer

        $sanity_ary = compact( 'subject', 'comment' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary, TRUE );
        extract( $sanity_ary );
        unset( $sanity_ary );

        // End Sanitizer

        if ( _MPN_USER && (!$xanonpost))
        {
            $name = $GLOBALS['uinf']["uname"];
            $email = $GLOBALS['uinf']["femail"];
            $url = $GLOBALS['uinf']["url"];
            $score = 1;
        } else {
            $name = ""; $email = ""; $url = "";
            $score = 0;
        }
        $ip = getenv("REMOTE_ADDR");

/* begin fake thread control */
        list($fake) = mysql_fetch_row(mysql_query("select count(*) from ".$mpnTables['stories']." where sid=$sid"));
        mysql_query("LOCK TABLES comments WRITE");
/* begin duplicate control */
        list($tia) = mysql_fetch_row(mysql_query("select count(*) from ".$mpnTables['comments']." where pid='$pid' and sid='$sid' and subject='$subject' and comment='$comment'"));
/* begin troll control */

        if(_MPN_USER) {
                list($troll) = mysql_fetch_row(mysql_query("select count(*) from ".$mpnTables['comments']." where (score=-1) and (name='" . $GLOBALS['uinf']['uname'] . "') and (to_days(now()) - to_days(date) < 3)"));
        } elseif(!$score) {
                list($troll) = mysql_fetch_row(mysql_query("select count(*) from ".$mpnTables['comments']." where (score=-1) and (host_name='$ip') and (to_days(now()) - to_days(date) < 3)"));
        }
        if((!$tia) && ($fake == 1) && ($troll < 6)) {
                mysql_query("insert into ".$mpnTables['comments']." values (NULL, '$pid', '$sid', now(), '$name', '$email', '$url', '$ip', '$subject', '$comment', '$score', '0')");
        } else {
                mysql_query("UNLOCK TABLES");
                include_once("header.$phpEx");
                if ($tia) {
                    echo "Duplicate.  Did you submit twice?<br /><br /><a href=\"article.$phpEx?sid=$sid&mode=$mode&order=$order&thold=$thold\">Back to comments</a>";
                } elseif($troll > 5) {
                    echo "This account or IP has been temporarily disabled.
                    This means that either this IP, or
                    user account has been moderated down more than 5 times in
                    the last few hours.  If you think this is unfair,
                    you should contact the admin.  If you
                    are being a troll, now is the time for you to either
                    grow up, or change your IP.<br /><br /><a href=\"article.$phpEx?sid=$sid&mode=$mode&order=$order&thold=$thold\">Back to comments</a>";
                } elseif($fake == 0) {
                    echo "According to my records, the topic you are trying
                    to reply to does not exist. If you're just trying to be
                    annoying, well then too bad.";
                }
                include_once("footer.$phpEx");
                exit;
        }
        mysql_query("UNLOCK TABLES");
        mysql_query("update ".$mpnTables['stories']." set comments=comments+1 where sid='$sid'");
        if ($ultramode) {
            ultramode();
        }

        $options = '';
        if (isset($GLOBALS['uinf'][4])) { $options .= "&mode=" . $GLOBALS['uinf'][4]; } else { $options .= "&mode=thread"; }
        if (isset($GLOBALS['uinf'][5])) { $options .= "&order=" . $GLOBALS['uinf'][5]; } else { $options .= "&order=0"; }
        if (isset($GLOBALS['uinf'][6])) { $options .= "&thold=" . $GLOBALS['uinf'][6]; } else { $options .= "&thold=0"; }

        if ($mpn_new_comment_notify == "1") {
            require_once('class.phpmailer.php');
            $mail = new phpmailer();

            /* SET MAIL DELIVERY OPTIONS */
            $mail->IsHTML(true);
            if ($mailmethod == "0") {
                $mail->IsMail();
            } else {
                $mail->IsSMTP();
                $mail->Host = $smtp;
            }

            $message = translate('A new comment regarding ') . stripslashes($subject) . translate(' was posted');
            $subject = translate('New comment on ') . $sitename;
//            if ($author != "") $message .= translate(' by ') . $author;
            $message .= "\n\n";
            $message .= "<a href = \"" . _MPN_ROOT_URI . "article.$phpEx?sid=$sid$options\" target=\"_blank\">" . _MPN_ROOT_URI . "article.$phpEx?sid=$sid$options</a>";
            $mail->From = $adminmail;
            $mail->FromName = $sitename . translate(' Mailer');
            $mail->AddAddress($adminmail);
            $mail->Subject = stripslashes($subject);
            $mail->Body = nl2br( stripslashes($message) );
            $mail->AltBody = strip_tags( stripslashes($message) );
            $mail->Send();
        }

        $_SERVER['F_LIB'] -> redirectRequest( 'article.php?sid=' . $sid . $options );
}

function RemoveAllComments ($tid, $sid) {
    global $ultramode, $mpnTables,$phpEx;

    // Delete all the kids
    RecurseDeleteCommentKids($tid, $sid);

    // Now delete this record
    mysql_query("UPDATE ".$mpnTables['stories']." SET comments=comments-1 WHERE sid='$sid'");
    mysql_query("DELETE FROM ".$mpnTables['comments']." WHERE tid=$tid and sid=$sid");

}

function RecurseDeleteCommentKids ($pid, $sid) {
    global $mpnTables,$phpEx;

    // Get the main entry
    $result = mysql_query("SELECT tid, pid, sid FROM ".$mpnTables['comments']." where pid=$pid and sid=$sid");
    $count = mysql_num_rows($result);
    # No records found, so bail out
    if ($count == 0) { return; };

    while (list($r_tid, $r_pid, $r_sid) = mysql_fetch_row($result)) {
        RecurseDeleteCommentKids($r_tid, $r_sid);

        # A this point, all sub-records are deleted, so delete this record
        mysql_query("UPDATE ".$mpnTables['stories']." SET comments=comments-1 WHERE sid='$r_sid'");
        mysql_query("DELETE FROM ".$mpnTables['comments']." WHERE tid=$r_tid and sid=$r_sid");

    }

}

if (!isset($op))
{
    $op = null;
}

switch($op) {

        case "RemoveAllComments":

                if(_MPN_ADMIN || ($moderate==2)) {
                    RemoveAllComments($tid, $sid);
                }

                $_SERVER['F_LIB'] -> redirectRequest( 'article.php?sid=' . $sid . '&mode=' . $mode . '&order=' . $order . '&thold=' . $thold );

                break;

    case "Edit":
                edit($tid, $pid, $sid, $mode, $order, $thold);
                break;

        case "Accept":

                if(_MPN_ADMIN || ($moderate==2)) {
                    UpdateEdit($tid, $pid, $sid, $comment, $posttype);
                }

                $_SERVER['F_LIB'] -> redirectRequest( 'article.php?sid=' . $sid . '&mode=' . $mode . '&order=' . $order . '&thold=' . $thold );

                break;

        case "Reply":
                if (!isset($mode))
                {
                    $mode = null;
                }

                if (!isset($order))
                {
                    $order = null;
                }

                if (!isset($thold))
                {
                    $thold = null;
                }

                reply($pid, $sid, $mode, $order, $thold);
                break;

        case translate("Preview"):
                if (!isset($xanonpost))
                {
                    $xanonpost = null;
                }

                replyPreview ($pid, $sid, $subject, $comment, $xanonpost, $mode, $order, $thold, $posttype);
                break;

        case translate("Ok!"):

                if ( empty( $xanonpost ) ) { $xanonpost = 0; }
                if ( empty( $host_name ) ) { $host_name = NULL; }


                CreateTopic($xanonpost, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype);
                break;

        case "moderate":

                if (_MPN_ADMIN || $moderate == 2)
                {
                    while(list($tdw, $emp) = each($HTTP_POST_VARS))
                    {
                        if (eregi("dkn", $tdw))
                        {
                            $emp = explode(":", $emp);

                            if ($emp[1] != 0)
                            {
                                $tdw = ereg_replace("dkn", "", $tdw);

                                $q = "UPDATE ".$mpnTables['comments']." SET";
                                $update = false;

                                if (($emp[1] == 9) && ($emp[0]>=0))
                                {
                                    # Overrated
                                    $q .= " score=score-1 where tid=$tdw";
                                    $update = true;
                                }
                                elseif (($emp[1] == 10) && ($emp[0]<=4))
                                {
                                    # Underrated
                                    $q .= " score=score+1 where tid=$tdw";
                                    $update = true;
                                }
                                elseif (($emp[1] > 4) && ($emp[0]<=4))
                                {
                                    $q .= " score=score+1, reason=$emp[1] where tid=$tdw";
                                    $update = true;
                                }
                                elseif (($emp[1] < 5) && ($emp[0] > -1))
                                {
                                    $q .= " score=score-1, reason=$emp[1] where tid=$tdw";
                                    $update = true;
                                }
                                elseif (($emp[0] == -1) || ($emp[0] == 5))
                                {
                                    $q .= " reason=$emp[1] where tid=$tdw";
                                    $update = true;
                                }

//                                if (strlen($q) > 20)
                                if ($update === true)
                                {
                                    mysql_query("$q");
                                }
                            }
                        }
                    }
                }

                $_SERVER['F_LIB'] -> redirectRequest( 'article.php?sid=' . $sid . '&mode=' . $mode . '&order=' . $order . '&thold=' . $thold );

                break;

        case "showreply":
                DisplayTopic($sid, $pid, $tid, $mode, $order, $thold);
                break;

        default:

                if ( ! isset( $mode ) ) { $mode = 'thread'; }
                if ( ! isset( $order ) ) { $order = 0; }
                if ( ! isset( $thold ) ) { $thold = 0; }

                if ((isset($tid)) && (!isset($pid)))
                {
                        singlecomment($tid, $sid, $mode, $order, $thold);
                }
                else
                {
                        if(!isset($pid)) $pid=0;
                        if(!isset($tid))
                        {
                            $tid = null;
                        }

                        if (!isset($thold))
                        {
                            $thold = null;
                        }

                        DisplayTopic($sid, $pid, $tid, $mode, $order, $thold);

                }
                break;
}

?>
