' . $message . '

'; } function echo_error($message) { global $error; echo '

' . $message . '

'; $error = true; } function verify_number($number, $name, $max_length) { if (!Validator::number($number)) echo_error($name . ' can contain only numbers.'); $number_length = strlen($number); if ($number_length <= 0 || $number_length > $max_length) echo_error($name . ' cannot be longer than ' . $max_length . ' digits.'); } $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); ?> query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($_REQUEST['search_name'])); if ($query->rowCount() == 1) { $query = $query->fetch(); $id = $query['id']; } else { $query = $db->query('SELECT `id`, `name` FROM `accounts` WHERE `name` LIKE ' . $db->quote('%' . $_REQUEST['search_name'] . '%')); if ($query->rowCount() > 0 && $query->rowCount() <= 10) { echo 'Do you mean?'; } else if ($query->rowCount() > 10) echo 'Specified name resulted with too many accounts.'; } } } } if ($id > 0) { $account = new OTS_Account(); $account->load($id); if (isset($account) && $account->isLoaded() && isset($_POST['save'])) {// we want to save $error = false; $name = $_POST['name']; $_error = ''; //if (!Validator::check_account_name($name)) // echo_error(Validator::getLastError()); $account_db = new OTS_Account(); $account_db->find($name); if ($account_db->isLoaded() && $account->getName() != $name) echo_error('This name is already used. Please choose another name!'); $account_db->load($id); if (!$account_db->isLoaded()) echo_error('Account with this id doesn\'t exist.'); //type $group = $_POST['group']; $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); if(!Validator::password($password)) { $errors['password'] = Validator::getLastError(); } //secret $secret = $_POST['secret']; //key $key = $_POST['key']; $email = $_POST['email']; if(!Validator::email($email)) $errors['email'] = Validator::getLastError(); // prem days $p_days = $_POST['p_days']; verify_number($p_days, 'Prem days', 11); //tibia coins if($hasCoinsColumn) { $t_coins = $_POST['t_coins']; verify_number($t_coins, 'Tibia coins', 12); } //prem points $p_points = $_POST['p_points']; verify_number($p_points, 'Prem Points', 11); //rl name $rl_name = $_POST['rl_name']; //location $rl_loca = $_POST['rl_loca']; //country $rl_country = $_POST['rl_country']; //created $created = $_POST['created']; verify_number($created, 'Created', 20); //last login $lastlogin = $_POST['lastlogin']; verify_number($lastlogin, 'Last login', 20); //web last login $web_lastlogin = $_POST['web_lastlogin']; verify_number($web_lastlogin, 'Web Last logout', 20); if (!$error) { $account->setName($name); $account->setCustomField('type', $group); $account->setCustomField('secret', $secret); $account->setCustomField('key', $key); $account->setEMail($email); $account->setPremDays($p_days); if($hasCoinsColumn) { $account->setCustomField('coins', $t_coins); } $account->setRLName($rl_name); $account->setLocation($rl_loca); $account->setCountry($rl_country); if ($db->hasColumn('accounts', 'premium_points')){ $account->setCustomField('premium_points', $p_points);} if (isset($password)) { $config_salt_enabled = $db->hasColumn('accounts', 'salt'); if($config_salt_enabled) { $salt = generateRandomString(10, false, true, true); $password = $salt . $password; $account_logged->setCustomField('salt', $salt); } $password = encrypt($password); $account->setPassword($password); if ($config_salt_enabled) $account->setCustomField('salt', $salt); } $account->setEMail($email); //$account->setCustomField('created', time()); $account->save(); echo_success('Account saved at: ' . date('G:i')); } } } $search_name = ''; $search_account = ''; if (isset($_REQUEST['search_name'])) $search_name = $_REQUEST['search_name']; else if (isset($_REQUEST['search_account'])) $search_account = $_REQUEST['search_account']; else if ($id > 0 && isset($account) && $account->isLoaded()) $search_name = $account->getName(); ?>
isLoaded()) { ?>
hasColumn('players', 'blessings')): ?>

Search Account:

isLoaded()) { $account_players = array(); $query = $db->query('SELECT `name`,`level`,`vocation` FROM `players` WHERE `account_id` = ' . $account->getId() . ' ORDER BY `name`')->fetchAll(); if (isset($query)) { ?>

Character List:

'; $i++; } ?>
# Name Level Edit
'.$i.'. '.$p['name'] . ' '.$p['level'].'