<?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 new_finish3 MAXIMUS directly...');
defined('MAXIMUS') OR header("Location: index.php");

    incoh();
    $user_email = strtolower($user_email);
    ya_userCheck($username);
    ya_mailCheck($user_email);
    $user_regdate = date("M d, Y");
    if (!isset($stop)) {
        $datekey = date("F j");
        $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $random_num . $datekey));
        $code = substr($rcode, 2, 6);
        if (extension_loaded("gd") AND $code != $gfx_check AND ($ya_config['usegfxcheck'] == 1 OR $ya_config['usegfxcheck'] == 3)) {
            redirect_url("modules.php?name=Your_Account");
            die();
        }
        $new_password = md5($user_password);
        $username = ya_fixtext($username);
        $user_email = ya_fixtext($user_email);
        $realname = ya_fixtext($realname);
        if($realname == "") { $realname = $row['username']; }
        $femail = ya_fixtext($femail);
        $user_website = check_html($user_website);
        if (!eregi("http://", $user_website) AND $user_website != "") { $user_website = "http://$user_website"; }
        $bio = str_replace("<br />", "\r\n", $bio);
        $bio = ya_fixtext($bio);
        $user_sig = str_replace("<br />", "\r\n", $user_sig);
        $user_sig = ya_fixtext($user_sig);
        $user_icq = ya_fixtext($user_icq);
        $user_aim = ya_fixtext($user_aim);
        $user_yim = ya_fixtext($user_yim);
        $user_msnm = ya_fixtext($user_msnm);
        $user_occ = ya_fixtext($user_occ);
        $user_from = ya_fixtext($user_from);
        $user_interests = ya_fixtext($user_interests);
        $user_dateformat = ya_fixtext($user_dateformat);
        $newsletter = intval($newsletter);
        $user_viewemail = intval($user_viewemail);
        $user_allow_viewonline = intval($user_allow_viewonline);
        $user_timezone = intval($user_timezone);
        $raw = $db->sql_fetchrow($db->sql_query("SELECT max(user_id) AS newest_uid FROM `".TABLE_USERS."`"));
	$newest_uid = intval($raw['newest_uid']);
        if ($newest_uid == "-1") { $new_uid = 1; } else { $new_uid = $newest_uid+1; }
        $lv = time();
        $result = $db->sql_query("INSERT INTO `".TABLE_USERS."` (user_id, name, username, user_email, user_avatar, user_regdate, user_viewemail, user_password, user_lang, user_lastvisit) VALUES ($new_uid, '$username', '$username', '$user_email', 'gallery/blank.gif', '$user_regdate', '0', '$new_password', '$language', '$lv')");
        $db->sql_query("LOCK TABLES `".TABLE_USERS."` WRITE");
        $db->sql_query("INSERT INTO `".TABLE_USERS."` (user_id, user_avatar, user_avatar_type, user_lang, user_lastvisit, umode) VALUES ($new_uid, 'gallery/blank.gif', '3', '$language', '$lv', 'nested')");
        $db->sql_query("UPDATE `".TABLE_USERS."` SET username='$username', name='$realname', user_email='$user_email', femail='$femail', user_website='$user_website', user_icq='$user_icq', user_aim='$user_aim', user_yim='$user_yim', user_msnm='$user_msnm', user_from='$user_from', user_occ='$user_occ', user_interests='$user_interests', newsletter='$newsletter', user_viewemail='$user_viewemail', user_allow_viewonline='$user_allow_viewonline', user_timezone='$user_timezone', user_dateformat='$user_dateformat', user_sig='$user_sig', bio='$bio', user_password='$user_password', user_regdate='$user_regdate' WHERE `user_id`='$new_uid'");
        $db->sql_query("UNLOCK TABLES");
        if(!$result) {
            Max_OpenTable();
            echo ""._ADDERROR."<br />";
            Max_CloseTable();
        } else {
            if ($ya_config['servermail'] == 0) {
                $message = _WELCOMETO." $sitename ($nukeurl)!\r\n\r\n";
                $message .= _YOUUSEDEMAIL." $user_email "._TOREGISTER." $sitename.\r\n\r\n";
                $message .= _FOLLOWINGMEM."\r\n"._UNICKNAME." $username\r\n"._UPASSWORD." $user_password";
                $subject = _REGISTRATIONSUB;
                $from  = "From: $adminmail\r\n";
                $from .= "Reply-To: $adminmail\r\n";
                $from .= "Return-Path: $adminmail\r\n";
                mail($user_email, $subject, $message, $from);
            }
            title(_USERREGLOGIN);
            Max_OpenTable();
            $result = $db->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `username`='$username' AND `user_password`='$user_password'");
            if ($db->sql_numrows($result) == 1) {
                $userinfo = $db->sql_fetchrow($result);
                yacookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
                echo "<META HTTP-EQUIV=\"refresh\" content=\"2;URL=/modules.php?name=$module_name\">";
                echo "<center><b>$userinfo[username]:</b> "._ACTMSG2."</center>";
            } else {
                echo "<center>"._SOMETHINGWRONG."</center><br />";
            }
            Max_CloseTable();
            if ($ya_config['sendaddmail'] == 1 AND $ya_config['servermail'] == 0) {
                $from  = "From: $user_email\r\n";
                $from .= "Reply-To: $user_email\r\n";
                $from .= "Return-Path: $user_email\r\n";
                $subject = "$sitename - "._MEMADD;
                $from_ip = $_SERVER['REMOTE_ADDR'];
                $message = "$username has been added to $sitename. from $from_ip\r\n";
                $message .= "-----------------------------------------------------------\r\n";
                $message .= _YA_NOREPLY;
                mail($adminmail, $subject, $message, $from);
            }
        }
    } else {
        echo "$stop";
    }
    incof();