<?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();
}

    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();
        }
        mt_srand ((double)microtime()*1000000);
        $maxran    = 1000000;
        $check_num = mt_rand(0, $maxran);
        $check_num = md5($check_num);
        $time      = time();
        $finishlink   = "$nukeurl/modules.php?name=$module_name&op=activate&username=$username&check_num=$check_num";
        $new_password = md5($user_password);
        $username   = check_html($username, 'nohtml');
        $user_email = check_html($user_email, 'nohtml');
        $raw = $db->sql_fetchrow($db->sql_query("SELECT max(user_id) AS newest_uid FROM `".TABLE_USERS_TEMP."`"));
	$newest_uid = $db->XMFnum($raw['newest_uid']);
        if ($newest_uid == "-1") { $new_uid = 1; } else { $new_uid = $newest_uid+1; }
        $result = $db->sql_query("INSERT INTO `".TABLE_USERS_TEMP."` (user_id, username, user_email, user_password, user_regdate, check_num, time) VALUES ($new_uid, '$username', '$user_email', '$new_password', '$user_regdate', '$check_num', '$time')");
        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 .= _TOFINISHUSER."\r\n\r\n$finishlink\r\n\r\n";
                $message .= _FOLLOWINGMEM."\r\n"._UNICKNAME." $username\r\n"._UPASSWORD." $user_password";
                $subject = _ACTIVATIONSUB;
                $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();
            echo "<center><b>"._ACCOUNTCREATED."</b><br /><br />";
            echo ""._YOUAREREGISTERED."<br /><br />";
            echo ""._FINISHUSERCONF."<br /><br />";
            echo ""._THANKSUSER." $sitename!</center>";
            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 - "._MEMACT;
                $from_ip = $_SERVER['REMOTE_ADDR'];
                $message  = "$username "._YA_APLTO." $sitename "._YA_FROM." $from_ip\r\n";
                $message .= "-----------------------------------------------------------\r\n";
                $message .= _YA_NOREPLY;
                mail($adminmail, $subject, $message, $from);
            }
        }
    } else {
        echo "$stop";
    }
    incof();