Updates + Fixes (#66)

* Updates

+added account editor country list
+added account editor website access flag editor.
+added player blessing1-8 editor
+added fav icon
+added $account->setLastLogin
+added $player->checkBlessings (for blessings 1-8)
+bug fixes

* Blessing Fix

Should now detect the amount of blessings if blessings1 onwards exists.
This commit is contained in:
Lee 2018-12-26 10:32:58 +00:00 committed by slawkens
parent 1b539f82ac
commit 2667d2b41c
6 changed files with 189 additions and 124 deletions

View File

@ -2,12 +2,18 @@
<!DOCTYPE html>
<html>
<head>
<?php echo template_header(true); ?>
<?php echo template_header(true);
$title_full = (isset($title) ? $title . $config['title_separator'] : '') . $config['lua']['serverName'];
?>
<title><?php echo $title_full ?></title>
<link rel="shortcut icon" href="<?php echo BASE_URL; ?>images/favicon.ico" type="image/x-icon" />
<link rel="icon" href="<?php echo BASE_URL; ?>images/favicon.ico" type="image/x-icon" />
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/AdminLTE.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/skins/skin-blue.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/ionicons.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
@ -16,13 +22,11 @@
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php if ($page != 'tools'): ?>
<?php
if ($logged && admin()) {
?>
@ -214,7 +218,7 @@
<div class="control-sidebar-bg"></div>
</div>
<?php } endif;
<?php }
if (!$logged && !admin()) {
echo $content;
}

View File

@ -426,7 +426,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
{
$this->data['country'] = (string) $country;
}
public function setLastLogin($lastlogin)
{
$this->data['lastday'] = (int) $lastlogin;
}
/**
* Name.

View File

@ -2231,6 +2231,36 @@ class OTS_Player extends OTS_Row_DAO
$this->data['blessings'] = (int) $blessings;
}
public function countBlessings()
{
if( !isset($this->db) )
{
throw new E_OTS_NotLoaded();
}
for( $i = 8; $i >= 1; $i-- ) {
if ($this->db->hasColumn('players', 'blessings' . $i)) {
break;
}
}
return $i;
}
public function checkBlessings($count)
{
if( !isset($this->data['id']) )
{
throw new E_OTS_NotLoaded();
}
$fields = array();
for( $i = 1; $i <= $count; $i++ ) {
$fields[] = 'blessings'.$i;
}
$value = $this->db->query('SELECT '. implode(', ', $fields) .' FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id'])->fetch();
return $value;
}
public function getStamina()
{
if( !isset($this->data['stamina']) )
@ -3608,4 +3638,4 @@ class OTS_Player extends OTS_Row_DAO
/**#@-*/
?>
?>

View File

@ -12,6 +12,9 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Account editor';
$base = BASE_URL . 'admin/?p=accounts';
if ($config['account_country'])
require SYSTEM . 'countries.conf.php';
function echo_success($message)
{
echo '<p class="success">' . $message . '</p>';
@ -35,6 +38,17 @@ function verify_number($number, $name, $max_length)
}
$hasCoinsColumn = $db->hasColumn('accounts', 'coins');
$hasPointsColumn = $db->hasColumn('accounts', 'premium_points');
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;
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
@ -69,7 +83,6 @@ else if (isset($_REQUEST['search_name'])) {
}
}
if ($id > 0) {
$account = new OTS_Account();
$account->load($id);
@ -79,10 +92,6 @@ if ($id > 0) {
$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)
@ -94,7 +103,6 @@ if ($id > 0) {
//type
$group = $_POST['group'];
$password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null));
if (!Validator::password($password)) {
$errors['password'] = Validator::getLastError();
@ -104,20 +112,18 @@ if ($id > 0) {
$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 days
$p_days = $_POST['p_days'];
verify_number($p_days, 'Prem days', 11);
//prem points
$p_points = $_POST['p_points'];
@ -132,18 +138,20 @@ if ($id > 0) {
//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', 20);
verify_number($created, 'Created', 11);
//last login
$lastlogin = $_POST['lastlogin'];
verify_number($lastlogin, 'Last login', 20);
verify_number($lastlogin, 'Last login', 11);
//web last login
$web_lastlogin = $_POST['web_lastlogin'];
verify_number($web_lastlogin, 'Web Last logout', 20);
verify_number($web_lastlogin, 'Web Last logout', 11);
if (!$error) {
$account->setName($name);
@ -151,18 +159,21 @@ if ($id > 0) {
$account->setCustomField('secret', $secret);
$account->setCustomField('key', $key);
$account->setEMail($email);
$account->setPremDays($p_days);
if ($hasCoinsColumn) {
$account->setCustomField('coins', $t_coins);
}
$account->setPremDays($p_days);
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->setLastLogin($lastlogin);
$account->setWebFlags($web_flags);
$account->setCustomField('web_lastlogin', $web_lastlogin);
if ($db->hasColumn('accounts', 'premium_points')) {
$account->setCustomField('premium_points', $p_points);
}
if (isset($password)) {
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
@ -178,9 +189,6 @@ if ($id > 0) {
if ($config_salt_enabled)
$account->setCustomField('salt', $salt);
}
$account->setEMail($email);
//$account->setCustomField('created', time());
$account->save();
@ -205,38 +213,22 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
?>
<?php $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
<?php $web_acc = array("None", "Admin", "Super Admin", "(Admin + Super Admin)"); ?>
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post"
class="form-horizontal">
<div class="col-md-8">
<div class="box box-primary">
<div class="box-body">
<div class="row">
<div class="col-xs-6">
<label for="name" class="control-label">Account Name</label>
<div class="col-xs-4">
<label for="name" class="control-label">Account Name:</label>
<input type="text" class="form-control" id="name" name="name"
autocomplete="off" style="cursor: auto;"
value="<?php echo $account->getName(); ?>"/>
</div>
<div class="col-xs-6">
<label for="account_id" class="control-label">Account id:</label>
<input type="text" class="form-control" id="account_id" name="account_id"
autocomplete="off" style="cursor: auto;" size="8" maxlength="11" disabled
value="<?php echo $account->getId(); ?>"/>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label for="group" class="control-label">Type</label>
<select name="group" id="group" class="form-control">
<?php foreach ($acc_type as $id => $a_type): ?>
<option value="<?php echo($id + 1); ?>" <?php echo($account->getCustomField('type') == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-xs-6">
<div class="col-xs-5">
<label for="c_pass" class="control-label">Password: (check to change)</label>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
name="c_pass"
@ -249,6 +241,31 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
value=""/>
</div>
</div>
<div class="col-xs-3">
<label for="account_id" class="control-label">Account ID:</label>
<input type="text" class="form-control" id="account_id" name="account_id"
autocomplete="off" style="cursor: auto;" size="8" maxlength="11" disabled
value="<?php echo $account->getId(); ?>"/>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label for="group" class="control-label">Account Type:</label>
<select name="group" id="group" class="form-control">
<?php foreach ($acc_type as $id => $a_type): ?>
<option value="<?php echo($id + 1); ?>" <?php echo($account->getCustomField('type') == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-xs-6">
<label for="web_flags" class="control-label">Website Access:</label>
<select name="web_flags" id="web_flags" class="form-control">
<?php foreach ($web_acc as $id => $a_type): ?>
<option value="<?php echo($id); ?>" <?php echo($account->getWebFlags() == ($id) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-6">
@ -271,12 +288,6 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
autocomplete="off" maxlength="20"
value="<?php echo $account->getEMail(); ?>"/>
</div>
<div class="col-xs-6">
<label for="p_days" class="control-label">Prem Days:</label>
<input type="text" class="form-control" id="p_days" name="p_days"
autocomplete="off" maxlength="11"
value="<?php echo $account->getPremDays(); ?>"/>
</div>
<?php if ($hasCoinsColumn): ?>
<div class="col-xs-6">
<label for="t_coins" class="control-label">Tibia Coins:</label>
@ -285,9 +296,15 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
value="<?php echo $account->getCustomField('coins') ?>"/>
</div>
<?php endif; ?>
<?php if ($db->hasColumn('players', 'blessings')): ?>
<div class="col-xs-6">
<label for="p_days" class="control-label">Premium Days:</label>
<input type="text" class="form-control" id="p_days" name="p_days"
autocomplete="off" maxlength="11"
value="<?php echo $account->getPremDays(); ?>"/>
</div>
<?php if ($hasPointsColumn): ?>
<div class="col-xs-6">
<label for="p_points" class="control-label">Prem Points:</label>
<label for="p_points" class="control-label">Premium Points:</label>
<input type="text" class="form-control" id="p_points" name="p_points"
autocomplete="off" maxlength="8"
value="<?php echo $account->getCustomField('premium_points') ?>"/>
@ -309,12 +326,13 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
</div>
<div class="col-xs-4">
<label for="rl_country" class="control-label">Country:</label>
<input type="text" class="form-control" id="rl_country" name="rl_country"
autocomplete="off" maxlength="8"
value="<?php echo $account->getCountry(); ?>"/>
<select name="rl_country" id="rl_country" class="form-control">
<?php foreach ($countries as $id => $a_type): ?>
<option value="<?php echo($id); ?>" <?php echo($account->getCountry() == ($id) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<label for="created" class="control-label">Created:</label>

View File

@ -17,7 +17,7 @@ $title = 'Logs viewer';
</div>
<div class="box-body">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-12">
<table id="tb_logs">
<thead>
<tr>

View File

@ -43,6 +43,10 @@ $skills = array(
POT::SKILL_SHIELD => array('Shielding', 'shield'),
POT::SKILL_FISH => array('Fishing', 'fish')
);
$hasBlessingsColumn = $db->hasColumn('players', 'blessings');
$hasBlessingColumn = $db->hasColumn('players', 'blessings1');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
@ -101,7 +105,6 @@ if ($id > 0) {
if ($player_db->isLoaded() && $player->getName() != $name)
echo_error('This name is already used. Please choose another name!');
$account_id = $_POST['account_id'];
verify_number($account_id, 'Account id', 11);
@ -181,13 +184,6 @@ if ($id > 0) {
verify_number($lastlogin, 'Last login', 20);
$lastlogout = $_POST['lastlogout'];
verify_number($lastlogout, 'Last logout', 20);
/* $lastip = $_POST['lastip'];
$exp = explode(".", $lastip);
$lastip = $exp[3] . '.' . $exp[2] . '.' . $exp[1] . '.' . $exp[0];
$lastip_length = strlen($lastip);
if ($lastip_length <= 0 || $lastip_length > 15)
echo_error('IP cannot be longer than 15 digits.');
*/
$skull = $_POST['skull'];
verify_number($skull, 'Skull', 1);
@ -211,10 +207,11 @@ if ($id > 0) {
verify_number($offlinetraining, 'Offline Training time', 11);
}
if ($db->hasColumn('players', 'blessings')) {
if ($hasBlessingsColumn) {
$blessings = $_POST['blessings'];
verify_number($blessings, 'Blessings', 2);
}
$balance = $_POST['balance'];
verify_number($balance, 'Balance', 20);
if ($db->hasColumn('players', 'stamina')) {
@ -235,6 +232,14 @@ if ($id > 0) {
foreach ($_POST['skills_tries'] as $skill => $value)
verify_number($value, $skills[$skill][0] . ' tries', 10);
$bless_count = $_POST['blesscount'];
if ($hasBlessingColumn) {
for ($i = 1; $i <= $bless_count; $i++) {
$a = 'blessing' . $i;
${'blessing' . $i} = (isset($_POST[$a]) && $_POST[$a] == 'true');
}
}
if (!$error) {
$player->setName($name);
$player->setAccount($account_db);
@ -278,6 +283,13 @@ if ($id > 0) {
}
if ($db->hasColumn('players', 'blessings'))
$player->setBlessings($blessings);
if ($hasBlessingColumn) {
for ($i = 1; $i <= $bless_count; $i++) {
$a = 'blessing' . $i;
$player->setCustomField('blessings' . $i, ${'blessing' . $i} ? '1' : '0');
}
}
$player->setBalance($balance);
if ($db->hasColumn('players', 'stamina'))
$player->setStamina($stamina);
@ -318,7 +330,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post"
class="form-horizontal">
<div class="col-md-8">
<div class="box box-primary">
<div class="box-body">
@ -381,7 +392,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</select>
</div>
<div class="col-xs-6">
<label for="blessings" class="control-label">Town:</label>
<label for="town" class="control-label">Town:</label>
<select name="town" id="town" class="form-control">
<?php foreach ($config['towns'] as $id => $town): ?>
<option value="<?php echo $id; ?>" <?php echo($player->getTownId() == $id ? 'selected' : ''); ?>><?php echo $town; ?></option>
@ -410,8 +421,24 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div>
</div>
<div class="row">
<?php if ($db->hasColumn('players', 'blessings')): ?>
<?php if ($hasBlessingColumn):
$blesscount = $player->countBlessings();
$bless = $player->checkBlessings($blesscount);
?>
<input type="hidden" name="blesscount" value="<?php echo $blesscount; ?>"/>
<div class="col-xs-6">
<label for="blessings" class="control-label">Blessings:</label>
<div class="checkbox">
<?php
for ($i = 1; $i <= $blesscount; $i++) {
echo '<label><input style="margin-left: -16px;" type="checkbox" name="blessing' . $i . '" id="blessing' . $i . '"
value="true" ' . (($bless[$i - 1] == 1) ? ' checked' : '') . '/>' . $i . '</label>';
}
?>
</div>
</div>
<?php endif; ?>
<?php if ($hasBlessingsColumn): ?>
<div class="col-xs-6">
<label for="blessings" class="control-label">Blessings:</label>
<input type="text" class="form-control" id="blessings" name="blessings"
@ -421,7 +448,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<?php endif; ?>
<div class="col-xs-6">
<label for="balance" class="control-label">Balance:</label>
<label for="balance" class="control-label">Bank Balance:</label>
<input type="text" class="form-control" id="balance" name="balance"
autocomplete="off" maxlength="20"
value="<?php echo $player->getBalance(); ?>"/>
@ -492,29 +519,13 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<div class="row">
<div class="col-xs-6 ">
<label for="mana" class="control-label">Mana:</label>
<input type="text" class="form-control" id="health" name="health"
autocomplete="off"
size="5" maxlength="11" style="cursor: auto;"
value="<?php echo $player->getHealth(); ?>"/>
</div>
<div class="col-xs-6">
<label for="mana_max" class="control-label">Mana max:</label>
<input type="text" class="form-control" id="health_max" name="health_max"
autocomplete="off"
size="5" maxlength="11" style="cursor: auto;"
value="<?php echo $player->getHealthMax(); ?>"/>
</div>
</div>
<div class="row">
<div class="col-xs-6 ">
<label for="health" class="control-label">Health:</label>
<input type="text" class="form-control" id="mana" name="mana"
autocomplete="off" size="3"
maxlength="11" style="cursor: auto;"
value="<?php echo $player->getMana(); ?>"/>
</div>
<div class="col-xs-6">
<label for="health_max" class="control-label">Health max:</label>
<label for="mana_max" class="control-label">Mana max:</label>
<input type="text" class="form-control" id="mana_max" name="mana_max"
autocomplete="off"
size="3" maxlength="11" style="cursor: auto;"
@ -522,13 +533,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div>
</div>
<div class="row">
<div class="col-xs-6 ">
<label for="soul" class="control-label">Soul:</label>
<input type="text" class="form-control" id="soul" name="soul"
autocomplete="off" size="3"
maxlength="10" style="cursor: auto;"
value="<?php echo $player->getSoul(); ?>"/>
</div>
<div class="col-xs-6">
<label for="capacity" class="control-label">Capacity:</label>
<input type="text" class="form-control" id="capacity" name="capacity"
@ -536,6 +540,13 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
size="3" maxlength="11" style="cursor: auto;"
value="<?php echo $player->getCap(); ?>"/>
</div>
<div class="col-xs-6 ">
<label for="soul" class="control-label">Soul:</label>
<input type="text" class="form-control" id="soul" name="soul"
autocomplete="off" size="3"
maxlength="10" style="cursor: auto;"
value="<?php echo $player->getSoul(); ?>"/>
</div>
<?php if ($db->hasColumn('players', 'stamina')): ?>
<div class="col-xs-6">
<label for="stamina" class="control-label">Stamina:</label>
@ -546,6 +557,16 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div>
<?php endif; ?>
<?php if ($db->hasColumn('players', 'offlinetraining_time')): ?>
<div class="col-xs-6">
<label for="offlinetraining" class="control-label">Offline Training
Time:</label>
<input type="text" class="form-control" id="offlinetraining"
name="offlinetraining" autocomplete="off"
maxlength="11"
value="<?php echo $player->getCustomField('offlinetraining_time'); ?>"/>
</div>
<?php endif; ?>
</div>
</div>
<div class="tab-pane" id="tab_3">
@ -653,16 +674,13 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div>
<div class="tab-pane" id="tab_5">
<div class="row">
<?php if ($db->hasColumn('players', 'offlinetraining_time')): ?>
<div class="col-xs-6">
<label for="offlinetraining" class="control-label">Offline Training
Time:</label>
<input type="text" class="form-control" id="offlinetraining"
name="offlinetraining" autocomplete="off"
maxlength="11"
value="<?php echo $player->getCustomField('offlinetraining_time'); ?>"/>
</div>
<?php endif; ?>
<div class="col-xs-6">
<label for="created" class="control-label">Created:</label>
<input type="text" class="form-control" id="created" name="created"
autocomplete="off"
maxlength="10"
value="<?php echo $player->getCustomField('created'); ?>"/>
</div>
<div class="col-xs-6">
<label for="lastlogin" class="control-label">Last login:</label>
<input type="text" class="form-control" id="lastlogin" name="lastlogin"
@ -682,13 +700,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
maxlength="10" value="<?php echo longToIp($player->getLastIP()); ?>"
readonly/>
</div>
<div class="col-xs-6">
<label for="created" class="control-label">Created:</label>
<input type="text" class="form-control" id="created" name="created"
autocomplete="off"
maxlength="10"
value="<?php echo $player->getCustomField('created'); ?>"/>
</div>
</div>
<?php if ($db->hasColumn('players', 'loss_experience')): ?>
<div class="row">
@ -727,14 +738,15 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
maxlength="11" value="<?php echo $player->getLossItems(); ?>"/>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-xs-12">
<label for="comment" class="control-label">Comment:</label>
<textarea class="form-control" name="comment" rows="10" cols="50"
wrap="virtual"><?php echo $player->getCustomField("comment"); ?></textarea><br>[max.
length: 2000 chars, 50 lines (ENTERs)]
wrap="virtual"><?php echo $player->getCustomField("comment"); ?></textarea>
<small>[max.
length: 2000 chars, 50 lines (ENTERs)]
</small>
</div>
</div>
</div>
@ -784,7 +796,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<div class="box-header">
<h3 class="box-title">Character List:</h3>
</div>
<!-- /.box-header -->
<div class="box-body no-padding">
<table class="table table-striped">
<tbody>
@ -809,9 +820,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<?php
};
};