Merge branch 'develop' into feature/new-router

This commit is contained in:
slawkens
2022-09-27 13:02:47 +02:00
124 changed files with 2122 additions and 163 deletions

View File

@@ -34,11 +34,13 @@ $errors = array();
$save = isset($_POST['save']) && $_POST['save'] == 1;
if($save)
{
if(USE_ACCOUNT_NAME) {
$account_name = $_POST['account'];
}
else {
$account_id = $_POST['account'];
if(!config('account_login_by_email')) {
if(USE_ACCOUNT_NAME) {
$account_name = $_POST['account'];
}
else {
$account_id = $_POST['account'];
}
}
$email = $_POST['email'];
@@ -46,12 +48,14 @@ if($save)
$password2 = $_POST['password2'];
// account
if(isset($account_id)) {
if(!Validator::accountId($account_id))
if(!config('account_login_by_email')) {
if (isset($account_id)) {
if (!Validator::accountId($account_id)) {
$errors['account'] = Validator::getLastError();
}
} else if (!Validator::accountName($account_name))
$errors['account'] = Validator::getLastError();
}
else if(!Validator::accountName($account_name))
$errors['account'] = Validator::getLastError();
// email
if(!Validator::email($email))
@@ -68,17 +72,12 @@ if($save)
$errors['country'] = 'Country is invalid.';
}
if($config['recaptcha_enabled'])
if(config('recaptcha_enabled'))
{
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response']))
{
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$config['recaptcha_secret_key'].'&response='.$_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
if(!$responseData->success)
$errors['verification'] = "Please confirm that you're not a robot.";
require LIBS . 'GoogleReCAPTCHA.php';
if (!GoogleReCAPTCHA::verify('register')) {
$errors['verification'] = GoogleReCAPTCHA::getErrorMessage();
}
else
$errors['verification'] = "Please confirm that you're not a robot.";
}
// password
@@ -93,7 +92,7 @@ if($save)
}
// check if account name is not equal to password
if(USE_ACCOUNT_NAME && strtoupper($account_name) == strtoupper($password)) {
if(!config('account_login_by_email') && USE_ACCOUNT_NAME && strtoupper($account_name) == strtoupper($password)) {
$errors['password'] = 'Password may not be the same as account name.';
}
@@ -106,16 +105,28 @@ if($save)
}
$account_db = new OTS_Account();
if(USE_ACCOUNT_NAME)
$account_db->find($account_name);
else
$account_db->load($account_id);
if (config('account_login_by_email')) {
$account_db->findByEMail($email);
}
else {
if(USE_ACCOUNT_NAME) {
$account_db->find($account_name);
}
else {
$account_db->load($account_id);
}
}
if($account_db->isLoaded()) {
if(USE_ACCOUNT_NAME)
$errors['account'] = 'Account with this name already exist.';
else
$errors['account'] = 'Account with this id already exist.';
if (config('account_login_by_email') && !config('account_mail_unique')) {
$errors['account'] = 'Account with this email already exist.';
}
else if (!config('account_login_by_email')) {
if (USE_ACCOUNT_NAME)
$errors['account'] = 'Account with this name already exist.';
else
$errors['account'] = 'Account with this id already exist.';
}
}
if(!isset($_POST['accept_rules']) || $_POST['accept_rules'] !== 'true')
@@ -130,11 +141,12 @@ if($save)
'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] === 'true' : false,
);
if(USE_ACCOUNT_NAME) {
$params['account_name'] = $_POST['account'];
}
else {
$params['account_id'] = $_POST['account'];
if (!config('account_login_by_email')) {
if (USE_ACCOUNT_NAME) {
$params['account_name'] = $_POST['account'];
} else {
$params['account_id'] = $_POST['account'];
}
}
$hooks->trigger(HOOK_ACCOUNT_CREATE_AFTER_SUBMIT, $params);
@@ -151,10 +163,15 @@ if($save)
if(empty($errors))
{
$new_account = new OTS_Account();
if(USE_ACCOUNT_NAME)
$new_account->create($account_name);
else
$new_account->create(NULL, $account_id);
if (config('account_login_by_email')) {
$new_account->createWithEmail($email);
}
else {
if(USE_ACCOUNT_NAME)
$new_account->create($account_name);
else
$new_account->create(NULL, $account_id);
}
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
if($config_salt_enabled)
@@ -192,7 +209,11 @@ if($save)
$new_account->setCustomField('premium_points', $config['account_premium_points']);
}
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
$tmp_account = $email;
if (!config('account_login_by_email')) {
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
}
if($config['mail_enabled'] && $config['account_mail_verify'])
{
$hash = md5(generateRandomString(16, true, true) . $email);

View File

@@ -13,5 +13,6 @@ $title = 'Login';
$twig->display('admin.login.html.twig', [
'logout' => (ACTION == 'logout' ? 'You have been logged out!' : ''),
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
'errors' => $errors ?? ''
]);
'account_login_by' => getAccountLoginByLabel(),
'errors' => isset($errors)? $errors : ''
));

View File

@@ -41,13 +41,10 @@ if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
$player->find($name);
if(!$player->isLoaded()) {
$errors[] = 'Player with name <b>'.$name.'</b> doesn\'t exist.';
}
else
{
$rank_of_player = $player->getRank();
if($rank_of_player->isLoaded()) {
$errors[] = 'Character with name <b>'.$name.'</b> is already in guild. You must leave guild before you join other guild.';
}
}else if ($player->getAccountID() != $account_logged->getId()) {
$errors[] = 'Character with name <b> ' . $name. ' </b> is not in your account.';
}else if ($player->getRank()->isLoaded()){
$errors[] = 'Character with name <b>'.$name.'</b> is already in guild. You must leave guild before you join other guild.';
}
}
}
@@ -65,9 +62,8 @@ if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
}
}
}
if(!$is_invited) {
$errors[] = 'Character '.$player->getName.' isn\'t invited to guild <b>'.$guild->getName().'</b>.';
$errors[] = 'Character '.$player->getName() .' isn\'t invited to guild <b>'.$guild->getName().'</b>.';
}
}
}

View File

@@ -88,7 +88,7 @@ if($guild_vice)
else
{
$player_in_guild = false;
if($guild->getName() === $player_to_change->getRank()->getGuild()->getName() || $guild_leader)
if($guild->getName() === $player_to_change->getRank()->getGuild()->getName())
{
$player_in_guild = true;
$player_has_lower_rank = false;