<?php
defined('IN_YA') OR die ('Access denied reactive_user MAXIMUS directly...');
defined('MAXIMUS') OR header("Location: index.php");

    incoh();
    if (strtolower($user_email) != strtolower($user_email2)) {
        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();
    }
    $user_email = strtolower($user_email);
    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, 8);
        if (extension_loaded("gd") AND $code != $gfx_check AND ($ya_config['usegfxcheck'] == 1 OR $ya_config['usegfxcheck'] == 3)) {
            redirect_url("modules.php?name=$module_name");
            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=reactivate&check_num=$check_num&time=$time";
        $user_email = check_html($user_email, nohtml);
        $result = $db->sql_query("INSERT INTO ".TABLE_USERS_REDO." (user_id, user_email, check_num, time) VALUES ($uid, '$user_email', '$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 "._TOREACTIVATE." $sitename.\r\n\r\n";
                $message .= _TOREACTIVATEUSER."\r\n\r\n$finishlink\r\n\r\n";
                $subject = _REACTIVATIONSUB;
                $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>"._REACTIVATEPENDING."</b><br /><br />";
            echo ""._FINISHREACTIVATECONF."<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 - "._MEMREA;
                $from_ip = $_SERVER['REMOTE_ADDR'];
                $message .= _YA_NOREPLY;
                mail($adminmail, $subject, $message, $from);
            }
        }
    } else {
        Max_OpenTable();
        echo "<center class='title'>$stop</center>\n";
        Max_CloseTable();
    }
    incof();