<?php
if(!isset($_POST['next'], $_POST['registrationBean_month'], $_POST['registrationBean_day'], $_POST['registrationBean_year'], $_POST['registrationBean_email'], $_POST['registrationBean_password'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'], $_POST['registrationBean_parentEmail'])):
echo '{"registrationErrors":{"registration_password":"Escribe una contraseña porfavor.","registration_birthday_format":"Please supply a valid birthdate","registration_termsofservice":"Please accept the terms of service","registration_email":"Please enter a valid email address","registration_captcha":"The security code was invalid, please try again."}}';
exit;
endif;
$responseJson = ['registrationErrors' => ['empty_field_error_message' => 'Hey, you forgot to fill me!']];
if(empty($_POST['registrationBean_password'])):
$responseJson['registrationErrors']['registration_password'] = 'Please enter a password';
elseif(strlen($_POST['registrationBean_password']) < 6):
$responseJson['registrationErrors']['registration_password'] = 'Your password needs be at least 6 characters long';
elseif(strlen($_POST['registrationBean_password']) > 32):
$responseJson['registrationErrors']['registration_password'] = 'Your password is too long';
elseif(!preg_match('`[0-9]`', $_POST['registrationBean_password'])):
$responseJson['registrationErrors']['registration_password'] = 'Your password must also include numbers';
endif;
if(!USER::CheckAge($_POST['registrationBean_day'], $_POST['registrationBean_month'], $_POST['registrationBean_year'])):
$responseJson['registrationErrors']['registration_birthday_format'] = 'Please supply a valid birthdate';
endif;
if(!isset($_POST['registrationBean_termsOfServiceSelection']) $_POST['registrationBean_termsOfServiceSelection'] != 'true'):
$responseJson['registrationErrors']['registration_termsofservice'] = 'Please accept the terms of service';
endif;
$_POST['registrationBean_email'] = str_replace('%40', '@', strtolower($_POST['registrationBean_email']));
if(empty($_POST['registrationBean_email']) strlen($_POST['registrationBean_email']) > 50 preg_match('/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i', $_POST['registrationBean_email']) !== 1):
$responseJson['registrationErrors']['registration_email'] = 'Please enter a valid email address';
else:
$r = USER::SomeRegistered($_POST['registrationBean_email']);
if($r === null):
$responseJson["registrationErrors"]['registration_password'] = 'Error 505 L29. Try later.';
elseif($r === true):
$responseJson['registrationErrors']['registration_email'] = 'Someone (probably you) has requested we do not send email to the address you tried to use. Please use another email address.';
endif;
endif;
if($responseJson['registrationErrors'] != ['empty_field_error_message' => 'Hey, you forgot to fill me!']):
echo json_encode($responseJson);
exit;
endif;
$RegisterSettings = CACHE::GetAIOConfig('Register');
if(!$RegisterSettings['register_enabled']):
$responseJson["registrationErrors"]['registration_password'] = 'Register is disabled, try later.';
echo json_encode($responseJson);
exit;
endif;
$userName = USER::GenerateName($_POST['registrationBean_email']);
if($userName === null):
$responseJson["registrationErrors"]['registration_password'] = 'Error 505 L48. Try later.';
echo json_encode($responseJson);
exit;
endif;
$birth = $_POST['registrationBean_day'] . '-' . $_POST['registrationBean_month'] . '-' . $_POST['registrationBean_year'];
$_IpExists = true;
if($MySQLi->query("SELECT null FROM users WHERE (ip_last = '" . MY_IP . "' OR ip_reg = '" . MY_IP . "')")->num_rows == 0):
$_IpExists = false;
endif;
if($RegisterSettings['onelimitip_enabled'] && $_IpExists):
$responseJson["registrationErrors"]["registration_password"] = 'Only one user per IP';
echo json_encode($responseJson);
exit;
endif;
$q = $MySQLi->query('INSERT INTO users (username, rank, vip_points, credits, activity_points, seasonal_currency, loyalty_points, look, gender, motto, mail, account_created, ip_last, vip) VALUES (\'' . $userName . '\', \'2\', \'500\', \'25000\', \'3000\', \'125\', \'250\', \'lg-270-82.hd-180-1.sh-290-91.ch-210-66.hr-100-42\', \'M\', \'Willkommen im ' . $shortname . ' Hotel!\', \'UNDEFINED\', ' . time() . ', \'' . MY_IP . '\', \'1\')');
if(!$q $MySQLi->affected_rows !== 1):
$responseJson['registrationErrors']['registration_password'] = 'Error MySQLi';
echo json_encode($responseJson);
exit;
endif;
$getroomsID = $MySQLi->query("SELECT id FROM rooms WHERE owner = '" . $userName . "'");
$userid = $MySQLi->insert_id;
$MySQLi->query('REPLACE INTO xdrcms_users_data (id, mail, password, birth, rpx_id, rpx_type, web_online, AddonData, RememberMeToken, AccountID, AccountIdentifier, AccountPhoto, securityTokens) VALUES (' . $userid . ', \'' . $_POST["registrationBean_email"] . '\', \'' . METHOD::HASH($_POST["registrationBean_password"]) . '\', \'' . $birth . '\', ' . METHOD::RANDOM(12, true, false) . ', \'habboid\', \'--\', \'\', \'\', \'\', \'\', \'\', \'\')');
if(isset($_SESSION['Register']['RefId']) && is_numeric($_SESSION['Register']['RefId']) && !$_IpExists):
$Users::NewRefer($userid, $_SESSION['Register']['RefId']);
endif;
ITEM::CREATE($userid, 0, '180', '366', '11', '', 's_paper_clip_1', '', 'sticker');
ITEM::CREATE($userid, 0, '130', '22', '10', '', 's_needle_3', '', 'sticker');
ITEM::CREATE($userid, 0, '280', '343', '3', '', 's_sticker_spaceduck', '', 'sticker');
ITEM::CREATE($userid, 0, '593', '11', '9', '', 's_sticker_arrow_down', '', 'sticker');
ITEM::CREATE($userid, 0, '107', '402', '8', '', 'n_skin_notepadskin', 'note.myfriends', 'stickie');
ITEM::CREATE($userid, 0, '57', '229', '6', '', 'n_skin_speechbubbleskin', 'note.welcome', 'stickie');
ITEM::CREATE($userid, 0, '148', '41', '7', '', 'n_skin_noteitskin', 'note.remember.security', 'stickie');
ITEM::CREATE($userid, 0, '457', '26', '4', 'ProfileWidget', 'w_skin_defaultskin', '', 'widget');
ITEM::CREATE($userid, 0, '450', '319', '1', 'RoomsWidget', 'w_skin_notepadskin', '', 'widget');
//if($SiteSettings['initial.credits.int'] > 0):
// newTransaction($userid, $date_full, $SiteSettings['initial.credits.int'], $System->CorrectStr('¡Bienvenido a ' . $shortname . '!'));
//endif;
unset($_SESSION["Registration"]);
$_SESSION['client_login'] = true;
$_SESSION['next_login'] = true;
$q = $MySQLi->query('INSERT INTO rooms (caption, owner, model_name, wallpaper, floor) VALUES (\'Raum von ' . $userName . '\', \'' . $userName . '\', \'model_b\', \'903\', \'110\')');
$q = $MySQLi->query('INSERT INTO user_badges (user_id, badge_id, badge_slot) VALUES (\'' . $userid . '\', \'HH1\', \'1\')');
$q = $MySQLi->query('INSERT INTO items (user_id, room_id, base_item, extra_data, x, y, z, rot) VALUES (\'' . $userid . '\', \'' . $getroomsID . '\', \'3062\', \'1\', \'6\', \'1\', \'0\', \'0\')');
USER::LOGIN($userid, $_POST['registrationBean_email'], METHOD::HASH($_POST['registrationBean_password']), 'habboid', false);
echo '{"registrationCompletionRedirectUrl":"' . str_replace("/", "\\/", PATH) . '\/client"}';
exit;
?>