<?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                          */
/********************************************************/
defined('IN_YA') OR die ('Access denied deleteconfirm MAXIMUS directly...');
defined('MAXIMUS') OR header("Location: index.php");

if ($ya_config['allowuserdelete'] == 1) {    
    incoh();
    @setcookie("user");
    $result = $GLOBALS['db']->sql_query("SELECT `user_email`, `user_website`, `username`, `user_password` FROM `".TABLE_USERS."` WHERE `user_id`='$uid'");
    $row   = $GLOBALS['db']->sql_fetchrow($result);
    $email = stripslashes($row['email']);
    $url   = stripslashes($row['url']);
    $uname = stripslashes($row['uname']);
    $pass  = stripslashes($row['pass']);
    if ($code == $pass) {
        if ($ya_config['senddeletemail'] == 1 && $ya_config['servermail'] < 1) {
            $to = $adminmail;
            $from  = "From: $email\r\n";
            $from .= "Reply-To: $email\r\n";
            $from .= "Return-Path: $email\r\n";
            $subject = "$sitename - "._MEMDEL;
            $message = "$uname has been deleted from $sitename.\r\n";
            $message .= "-----------------------------------------------------------\r\n";
            $message .= _YA_NOREPLY;
            mail($to, $subject, $message, $from);
        }
        $GLOBALS['db']->sql_query("UPDATE `".TABLE_USERS."` SET name='"._MEMDEL."', user_email='".md5($user_email)."', user_password='', user_website='', user_sig='', user_regdate='Non 0, 0000', user_level='-1', user_active='0', user_allow_pm='0' WHERE `user_id`='$uid'");
        cookiedecode($user);
        $r_uid = $cookie[0];
        $r_uname = $cookie[1];
        @setcookie("user");
        $result = $GLOBALS['db']->sql_query("DELETE FROM `".TABLE_SESSION."` where `uname`='$r_uname'");
        $GLOBALS['db']->sql_query("OPTIMIZE TABLE `".TABLE_SESSION."`");
        $result = $GLOBALS['db']->sql_query("DELETE FROM `".$prefix."_bbsessions` where `session_user_id`='$r_uid'");
        $GLOBALS['db']->sql_query("OPTIMIZE TABLE `".$prefix."_bbsessions`");
        echo "<META HTTP-EQUIV=\"refresh\" content=\"2;URL=$nukeurl\">";
        title(_ACCTDELETE);
    } else {
        title(_YOUBAD);
    }
    incof();
} else { disabled(); }