<?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                                           |
// +----------------------------------------------------------------------+
// $Id: user.php,v 1.35.2.34 2004/09/12 15:51:38 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.       */
/************************************************************************/

define( '_MPN_PAGE_ID', 8 );

if ( _MPN_USER ) { $index = 2; }

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;
}

function nav()
{
    //Kiril: broke this section into 2 lines and removed the table.  Added a few <br> for badly spaced form buttons on login page.

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

        echo "<a class='bare' href='./user.php&#063;op&#061;edituser'>\n";

            echo "<span class='button'>\n";

                 echo translate( 'Edit Your Info' );

            echo "</span>\n";

        echo "</a>&nbsp;&nbsp;&nbsp;\n";

        echo "<a class='bare' href='./user.php&#063;op&#061;edithome'>\n";

            echo "<span class='button'>\n";

                 echo translate( 'Homepage Options' );

            echo "</span>\n";

        echo "</a>&nbsp;&nbsp;&nbsp;\n";

        echo "<a class='bare' href='./user.php&#063;op&#061;editcomm'>\n";

            echo "<span class='button'>\n";

                 echo translate( 'Comments' );

            echo "</span>\n";

        echo "</a>&nbsp;&nbsp;&nbsp;\n";

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

        echo "<a class='bare' href='./user.php&#063;op&#061;chgtheme'>\n";

            echo "<span class='button'>\n";

                 echo translate( 'Select A Theme' );

            echo "</span>\n";

        echo "</a>&nbsp;&nbsp;&nbsp;\n";

        echo "<a class='bare' href='./user.php&#063;op&#061;logout'>\n";

            echo "<span class='button'>\n";

                 echo translate( 'Logout' );

            echo "</span>\n";

        echo "</a>\n";

    echo "</div>\n";

    echo "<br />\n";

}

function userCheck($uname, $email)
{
        global $stop, $mpn_uname_test_level, $mpnTables;

        // Checks

        $verify_check_ary = $_SERVER['SAN'] -> verifyContent( array( $uname, $email ), 3 );
        $return_ary = array( 'page' => 'user.php', 'op' => 'register' );

        // Check For Empty uname and email

        if ( in_array( (bool)FALSE, $verify_check_ary ) )
        {
            goBack( translate( 'You Failed To Include Required Information' ), TRUE, $return_ary );
            exit;
        }

        // Check For Valid Email

        $dbemail = mysql_num_rows( mysql_query( "select email from ".$mpnTables['users']." where email='" . addslashes( $email ) . "'" ) ) > 0;

        if ( $email == '' || $dbemail || ! $_SERVER['SAN'] -> verifyContent( $email, 2 ) )
        {
            $msg = ( $dbemail ) ? ( translate( 'Email Already Taken' ) ) : ( translate( 'Invalid Email' ) );
            goBack( $msg, TRUE, $return_ary );
            exit;
        }

        // User Nickname Checks

        $strict = "^a-zA-Z0-9_";
        $medium = $strict."<>,.$%#@!\'\"";
        $loose = $medium."?{}\[\]\(\)\^&*`~;:\\+=";

        switch($mpn_uname_test_level)
        {
                case 0:
                        $restriction = $strict;
                        break;
                case 1:
                        $restriction = $medium;
                        break;
                case 2:
                        $restriction = $loose;
                        break;
        }

        $uname_charachk = ereg( "[".$restriction."-]" , $uname );

        $dbuname = mysql_num_rows( mysql_query( "select uname from ".$mpnTables['users']." where uname='$uname'" ) ) > 0;

        $uname_len = strlen($uname) > 25;

       $uname_restrict = eregi( "^((root)|(adm)|(linux)|(webmaster)|(admin)|(god)|(administrator)|(administrador)|(nobody)|(anonymous)|(anonimo)|(anónimo)|(operator))$" , $uname );

        $uname_sp = (bool)FALSE !== strrpos( $uname,' ' );

        if ( $uname_charachk || $dbuname || $uname_len || $uname_restrict || $uname_sp )
        {
            switch( (bool)TRUE )
            {
                case $uname_charachk:

                    $msg = translate( 'Invalid Nickname' );

                break;

                case $dbuname:

                    $msg = translate( 'Nickname Already Taken' );

                break;

                case $uname_len:

                    $msg = translate( 'Nickname Must Be Less Than 25 Characters Long' );

                break;

                case $uname_restrict:

                    $msg = translate( 'Nickname Is Restricted' );

                break;

                case $uname_sp:

                    $msg = translate( 'Nickname Cannot Contain Spaces' );

                break;

                default:

                    $msg = translate( 'Nickname Is Invalid' );

                break;

            } // End Message Switch

            goBack( $msg, TRUE, $return_ary );
            exit;
        }

} // End userCheck


function confirmNewUser( $uname, $email )
{
    global $stop;

    userCheck( $uname, $email );

    if ( isset( $stop ) ) { goBack( $stop . '**' . __FILE__ . '***' .  __LINE__ ); }

    include 'header.php';

    echo '<h1>' . translate( 'New User Confirmation' ) . '</h1>' . "\n";

    OpenTable();

    echo '<div class="center">' . "\n";

        echo '<h2>' . translate( 'You Entered The Following Information' ) . '</h2>' . "\n";
        echo '<hr class="w60" />' . "\n";

        echo '<b>' . translate( 'User Nick Name' ) . ':</b> ' . $uname . "\n";
        echo '<br /><br />' . "\n";
        echo '<b>' . translate( 'Your Email Address' ) . ':</b> ' . $email . "\n";

        echo '<br /><hr class="w60" /><br />' . "\n";

        echo translate( 'Is This Information Correct' ) . '?';

        echo '<form action="user.php" method="post">' . "\n";

            echo '<input type="hidden" name="uname" value="' . $uname . '" />' . "\n";
            echo '<input type="hidden" name="email" value="' . $email . '" />' . "\n";

            echo "<input type='hidden' name='clickit_form' value='user_sig' />\n";
            echo "<input type='hidden' name='stripit_form' value='uname|email' />\n";
            echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

            echo '<input type="hidden" name="op" value="finish" />' . "\n";

            echo '<input class="button" type="submit" value="' . translate( "Yes" ) . '" />' . "\n";
            echo '&nbsp;  &nbsp;';
            echo '<input class="button" type="submit" name="editdata" value="' . translate( "No" ) . '" />' . "\n";

        echo '</form>' . "\n";

    echo '</div>' . "\n";

    CloseTable();

    include 'footer.php';

} // End Function

function finishNewUser( $uname, $email )
{
    global $stop, $EditedMessage, $adminmail, $sitename;
    global $mpn_new_user_notify, $mpn_mail_newuser_password;
    global $mpnTables, $mail, $registration_email_text;

    if ( isset( $_POST['editdata'] ) && $_POST['editdata'] == 'No' )
    {
        $msg = translate( 'Return To User Registration Form' );
        $msg .= '<br />';
        $msg .= translate( 'To Edit Your Information' );
        $return_ary = array( 'page' => 'user.php', 'op' => 'register' );
        goBack( $msg, FALSE, $return_ary );
    }

    userCheck( $uname, $email );

    if ( isset( $stop ) ) { goBack( $stop . '**' . __FILE__ . '***' .  __LINE__ ); }

    $user_regdate = date("Y-m-d");
    $makepass = $_SERVER['F_LIB'] -> generateKey( 8, FALSE );
    $cryptpass = md5( $makepass );

    $sql = 'SELECT ( MAX(uid) + 1 ) AS new_userid
            FROM ' . $mpnTables['users'] . '
            WHERE uid >= 1';

    $result = mysql_query( $sql );

    if ( ! $result || ! @mysql_data_seek( $result, 0 ) )
    {
        goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
    }

    list( $new_userid ) = mysql_fetch_row( $result );

    if ( $new_userid == 1 ) { $new_userid++; }

    $sql = 'INSERT INTO ' . $mpnTables['users'] . '
            SET
                uid = ' . $new_userid . '
              , uname = "' . $uname . '"
              , pass = "' . $cryptpass . '"
              , email = "' . $email . '"
              , user_regdate = "' . $user_regdate . '"
              , user_avatar = "blank.gif"
              , user_from_flag = "blank.gif"
              , user_viewemail = 0
              , allowemail = 1';

    $sql_1 = 'INSERT
              INTO ' . $mpnTables['users_status'] . '
                (uid, posts, attachsig, rank, level)
              VALUES
                ( ' . $new_userid . ', 0, 0, 0, 1 )';

    if ( ! @mysql_query( $sql ) || ! @mysql_query( $sql_1 ) )
    {
        $sql = 'DELETE
                FROM ' . $mpnTables['users'] . '
                WHERE uid = ' . $new_userid;

        $sql_1 = 'DELETE
                  FROM ' . $mpnTables['users_status'] . '
                  WHERE uid = ' . $new_userid;

        @mysql_query( $sql );
        @mysql_query( $sql_1 );

        goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
    }

    if ( $mpn_new_user_notify == 1 )
    {
        $subject = translate("New user registration at ") . $sitename;
        $message = $uname . translate(" has just registered!");
        $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();
        $mail->ClearAddresses();
    }

    if ( $mpn_mail_newuser_password == 1 )
    {
        $message  = translate('Welcome to ') . $sitename . "!\n\n";
        $message .= translate('You or someone else has used your email account ') . $email;
        $message .= translate(' to register an account at ') . $sitename . ".\n";
        $message .= translate('The following is the member information:') . "\n\n";
        $message .= translate('-Nickname: ') . $uname . "\n";
        $message .= translate('-Password: ') . $makepass;
        $subject  = translate('User Password for ') . $uname;
        $message .= "\n\n\n";
        $message .= $registration_email_text;

        $mail->From = $adminmail;
        $mail->FromName = $sitename . translate(' Mailer');
        $mail->AddAddress($email, $uname);
        $mail->Subject = stripslashes($subject);
        $mail->Body = nl2br( stripslashes($message) );
        $mail->AltBody = strip_tags( stripslashes($message) );
        $mail->Send();
        $mail->ClearAddresses();

        goHome( translate("You are now registered. You should receive your password at the email account you provided.") );
        exit;
    }

    include 'header.php';

    echo translate( 'Your username is: ' ) . '<b>' . $uname . '</b><br />';
    echo translate( 'Your password is: ' ) . '<b>' . $makepass . '</b><br /><br />';

    echo translate( 'Please Login to change your info' );
    echo '<br /><br />' . "\n";

    echo userLoginForm( 'center', FALSE );

    include 'footer.php';

} // End Function


function userinfo($uname, $bypass=0)
{
        global $sitename, $mpnTables, $phpEx, $bgcolor1, $bgcolor2, $bgcolor3, $anonymous;

        include './header.php';

        if ( $bypass == 1 && $uname != $anonymous && $uname == $GLOBALS['uinf']['uname'] )
        {
            nav();
            OpenTable();
            echo "<center><B>$uname, ".translate("Welcome to")." $sitename !</B><br><br>";
            echo "".translate("This is your personal page")."</center><br><br>";
        }
        else
        {
                OpenTable();
                echo "<center><B>".translate("Information For")." $uname</B><br><br>";
        }

       $result = mysql_query("select femail, url, bio, user_avatar, user_icq, user_aim, user_yim, user_msnm, user_from, user_from_flag, user_occ, user_intrest, user_sig from ".$mpnTables['users']." where uname='$uname'");

        if ( ! ( $userinfo = mysql_fetch_array($result) ) || $userinfo == '' )
        {
            goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
        }

        // Kiril: New Sanitizer

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

        if ( $userinfo['user_sig'] != '' )
        {
            $_SERVER['SAN'] -> adjustFormat( $userinfo['user_sig'], 3, 10 );
        }

        // End New Saintizer

        if((mysql_num_rows($result)==1) && ($userinfo['url'] || $userinfo['femail'] || $userinfo['bio'] || $userinfo['user_avatar'] || $userinfo['user_icq'] || $userinfo['user_aim'] || $userinfo['user_yim'] || $userinfo['user_msnm'] || $userinfo['user_from'] || $userinfo['user_occ'] || $userinfo['user_intrest'] || $userinfo['user_sig']))
        {

            echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=5><tr align = \"center\" valign = \"top\">\n";

            if ($userinfo['user_avatar']) echo "<td><img src=\"images/forum/avatar/" . $userinfo['user_avatar'] . "\"></td>\n";

            if ($userinfo['user_from_flag'] != '' && $userinfo['user_from_flag'] != 'blank.gif' ) echo "<td><img src=\"images/flags/" . $userinfo['user_from_flag'] . "\" ALIGN=\"absmiddle\"></td><br><br>\n";
echo "</CENTER></TD><TD><TABLE BORDER=0 WIDTH=100% CELLPADDING=2 CELLSPACING=3 BGCOLOR=\"$bgcolor3\">";

            echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Nickname")." : </TD><TD>$uname</TD></TR>\n";
            if ($userinfo['url']) { echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("My HomePage:")." </TD><TD><a href=\"" . $userinfo['url'] . "\" TARGET=\"_blank\">" . $userinfo['url'] . "</a></TD></TR>\n"; }
            if ($userinfo['femail']) { echo "<TR BGCOLOR=\"$bgcolor1\"><TD WIDTH=\"25%\">".translate("My E-Mail:")." </TD><TD><a href=\"mailto:" . $userinfo['femail'] . "\">" . $userinfo['femail'] . "</a></TD></TR>\n"; }
            if ($userinfo['user_icq']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Your ICQ: ")." </TD><TD>" . $userinfo['user_icq'] . "</TD></TR>\n";
            if ($userinfo['user_aim']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD> ".translate("Your AIM: ")." </TD><TD>" . $userinfo['user_aim'] . "</TD></TR>\n";
            if ($userinfo['user_yim']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Your YIM: ")." </TD><TD>" . $userinfo['user_yim'] . "</TD></TR>\n";
            if ($userinfo['user_msnm']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Your MSNM: ")." </TD><TD>" . $userinfo['user_msnm'] . "</TD></TR>\n";
            if ($userinfo['user_from']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Location: ")." </TD><TD>" . $userinfo['user_from'] . "</TD></TR>\n";
            if ($userinfo['user_occ']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Occupation: ")." </TD><TD>" . $userinfo['user_occ'] . "</TD></TR>\n";
            if ($userinfo['user_intrest']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD>".translate("Interest: ")." </TD><TD>" . $userinfo['user_intrest'] . "</TD></TR>\n";
            //$userinfo['user_sig'] = nl2br($userinfo['user_sig']);


            if ($userinfo['user_sig']) echo "<TR BGCOLOR=\"$bgcolor1\"><TD COLSPAN=2><b>".translate("Signature: ")."</b><BR>" . $userinfo['user_sig'] . "</TD></TR>\n";
            if ($userinfo['bio']) { echo "<TR BGCOLOR=\"$bgcolor1\"><TD COLSPAN=2><b>".translate("Extra Info:")."</b><BR>" . $userinfo['bio'] . "</TD></TR>\n"; }
echo "</TABLE></TD></TR></TABLE>";
echo "<br><center>[ <a href=\"replypmsg.$phpEx?send2=1&to_userid=$uname\">" . sprintf(translate("Send Private Message To %s"), $uname) . "</a> ]</center>";
            echo "</center>";
        }
        else
        {
            echo "<center>".translate("There is no available info for")." $uname</center>";
        }

        CloseTable();
        echo "<center><br><br>";
        OpenTable();
        echo "<b>".translate("Last 10 comments by")." $uname:</b><br>";
        $result = mysql_query("select tid, sid, subject from ".$mpnTables['comments']." where name='$uname' order by tid DESC limit 0,10");
        while(list($tid, $sid, $subject) = mysql_fetch_row($result)) {
            echo "<li><a href=article.$phpEx?thold=-1&mode=flat&order=0&sid=$sid#$tid>$subject</a><br>";
        }
        CloseTable();
        echo "<br><br>";
        OpenTable();
        echo "<b>".translate("Last 10 news submissions sent by")." $uname:</b><br>";
        $result = mysql_query("select sid, title from ".$mpnTables['stories']." where informant='$uname' order by sid DESC limit 0,10");
        while(list($sid, $title) = mysql_fetch_row($result)) {
            echo "<li><a href=article.$phpEx?sid=$sid>$title</a><br>";
        }
        CloseTable();
        echo "</center>";
        include("footer.$phpEx");
}

function main()
{
    global $mpn_split_userpage;

    $showreg = ( $_REQUEST['op'] == 'register' || $mpn_split_userpage == 0 ) ? ( (bool)TRUE ) : ( (bool)FALSE );

    if ( _MPN_USER )
    {
        userinfo( $GLOBALS['uinf']['uname'], 1 );
        exit;
    }

    include 'header.php';

    if ( ( $_REQUEST['op'] != 'register' && $mpn_split_userpage == 0 ) || ! $showreg )
    {
        echo userLoginForm();

        echo lostPassword();
    }

    if ( $showreg )
    {
        if ( ! empty( $_POST ) )
        {
            extract( $_POST );
        }
        else
        {
            $tmp_ary = array( 'uname', 'email' );

            foreach( $tmp_ary as $v )
            {
                ${$v} = '';
            }

            unset( $tmp_ary );
        }

        echo '<br /><br />' . "\n";
        echo '<h1>' . translate ( 'New User Registration' ) . '</h1>' . "\n";
        echo '<hr class="w80" /><br />' . "\n";

        echo getUserRegForm( $uname, $email );
    }

    include 'footer.php';

} // End Function

function logout()
{
    $cktype = 'user';
    @( include_once __ROOT__ . 'logout.php' )
      OR goBack( translate( 'Include Error' ) );
    exit;
}

function docookie( $uid, $upass )
{
    makeUserCookie( $uid, $upass );
}

function login( $uname, $pass, $redirect = NULL )
{
    $redirect = 'user.php?op=userinfo&bypass=1&uname=' . $uname;

    userLogin( $uname, $pass, $redirect );
}


function edituser()
{
        global $mpnTables,$phpEx;

        if ( ! _MPN_USER ) { $_SERVER['F_LIB'] -> redirectRequest( 'user.php' ); }
        $index = 2;
        $userinfo = $GLOBALS['uinf'];

        if ( ! isset( $userinfo['user_avatar'] ) || $userinfo['user_avatar'] == '' ) { $userinfo['user_avatar'] = 'pix.gif'; }

        if ( ! isset( $userinfo['user_from_flag'] ) || $userinfo['user_from_flag'] == '' ) { $userinfo['user_from_flag'] = 'pix.gif'; }

        if ( ! $_SERVER['SAN'] -> validateInput( $userinfo['url'], 1 ) || ( 0 === strcasecmp( $userinfo['url'], 'http://' ) || (bool)FALSE !== strpos( $userinfo['url'], 'ftp://' ) || (bool)FALSE !== strpos( $userinfo['url'], 'https://' ) ) )
        {
            $userinfo['url'] = '';
        }

        include("header.$phpEx");

        nav();
        OpenTable();
        ?>
        <table cellpadding=8 border=0><tr><td>
        <?php echo "<form name=\"Register\" action=\"user.$phpEx\" method=\"post\">"; ?>
        <b><?php echo translate("Real Name"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="name" value="<?PHP echo $userinfo['name']; ?>" size=30 maxlength=60><br><br>
        <b><?php echo translate("Real Email"); ?></b> <?php echo translate("(required)"); ?><br>
        <?php echo translate("(This Email will not be public but is required, will be used to send your password if you lost it)"); ?><br>
       <input class=textbox type="text" name="email" value="<?PHP echo $userinfo['email']; ?>" size=30 maxlength=60><br><br>
        <b><?php echo translate("Fake Email"); ?></b> <?php echo translate("(optional)"); ?><br>
        <?php echo translate("(This Email will be public. Just type what you want, Spam proof)"); ?><br>
        <input class=textbox type="text" name="femail" value="<?PHP echo $userinfo['femail']; ?>" size=30 maxlength=60><br><br>
        <b><?php echo translate("Your HomePage"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="url" value="<?PHP echo $userinfo['url']; ?>" size=30 maxlength=100><br><br>

        <b><?php echo translate("Your Avatar"); ?></b> <?php echo translate("(optional)"); ?>&nbsp;[
        <?php echo "<a href=\"user.$phpEx?op=avatarlist\">".translate("List")."</a> ]<br>";

        // REF: getShowImageSelect( $rdir, $formname, $selname, $selimg, $imgtar )

        echo $_SERVER['F_LIB'] -> getShowImageSelect( 'images/forum/avatar/', 'Register', 'user_avatar', $userinfo['user_avatar'], 'uavatar' );

        ?>
        <br><br>
        <b><?php echo translate("Your ICQ"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_icq" value="<?PHP echo $userinfo['user_icq']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Your AIM"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_aim" value="<?PHP echo $userinfo['user_aim']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Your YIM"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_yim" value="<?PHP echo $userinfo['user_yim']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Your MSNM"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_msnm" value="<?PHP echo $userinfo['user_msnm']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Your Location"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_from" value="<?PHP echo $userinfo['user_from']; ?>" size=30 maxlength=100><br><br>

        <b><?php echo translate("Your Flag"); ?></b> <?php echo translate("(optional)"); ?><br>
        <?php

		// REF: getShowImageSelect( $rdir, $formname, $selname, $selimg, $imgtar )

		echo $_SERVER['F_LIB'] -> getShowImageSelect( 'images/flags/', 'Register', 'user_from_flag', $userinfo['user_from_flag'], 'uflag' );

        ?>

        <br /><br /><b><?php echo translate("Your Occupation"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_occ" value="<?PHP echo $userinfo['user_occ']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Your Interest"); ?></b> <?php echo translate("(optional)"); ?><br>
        <input class=textbox type="text" name="user_intrest" value="<?PHP echo $userinfo['user_intrest']; ?>" size=30 maxlength=100><br><br>
        <b><?php echo translate("Signature"); ?></b> <?php echo translate("(optional)"); ?><br>
        <?php echo translate("(255 characters max. Type your signature with HTML coding)"); ?><br>
        <textarea class=textbox wrap=virtual cols=40 rows=5 name=user_sig><?PHP echo $userinfo['user_sig']; ?></TEXTAREA><br><br>
        <?php
        $asig = mysql_query("select u.allowemail, us.attachsig from ".$mpnTables['users']." u,".$mpnTables['users_status']." us where us.uid='" . $userinfo['uid'] . "' and u.uid = us.uid");
        list($allowemail, $attsig) = mysql_fetch_row($asig);
        if ($attsig == 1) {
            $sel = "checked";
        } else {
            $sel = "";
        }

        if ($allowemail == '1') {
            $esel = 'checked';
        } else {
            $esel = '';
        }
        ?>
        <input type=checkbox name=attach <?php echo $sel ?>> <?php echo translate("Show signature"); ?>
        <br><br>
        <input type=checkbox name=MLMail <?php echo $esel; ?>> <?php echo translate("Receive E-Mail from Mailing List"); ?>
        <br><br>
        <b><?php echo translate("Extra Info"); ?></b> <?php echo translate("(optional)"); ?><br>
        <?php echo translate("(255 characters max. Type what others can know about yourself)"); ?><br>
        <textarea class=textbox wrap=virtual cols=40 rows=5 name=bio><?PHP echo $userinfo['bio']; ?></TEXTAREA>
        <br><br>
        <b><?php echo translate("Password"); ?></b> <?php echo translate("(type a new password twice to change it)"); ?><br>
        <input class=textbox type="password" name="pass" size=10 maxlength=20> <input class=textbox type="password" name="vpass" size=10 maxlength=20>
        <br><br>

        <?php

        // Kiril: New Sanitizer

        echo "<input type='hidden' name='clickit_form' value='user_sig' />\n";
        echo "<input type='hidden' name='stripit_form' value='name|uname|email|femail|url|pass|vpass|bio|user_avatar|user_icq|user_occ|user_from|user_from_flag|user_intrest|user_aim|user_yim|user_msnm|attach|MLMail' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End Sanitizer

        ?>

        <input type="hidden" name="uname" value="<?PHP echo $userinfo['uname']; ?>">
        <input type="hidden" name="uid" value="<?PHP echo $userinfo['uid']; ?>">
        <input type="hidden" name="op" value="saveuser">
        <input class='button' type="submit" value="<?php echo translate("Save Changes"); ?>">
        </form></td></tr></table>
        <?PHP
        CloseTable();
        echo "<br><br>";
        include("footer.$phpEx");
}


function saveuser($uid, $name, $uname, $email, $femail, $url, $pass, $vpass, $bio, $user_avatar, $user_icq, $user_occ, $user_from, $user_from_flag, $user_intrest, $user_sig, $user_aim, $user_yim, $user_msnm, $attach, $MLMail) {
    global $EditedMessage, $mpnTables,$phpEx, $minpass, $stop;

    $userinfo = $GLOBALS['uinf'];

    if ( ! is_array( $userinfo ) ) { goBack( translate("Oops, sorry that not allowed!!") ); }

    $chkary = $email;
    $sql = 'SELECT *';

    if ( ( isset( $femail ) && $femail != '' ) )
    {
        $chkary = array( 'email' => $email, 'femail' => $femail );
        $cond = ' || femail = "' . $femail . '" || email = "' . $femail . '"';
    }

    $sql .= ' FROM ' . $mpnTables['users'] . ' WHERE uid != ' . $uid . ' && ( email = "' . $email . '"';

    if ( isset( $cond ) ) { $sql .= $cond; }

    $sql .= ' )';

    $chkmail = mysql_query( $sql );

    if ( mysql_num_rows( $chkmail ) != 0 || ! $_SERVER['SAN'] -> verifyContent( $chkary, 2 ) )
    {
        goBack( translate( 'Invalid Email Or Email Already Taken.' ) );
    }

    if ( ( isset( $pass ) ) && ( $pass != $vpass ) ) { goBack( translate("Both passwords are different. They need to be identical.") ); }

    if ( $pass != '' && strlen( $pass ) < $minpass ) { goBack( translate("Sorry, your password must be at least")." <b>$minpass</b> " . translate( "characters long" ) ); }

    if ( isset( $url ) && $url != '' )
    {
        $url = trim( $url );

        if ( ! $_SERVER['SAN'] -> validateInput( $url, 1 ) || ( 0 === strcasecmp( $url, 'http://' ) || (bool)FALSE !== strpos( $url, 'ftp://' ) || (bool)FALSE !== strpos( $url, 'https://' ) ) )
        {
            $url = '';
        }
        else
        {
            if ( ! stristr( $url, 'http://' ) )
            {
                $url = 'http://' . $url;
            }

            if ( substr( $url, -1 ) !== '/' )
            {
                $url .= '/';
            }
        }
    }

    $mail_list = isset($MLMail) ? 1 : 0;

    if ( $pass != '' )
    {
        $cookie = cookiedecode();
        $oldpass = $cookie[2];
        $result = mysql_query( "select uid, pass from ".$mpnTables['users']." where uname='$uname' and pass='$oldpass' && uid > 1" );

        if ( mysql_num_rows( $result ) === 1 )
        {
            @mysql_query("LOCK TABLES ".$mpnTables['users'] . ", " . $mpnTables['users_status'] . " WRITE");
            $pass = md5($pass);

            $sql_1 = "update ".$mpnTables['users']." set name='$name', email='$email', femail='$femail', url='$url', pass='$pass', bio='$bio', user_avatar='$user_avatar', user_icq='$user_icq', user_occ='$user_occ', user_from='$user_from', user_from_flag='$user_from_flag', user_intrest='$user_intrest', user_sig='$user_sig', user_aim='$user_aim', user_yim='$user_yim', user_msnm='$user_msnm' where uid=" . $userinfo['uid'] . " && uid > 1";

            $a = ( isset( $attach ) && $attach != '' ) ? ( 1 ) : ( 0 );

            $sql_2 = "update ".$mpnTables['users_status']." set attachsig='$a' where uid=" . $userinfo['uid'] . " && uid > 1";

            if ( ! @mysql_query( $sql_1 ) || ! @mysql_query( $sql_2 ) )
            {
                goBack( translate( 'User Information Update Failed' ) );
            }

            @mysql_query("UNLOCK TABLES");

            $result = mysql_query( "select uid, pass from ".$mpnTables['users']." where uname='$uname' and pass='$pass' && uid > 1" );

            $tmp = mysql_fetch_row( $result );

            docookie( $tmp[0], $tmp[1] );

            unset( $tmp );
        }
        else
        {
            goBack( translate( 'Unable To Verify Your Identity' ) );
            exit;
        }
    }
    else
    {
        $sql_1 = "update ".$mpnTables['users']." set name='$name', email='$email', femail='$femail', url='$url', bio='$bio' , user_avatar='$user_avatar', user_icq='$user_icq', user_occ='$user_occ', user_from='$user_from', user_from_flag='$user_from_flag', user_intrest='$user_intrest', user_sig='$user_sig', user_aim='$user_aim', user_yim='$user_yim', user_msnm='$user_msnm', allowemail='$mail_list' where uid=" . $userinfo['uid'] . " && uid > 1";

        $a = ( isset( $attach ) && $attach != '' ) ? ( 1 ) : ( 0 );

        $sql_2 = "update ".$mpnTables['users_status']." set attachsig='$a' where uid=" . $userinfo['uid'] . " && uid > 1 ";

        if ( ! @mysql_query( $sql_1 ) || ! @mysql_query( $sql_2 ) )
        {
            goBack( translate( 'User Information Update Failed' ) );
        }
    }

    $_SERVER['F_LIB'] -> redirectRequest( 'user.php' );

} // End Function

function edithome()
{
        global $phpEx;
        include ("header.$phpEx");
        include ("config.$phpEx");
        $userinfo = $GLOBALS['uinf'];
        nav();
        if($userinfo['theme']=="") {
            $userinfo['theme'] = "$Default_Theme";
        }
        OpenTable();
        echo "
        <form action=\"user.$phpEx\" method=\"post\">
        <b>".translate("News number in the Home")."</b> (max. 127):
        <input class=\"textbox\" type=\"text\" name=\"storynum\" size=3 maxlength=3 value=\"" . $userinfo['storynum'] . "\">
        <br><br>";
        if ($userinfo['ublockon']==1) {
            $sel = "checked";
        }
        else
        {
            $sel = null;
        }

        echo "
        <INPUT type=\"checkbox\" name=\"ublockon\" $sel>
        <B>".translate("Activate Personal Menu")."</B>
        <br>".translate("(Check this option and the following text will appear in the Home)")."
        <br>".translate("(You can use HTML code to put links, for example)")."<br>
        <textarea class=\"textbox\" cols=40 rows=10 name=\"ublock\">" . $userinfo['ublock'] . "</textarea>
        <br><br>\n";

        // Kiril: New Sanitizer

        echo "<input type='hidden' name='clickit_form' value='ublock' />\n";
        echo "<input type='hidden' name='stripit_form' value='ublockon|storynum' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End Sanitizer

        echo "<input type=\"hidden\" name=\"theme\" value=\"" . $userinfo['theme'] . "\">
        <input type=\"hidden\" name=\"uname\" value=\"" . $userinfo['uname'] . "\">
        <input type=\"hidden\" name=\"uid\" value=\"" . $userinfo['uid'] . "\">
        <input type=\"hidden\" name=\"op\" value=\"savehome\">
        <input class='button' type=\"submit\" value=\"".translate("Save Changes!")."\">
        </form>";
        CloseTable();
        include ("footer.$phpEx");
}

function chgtheme()
{
    include_once './header.php';

    echo '<div id="useredittheme">' . "\n";

        nav();

        echo getThemeOptions( FALSE, FALSE );

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

        echo @( include _DP_THEME_PAR . 'theme_info.inc.php' );

    echo '</div>' . "\n";

    include_once './footer.php';

} // End Function


function savetheme()
{
    global $mpnTables, $Default_Theme;

    $tmp = array();

    if ( ( ! _MPN_USER || ! _MPN_ADMIN ) && $GLOBALS['uinf']['uid'] != $_POST['uid'] )
    {
        goBack( translate( 'Unable To Verify Your Identity' ) );
    }

    $t_format = ( ! defined( '_T_BLOCK_FORMAT' ) ) ? ( 0 ) : ( _T_BLOCK_FORMAT );
    $t_layout = ( ! defined( '_T_PAGE_LAYOUT' ) ) ? ( 0 ) : ( _T_PAGE_LAYOUT );

    $tmp['theme'] = ( ! isset( $_POST['theme'] ) ) ? ( $Default_Theme ) : ( $_POST['theme'] );
    $tmp['theme_layout'] = ( ! isset( $_POST['theme_layout'] ) ) ? ( $t_layout ) : ( $_POST['theme_layout'] );
    $tmp['theme_format'] = ( ! isset( $_POST['theme_format'] ) ) ? ( $t_format ) : ( $_POST['theme_format'] );

    foreach ( $tmp as $key => $v )
    {
        $sql = 'UPDATE ' . $mpnTables['users'] . '
                SET ' . $key . ' = "' . $v . '"
                WHERE uid = ' . $_POST['uid'];

        if ( ! @mysql_query( $sql ) )
        {
            goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
            exit;
        }
    }

    $redirect = ( isset( $_POST['redirect'] ) ) ? ( $_POST['redirect'] ) : ( 'user.php?theme=' . $theme );
    $_SERVER['F_LIB'] -> redirectRequest( $redirect );

} // End Function


function savehome($uid, $uname, $theme, $storynum, $ublockon, $ublock) {
    global $mpnTables,$phpEx;

    $cookie = cookiedecode();
    $check = $cookie[1];
    $result = mysql_query("select uid from ".$mpnTables['users']." where uname='$check' && uid > 1");
    list($vuid) = mysql_fetch_row($result);

    if (($check == $uname) AND ($uid == $vuid))
    {
        if(isset($ublockon)) $ublockon=1; else $ublockon=0;

        mysql_query("update ".$mpnTables['users']." set storynum='$storynum', ublockon='$ublockon', ublock='$ublock' where uid=$uid && uid > 1");

        $result = mysql_query("select uid, pass from ".$mpnTables['users']." where uid='$cookie[0]' && pass='$cookie[2]' && uid > 1");

        if ( mysql_num_rows( $result ) === 1 )
        {
            $tmp = mysql_fetch_row( $result );
            docookie( $tmp[0], $tmp[1] );
            unset( $tmp );
        }
        else
        {
            goBack( translate( 'Unable To Verify Your Identity' ) );
            exit;
        }

        $_SERVER['F_LIB'] -> redirectRequest( 'user.php' );
    }
}


function editcomm() {
        global $phpEx;
        include ("header.$phpEx");
        $userinfo = $GLOBALS['uinf'];
        nav();
        OpenTable();
        ?>
        <table cellpadding=8 border=0><tr><td>
        <?php echo "<form action=\"user.$phpEx\" method=\"post\">"; ?>
        <b><?php echo translate("Display Mode"); ?></b>
        <select class=textbox name=umode>
        <option value="nocomments" <?PHP if ($userinfo['umode'] == 'nocomments') { echo "selected"; } ?>><?php echo translate("No Comments"); ?>
        <option value="nested" <?PHP if ($userinfo['umode'] == 'nested') { echo "selected"; } ?>><?php echo translate("Nested"); ?>
        <option value="flat" <?PHP if ($userinfo['umode'] == 'flat') { echo "selected"; } ?>><?php echo translate("Flat"); ?>
        <option value="thread" <?PHP if (!isset($userinfo['umode']) || ($userinfo['umode']=="") || $userinfo['umode']=='thread') { echo "selected"; } ?>><?php echo translate("Thread"); ?>
        </select>
        <br><br>
        <b><?php echo translate("Sort Order"); ?></b>
        <select class=textbox name=uorder>
        <option value="0" <?PHP if (!$userinfo['uorder']) { echo "selected"; } ?>><?php echo translate("Oldest First"); ?>
        <option value="1" <?PHP if ($userinfo['uorder']==1) { echo "selected"; } ?>><?php echo translate("Newest First"); ?>
        <option value="2" <?PHP if ($userinfo['uorder']==2) { echo "selected"; } ?>><?php echo translate("Highest Scores First"); ?>
        </select>
        <br><br>
        <b><?php echo translate("Threshold"); ?></b>
        <?php echo translate("Comments scored less than this setting will be ignored."); ?><br>
        <select class=textbox name=thold>
        <option value="-1" <?PHP if ($userinfo['thold']==-1) { echo "selected"; } ?>>-1: <?php echo translate("Uncut and Raw"); ?>
        <option value="0" <?PHP if ($userinfo['thold']==0) { echo "selected"; } ?>>0: <?php echo translate("Almost Everything"); ?>
        <option value="1" <?PHP if ($userinfo['thold']==1) { echo "selected"; } ?>>1: <?php echo translate("Filter Most Anon"); ?>
        <option value="2" <?PHP if ($userinfo['thold']==2) { echo "selected"; } ?>>2: <?php echo translate("Score"); ?> +2
        <option value="3" <?PHP if ($userinfo['thold']==3) { echo "selected"; } ?>>3: <?php echo translate("Score"); ?> +3
        <option value="4" <?PHP if ($userinfo['thold']==4) { echo "selected"; } ?>>4: <?php echo translate("Score"); ?> +4
        <option value="5" <?PHP if ($userinfo['thold']==5) { echo "selected"; } ?>>5: <?php echo translate("Score"); ?> +5
        </select><br>
        <?php echo translate("Anonymous posts start at 0, logged in posts start at 1. Moderators add and subtract points."); ?>
        <br><br>
        <INPUT type=checkbox name=noscore <?PHP if ($userinfo['noscore']==1) { echo "checked"; } ?>><B> <?php echo translate("Do Not Display Scores"); ?></B> <?php echo translate("(Hides score: They still apply, you just don't see them.)"); ?>
        <br><br>
        <b><?php echo translate("Max Comment Length"); ?></b> <?php echo translate("(Truncates long comments, and adds a Read More link. Set really big to disable)"); ?><br>
        <input class=textbox type="text" name="commentmax" value="<?PHP echo $userinfo['commentmax'] ?>" size=11 maxlength=11> bytes (1024 bytes = 1K)
        <br><br>

        <?php

        // Kiril: New Sanitizer

        echo "<input type='hidden' name='stripit_form' value='umode|uorder|thold|noscore|commentmax' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End Sanitizer

        ?>

        <input type="hidden" name="uname" value="<?PHP echo $userinfo['uname']; ?>">
        <input type="hidden" name="uid" value="<?PHP echo $userinfo['uid']; ?>">
        <input type="hidden" name="op" value="savecomm">
        <input class='button' type="submit" value="<?php echo translate("Save Changes"); ?>">
        </form></td></tr></table>
        <?PHP
        CloseTable();
        include ("footer.$phpEx");
}

function savecomm($uid, $uname, $umode, $uorder, $thold, $noscore, $commentmax) {
    global $mpnTables,$phpEx;

    $cookie = cookiedecode();
    $check = $cookie[1];
    $result = mysql_query("select uid from ".$mpnTables['users']." where uname='$check' && uid > 1");
    list($vuid) = mysql_fetch_row($result);
    if (($check == $uname) AND ($uid == $vuid))
    {
        if(isset($noscore)) $noscore=1; else $noscore=0;

        mysql_query("update ".$mpnTables['users']." set umode='$umode', uorder='$uorder', thold='$thold', noscore='$noscore', commentmax='$commentmax' where uid=$uid && uid > 1");

        $result = mysql_query("select uid, pass from ".$mpnTables['users']." where uid='$cookie[0]' && pass='$cookie[2]' && uid > 1");

        if ( mysql_num_rows( $result ) === 1 )
        {
            $tmp = mysql_fetch_row( $result );
            docookie( $tmp[0], $tmp[1] );
            unset( $tmp );
        }
        else
        {
            goBack( translate( 'Unable To Verify Your Identity' ) );
            exit;
        }

        $_SERVER['F_LIB'] -> redirectRequest( 'user.php' );
    }
}

function avatarlist()
{
        global $phpEx;
    include("header.$phpEx");
    Opentable();

    $directory = "images/forum/avatar";
    $handle = opendir($directory);

    while ( $file = readdir($handle) ){
        $filelist[] = $file;
    }

    echo "<center><font size=3><b>".translate("Available Avatar's List")."</b></font></center><br><br>\n";
    asort($filelist);

    $cntavs=0;
        sort($filelist);
        reset($filelist);
    echo "<table width=\"100%\"><tr>";
    while ( list(, $file) = each($filelist) ) {
        if ( ereg(".gif|.jpg|.png",$file) ) {
            if ( $cntavs > 5 ) {
                echo "<tr>";
            }

            echo '<td><img src="images/forum/avatar/'.$file.'" border="0" width="32" height="32" Alt="'.$file.'" hspace="10" vspace="10" align="top"><br>'.$file.'</td>';

            $cntavs++;

            if ( $cntavs > 5 ) {
                echo "</tr>\n";
                $cntavs=0;
            }
        }
    }

    echo "</table>";
    echo "<br><br><br><center><b>[ <A HREF=\"javascript:history.go(-1)\">".translate("Go Back")."</a> ]</b></center>\n";

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

function lostPassword()
{
    $content  = '<br /><br >';

    $content .= "<h2>" . translate ( "Forgotten or Lost your Password?" ) . "</h2>\n";

    $content .= "<hr class='w80' /><br />\n";

    $content .= '<div class="subtitle2">' . "\n";

        $content .= translate ( 'Please Enter your Nickname And Registration E-Mail' ) . "\n";

    $content .= '</div>' . "\n";

    $content .= '<br /><br />';

    $content .= "<div class='center'>\n";

        $content .= "<form action='./user.php?op=mailpasswd' method='post'>\n";

           $content .= "<input type='hidden' name='stripit_form' value='uname|email' />\n";
           $content .= "<input type='hidden' name='mpn_sectype' value='1' />\n";

           $content .= "<p class='forms'>\n";

                $content .= '<label>' . translate ( 'Nickname' ) . '&#058;&nbsp;&nbsp;</label>' . "\n";

                $content .= "<input type='text' name='uname' size='30' maxlength='25' />\n";

                $content .= '<br /><br />' . "\n";

                $content .= '<label>' . translate ( 'Registration E-Mail' ) . '&#058;&nbsp;&nbsp;</label>' . "\n";

                $content .= "<input type='text' name='email' size='30' maxlength='60' />\n";

                $content .= '<div class="subtitle2">' . "\n";

                    $content .= '<br /><br />';

                    $content .= translate( 'Once Your User Name And Email Address Are Confirmed' );
                    $content .= ',<br />';

                    $content .= translate( 'Your New Password Will Be Sent' );

                    $content .= '<br /><br />';

                    $content .= "<input class='button' type='submit' value='" . translate ( "Send Password" ) . "' />\n";

                $content .= "</div>\n";

            $content .= "</p>\n";

        $content .= "</form>\n";

    $content .= "</div>\n";

    $content .= "<br /><br />\n";

    return $content;

} // End Function

/**
 *
 *
 *
 */

function mailPassword()
{
    global $mpnTables, $mail, $sitename, $adminmail;

    if ( ( ! isset( $_POST['uname'] ) || $_POST['uname'] == '' ) || ( ! isset( $_POST['email'] ) || $_POST['email'] == '' ) )
    {
        goBack( translate( 'Please Enter A Valid Username Or User Email' ) . '**' . __FILE__ . '***' .  __LINE__ );
    }

    $sql = 'SELECT uid, uname, email, pass
            FROM ' . $mpnTables['users'] . '
            WHERE uname = "' . $_POST['uname'] . '"
                && email = "' . $_POST['email'] . '"
                && uid > 1
                && pass != ""
            LIMIT 1';

    @( ( $result = mysql_query( $sql ) ) && mysql_data_seek( $result, 0 ) )
      OR goBack( translate( 'Unable To Verify Valid Username Or Email' ) . '**' . __FILE__ . '***' .  __LINE__ );

    $host_name = ( isset( $_SERVER['REMOTE_ADDR'] ) )
               ? ( $_SERVER['REMOTE_ADDR'] )
               : ( translate( 'Unknown' ) );

    list ( $uid, $uname, $email, $pass ) = mysql_fetch_row( $result );

    $randpass = $_SERVER['F_LIB'] -> generatekey( 8, FALSE );
    $newpass = md5( $randpass );

	mysql_query ( 'LOCK TABLES ' . $mpnTables['users'] . ' WRITE' );

	$sql = 'UPDATE ' . $mpnTables['users'] . '
	        SET pass = "' . $newpass . '"
	        WHERE uid = ' . $uid . '
	            && uid > 1
	            && uname = "' . $uname . '"';

	if ( ! @( $result = mysql_query( $sql ) ) )
    {
        mysql_query ( 'UNLOCK TABLES' );
		goBack( translate( 'Unable To Set New Password' ) . '**' . __FILE__ . '***' .  __LINE__ );
	}

    mysql_query ( 'UNLOCK TABLES' );

    $message = translate( 'A web user from ' ) . $host_name . translate( ' has just requested that a password be sent to this address.' ) . "\n\n";

    $message .= translate( 'The user account ' ) . $uname . translate( ' at ' ) . $sitename . translate( ' has this email associated with it.' ) . "\n\n";

    $message .= translate( 'If you did not request a new password be sent there is no need to worry as you are the only recipient of this mail' ) . "\n\n";

    $message .= translate('Your New Password Is: ') . $randpass . "\n\n";

    $message .= translate('You can change it after you login at ') . "<a href=\"" . _MPN_ROOT_URI . "user.php\" target=\"_blank\">" . $sitename  . "</a>\n\n";


    $subject = $sitename . ' ' . translate( 'Password Request For' ) . ' ' . $uname;

    $mail -> From = $adminmail;
    $mail -> FromName = $sitename . translate(' Mailer');
    $mail -> AddAddress( $email, $uname );
    $mail -> Subject = stripslashes($subject);
    $mail -> Body = nl2br( stripslashes($message) );
    $mail -> AltBody = strip_tags( stripslashes($message) );

    if ( ! $mail -> Send() )
    {
       $vmsg  = translate ( 'Unable To Send New Password' );
       $vmsg .= '<br /><br />';
       $vmsg .= translate ( 'Please Contact The Site Administrator At' );
       $vmsg .= '<br />';
       $vmsg .= '<a href="mailto:' . $adminmail . '" title="Contact Administrator"><i>' . $adminmail . '</i></a>';
    }
    else
    {
       $vmsg = $uname;
       $vmsg .= ',<br />';
       $vmsg .= translate ( 'Your New Password Has Been Sent To' );
       $vmsg .= ' <i>' . $email . '</i>';
    }

    goHome( $vmsg, FALSE );

}  // End Function

function getUserRegForm( $uname, $email )
{
    $content = '<div class="center">' . "\n";

    $content .= '<form name="Register" action="user.php" method="post">' . "\n";

        $content .= '<input type="hidden" name="op" value="newuser" />' . "\n";
        $content .= '<input type="hidden" name="clickit_form" value="user_sig" />' . "\n";
        $content .= '<input type="hidden" name="stripit_form" value="uname|email" />' . "\n";

        $content .= '<input type="hidden" name="mpn_sectype" value="1" />' . "\n";

        $content .= '<p class="forms">' . "\n";

            $content .= '<label>' . translate( 'Nickname: ' ) . '</label>' . "\n";
            $content .= '<input type="text" name="uname" size="26" maxlength="25" value="' . $uname . '" />' . "\n";

            $content .= '<br /><br />' . "\n";

            $content .= '<label>' . translate( 'E-Mail: ' ) . '</label>' . "\n";
            $content .= '<input type="text" name="email" value="' . $email . '" size="25" maxlength="60" />' . "\n";
        $content .= '<br /><br />' . "\n";

        $content .= '<input class="button" type="submit" value="' . translate( 'Register' ) . '">' . "\n";

        $content .= '</p>' . "\n";

    $content .= '</form>' . "\n";

    $content .= '</div>' . "\n";

    $content .= '<b>' . translate( 'Your Password Will Be Sent To The Email Address You Entered' ) . '</b>';
    $content .= '<br /><br />' . "\n";
    $content .= '<em class="look">' . translate( 'Notice' ) . '&#058;  </em>';
    $content .= translate( 'Account preferences are cookie based' ) . '&#046;';
    $content .= '<br />' . "\n";
    $content .= translate( 'You must allow cookies to be set by this site' ) . '&#046;';
    $content .= '<br /><br />' . "\n";
    $content .= translate( 'If your having problems logging in, please check your browsers privacy settings' ) . '&#046;';
    $content .= '<br /><br />' . "\n";

    $content .= '<h3>' . translate( "As a registered user you can:" ) . '</h3>';
    $content .= '<hr class="w40" />' . "\n";

    $content .= '<div class="centerlist">' . "\n";

        $content .= '<ul>' . "\n";

            $content .= '<li />' . translate("Post comments with your name") . "\n";
            $content .= '<li />' . translate("Send news with your name") . "\n";
            $content .= '<li />' . translate("Have a personal box in the Home") . "\n";
            $content .= '<li />' . translate("Select how many news you want in the Home") . "\n";
            $content .= '<li />' . translate("Customize the comments") . "\n";
            $content .= '<li />' . translate("Select different themes") . "\n";
            $content .= '<li />' . translate("some other cool stuff...") . "\n";

        $content .= '</ul>' . "\n";

    $content .= '</div>' . "\n";

    $content .= '<br /><br />' . "\n";

    $content .= translate("Register Now! It's Free!");

    return $content;

} // End Function


function Err($stop)
{
    OpenTable();
    echo $stop;
    CloseTable();
}

if ( empty( $_REQUEST['op'] ) ) { $_REQUEST['op'] = NULL; }

switch( $_REQUEST['op'] )
{
    case "logout":
            logout();
            break;

    case "newuser":
        if (!isset($user_viewemail))
        {
            $user_viewemail = null;
        }

        confirmNewUser( $uname, $email );
        break;

    case "finish":
        finishNewUser( $uname, $email );
        break;

case "mailpasswd":
        mailPassword();
        break;

    case "userinfo":

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

        userinfo($uname, $bypass);
        break;

    case "login":
        login($uname, $pass);
        break;

    case "edituser":
        edituser();
        break;

    case "saveuser":
        if (!isset($attach))
        {
            $attach = '';
        }

        saveuser($uid, $name, $uname, $email, $femail, $url, $pass, $vpass, $bio, $user_avatar, $user_icq, $user_occ, $user_from, $user_from_flag, $user_intrest, $user_sig, $user_aim, $user_yim, $user_msnm, $attach, $MLMail);

        break;

    case "edithome":
        edithome();
        break;

    case "chgtheme":
        chgtheme();
        break;

    case "savehome":
        savehome($uid, $uname, $theme, $storynum, $ublockon, $ublock);
        break;

    case "savetheme":
        savetheme();
        break;

    case "avatarlist":
        avatarlist();
        break;

    case "editcomm":
        editcomm();
        break;

    case "savecomm":
        savecomm($uid, $uname, $umode, $uorder, $thold, $noscore, $commentmax);
        break;

    /*case "register":
        main('1');
        break;*/

    default:

        main();

    break;
}

?>