<?php

######################################################################
# Modulo Splatt Forum per PHP-NUKE 
#-------------------------
# Versione: 3.2
#
# Copyright (c) 2002 by:
#
# Giorgio Ciranni (~Splatt~)
# (http://www.splatt.it)
# (webmaster@splatt.it)
#
# Supporto tecnico disponibile sul Forum di www.splatt.it
######################################################################
# Splatt Forum 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.
# Splatt Forum is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
# 02111-1307  USA
######################################################################

$module_name = "$name";

include("config.php");
include("modules/".$module_name."/functions.php");
include("modules/".$module_name."/auth.php");
include("header.php");

if($submit) {



        $mod_data = get_userdata($username, $db);
        $moderators = get_moderators($forum, $db);
        reset ($moderators);
        while(list($null, $mods) = each($moderators)) {
                while(list($mod_id, $mod_name) = each($mods)) {

                        if ($mod_data[uid] == $mod_id) {
                                $mod = $mod_id;
                                break 2;
                        }
                }
        }

	

        if ($username == '' || $passwd == '')
                die(""._FENTNIPAS."");

        if($mod != $mod_data[uid] && $level >= 2)
                die(""._FTUNOMOD."");




 
$dbpass=$mod_data[pass];
$non_crypt_pass = $passwd;
$old_crypt_pass = crypt($passwd,substr($dbpass,0,2));
$password = md5($passwd);
	if (($dbpass == $non_crypt_pass) OR ($dbpass ==
$old_crypt_pass) OR ($dbpass == $password))
		{
			$password=$dbpass;
		}


    if($mod_data[pass] != $password )
		die(""._ERRORPASS."");

    echo "<center>";

        switch($mode) {
                case 'del':
                        $sql = "DELETE FROM ${prefix}_posts WHERE topic_id = '$topic'";
                        if(!$result = mysql_query($sql, $db))
                                die("Error - Could not remove posts from the database!");
                        $sql = "DELETE FROM ${prefix}_forumtopics WHERE topic_id = '$topic'";
                        if(!$result = mysql_query($sql, $db))
                                die("Error - Could not remove posts from the database!");
                        echo ""._FTOPDEL."<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewforum&forum=$forum\">"._FCLIKTORET."</a><br><a href=\"modules.php?op=modload&name=".$module_name."&file=index\">"._CLIKRET."</a>";
                break;
                case 'move':
                        $sql = "UPDATE ${prefix}_forumtopics SET forum_id = '$newforum' WHERE topic_id = '$topic'";
                        if(!$r = mysql_query($sql, $db))
                                die("Error - Could not move selected topic to selected forum. Please go back and try again.");
                        $sql = "UPDATE ${prefix}_posts SET forum_id = '$newforum' WHERE topic_id = '$topic'";
                        if(!$r = mysql_query($sql, $db))
                                die("Error - Could not move selected topic to selected forum. Please go back and try again.");
                        echo ""._FTOPMOV."<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$topic&forum=$newforum\">"._CLIKVUPD."</a><br><a href=\"modules.php?op=modload&name=".$module_name."&file=index\">"._CLIKRET."</a>";
                break;
                case 'lock':
                        $sql = "UPDATE ${prefix}_forumtopics SET topic_status = 1 WHERE topic_id = '$topic'";
                        if(!$r = mysql_query($sql, $db))
                                die("Error - Could not lock the selected topic. Please go back and try again.");
                        echo ""._FTOPLOK."<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$topic&forum=$forum\">"._CLIKVUPD."</a><br><a href=\"modules.php?op=modload&name=".$module_name."&file=index\">"._CLIKRET."</a>";
                break;
                case 'unlock':
                        $sql = "UPDATE ${prefix}_forumtopics SET topic_status = '0' WHERE topic_id = '$topic'";
                        if(!$r = mysql_query($sql, $db))
                                die("Error - Could not unlock the selected topic. Please go back and try again.");
                        echo ""._FTOPSBLOK."<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$topic&forum=$forum\">"._CLIKVUPD."</a><br><a href=\"modules.php?op=modload&name=".$module_name."&file=index\">"._CLIKRET."</a>";
                break;
                case 'viewip':
                        $sql = "SELECT u.uname, p.poster_ip FROM ".$user_prefix."_users u, ${prefix}_posts p WHERE p.post_id = '$post' AND u.uid = p.poster_id";
                        if(!$r = mysql_query($sql, $db))
                                die("Error - Could not query the database. <BR>Error: mysql_error()");
                        if(!$m = mysql_fetch_array($r))
                                die("Error - No such user or post in the database.");
?>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACEING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD BGCOLOR="<?php echo $table_bgcolor?>">
<TABLE BORDER="0" CELLPADDING="1" CELLSPACEING="1" WIDTH="100%">
<TR BGCOLOR="<?php echo $bgcolor3?>" ALIGN="LEFT">
        <TD COLSPAN="2" ALIGN="CENTER"><?php echo _FUSIP;?></TD>
</TR>
<TR BGCOLOR="<?php echo $bgcolor1?>" ALIGN="LEFT">
        <TD><?php echo _FNICK;?></TD>
        <TD><?php echo $m[uname]?></TD>
</TR>
<TR BGCOLOR="<?php echo $bgcolor1?>" ALIGN="LEFT">
        <TD><?php echo _FFUSIP;?></TD>
        <TD><?php echo $m[poster_ip]?></TD>
</TR>
</TABLE></TD></TR></TABLE>
<A HREF="javascript:history.go(-2)">Back</a>
<?php
                break;

        }
        echo "</center>";
}
else {
               $user = base64_decode($user);
               $userdata = explode(":", $user);
               $userdata = get_userdata_from_id($userdata[0], $db);


                $moderators = get_moderators($forum, $db);
                reset ($moderators);
                while(list($null, $mods) = each($moderators)) {
                        while(list($mod_id, $mod_name) = each($mods)) {

                                if ($userdata[0] == $mod_id) {
                                        $mod = $mod_id;
                                        break 2;
                                }
                        }
                }

               if ($userdata[user_level] >= 2 && $userdata[uid] == $mod || $userdata[user_level] == 3) {
?>
<FORM ACTION="modules.php?op=modload&name=<?php echo $module_name?>&file=topicadmin" METHOD="POST">
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="100%"><TR><TD>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
<TR BGCOLOR="<?php echo $bgcolor3?>" ALIGN="LEFT">
<?php
        switch($mode) {
                case 'del':
?>
        <TD COLSPAN=2><B><?php echo _FREDVIS;?></b><br><?php echo _FIDENTMOD; ?><br><FONT SIZE=1><i><?php echo _FONCEDEL;?></FONT></i></TD>
<?php
                break;
                case 'move':
?>
        <TD COLSPAN=2><B><?php echo _FREDVIS;?></b><br><?php echo _FIDENTMOD; ?><br><FONT SIZE=1><i><?php echo _FONCEMOV;?></i></FONT></TD>
<?php
                break;
                case 'lock':
?>
        <TD COLSPAN=2><B><?php echo _FREDVIS;?></b><br><?php echo _FIDENTMOD; ?><br><FONT SIZE=1><i><?php echo _FONCELOK;?></FONT></i></TD>
<?php
                break;
                case 'unlock':
?>
        <TD COLSPAN=2><B><?php echo _FREDVIS;?></b><br><?php echo _FIDENTMOD; ?><br><FONT SIZE=1><i><?php echo _FONCEUNLOK;?></i></FONT></TD>
<?php
                break;
                case 'viewip':
?>
        <TD COLSPAN=2><B><?php echo _FREDVIS;?></b><?php echo _FIDENTMOD; ?></FONT></TD>
<?php
                break;
        }
?>
</TR>
<TR>
        <TD BGCOLOR="<?php echo $bgcolor3?>">User:</TD>
        <TD BGCOLOR="<?php echo $bgcolor1?>"><INPUT CLASS=textbox TYPE="TEXT" NAME="username" SIZE="25" MAXLENGTH="40"></TD>
</TR>
<TR>
        <TD BGCOLOR="<?php echo $bgcolor3?>">Password:</TD>
        <TD BGCOLOR="<?php echo $bgcolor1?>"><INPUT CLASS=textbox TYPE="PASSWORD" NAME="passwd" SIZE="25" MAXLENGTH="25"></TD>
</TR>
<?php
        if($mode == 'move') {
?>
<TR>
        <TD BGCOLOR="<?php echo $bgcolor3?>"><?php echo _FMOVETO;?></TD>
        <TD BGCOLOR="<?php echo $bgcolor1?>"><SELECT NAME="newforum" SIZE="0">
<?php
        $sql = "SELECT forum_id, forum_name FROM ${prefix}_forums WHERE forum_id != '$forum' ORDER BY forum_id";
        if($result = mysql_query($sql, $db)) {
                if($myrow = mysql_fetch_array($result)) {
                        do {
                                echo "<OPTION VALUE=\"$myrow[forum_id]\">$myrow[forum_name]</OPTION>\n";
                        } while($myrow = mysql_fetch_array($result));
                }
                else {
                        echo "<OPTION VALUE=\"-1\">"._FNOMORE."</OPTION>\n";
                }
        }
        else {
                echo "<OPTION VALUE=\"-1\">Database Error</OPTION>\n";
        }
?>
        </SELECT></TD>
</TR>
<?php
        }
?>
<TR BGCOLOR="<?php echo $bgcolor3?>">
        <TD COLSPAN="2" ALIGN="CENTER">
<?php
        switch($mode) {
                case 'del':
?>
                <INPUT TYPE="HIDDEN" NAME="mode" VALUE="del">
                <INPUT TYPE="HIDDEN" NAME="topic" VALUE="<?php echo $topic?>">
                <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
                <INPUT TYPE="SUBMIT" NAME="submit" VALUE="<?php echo _FDELT;?>">
<?php
                break;
                case 'move':
?>
                <INPUT TYPE="HIDDEN" NAME="mode" VALUE="move">
                <INPUT TYPE="HIDDEN" NAME="topic" VALUE="<?php echo $topic?>">
                <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
                <INPUT TYPE="SUBMIT" NAME="submit" VALUE="<?php echo _FMOVET;?>">
<?php
                break;
                case 'lock':
?>
                <INPUT TYPE="HIDDEN" NAME="mode" VALUE="lock">
                <INPUT TYPE="HIDDEN" NAME="topic" VALUE="<?php echo $topic?>">
                <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
                <INPUT TYPE="SUBMIT" NAME="submit" VALUE="<?php echo _LOCKTHIS;?>">
<?php
                break;
                case 'unlock':
?>
                <INPUT TYPE="HIDDEN" NAME="mode" VALUE="unlock">
                <INPUT TYPE="HIDDEN" NAME="topic" VALUE="<?php echo $topic?>">
                <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
                <INPUT TYPE="SUBMIT" NAME="submit" VALUE="<?php echo _UNLOCKTHIS;?>">
<?php
                break;
                case 'viewip':
?>
                <INPUT TYPE="HIDDEN" NAME="mode" VALUE="viewip">
                <INPUT TYPE="HIDDEN" NAME="post" VALUE="<?php echo $post?>">
                <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
                <INPUT TYPE="SUBMIT" NAME="submit" VALUE="<?php echo _FVIEWIP;?>">
<?php
                break;
        }
?>
<INPUT TYPE="HIDDEN" NAME="level" VALUE="<?php echo $userdata[user_level];?>">
</TD></TR>
</FORM>
</TABLE></TD></TR></TABLE></TD></TR></TABLE>
<?php
}
else {
?>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING=0" ALIGN="CENTER" VALIGN="TOP" WIDTH="100%"><TR><TD>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING=1" WIDTH="100%">
<TR BGCOLOR="<?php echo $bgcolor3?>">
<TD ALIGN="CENTER">
<?php echo _FTUNOMOD;?><br>
<A HREF="javascript:history.go(-1)">back</a>
</TD>
</TR>
</TABLE></TD></TR></TABLE>

<!-- Don't touch the lines below please! --> 
<?php
echo"<p align=\"center\">Splatt Forum &copy; By: <a href=\"http://www.splatt.it\" target=\"_blank\">Splatt.it</a><br>Version: $forumver</font></p><br><br>";
}
}

include('footer.php');
?>








