<?php
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.fr)   */
/* http://www.nukescripts.fr                            */
/* Copyright  2000-2004 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* NSN YAT 320 from www.nukescripts.net                 */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
global $admin_file;
$aid = substr("$aid", 0,25);
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `title`, `admins` FROM `".TABLE_MODULES."` WHERE title='Your_Account'"));
$row2 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `name`, `radminsuper` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
    if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
        $auth_user = 1;
    }
}
if ($row2['radminsuper'] == 1 || $auth_user == 1) {


    if ($add_email != $add_email2) {
        incoh();
        Max_OpenTable();
        echo "<center><font class='title'><b>"._ERRORREG."</b></font>";
	br('2');
        echo "<font class='content'>"._EMAILDIFFERENT."<br /><br />"._GOBACK."</font></center>";
        Max_CloseTable();
        incof();
        die();
    }
    $add_email = strtolower($add_email);
    ya_userCheck($add_uname);
    ya_mailCheck($add_email);
    ya_passCheck($add_pass, $add_pass2);
    $add_name = ya_fixtext($realname);
    if($add_name == "") { $add_name = $add_uname; }
    $add_femail = ya_fixtext($add_femail);
    $add_url = check_html($add_url);
    if (!eregi("http://", $add_url) AND $add_url != "") { $add_url = "http://$add_url"; }
    $add_user_sig = str_replace("<br />", "\r\n", $add_user_sig);
    $add_user_sig = ya_fixtext($add_user_sig);
    $add_user_icq = ya_fixtext($add_user_icq);
    $add_user_aim = ya_fixtext($add_user_aim);
    $add_user_yim = ya_fixtext($add_user_yim);
    $add_user_msnm = ya_fixtext($add_user_msnm);
    $add_user_from = ya_fixtext($add_user_from);
    $add_user_occ = ya_fixtext($add_user_occ);
    $add_user_interest = ya_fixtext($add_user_interest);
    $add_user_viewemail = intval($add_user_viewemail);
    $add_newsletter = intval($add_newsletter);
    $user_points = intval($user_points);
    if ($stop == "") {
        $user_password = $add_pass;
        $add_pass = md5($add_pass);
        $user_regdate = date("M d, Y");
        $raw = $db->sql_fetchrow($db->sql_query("SELECT max(user_id) AS newest_uid FROM ".TABLE_USERS.""));
	$newest_uid = $db->XMFnum($raw['newest_uid']);
        if ($newest_uid == "-1") { $new_uid = 1; } else { $new_uid = $newest_uid+1; }
        $sql = "INSERT INTO ".TABLE_USERS." ";
        $sql .= "(user_id, name, username, user_email, femail, user_website, user_regdate, user_icq, user_aim, user_yim, user_msnm, user_from, user_occ, user_interests, user_viewemail, user_avatar, user_avatar_type, user_sig, user_password, newsletter, broadcast, popmeson, points) ";
        $sql .= "VALUES ('$new_uid','$add_name','$add_uname','$add_email','$add_femail','$add_url','$user_regdate','$add_user_icq','$add_user_aim','$add_user_yim','$add_user_msnm','$add_user_from','$add_user_occ','$add_user_intrest','$add_user_viewemail','gallery/blank.gif','3','$add_user_sig','$add_pass','$add_newsletter','1','0','$add_points')";
        $result = $db->sql_query($sql);
        if (!$result) {
            $pagetitle = ": "._USERADMIN;
            incoh();
            title(_USERADMIN);
            Max_OpenTable();
            echo "<center><b>"._ERRORSQL."</b></center>";
            Max_CloseTable();
            incof();
            return;
        } else {
            if ($ya_config['servermail'] == 0) {
                $message = _WELCOMETO." $sitename!\r\n\r\n";
                $message .= _YOUUSEDEMAIL." ($add_email) "._TOREGISTER." $sitename.\r\n\r\n";
                $message .= _FOLLOWINGMEM."\r\n"._UNICKNAME." $add_uname\r\n"._UPASSWORD." $user_password";
                $subject = _ACCOUNTCREATED;
                $from  = "From: $adminmail\r\n";
                $from .= "Reply-To: $adminmail\r\n";
                $from .= "Return-Path: $adminmail\r\n";
                mail($user_email, $subject, $message, $from);
            }
            if (isset($min)) { $xmin = "&amp;min=$min"; }
            if (isset($xop)) { $xxop = "&amp;op=$xop"; }
            redirect_url("".$admin_file.".php?op=members"."$xxop"."$xmin");
        }
    } else {
        $pagetitle = ": "._USERADMIN;
        incoh();
        title(_USERADMIN);
        amain();
        br('1');
        Max_OpenTable();
        echo "<b>$stop</b>\n";
        Max_CloseTable();
        incof();
        return;
    }

}