' . $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.'); } $hasSecretColumn = $db->hasColumn('accounts', 'secret'); $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); $hasPointsColumn = $db->hasColumn('accounts', 'premium_points'); $hasTypeColumn = $db->hasColumn('accounts', 'type'); $hasGroupColumn = $db->hasColumn('accounts', 'group_id'); if ($config['account_country']) { $countries = array(); foreach (array('pl', 'se', 'br', 'us', 'gb') as $c) $countries[$c] = $config['countries'][$c]; $countries['--'] = '----------'; foreach ($config['countries'] as $code => $c) $countries[$code] = $c; } ?> 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.'; } } } } $groups = new OTS_Groups_List(); if ($id > 0) { $account = new OTS_Account(); $account->load($id); if (isset($account, $_POST['save']) && $account->isLoaded()) {// we want to save $error = false; $_error = ''; $account_db = new OTS_Account(); if(USE_ACCOUNT_NAME) { $name = $_POST['name']; $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 if($hasTypeColumn || $hasGroupColumn) { $group = $_POST['group']; } $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); if (!Validator::password($password)) { $errors['password'] = Validator::getLastError(); } //secret if($hasSecretColumn) { $secret = $_POST['secret']; } //key $key = $_POST['key']; $email = $_POST['email']; if (!Validator::email($email)) $errors['email'] = Validator::getLastError(); //tibia coins if ($hasCoinsColumn) { $t_coins = $_POST['t_coins']; verify_number($t_coins, 'Tibia coins', 12); } // prem days $p_days = (int)$_POST['p_days']; verify_number($p_days, 'Prem days', 11); //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']; $web_flags = $_POST['web_flags']; verify_number($web_flags, 'Web Flags', 1); //created $created = $_POST['created']; verify_number($created, 'Created', 11); //web last login $web_lastlogin = $_POST['web_lastlogin']; verify_number($web_lastlogin, 'Web Last logout', 11); if (!$error) { if(USE_ACCOUNT_NAME) { $account->setName($name); } if ($hasTypeColumn) { $account->setCustomField('type', $group); } elseif ($hasGroupColumn) { $account->setCustomField('group_id', $group); } if($hasSecretColumn) { $account->setCustomField('secret', $secret); } $account->setCustomField('key', $key); $account->setEMail($email); if ($hasCoinsColumn) { $account->setCustomField('coins', $t_coins); } $lastDay = 0; if($p_days != 0 && $p_days != PHP_INT_MAX ) { $lastDay = time(); } else if ($lastDay != 0) { $lastDay = 0; } $account->setPremDays($p_days); $account->setLastLogin($lastDay); if ($hasPointsColumn) { $account->setCustomField('premium_points', $p_points); } $account->setRLName($rl_name); $account->setLocation($rl_loca); $account->setCountry($rl_country); $account->setCustomField('created', $created); $account->setWebFlags($web_flags); $account->setCustomField('web_lastlogin', $web_lastlogin); 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->save(); echo_success('Account saved at: ' . date('G:i')); } } } $search_account = ''; if (isset($_REQUEST['search_name'])) $search_account = $_REQUEST['search_name']; else if (isset($_REQUEST['search_account'])) $search_account = $_REQUEST['search_account']; else if ($id > 0 && isset($account) && $account->isLoaded()) { if(USE_ACCOUNT_NAME) { $search_account = $account->getName(); } else { $search_account = $account->getId(); } } ?>
isLoaded()) { ?>
getAccGroupId(); if ($hasTypeColumn) { $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>

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'] . '