Esempio n. 1
0
//      this list of conditions and the following disclaimer in the documentation
//      and/or other materials provided with the distribution.
//   3. The name of the author may not be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
////////////////////////////////////////////////////////////////////////////////////
if (!defined("IN_BTIT")) {
    die("non direct access!");
}
if (!defined("IN_ACP")) {
    die("non direct access!");
}
isset($_GET["essentials"]) && !empty($_GET["essentials"]) ? $essentials = unserialize(base64_decode(urldecode($_GET["essentials"]))) : ($essentials = FALSE);
isset($_GET["case"]) && !empty($_GET["case"]) && ($_GET["case"] == 5 || $_GET["case"] == 6) ? $case = $_GET["case"] : ($case = FALSE);
if ($essentials !== FALSE && is_array($essentials) && $case !== FALSE) {
    ipb_create($essentials["username"], $essentials["email"], $essentials["password"], $essentials["id_level"], $essentials["newuid"]);
    header("Location: index.php?page=admin&user="******"uid"] . "&code=" . $CURUSER["random"] . "&do=newuser&action=" . ($case == 5 ? "save_ok" : "save_pb"));
} else {
    stderr($language["ERROR"], $language["BAD_DATA"]);
}
Esempio n. 2
0
function aggiungiutente()
{
    global $DBDT, $INVITATIONSON, $VALID_INV, $SITENAME, $SITEEMAIL, $BASEURL, $VALIDATION, $USERLANG, $USE_IMAGECODE, $TABLE_PREFIX, $XBTT_USE, $language, $THIS_BASEPATH, $FORUMLINK, $db_prefix, $btit_settings;
    $dobdate = $_POST["datepicker"];
    $parts = explode('-', $dobdate);
    $dobday = $parts[0];
    $dobmonth = $parts[1];
    $dobyear = $parts[2];
    $utente = mysqli_real_escape_string($DBDT, $_POST["user"]);
    $pwd = mysqli_real_escape_string($DBDT, $_POST["pwd"]);
    $pwd1 = mysqli_real_escape_string($DBDT, $_POST["pwd1"]);
    $email = mysqli_real_escape_string($DBDT, $_POST["email"]);
    if (isset($_POST["language"])) {
        $idlangue = intval($_POST["language"]);
    } else {
        $idlangue = max(1, $btit_settings["default_language"]);
    }
    if (isset($_POST["style"])) {
        $idstyle = intval($_POST["style"]);
    } else {
        $idstyle = max(1, $btit_settings["default_style"]);
    }
    $idflag = intval($_POST["flag"]);
    $timezone = intval($_POST["timezone"]);
    $heard = mysqli_real_escape_string($DBDT, $_POST["heardaboutus"]);
    // Dt Referral
    if ($btit_settings["ref_on"] == true) {
        $rid = intval($_POST["refa"]);
    }
    // Dt Referral
    if (strtoupper($utente) == strtoupper("Guest")) {
        err_msg($language["ERROR"], $language["ERR_GUEST_EXISTS"]);
        stdfoot();
        exit;
    }
    if ($pwd != $pwd1) {
        err_msg($language["ERROR"], $language["DIF_PASSWORDS"]);
        stdfoot();
        exit;
    }
    if ($VALIDATION == "none") {
        $idlevel = 3;
    } else {
        $idlevel = 2;
    }
    //begin invitation system by dodge
    if ($INVITATIONSON == "true") {
        if ($VALID_INV == "true") {
            $idlevel = 2;
        } else {
            $idlevel = 3;
        }
    }
    //end invitation system
    # Create Random number
    $floor = 100000;
    $ceiling = 999999;
    srand((double) microtime() * 1000000);
    $random = rand($floor, $ceiling);
    if ($utente == "" || $pwd == "" || $email == "") {
        return -1;
        exit;
    }
    $res = do_sqlquery("SELECT email FROM {$TABLE_PREFIX}users WHERE email='{$email}'", true);
    if (mysqli_num_rows($res) > 0) {
        return -2;
        exit;
    }
    // valid email check - by vibes
    $regex = '/\\b[\\w\\.-]+@[\\w\\.-]+\\.\\w{2,4}\\b/i';
    if (!preg_match($regex, $email)) {
        return -3;
        exit;
    }
    // valid email check end
    //Function changed by fatepower so now the variable checks the right data.
    //Added the image also. Cheers boys
    // check if IP is already in use
    if ($btit_settings["dupip"] == "true") {
        $ip = getip();
        $i = @mysqli_fetch_row(@mysqli_query($GLOBALS["___mysqli_ston"], "SELECT count(*) FROM {$TABLE_PREFIX}users WHERE cip='{$ip}'")) or die(is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false));
        if ($i[0] != 0) {
            err_msg(ERROR, "[" . $ip . "]<br /><img src=\"images/shared_ip.gif\" border=\"0\" alt=\"\" />");
            block_end();
            stdfoot();
            exit;
        }
    }
    // duplicate username
    $res = do_sqlquery("SELECT username FROM {$TABLE_PREFIX}users WHERE username='******'", true);
    if (mysqli_num_rows($res) > 0) {
        return -4;
        exit;
    }
    // duplicate username
    if (strpos(mysqli_real_escape_string($DBDT, $utente), " ") == true) {
        return -7;
        exit;
    }
    if ($btit_settings["gcsw"] == false) {
        if ($USE_IMAGECODE) {
            if (extension_loaded('gd')) {
                $arr = gd_info();
                if ($arr['FreeType Support'] == 1) {
                    $public = $_POST['public_key'];
                    $private = $_POST['private_key'];
                    $p = new ocr_captcha();
                    if ($p->check_captcha($public, $private) != true) {
                        err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                        stdfoot();
                        exit;
                    }
                } else {
                    include "{$THIS_BASEPATH}/include/security_code.php";
                    $scode_index = intval($_POST["security_index"]);
                    if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
                        err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                        stdfoot();
                        exit;
                    }
                }
            } else {
                include "{$THIS_BASEPATH}/include/security_code.php";
                $scode_index = intval($_POST["security_index"]);
                if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
                    err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                    stdfoot();
                    exit;
                }
            }
        } else {
            include "{$THIS_BASEPATH}/include/security_code.php";
            $scode_index = intval($_POST["security_index"]);
            if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
                err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                stdfoot();
                exit;
            }
        }
    } else {
        require_once "include/recaptchalib.php";
        // reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
        $lang = "en";
        // The response from reCAPTCHA
        $resp = null;
        // The error code from reCAPTCHA, if any
        $error = null;
        $reCaptcha = new ReCaptcha($btit_settings["gcsekk"]);
        if ($_POST["g-recaptcha-response"]) {
            $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
        } else {
            err_msg($language["ERROR"], "Recaptcha Not submitted");
            stdfoot();
            exit;
        }
        if ($resp != null && $resp->success) {
        } else {
            err_msg($language["ERROR"], "Google reports , you are a Robot !");
            stdfoot();
            exit;
        }
    }
    $bannedchar = array("\\", "/", ":", "*", "?", "\"", "@", "\$", "'", "`", ",", ";", ".", "<", ">", "!", "£", "%", "^", "&", "(", ")", "+", "=", "#", "~");
    if (straipos(mysqli_real_escape_string($DBDT, $utente), $bannedchar) == true) {
        return -8;
        exit;
    }
    $pass_to_test = $_POST["pwd"];
    $pass_min_req = explode(",", $btit_settings["secsui_pass_min_req"]);
    if (strlen($pass_to_test) < $pass_min_req[0]) {
        return -9;
        exit;
    }
    $exploded = explode("@", $email);
    $exploded2 = explode(".", $exploded[1]);
    $cheapmail = mysqli_real_escape_string($DBDT, $exploded[1]);
    $cheapmail2 = mysqli_real_escape_string($DBDT, "@" . $exploded2[0] . ".");
    $mailischeap = do_sqlquery("SELECT `domain` FROM `{$TABLE_PREFIX}cheapmail` WHERE `domain`='" . $cheapmail . "' OR `domain`='" . $cheapmail2 . "'", true);
    if (@mysqli_num_rows($mailischeap) > 0) {
        return -999;
    }
    $userip = getip();
    $signupipblock = @mysqli_fetch_assoc(@mysqli_query($GLOBALS["___mysqli_ston"], "SELECT `id` FROM `{$TABLE_PREFIX}signup_ip_block` WHERE `first_ip` <=INET_ATON('{$userip}') AND `last_ip` >=INET_ATON('{$userip}')"));
    if ($signupipblock) {
        return -99;
        exit;
    }
    $lct_count = 0;
    $uct_count = 0;
    $num_count = 0;
    $sym_count = 0;
    $pass_end = (int) (strlen($pass_to_test) - 1);
    $pass_position = 0;
    $pattern1 = '#[a-z]#';
    $pattern2 = '#[A-Z]#';
    $pattern3 = '#[0-9]#';
    $pattern4 = '/[¬!"£$%^&*()`{}\\[\\]:@~;\'#<>?,.\\/\\-=_+\\|]/';
    for ($pass_position = 0; $pass_position <= $pass_end; $pass_position++) {
        if (preg_match($pattern1, substr($pass_to_test, $pass_position, 1), $matches)) {
            $lct_count++;
        } elseif (preg_match($pattern2, substr($pass_to_test, $pass_position, 1), $matches)) {
            $uct_count++;
        } elseif (preg_match($pattern3, substr($pass_to_test, $pass_position, 1), $matches)) {
            $num_count++;
        } elseif (preg_match($pattern4, substr($pass_to_test, $pass_position, 1), $matches)) {
            $sym_count++;
        }
    }
    if ($lct_count < $pass_min_req[1] || $uct_count < $pass_min_req[2] || $num_count < $pass_min_req[3] || $sym_count < $pass_min_req[4]) {
        return -998;
        exit;
    }
    $multipass = hash_generate(array("salt" => ""), $_POST["pwd"], $_POST["user"]);
    $i = $btit_settings["secsui_pass_type"];
    $sql = "SELECT value FROM {$TABLE_PREFIX}settings WHERE `key` = \"donate_upload\"";
    $req = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die('Erreur SQL !<br />' . $sql . '<br />' . (is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
    $result = mysqli_fetch_array($req);
    $credit = $result['value'];
    $sql = "SELECT value FROM {$TABLE_PREFIX}settings WHERE `key` = \"unit\"";
    $req = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die('Erreur SQL !<br />' . $sql . '<br />' . (is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
    $result = mysqli_fetch_array($req);
    $unit = $result['value'];
    mysqli_free_result($req) || is_object($req) && get_class($req) == "mysqli_result" ? true : false;
    $kb = 1024;
    $mb = 1024 * 1024;
    $gb = 1024 * 1024 * 1024;
    $tb = 1024 * 1024 * 1024 * 1024;
    if ($unit == 'Kb') {
        $uploaded = $credit * $kb;
    } elseif ($unit == 'Mb') {
        $uploaded = $credit * $mb;
    } elseif ($unit == 'Gb') {
        $uploaded = $credit * $gb;
    } elseif ($unit == 'Tb') {
        $uploaded = $credit * $tb;
    }
    $realdate = checkdate($dobmonth, $dobday, $dobyear);
    if ($realdate) {
        $dob = $dobyear . "-" . $dobmonth . "-" . $dobday;
        $age = userage($dobyear, $dobmonth, $dobday);
        $dobtime = mktime(0, 0, 0, $dobmonth, $dobday, $dobyear);
        if ($dobtime > time()) {
            err_msg($language["ERROR"], $language["ERR_BORN_IN_FUTURE"]);
            stdfoot();
            exit;
        } elseif ($age < $btit_settings["birthday_lower_limit"]) {
            err_msg($language["ERROR"], $language["ERR_DOB_1"] . $age . $language["ERR_DOB_2"]);
            stdfoot();
            exit;
        } elseif ($age > $btit_settings["birthday_upper_limit"]) {
            err_msg($language["ERROR"], $language["ERR_DOB_1"] . $age . $language["ERR_DOB_2"]);
            stdfoot();
            exit;
        }
    } else {
        err_msg($language["ERROR"], $language["INVALID_DOB_1"] . $dobday . "/" . $dobmonth . "/" . $dobyear . $language["INVALID_DOB_2"]);
        stdfoot();
        exit;
    }
    $mtpp = $btit_settings["max_torrents_per_page"];
    $pid = md5(uniqid(rand(), true));
    $gen = intval($_POST['gen']);
    do_sqlquery("INSERT INTO `{$TABLE_PREFIX}users` (`username`, `password`, `dob` ,`salt`, `pass_type`, `dupe_hash`, `random`, `id_level`, `email`, `style`, `language`, `flag`, `joined`, `lastconnect`, `pid`, `time_offset`, `whereheard`,`gender` , `torrentsperpage`) VALUES ('" . $utente . "', '" . mysqli_real_escape_string($DBDT, $multipass[$i]["rehash"]) . "', '" . $dob . "' , '" . mysqli_real_escape_string($DBDT, $multipass[$i]["salt"]) . "', '" . $i . "', '" . mysqli_real_escape_string($DBDT, $multipass[$i]["dupehash"]) . "', " . $random . ", " . $idlevel . ", '" . $email . "', " . $idstyle . ", " . $idlangue . ", " . $idflag . ", NOW(), NOW(),'" . $pid . "', '" . $timezone . "','" . $heard . "','" . $gen . "','" . $mtpp . "')", true);
    $newuid = is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"])) ? false : $___mysqli_res;
    // DT reputation system start
    $reput = do_sqlquery("SELECT * FROM {$TABLE_PREFIX}reputation_settings WHERE id =1");
    $setrep = mysqli_fetch_array($reput);
    $plus = $setrep["rep_default"];
    if ($setrep["rep_is_online"] == 'false') {
        //do nothing
    } else {
        @mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE {$TABLE_PREFIX}users SET reputation = reputation + '{$plus}' WHERE id='{$newuid}'");
    }
    // DT reputation system end
    //begin invitation system by dodge
    if ($INVITATIONSON == "true") {
        $inviter = 0 + $_POST["inviter"];
        $code = unesc($_POST["code"]);
        $res = do_sqlquery("SELECT username FROM {$TABLE_PREFIX}users WHERE id = {$inviter}", true);
        $arr = mysqli_fetch_assoc($res);
        $invusername = $arr["username"];
        do_sqlquery("UPDATE {$TABLE_PREFIX}users SET invited_by='" . $inviter . "' WHERE id='" . $newuid . "'", true);
        do_sqlquery("UPDATE {$TABLE_PREFIX}invitations SET confirmed='true' WHERE hash='{$code}'", true);
        $msg = sqlesc($language["WELCOME MESSAGE"]);
    }
    //end invitation system
    //DT referral system start
    if ($btit_settings["ref_on"] == true) {
        $rup = $btit_settings["ref_gb"] * 1024 * 1024 * 1024;
        $rap = $btit_settings["ref_sb"];
        do_sqlquery("UPDATE {$TABLE_PREFIX}users SET referral={$rid} where id={$newuid}", true);
        if ($btit_settings["ref_switch"] == true) {
            do_sqlquery("UPDATE {$TABLE_PREFIX}users SET uploaded=uploaded + '{$rup}' where id='{$rid}'");
        } else {
            do_sqlquery("UPDATE {$TABLE_PREFIX}users SET seedbonus=seedbonus + '{$rap}' where id='{$rid}'");
        }
    }
    //DT referral system end
    do_sqlquery("UPDATE {$TABLE_PREFIX}users SET uploaded={$uploaded} WHERE id={$newuid}", true);
    // begin - announce new confirmed user in shoutbox
    if ($btit_settings["sbtwo"] == true) {
        $al = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM {$TABLE_PREFIX}chat ORDER BY id DESC LIMIT 1");
        $rw = mysqli_fetch_assoc($al);
        $ct = $rw["count"] + 1;
        do_sqlquery("INSERT INTO {$TABLE_PREFIX}chat (uid, time, name, text,count) VALUES (0," . time() . ", 'System','[color=green]Welcome New User :[/color][url={$BASEURL}/index.php?page=userdetails&id={$newuid}]" . $utente . "[/url]'," . $ct . ")");
    }
    // end - announce new confirmed user in shoutbox
    // Continue to create smf members if they disable smf mode
    $test = do_sqlquery("SHOW TABLES LIKE '{$db_prefix}members'", true);
    if (substr($FORUMLINK, 0, 3) == "smf" || mysqli_num_rows($test)) {
        $smfpass = smf_passgen($utente, $pwd);
        $fetch = get_result("SELECT `smf_group_mirror` FROM `{$TABLE_PREFIX}users_level` WHERE `id`=" . $idlevel, true, $btit_settings["cache_duration"]);
        $flevel = $fetch[0]["smf_group_mirror"] > 0 ? $fetch[0]["smf_group_mirror"] : $idlevel + 10;
        if ($FORUMLINK == "smf") {
            do_sqlquery("INSERT INTO `{$db_prefix}members` (`memberName`, `dateRegistered`, `ID_GROUP`, `realName`, `passwd`, `emailAddress`, `memberIP`, `memberIP2`, `is_activated`, `passwordSalt`) VALUES ('{$utente}', UNIX_TIMESTAMP(), {$flevel}, '{$utente}', '{$smfpass['0']}', '{$email}', '" . getip() . "', '" . getip() . "', 1, '{$smfpass['1']}')", true);
        } else {
            do_sqlquery("INSERT INTO `{$db_prefix}members` (`member_name`, `date_registered`, `id_group`, `real_name`, `passwd`, `email_address`, `member_ip`, `member_ip2`, `is_activated`, `password_salt`) VALUES ('{$utente}', UNIX_TIMESTAMP(), {$flevel}, '{$utente}', '{$smfpass['0']}', '{$email}', '" . getip() . "', '" . getip() . "', 1, '{$smfpass['1']}')", true);
        }
        $fid = is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"])) ? false : $___mysqli_res;
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = {$fid} WHERE `variable` = 'latestMember'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = '{$utente}' WHERE `variable` = 'latestRealName'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = UNIX_TIMESTAMP() WHERE `variable` = 'memberlist_updated'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = `value` + 1 WHERE `variable` = 'totalMembers'", true);
        do_sqlquery("UPDATE `{$TABLE_PREFIX}users` SET `smf_fid`={$fid} WHERE `id`={$newuid}", true);
    }
    // Continue to create ipb members if they disable ipb mode
    $test = do_sqlquery("SHOW TABLES LIKE '{$ipb_prefix}members'");
    if ($FORUMLINK == "ipb" || mysqli_num_rows($test)) {
        ipb_create($utente, $email, $pwd, $idlevel, $newuid);
    }
    // xbt
    if ($XBTT_USE) {
        $resin = do_sqlquery("INSERT INTO xbt_users (uid, torrent_pass) VALUES ({$newuid},'{$pid}')", true);
    }
    include "include/userstuff.php";
    $sub = sqlesc("{$GLOBALS['welcome_sub']}");
    $mess = sqlesc("{$GLOBALS['welcome_msg']}");
    send_pm(0, $newuid, $sub, $mess);
    if ($INVITATIONSON == "true") {
        send_pm('2', $newuid, '" . $language["WELCOME"] . "', $msg);
        if ($VALID_INV == "true") {
            send_mail($email, "{$SITENAME} " . $language["REG_CONFIRM"] . "", $language["INVIT_MSGINFO"] . "{$email}" . $language["INVIT_MSGINFO1"] . " {$utente}\n" . $language["INVIT_MSGINFO2"] . " {$pwd}\n\n" . $language["INVIT_MSGINFO3"], "From: {$SITENAME} <{$SITEEMAIL}>");
        } else {
            send_mail($email, "{$SITENAME} " . $language["REG_CONFIRM"] . "", $language["INVIT_MSGINFO"] . "{$email}" . $language["INVIT_MSGINFO1"] . " {$utente}\n" . $language["INVIT_MSGINFO2"] . " {$pwd}\n\n\n" . $language["INVIT_MSG_AUTOCONFIRM3"], "From: {$SITENAME} <{$SITEEMAIL}>");
        }
        write_log("Signup new user {$utente} ({$email})", "add");
    } else {
        if ($VALIDATION == "user") {
            ini_set("sendmail_from", "");
            if ((is_object($GLOBALS["___mysqli_ston"]) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)) == 0) {
                send_mail($email, $language["ACCOUNT_CONFIRM"], $language["ACCOUNT_MSG"] . "\n\n" . $BASEURL . "/index.php?page=account&act=confirm&confirm={$random}&language={$idlangue}");
                write_log("Signup new user {$utente} ({$email})", "add");
            } else {
                die(is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false));
            }
        }
    }
    return is_object($GLOBALS["___mysqli_ston"]) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false);
}
Esempio n. 3
0
function aggiungiutente()
{
    global $SITENAME, $SITEEMAIL, $BASEURL, $VALIDATION, $USERLANG, $USE_IMAGECODE, $TABLE_PREFIX, $XBTT_USE, $language, $THIS_BASEPATH, $FORUMLINK, $db_prefix, $btit_settings;
    $utente = isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST["user"]) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "");
    $pwd = isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST["pwd"]) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "");
    $pwd1 = isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST["pwd1"]) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "");
    $email = isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST["email"]) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "");
    $idlangue = intval($_POST["language"]);
    $idstyle = intval($_POST["style"]);
    $idflag = intval($_POST["flag"]);
    $timezone = intval($_POST["timezone"]);
    if (strtoupper($utente) == strtoupper("Guest")) {
        err_msg($language["ERROR"], $language["ERR_GUEST_EXISTS"]);
        stdfoot();
        exit;
    }
    if ($pwd != $pwd1) {
        err_msg($language["ERROR"], $language["DIF_PASSWORDS"]);
        stdfoot();
        exit;
    }
    if ($VALIDATION == "none") {
        $idlevel = 3;
    } else {
        $idlevel = 2;
    }
    # Create Random number
    $floor = 100000;
    $ceiling = 999999;
    srand((double) microtime() * 1000000);
    $random = rand($floor, $ceiling);
    if ($utente == "" || $pwd == "" || $email == "") {
        return -1;
        exit;
    }
    $res = do_sqlquery("SELECT email FROM {$TABLE_PREFIX}users WHERE email='{$email}'", true);
    if (mysqli_num_rows($res) > 0) {
        return -2;
        exit;
    }
    // valid email check - by vibes
    $regex = '/\\b[\\w\\.-]+@[\\w\\.-]+\\.\\w{2,4}\\b/i';
    if (!preg_match($regex, $email)) {
        return -3;
        exit;
    }
    // valid email check end
    // duplicate username
    $res = do_sqlquery("SELECT username FROM {$TABLE_PREFIX}users WHERE username='******'", true);
    if (mysqli_num_rows($res) > 0) {
        return -4;
        exit;
    }
    // duplicate username
    if (strpos(isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $utente) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : ""), " ") == true) {
        return -7;
        exit;
    }
    if ($USE_IMAGECODE) {
        if (extension_loaded('gd')) {
            $arr = gd_info();
            if ($arr['FreeType Support'] == 1) {
                $public = $_POST['public_key'];
                $private = $_POST['private_key'];
                $p = new ocr_captcha();
                if ($p->check_captcha($public, $private) != true) {
                    err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                    stdfoot();
                    exit;
                }
            } else {
                include "{$THIS_BASEPATH}/include/security_code.php";
                $scode_index = intval($_POST["security_index"]);
                if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
                    err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                    stdfoot();
                    exit;
                }
            }
        } else {
            include "{$THIS_BASEPATH}/include/security_code.php";
            $scode_index = intval($_POST["security_index"]);
            if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
                err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
                stdfoot();
                exit;
            }
        }
    } else {
        include "{$THIS_BASEPATH}/include/security_code.php";
        $scode_index = intval($_POST["security_index"]);
        if ($security_code[$scode_index]["answer"] != $_POST["scode_answer"]) {
            err_msg($language["ERROR"], $language["ERR_IMAGE_CODE"]);
            stdfoot();
            exit;
        }
    }
    $bannedchar = array("\\", "/", ":", "*", "?", "\"", "@", "\$", "'", "`", ",", ";", ".", "<", ">", "!", "£", "%", "^", "&", "(", ")", "+", "=", "#", "~");
    if (straipos(isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $utente) : (trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : ""), $bannedchar) == true) {
        return -8;
        exit;
    }
    $pass_to_test = $_POST["pwd"];
    $pass_min_req = explode(",", $btit_settings["secsui_pass_min_req"]);
    if (strlen($pass_to_test) < $pass_min_req[0]) {
        return -9;
        exit;
    }
    $lct_count = 0;
    $uct_count = 0;
    $num_count = 0;
    $sym_count = 0;
    $pass_end = (int) (strlen($pass_to_test) - 1);
    $pass_position = 0;
    $pattern1 = '#[a-z]#';
    $pattern2 = '#[A-Z]#';
    $pattern3 = '#[0-9]#';
    $pattern4 = '/[¬!"£$%^&*()`{}\\[\\]:@~;\'#<>?,.\\/\\-=_+\\|]/';
    for ($pass_position = 0; $pass_position <= $pass_end; $pass_position++) {
        if (preg_match($pattern1, substr($pass_to_test, $pass_position, 1), $matches)) {
            $lct_count++;
        } elseif (preg_match($pattern2, substr($pass_to_test, $pass_position, 1), $matches)) {
            $uct_count++;
        } elseif (preg_match($pattern3, substr($pass_to_test, $pass_position, 1), $matches)) {
            $num_count++;
        } elseif (preg_match($pattern4, substr($pass_to_test, $pass_position, 1), $matches)) {
            $sym_count++;
        }
    }
    if ($lct_count < $pass_min_req[1] || $uct_count < $pass_min_req[2] || $num_count < $pass_min_req[3] || $sym_count < $pass_min_req[4]) {
        return -998;
        exit;
    }
    $multipass = hash_generate(array("salt" => ""), $_POST["pwd"], $_POST["user"]);
    $i = $btit_settings["secsui_pass_type"];
    $pid = md5(uniqid(rand(), true));
    do_sqlquery("INSERT INTO `{$TABLE_PREFIX}users` (`username`, `password`, `salt`, `pass_type`, `dupe_hash`, `random`, `id_level`, `email`, `style`, `language`, `flag`, `joined`, `lastconnect`, `pid`, `time_offset`) VALUES ('" . $utente . "', '" . (isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $multipass[$i]["rehash"]) : (trigger_error("[MySQLConverterToo] Fix the mysqli_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "")) . "', '" . (isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $multipass[$i]["salt"]) : (trigger_error("[MySQLConverterToo] Fix the mysqli_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "")) . "', '" . $i . "', '" . (isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"]) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $multipass[$i]["dupehash"]) : (trigger_error("[MySQLConverterToo] Fix the mysqli_escape_string() call! This code does not work.", E_USER_ERROR) ? "" : "")) . "', " . $random . ", " . $idlevel . ", '" . $email . "', " . $idstyle . ", " . $idlangue . ", " . $idflag . ", NOW(), NOW(),'" . $pid . "', '" . $timezone . "')", true);
    $newuid = is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"])) ? false : $___mysqli_res;
    // Continue to create smf members if they disable smf mode
    $test = do_sqlquery("SHOW TABLES LIKE '{$db_prefix}members'", true);
    if (substr($FORUMLINK, 0, 3) == "smf" || mysqli_num_rows($test)) {
        $smfpass = smf_passgen($utente, $pwd);
        $fetch = get_result("SELECT `smf_group_mirror` FROM `{$TABLE_PREFIX}users_level` WHERE `id`=" . $idlevel, true, $btit_settings["cache_duration"]);
        $flevel = $fetch[0]["smf_group_mirror"] > 0 ? $fetch[0]["smf_group_mirror"] : $idlevel + 10;
        if ($FORUMLINK == "smf") {
            do_sqlquery("INSERT INTO `{$db_prefix}members` (`memberName`, `dateRegistered`, `ID_GROUP`, `realName`, `passwd`, `emailAddress`, `memberIP`, `memberIP2`, `is_activated`, `passwordSalt`) VALUES ('{$utente}', UNIX_TIMESTAMP(), {$flevel}, '{$utente}', '{$smfpass['0']}', '{$email}', '" . getip() . "', '" . getip() . "', 1, '{$smfpass['1']}')", true);
        } else {
            do_sqlquery("INSERT INTO `{$db_prefix}members` (`member_name`, `date_registered`, `id_group`, `real_name`, `passwd`, `email_address`, `member_ip`, `member_ip2`, `is_activated`, `password_salt`) VALUES ('{$utente}', UNIX_TIMESTAMP(), {$flevel}, '{$utente}', '{$smfpass['0']}', '{$email}', '" . getip() . "', '" . getip() . "', 1, '{$smfpass['1']}')", true);
        }
        $fid = is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"])) ? false : $___mysqli_res;
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = {$fid} WHERE `variable` = 'latestMember'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = '{$utente}' WHERE `variable` = 'latestRealName'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = UNIX_TIMESTAMP() WHERE `variable` = 'memberlist_updated'", true);
        do_sqlquery("UPDATE `{$db_prefix}settings` SET `value` = `value` + 1 WHERE `variable` = 'totalMembers'", true);
        do_sqlquery("UPDATE `{$TABLE_PREFIX}users` SET `smf_fid`={$fid} WHERE `id`={$newuid}", true);
    }
    // Continue to create ipb members if they disable ipb mode
    $test = do_sqlquery("SHOW TABLES LIKE '{$ipb_prefix}members'");
    if ($FORUMLINK == "ipb" || mysqli_num_rows($test)) {
        ipb_create($utente, $email, $pwd, $idlevel, $newuid);
    }
    // xbt
    if ($XBTT_USE) {
        $resin = do_sqlquery("INSERT INTO xbt_users (uid, torrent_pass) VALUES ({$newuid},'{$pid}')", true);
    }
    if ($VALIDATION == "user") {
        ini_set("sendmail_from", "");
        if ((is_object($GLOBALS["___mysqli_ston"]) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)) == 0) {
            send_mail($email, $language["ACCOUNT_CONFIRM"], $language["ACCOUNT_MSG"] . "\n\n" . $BASEURL . "/index.php?page=account&act=confirm&confirm={$random}&language={$idlangue}");
            write_log("Signup new user {$utente} ({$email})", "add");
        } else {
            die(is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false));
        }
    }
    return is_object($GLOBALS["___mysqli_ston"]) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false);
}