<?php
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.fr                            */
/* Original Script www.nukescripst.net                  */
/* Copyright  2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/

if (!defined('IN_YA')) { die("You can't access this file directly."); }
if (!defined('MAXIMUS')) {
header("Location: index.php");
  die();
}
    if ($username != "" AND $user_email == "") {
        $sql = "SELECT username, user_email, user_password, user_level FROM ".TABLE_USERS." WHERE username='$username'";
    } else if ($username == "" AND $user_email != "") {
        $sql = "SELECT username, user_email, user_password, user_level FROM ".TABLE_USERS." WHERE user_email='$user_email'";
    } else {
        incoh();
        title(_YA_MUSTSUPPLY);
        incof();
        die();
    }
    $result = $db->sql_query($sql);
    if(!$result) {
        incoh();
        title(_SORRYNOUSERINFO);
        incof();
    } else {
        if ($ya_config['servermail'] == 0) {
            $host_name = $_SERVER["REMOTE_ADDR"];
            $row = $db->sql_fetchrow($result);
            $user_name = stripslashes($row['username']);
            $user_email = stripslashes($row['user_email']);
            $user_password = stripslashes($row['user_password']);
            $user_level = $db->XMFnum($row['user_level']);
            if ($user_level > 0) {
                $areyou = substr($user_password, 0, 10);
                if ($areyou==$code) {
                    $newpass = YA_MakePass();
                    $message .= _USERACCOUNT." ";
                    if ($username != "") {
                        $message .= "'$username' ";
                    } else if ($user_email !="") {
                        $message .= "'$user_email' ";
                    }
                    $message .= _AT." $sitename "._HASTHISEMAIL."  "._AWEBUSERFROM." $host_name "._HASREQUESTED."\r\n\r\n";
                    $message .= _YOURNEWPASSWORD." $newpass\r\n\r\n ";
                    $message .= _YOUCANCHANGE." $nukeurl/modules.php?name=$module_name\r\n\r\n"._IFYOUDIDNOTASK;
                    $subject = _USERPASSWORD4;
                    if ($username != "") {
                        $subject .= " $username";
                    } else if ($user_email !="") {
                        $subject .= " $user_email";
                    }
                    $from  = "From: $adminmail\r\n";
                    $from .= "Reply-To: $adminmail\r\n";
                    $from .= "Return-Path: $adminmail\r\n";
                    mail($user_email, $subject, $message, $from);
                    $cryptpass = md5($newpass);
                    if ($username != "") {
                        $query = "UPDATE ".TABLE_USERS." SET user_password='$cryptpass' WHERE username='$username'";
                    } else if ($user_email !="") {
                        $query = "UPDATE ".TABLE_USERS." SET user_password='$cryptpass' WHERE user_email='$user_email'";
                    }
                    incoh();
                    Max_OpenTable();
                    if (!$db->sql_query($query)) { echo "<center>"._UPDATEFAILED."</center><br />"; }
                    echo "<center>"._PASSWORD4." ";
                    if ($username != "") { echo "'$username'"; } else if ($user_email != "") { echo "'$user_email'"; }
                    echo " "._MAILED."<br /><br />"._GOBACK."</center>";
                    Max_CloseTable();
                    incof();
                } else {
                    $result = $db->sql_query($sql);
                    if(!$result) {
                        incoh();
                        title(_SORRYNOUSERINFO);
                        incof();
                    } else {
                        $host_name = $_SERVER["REMOTE_ADDR"];
                        $row = $db->sql_fetchrow($result);
                        $user_email = stripslashes($row['user_email']);
                        $user_password = stripslashes($row['user_password']);
                        $areyou = substr($user_password, 0, 10);
                        $message = _USERACCOUNT." '$user_name' "._AT." $sitename "._HASTHISEMAIL." "._AWEBUSERFROM." $host_name "._CODEREQUESTED."\r\n\r\n";
                        $message .= _YOURCODEIS." $areyou \r\n\r\n";
                        $message .= _WITHTHISCODE." $nukeurl/modules.php?name=$module_name&op=pass_lost\r\n\r\n";
                        $message .= _IFYOUDIDNOTASK2;
                        $subject = _CODEFOR." $username";
                        $from  = "From: $adminmail\r\n";
                        $from .= "Reply-To: $adminmail\r\n";
                        $from .= "Return-Path: $adminmail\r\n";
                        mail($user_email, $subject, $message, $from);
                        incoh();
                        Max_OpenTable();
                        echo "<center>"._CODEFOR." $username "._MAILED."<br /><br />"._GOBACK."</center>";
                        Max_CloseTable();
                        incof();
                    }
                }
            } else {
                incoh();
                title(_USERREGLOGIN);
                Max_OpenTable();
                echo "<center>"._SERVERNOMAIL."</center>\n";
                Max_CloseTable();
                incof();
            }
        } elseif ($user_level == 0) {
            incoh();
            title(_ACCSUSPENDED);
            incof();
        } elseif ($user_level == -1) {
            incoh();
            title(_ACCDELETED);
            incof();
        }
    }

?>