mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
Move admin files
This commit is contained in:
484
admin/pages/admin/accounts.php
Normal file
484
admin/pages/admin/accounts.php
Normal file
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
/**
|
||||
* Account editor
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Lee
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
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>';
|
||||
}
|
||||
|
||||
function echo_error($message)
|
||||
{
|
||||
global $error;
|
||||
echo '<p class="error">' . $message . '</p>';
|
||||
$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;
|
||||
}
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
|
||||
<script src="<?php echo BASE_URL; ?>tools/js/jquery.datetimepicker.js"></script>
|
||||
|
||||
<?php
|
||||
$id = 0;
|
||||
if (isset($_REQUEST['id']))
|
||||
$id = (int)$_REQUEST['id'];
|
||||
else if (isset($_REQUEST['search_name'])) {
|
||||
if (strlen($_REQUEST['search_name']) < 3 && !Validator::number($_REQUEST['search_name'])) {
|
||||
echo 'Player name is too short.';
|
||||
} else {
|
||||
if (Validator::number($_REQUEST['search_name']))
|
||||
$id = $_REQUEST['search_name'];
|
||||
else {
|
||||
$query = $db->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?<ul>';
|
||||
foreach ($query as $row)
|
||||
echo '<li><a href="' . $base . '&id=' . $row['id'] . '">' . $row['name'] . '</a></li>';
|
||||
echo '</ul>';
|
||||
} 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 != OTS_Account::GRATIS_PREMIUM_DAYS) {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
<?php if (isset($account) && $account->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">
|
||||
<div class="row">
|
||||
<?php if(USE_ACCOUNT_NAME): ?>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<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"
|
||||
id="c_pass"
|
||||
value="false"
|
||||
class="input_control"/>
|
||||
</span>
|
||||
<input type="text" class="form-control" id="pass" name="pass"
|
||||
autocomplete="off" maxlength="20"
|
||||
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">
|
||||
<?php
|
||||
$acc_group = $account->getAccGroupId();
|
||||
if ($hasTypeColumn) {
|
||||
$acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
|
||||
<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($acc_group == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
} elseif ($hasGroupColumn) {
|
||||
?>
|
||||
<div class="col-xs-6">
|
||||
<label for="group" class="control-label">Account Type:</label>
|
||||
<select name="group" id="group" class="form-control">
|
||||
<?php
|
||||
foreach ($groups->getGroups() as $id => $group): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo($acc_group == $id ? 'selected' : ''); ?>><?php echo $group->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<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 $web_acc = array("None", "Admin", "Super Admin", "(Admin + Super Admin)");
|
||||
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">
|
||||
<?php if($hasSecretColumn): ?>
|
||||
<div class="col-xs-6">
|
||||
<label for="secret" class="control-label">Secret:</label>
|
||||
<input type="text" class="form-control" id="secret" name="secret"
|
||||
autocomplete="off" style="cursor: auto;" size="8" maxlength="11"
|
||||
value="<?php echo $account->getCustomField('secret'); ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-xs-6">
|
||||
<label for="key" class="control-label">Key:</label>
|
||||
<input type="text" class="form-control" id="key" name="key"
|
||||
autocomplete="off" style="cursor: auto;" size="8" maxlength="11"
|
||||
value="<?php echo $account->getCustomField('key'); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="email" class="control-label">Email:</label>
|
||||
<input type="text" class="form-control" id="email" name="email"
|
||||
autocomplete="off" maxlength="20"
|
||||
value="<?php echo $account->getEMail(); ?>"/>
|
||||
</div>
|
||||
<?php if ($hasCoinsColumn): ?>
|
||||
<div class="col-xs-6">
|
||||
<label for="t_coins" class="control-label">Tibia Coins:</label>
|
||||
<input type="text" class="form-control" id="t_coins" name="t_coins"
|
||||
autocomplete="off" maxlength="8"
|
||||
value="<?php echo $account->getCustomField('coins') ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<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">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') ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<label for="rl_name" class="control-label">RL Name:</label>
|
||||
<input type="text" class="form-control" id="rl_name" name="rl_name"
|
||||
autocomplete="off" maxlength="20"
|
||||
value="<?php echo $account->getRLName(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label for="rl_loca" class="control-label">Location:</label>
|
||||
<input type="text" class="form-control" id="rl_loca" name="rl_loca"
|
||||
autocomplete="off" maxlength="20"
|
||||
value="<?php echo $account->getLocation(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label for="rl_country" class="control-label">Country:</label>
|
||||
<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>
|
||||
<input type="text" class="form-control" id="created" name="created"
|
||||
autocomplete="off" maxlength="20"
|
||||
value="<?php echo $account->getCustomField('created'); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label for="web_lastlogin" class="control-label">Web Last Login:</label>
|
||||
<input type="text" class="form-control" id="web_lastlogin" name="web_lastlogin"
|
||||
autocomplete="off" maxlength="20"
|
||||
value="<?php echo $account->getCustomField('web_lastlogin'); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="save" value="yes"/>
|
||||
<div class="box-footer">
|
||||
<a href="<?php echo ADMIN_URL; ?>?p=accounts"><span class="btn btn-danger">Cancel</span></a>
|
||||
<div class="pull-right">
|
||||
<input type="submit" class="btn btn-primary" value="Update">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="col-md-4">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Search Account:</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<form action="<?php echo $base; ?>" method="post">
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" class="form-control" name="search_name" value="<?php echo $search_account; ?>"
|
||||
maxlength="32" size="32">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" type="button" class="btn btn-info btn-flat">Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($account) && $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)) {
|
||||
?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Character List:</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 10px">#</th>
|
||||
<th>Name</th>
|
||||
<th>Level</th>
|
||||
<th style="width: 40px">Edit</th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 1;
|
||||
foreach ($query as $p) {
|
||||
$account_players[] = $p;
|
||||
echo '<tr>
|
||||
<td>' . $i . '.</td>
|
||||
<td>' . $p['name'] . '</td>
|
||||
<td>' . $p['level'] . '</td>
|
||||
<td><a href="?p=players&search_name=' . $p['name'] . '"><span class="btn btn-success btn-sm edit btn-flat"><i class="fa fa-edit"></i></span></a></span></td>
|
||||
</tr>';
|
||||
$i++;
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
};
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#lastlogout').datetimepicker({format: 'unixtime'});
|
||||
$('#created').datetimepicker({format: 'unixtime'});
|
||||
$('#web_lastlogin').datetimepicker({format: 'unixtime'});
|
||||
$(document).ready(function () {
|
||||
$('.input_control').change(function () {
|
||||
$('input[name=pass]')[0].disabled = !this.checked;
|
||||
$('input[name=pass]')[0].value = '';
|
||||
}).change();
|
||||
});
|
||||
</script>
|
26
admin/pages/admin/changelog.php
Normal file
26
admin/pages/admin/changelog.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* CHANGELOG viewer
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'MyAAC Changelog';
|
||||
|
||||
if (!file_exists(BASE . 'CHANGELOG.md')) {
|
||||
echo 'File CHANGELOG.md doesn\'t exist.';
|
||||
return;
|
||||
}
|
||||
|
||||
require LIBS . 'Parsedown.php';
|
||||
|
||||
$changelog = file_get_contents(BASE . 'CHANGELOG.md');
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
|
||||
$changelog = $Parsedown->text($changelog); # prints: <p>Hello <em>Parsedown</em>!</p>
|
||||
|
||||
echo '<div>' . $changelog . '</div>';
|
91
admin/pages/admin/dashboard.php
Normal file
91
admin/pages/admin/dashboard.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Dashboard
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Dashboard';
|
||||
|
||||
if (isset($_GET['clear_cache'])) {
|
||||
if (clearCache()) {
|
||||
success('Cache cleared.');
|
||||
} else {
|
||||
error('Error while clearing cache.');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['maintenance'])) {
|
||||
$_status = (int)$_POST['status'];
|
||||
$message = $_POST['message'];
|
||||
if (empty($message)) {
|
||||
error('Message cannot be empty.');
|
||||
} else if (strlen($message) > 255) {
|
||||
error('Message is too long. Maximum length allowed is 255 chars.');
|
||||
} else {
|
||||
$tmp = '';
|
||||
if (fetchDatabaseConfig('site_closed', $tmp))
|
||||
updateDatabaseConfig('site_closed', $_status);
|
||||
else
|
||||
registerDatabaseConfig('site_closed', $_status);
|
||||
|
||||
if (fetchDatabaseConfig('site_closed_message', $tmp))
|
||||
updateDatabaseConfig('site_closed_message', $message);
|
||||
else
|
||||
registerDatabaseConfig('site_closed_message', $message);
|
||||
}
|
||||
}
|
||||
$is_closed = getDatabaseConfig('site_closed') == '1';
|
||||
|
||||
$closed_message = 'Server is under maintenance, please visit later.';
|
||||
$tmp = '';
|
||||
if (fetchDatabaseConfig('site_closed_message', $tmp))
|
||||
$closed_message = $tmp;
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `accounts`;');
|
||||
$query = $query->fetch();
|
||||
$total_accounts = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `players`;');
|
||||
$query = $query->fetch();
|
||||
$total_players = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `guilds`;');
|
||||
$query = $query->fetch();
|
||||
$total_guilds = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `houses`;');
|
||||
$query = $query->fetch();
|
||||
$total_houses = $query['how_much'];
|
||||
|
||||
$twig->display('admin.statistics.html.twig', array(
|
||||
'total_accounts' => $total_accounts,
|
||||
'total_players' => $total_players,
|
||||
'total_guilds' => $total_guilds,
|
||||
'total_houses' => $total_houses
|
||||
));
|
||||
|
||||
$twig->display('admin.dashboard.html.twig', array(
|
||||
'is_closed' => $is_closed,
|
||||
'closed_message' => $closed_message,
|
||||
'status' => $status,
|
||||
'account_type' => USE_ACCOUNT_NAME ? 'name' : 'number'
|
||||
));
|
||||
|
||||
echo '<div class="row">';
|
||||
|
||||
$configAdminPanelModules = config('admin_panel_modules');
|
||||
if(isset($configAdminPanelModules))
|
||||
$configAdminPanelModules = explode(',', $configAdminPanelModules);
|
||||
|
||||
$twig_loader->prependPath(__DIR__ . '/modules/templates');
|
||||
foreach($configAdminPanelModules as $box) {
|
||||
$file = __DIR__ . '/modules/' . $box . '.php';
|
||||
if(file_exists($file)) {
|
||||
include($file);
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
0
admin/pages/admin/index.html
Normal file
0
admin/pages/admin/index.html
Normal file
35
admin/pages/admin/items.php
Normal file
35
admin/pages/admin/items.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Load items.xml
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Load items.xml';
|
||||
|
||||
require LIBS . 'items.php';
|
||||
require LIBS . 'weapons.php';
|
||||
|
||||
$twig->display('admin.items.html.twig');
|
||||
|
||||
$reload = isset($_REQUEST['reload']) && (int)$_REQUEST['reload'] === 1;
|
||||
if ($reload) {
|
||||
$items_start_time = microtime(true);
|
||||
if (Items::loadFromXML(true)) {
|
||||
success('Successfully loaded items (in ' . round(microtime(true) - $items_start_time, 4) . ' seconds).');
|
||||
}
|
||||
else {
|
||||
error(Items::getError());
|
||||
}
|
||||
|
||||
$weapons_start_time = microtime(true);
|
||||
if (Weapons::loadFromXML(true)) {
|
||||
success('Successfully loaded weapons (in ' . round(microtime(true) - $weapons_start_time, 4) . ' seconds).');
|
||||
}
|
||||
else {
|
||||
error(Weapons::getError());
|
||||
}
|
||||
}
|
26
admin/pages/admin/login.php
Normal file
26
admin/pages/admin/login.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Login
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Login';
|
||||
$logout = '';
|
||||
if ($action == 'logout') {
|
||||
$logout = "You have been logged out!";
|
||||
}
|
||||
|
||||
if (isset($errors)) {
|
||||
foreach ($errors as $error) {
|
||||
error($error);
|
||||
}
|
||||
}
|
||||
|
||||
$twig->display('admin.login.html.twig', array(
|
||||
'logout' => $logout,
|
||||
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
|
||||
));
|
81
admin/pages/admin/logs.php
Normal file
81
admin/pages/admin/logs.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Logs
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Logs Viewer';
|
||||
|
||||
$files = array();
|
||||
$aac_path_logs = BASE . 'system/logs/';
|
||||
foreach (scandir($aac_path_logs, SCANDIR_SORT_ASCENDING) as $f) {
|
||||
if ($f[0] === '.' || is_dir($aac_path_logs . $f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = array($f, $aac_path_logs);
|
||||
}
|
||||
|
||||
$server_path_logs = $config['server_path'] . 'logs/';
|
||||
if (!file_exists($server_path_logs)) {
|
||||
$server_path_logs = $config['data_path'] . 'logs/';
|
||||
}
|
||||
|
||||
if (file_exists($server_path_logs)) {
|
||||
foreach (scandir($server_path_logs, SCANDIR_SORT_ASCENDING) as $f) {
|
||||
if ($f[0] === '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($server_path_logs . $f)) {
|
||||
foreach (scandir($server_path_logs . $f, SCANDIR_SORT_ASCENDING) as $f2) {
|
||||
if ($f2[0] === '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = array($f . '/' . $f2, $server_path_logs);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = array($f, $server_path_logs);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as &$f) {
|
||||
$f['mtime'] = filemtime($f[1] . $f[0]);
|
||||
$f['name'] = $f[0];
|
||||
}
|
||||
unset($f);
|
||||
|
||||
$twig->display('admin.logs.html.twig', array('files' => $files));
|
||||
|
||||
define('EXIST_NONE', 0);
|
||||
define('EXIST_SERVER_LOG', 1);
|
||||
define('EXIST_AAC_LOG', 2);
|
||||
|
||||
$exist = EXIST_NONE;
|
||||
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
||||
if (!empty($file)) {
|
||||
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
||||
if (file_exists($aac_path_logs . $file)) {
|
||||
$exist = EXIST_AAC_LOG;
|
||||
} else if (file_exists($server_path_logs . $file)) {
|
||||
$exist = EXIST_SERVER_LOG;
|
||||
} else {
|
||||
echo 'Specified file does not exist.';
|
||||
}
|
||||
|
||||
if ($exist !== EXIST_NONE) {
|
||||
$content = nl2br(file_get_contents(($exist === EXIST_SERVER_LOG ? $server_path_logs : $aac_path_logs) . $file));
|
||||
$twig->display('admin.logs.view.html.twig', array('file' => $file, 'content' => $content));
|
||||
}
|
||||
} else {
|
||||
echo 'Invalid file name specified.';
|
||||
}
|
||||
}
|
69
admin/pages/admin/mailer.php
Normal file
69
admin/pages/admin/mailer.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Mailer
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Mailer';
|
||||
|
||||
if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) {
|
||||
echo 'Access denied.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$config['mail_enabled']) {
|
||||
echo 'Mail support disabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
$mail_content = isset($_POST['mail_content']) ? stripslashes($_POST['mail_content']) : NULL;
|
||||
$mail_subject = isset($_POST['mail_subject']) ? stripslashes($_POST['mail_subject']) : NULL;
|
||||
$preview = isset($_REQUEST['preview']);
|
||||
|
||||
$preview_done = false;
|
||||
if ($preview) {
|
||||
if (!empty($mail_content) && !empty($mail_subject)) {
|
||||
$preview_done = _mail($account_logged->getCustomField('email'), $mail_subject, $mail_content);
|
||||
|
||||
if (!$preview_done)
|
||||
error('Error while sending preview mail. More info can be found in system/logs/mailer-error.log');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$twig->display('admin.mailer.html.twig', array(
|
||||
'mail_subject' => $mail_subject,
|
||||
'mail_content' => $mail_content,
|
||||
'preview_done' => $preview_done
|
||||
));
|
||||
|
||||
if (empty($mail_content) || empty($mail_subject) || $preview)
|
||||
return;
|
||||
|
||||
$success = 0;
|
||||
$failed = 0;
|
||||
|
||||
$add = '';
|
||||
if ($config['account_mail_verify']) {
|
||||
note('Note: Sending only to users with verified E-Mail.');
|
||||
$add = ' AND ' . $db->fieldName('email_verified') . ' = 1';
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT ' . $db->fieldName('email') . ' FROM ' . $db->tableName('accounts') . ' WHERE ' . $db->fieldName('email') . ' != ""' . $add);
|
||||
foreach ($query as $email) {
|
||||
if (_mail($email['email'], $mail_subject, $mail_content))
|
||||
$success++;
|
||||
else {
|
||||
$failed++;
|
||||
echo '<br />';
|
||||
error('An error occorred while sending email to <b>' . $email['email'] . '</b>. For Admin: More info can be found in system/logs/mailer-error.log');
|
||||
}
|
||||
}
|
||||
|
||||
success('Mailing finished.');
|
||||
success("$success emails delivered.");
|
||||
warning("$failed emails failed.");
|
137
admin/pages/admin/menus.php
Normal file
137
admin/pages/admin/menus.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Menus
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Menus';
|
||||
|
||||
if (!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin()) {
|
||||
echo 'Access denied.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['template'])) {
|
||||
$template = $_REQUEST['template'];
|
||||
|
||||
if (isset($_REQUEST['menu'])) {
|
||||
$post_menu = $_REQUEST['menu'];
|
||||
$post_menu_link = $_REQUEST['menu_link'];
|
||||
$post_menu_blank = $_REQUEST['menu_blank'];
|
||||
$post_menu_color = $_REQUEST['menu_color'];
|
||||
if (count($post_menu) != count($post_menu_link)) {
|
||||
echo 'Menu count is not equal menu links. Something went wrong when sending form.';
|
||||
return;
|
||||
}
|
||||
|
||||
$db->query('DELETE FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template));
|
||||
foreach ($post_menu as $category => $menus) {
|
||||
foreach ($menus as $i => $menu) {
|
||||
if (empty($menu)) // don't save empty menu item
|
||||
continue;
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'blank' => $post_menu_blank[$category][$i] == 'on' ? 1 : 0, 'color' => str_replace('#', '', $post_menu_color[$category][$i]), 'category' => $category, 'ordering' => $i));
|
||||
} catch (PDOException $error) {
|
||||
warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$cache->delete('template_menus');
|
||||
}
|
||||
|
||||
success('Saved at ' . date('H:i'));
|
||||
}
|
||||
|
||||
$file = TEMPLATES . $template . '/config.php';
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
} else {
|
||||
echo 'Cannot find template config.php file.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($config['menu_categories'])) {
|
||||
echo "No menu categories set in template config.php.<br/>This template doesn't support dynamic menus.";
|
||||
return;
|
||||
}
|
||||
|
||||
echo 'Hint: You can drag menu items.<br/>
|
||||
Hint: Add links to external sites using: <b>http://</b> or <b>https://</b> prefix.<br/>
|
||||
Not all templates support blank and colorful links.<br/><br/>
|
||||
<div class="row">';
|
||||
$menus = array();
|
||||
$menus_db = $db->query('SELECT `name`, `link`, `blank`, `color`, `category`, `ordering` FROM `' . TABLE_PREFIX . 'menu` WHERE `enabled` = 1 AND `template` = ' . $db->quote($template) . ' ORDER BY `ordering` ASC;')->fetchAll();
|
||||
foreach ($menus_db as $menu) {
|
||||
$menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'blank' => $menu['blank'], 'color' => $menu['color'], 'ordering' => $menu['ordering']);
|
||||
}
|
||||
|
||||
$last_id = array();
|
||||
echo '<form method="post" id="menus-form" action="?p=menus">';
|
||||
echo '<input type="hidden" name="template" value="' . $template . '"/>';
|
||||
foreach ($config['menu_categories'] as $id => $cat) {
|
||||
echo ' <div class="col-md-12 col-lg-6">
|
||||
<div class="box box-danger">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">' . $cat['name'] . ' <img class="add-button" id="add-button-' . $id . '" src="' . BASE_URL . 'images/plus.png" width="16" height="16"/></h3>
|
||||
</div>
|
||||
<div class="box-body">';
|
||||
|
||||
|
||||
echo '<ul class="sortable" id="sortable-' . $id . '">';
|
||||
if (isset($menus[$id])) {
|
||||
$i = 0;
|
||||
foreach ($menus[$id] as $menu) {
|
||||
echo '<li class="ui-state-default" id="list-' . $id . '-' . $i . '"><label>Name:</label><input type="text" name="menu[' . $id . '][]" value="' . $menu['name'] . '"/>
|
||||
<label>Link:</label><input type="text" name="menu_link[' . $id . '][]" value="' . $menu['link'] . '"/>
|
||||
<input type="hidden" name="menu_blank[' . $id . '][]" value="0" />
|
||||
<label><input class="blank-checkbox" type="checkbox" ' . ($menu['blank'] == 1 ? 'checked' : '') . '/><span title="Open in New Window">Open in New Window</span></label>
|
||||
|
||||
<input class="color-picker" type="text" name="menu_color[' . $id . '][]" value="#' . $menu['color'] . '" />
|
||||
|
||||
<a class="remove-button" id="remove-button-' . $id . '-' . $i . '"><img src="' . BASE_URL . 'images/del.png"/></a></li>';
|
||||
|
||||
$i++;
|
||||
$last_id[$id] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo ' </div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
echo ' </div><div class="row"><div class="col-md-6">';
|
||||
echo '<input type="submit" class="btn btn-info" value="Save">';
|
||||
echo '<input type="button" class="btn btn-default pull-right" value="Cancel" onclick="window.location = \'' . ADMIN_URL . '?p=menus&template=' . $template . '\';">';
|
||||
echo '</div></div>';
|
||||
echo '</form>';
|
||||
|
||||
$twig->display('admin.menus.js.html.twig', array(
|
||||
'menus' => $menus,
|
||||
'last_id' => $last_id
|
||||
));
|
||||
?>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
$templates = $db->query('SELECT `template` FROM `' . TABLE_PREFIX . 'menu` GROUP BY `template`;')->fetchAll();
|
||||
foreach ($templates as $key => $value) {
|
||||
$file = TEMPLATES . $value['template'] . '/config.php';
|
||||
if (!file_exists($file)) {
|
||||
unset($templates[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$twig->display('admin.menus.form.html.twig', array(
|
||||
'templates' => $templates
|
||||
));
|
||||
}
|
11
admin/pages/admin/modules/coins.php
Normal file
11
admin/pages/admin/modules/coins.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if ($db->hasColumn('accounts', 'coins')) {
|
||||
$coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;');
|
||||
} else {
|
||||
$coins = 0;
|
||||
}
|
||||
|
||||
$twig->display('coins.html.twig', array(
|
||||
'coins' => $coins
|
||||
));
|
0
admin/pages/admin/modules/index.html
Normal file
0
admin/pages/admin/modules/index.html
Normal file
11
admin/pages/admin/modules/lastlogin.php
Normal file
11
admin/pages/admin/modules/lastlogin.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if ($db->hasColumn('players', 'lastlogin')) {
|
||||
$players = $db->query('SELECT name, level, lastlogin FROM players ORDER BY lastlogin DESC LIMIT 10;');
|
||||
} else {
|
||||
$players = 0;
|
||||
}
|
||||
|
||||
$twig->display('lastlogin.html.twig', array(
|
||||
'players' => $players,
|
||||
));
|
10
admin/pages/admin/modules/points.php
Normal file
10
admin/pages/admin/modules/points.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ($db->hasColumn('accounts', 'premium_points')) {
|
||||
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
|
||||
} else {
|
||||
$points = 0;
|
||||
}
|
||||
|
||||
$twig->display('points.html.twig', array(
|
||||
'points' => $points,
|
||||
));
|
29
admin/pages/admin/modules/templates/coins.html.twig
Normal file
29
admin/pages/admin/modules/templates/coins.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% if coins is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Top 10 - Most coins</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Account {{ account_type }}</th>
|
||||
<th>Tibia coins</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in coins %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.coins }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
0
admin/pages/admin/modules/templates/index.html
Normal file
0
admin/pages/admin/modules/templates/index.html
Normal file
29
admin/pages/admin/modules/templates/lastlogin.html.twig
Normal file
29
admin/pages/admin/modules/templates/lastlogin.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% if players is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Last 10 Logins</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Player</th>
|
||||
<th>Login Date</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in players %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.lastlogin|date("M d Y, H:i:s") }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
29
admin/pages/admin/modules/templates/points.html.twig
Normal file
29
admin/pages/admin/modules/templates/points.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% if points is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Top 10 - Most premium points</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Account {{ account_type }}</th>
|
||||
<th>Premium points</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in points %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.premium_points }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
154
admin/pages/admin/news.php
Normal file
154
admin/pages/admin/news.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Pages
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
require_once LIBS . 'forum.php';
|
||||
require_once LIBS . 'news.php';
|
||||
|
||||
$title = 'News Panel';
|
||||
|
||||
if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
|
||||
echo 'Access denied.';
|
||||
return;
|
||||
}
|
||||
|
||||
header('X-XSS-Protection:0');
|
||||
|
||||
// some constants, used mainly by database (cannot by modified without schema changes)
|
||||
define('TITLE_LIMIT', 100);
|
||||
define('BODY_LIMIT', 65535); // maximum news body length
|
||||
define('ARTICLE_TEXT_LIMIT', 300);
|
||||
define('ARTICLE_IMAGE_LIMIT', 100);
|
||||
|
||||
$name = $p_title = '';
|
||||
if(!empty($action))
|
||||
{
|
||||
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
|
||||
$p_title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
|
||||
$body = isset($_REQUEST['body']) ? stripslashes($_REQUEST['body']) : null;
|
||||
$comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : null;
|
||||
$type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : null;
|
||||
$category = isset($_REQUEST['category']) ? (int)$_REQUEST['category'] : null;
|
||||
$player_id = isset($_REQUEST['player_id']) ? (int)$_REQUEST['player_id'] : null;
|
||||
$article_text = isset($_REQUEST['article_text']) ? $_REQUEST['article_text'] : null;
|
||||
$article_image = isset($_REQUEST['article_image']) ? $_REQUEST['article_image'] : null;
|
||||
$forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null;
|
||||
$errors = array();
|
||||
|
||||
if($action == 'add') {
|
||||
if(isset($forum_section) && $forum_section != '-1') {
|
||||
$forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors);
|
||||
}
|
||||
|
||||
if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) {
|
||||
$p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
|
||||
success("Added successful.");
|
||||
}
|
||||
}
|
||||
else if($action == 'delete') {
|
||||
News::delete($id, $errors);
|
||||
success("Deleted successful.");
|
||||
}
|
||||
else if($action == 'edit')
|
||||
{
|
||||
if(isset($id) && !isset($p_title)) {
|
||||
$news = News::get($id);
|
||||
$p_title = $news['title'];
|
||||
$body = $news['body'];
|
||||
$comments = $news['comments'];
|
||||
$type = $news['type'];
|
||||
$category = $news['category'];
|
||||
$player_id = $news['player_id'];
|
||||
$article_text = $news['article_text'];
|
||||
$article_image = $news['article_image'];
|
||||
}
|
||||
else {
|
||||
if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $article_text, $article_image, $errors)) {
|
||||
// update forum thread if exists
|
||||
if(isset($forum_section) && Validator::number($forum_section)) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section));
|
||||
}
|
||||
|
||||
$action = $p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
|
||||
success("Updated successful.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($action == 'hide') {
|
||||
News::toggleHidden($id, $errors, $status);
|
||||
success(($status == 1 ? 'Show' : 'Hide') . " successful.");
|
||||
}
|
||||
|
||||
if(!empty($errors))
|
||||
error(implode(", ", $errors));
|
||||
}
|
||||
|
||||
$categories = array();
|
||||
foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat)
|
||||
{
|
||||
$categories[$cat['id']] = array(
|
||||
'name' => $cat['name'],
|
||||
'icon_id' => $cat['icon_id']
|
||||
);
|
||||
}
|
||||
|
||||
if($action == 'edit' || $action == 'new') {
|
||||
if($action == 'edit') {
|
||||
$player = new OTS_Player();
|
||||
$player->load($player_id);
|
||||
}
|
||||
|
||||
$account_players = $account_logged->getPlayersList();
|
||||
$account_players->orderBy('group_id', POT::ORDER_DESC);
|
||||
$twig->display('admin.news.form.html.twig', array(
|
||||
'action' => $action,
|
||||
'news_link' => getLink(PAGE),
|
||||
'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'add'),
|
||||
'news_id' => isset($id) ? $id : null,
|
||||
'title' => isset($p_title) ? $p_title : '',
|
||||
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
|
||||
'type' => isset($type) ? $type : null,
|
||||
'player' => isset($player) && $player->isLoaded() ? $player : null,
|
||||
'player_id' => isset($player_id) ? $player_id : null,
|
||||
'account_players' => $account_players,
|
||||
'category' => isset($category) ? $category : 0,
|
||||
'categories' => $categories,
|
||||
'forum_boards' => getForumBoards(),
|
||||
'forum_section' => isset($forum_section) ? $forum_section : null,
|
||||
'comments' => isset($comments) ? $comments : null,
|
||||
'article_text' => isset($article_text) ? $article_text : null,
|
||||
'article_image' => isset($article_image) ? $article_image : null
|
||||
));
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
||||
$newses = array();
|
||||
foreach ($query as $_news) {
|
||||
$_player = new OTS_Player();
|
||||
$_player->load($_news['player_id']);
|
||||
|
||||
$newses[$_news['type']][] = array(
|
||||
'id' => $_news['id'],
|
||||
'hidden' => $_news['hidden'],
|
||||
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
||||
'title' => $_news['title'],
|
||||
'date' => $_news['date'],
|
||||
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||
);
|
||||
}
|
||||
|
||||
$twig->display('admin.news.html.twig', array(
|
||||
'newses' => $newses
|
||||
));
|
52
admin/pages/admin/notepad.php
Normal file
52
admin/pages/admin/notepad.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Notepad
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Notepad';
|
||||
|
||||
$notepad_content = Notepad::get($account_logged->getId());
|
||||
if (isset($_POST['content'])) {
|
||||
$_content = html_entity_decode(stripslashes($_POST['content']));
|
||||
if (!$notepad_content)
|
||||
Notepad::create($account_logged->getId(), $_content);
|
||||
else
|
||||
Notepad::update($account_logged->getId(), $_content);
|
||||
|
||||
echo '<div class="success" style="text-align: center;">Saved at ' . date('H:i') . '</div>';
|
||||
} else {
|
||||
if ($notepad_content !== false)
|
||||
$_content = $notepad_content;
|
||||
}
|
||||
|
||||
$twig->display('admin.notepad.html.twig', array('content' => isset($_content) ? $_content : null));
|
||||
|
||||
class Notepad
|
||||
{
|
||||
static public function get($account_id)
|
||||
{
|
||||
global $db;
|
||||
$query = $db->select(TABLE_PREFIX . 'notepad', array('account_id' => $account_id));
|
||||
if ($query !== false)
|
||||
return $query['content'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function create($account_id, $content = '')
|
||||
{
|
||||
global $db;
|
||||
$db->insert(TABLE_PREFIX . 'notepad', array('account_id' => $account_id, 'content' => $content));
|
||||
}
|
||||
|
||||
static public function update($account_id, $content = '')
|
||||
{
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'notepad', array('content' => $content), array('account_id' => $account_id));
|
||||
}
|
||||
}
|
200
admin/pages/admin/pages.php
Normal file
200
admin/pages/admin/pages.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* Pages
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Pages';
|
||||
|
||||
if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
|
||||
echo 'Access denied.';
|
||||
return;
|
||||
}
|
||||
|
||||
header('X-XSS-Protection:0');
|
||||
|
||||
$name = $p_title = '';
|
||||
$groups = new OTS_Groups_List();
|
||||
|
||||
$php = false;
|
||||
$enable_tinymce = true;
|
||||
$access = 0;
|
||||
|
||||
if (!empty($action)) {
|
||||
if ($action == 'delete' || $action == 'edit' || $action == 'hide')
|
||||
$id = $_REQUEST['id'];
|
||||
|
||||
if (isset($_REQUEST['name']))
|
||||
$name = $_REQUEST['name'];
|
||||
|
||||
if (isset($_REQUEST['title']))
|
||||
$p_title = $_REQUEST['title'];
|
||||
|
||||
$php = isset($_REQUEST['php']) && $_REQUEST['php'] == 1;
|
||||
$enable_tinymce = isset($_REQUEST['enable_tinymce']) && $_REQUEST['enable_tinymce'] == 1;
|
||||
if ($php)
|
||||
$body = $_REQUEST['body'];
|
||||
else if (isset($_REQUEST['body'])) {
|
||||
//$body = $_REQUEST['body'];
|
||||
$body = html_entity_decode(stripslashes($_REQUEST['body']));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['access']))
|
||||
$access = $_REQUEST['access'];
|
||||
|
||||
$errors = array();
|
||||
$player_id = 1;
|
||||
|
||||
if ($action == 'add') {
|
||||
if (Pages::add($name, $p_title, $body, $player_id, $php, $enable_tinymce, $access, $errors)) {
|
||||
$name = $p_title = $body = '';
|
||||
$player_id = $access = 0;
|
||||
$php = false;
|
||||
$enable_tinymce = true;
|
||||
}
|
||||
} else if ($action == 'delete') {
|
||||
if (Pages::delete($id, $errors))
|
||||
success('Page with id ' . $id . ' has been deleted');
|
||||
} else if ($action == 'edit') {
|
||||
if (isset($id) && !isset($_REQUEST['name'])) {
|
||||
$_page = Pages::get($id);
|
||||
$name = $_page['name'];
|
||||
$p_title = $_page['title'];
|
||||
$body = $_page['body'];
|
||||
$php = $_page['php'] == '1';
|
||||
$enable_tinymce = $_page['enable_tinymce'] == '1';
|
||||
$access = $_page['access'];
|
||||
} else {
|
||||
Pages::update($id, $name, $p_title, $body, $player_id, $php, $enable_tinymce, $access);
|
||||
$action = $name = $p_title = $body = '';
|
||||
$player_id = 1;
|
||||
$access = 0;
|
||||
$php = false;
|
||||
$enable_tinymce = true;
|
||||
}
|
||||
} else if ($action == 'hide') {
|
||||
Pages::toggleHidden($id, $errors);
|
||||
}
|
||||
|
||||
if (!empty($errors))
|
||||
error(implode(", ", $errors));
|
||||
}
|
||||
|
||||
$query =
|
||||
$db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'pages'));
|
||||
|
||||
$pages = array();
|
||||
foreach ($query as $_page) {
|
||||
$pages[] = array(
|
||||
'link' => getFullLink($_page['name'], $_page['name'], true),
|
||||
'title' => substr($_page['title'], 0, 20),
|
||||
'php' => $_page['php'] == '1',
|
||||
'id' => $_page['id'],
|
||||
'hidden' => $_page['hidden']
|
||||
);
|
||||
}
|
||||
|
||||
$twig->display('admin.pages.form.html.twig', array(
|
||||
'action' => $action,
|
||||
'id' => $action == 'edit' ? $id : null,
|
||||
'name' => $name,
|
||||
'title' => $p_title,
|
||||
'php' => $php,
|
||||
'enable_tinymce' => $enable_tinymce,
|
||||
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
|
||||
'groups' => $groups->getGroups(),
|
||||
'access' => $access
|
||||
));
|
||||
|
||||
$twig->display('admin.pages.html.twig', array(
|
||||
'pages' => $pages
|
||||
));
|
||||
|
||||
class Pages
|
||||
{
|
||||
static public function get($id)
|
||||
{
|
||||
global $db;
|
||||
$query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id));
|
||||
if ($query !== false)
|
||||
return $query;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function add($name, $title, $body, $player_id, $php, $enable_tinymce, $access, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if (isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0) {
|
||||
$query = $db->select(TABLE_PREFIX . 'pages', array('name' => $name));
|
||||
if ($query === false)
|
||||
$db->insert(TABLE_PREFIX . 'pages',
|
||||
array(
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'player_id' => $player_id,
|
||||
'php' => $php ? '1' : '0',
|
||||
'enable_tinymce' => $enable_tinymce ? '1' : '0',
|
||||
'access' => $access
|
||||
)
|
||||
);
|
||||
else
|
||||
$errors[] = 'Page with this link already exists.';
|
||||
} else
|
||||
$errors[] = 'Please fill all inputs.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function update($id, $name, $title, $body, $player_id, $php, $enable_tinymce, $access)
|
||||
{
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'pages',
|
||||
array(
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'player_id' => $player_id,
|
||||
'php' => $php ? '1' : '0',
|
||||
'enable_tinymce' => $enable_tinymce ? '1' : '0',
|
||||
'access' => $access
|
||||
),
|
||||
array('id' => $id));
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if (isset($id)) {
|
||||
if ($db->select(TABLE_PREFIX . 'pages', array('id' => $id)) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'pages', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Page with id ' . $id . ' does not exists.';
|
||||
} else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function toggleHidden($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if (isset($id)) {
|
||||
$query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id));
|
||||
if ($query !== false)
|
||||
$db->update(TABLE_PREFIX . 'pages', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Page with id ' . $id . ' does not exists.';
|
||||
} else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
19
admin/pages/admin/phpinfo.php
Normal file
19
admin/pages/admin/phpinfo.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Info
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'PHP Info';
|
||||
|
||||
if (!function_exists('phpinfo')) { ?>
|
||||
<b>phpinfo()</b> function is disabled in your webserver config.<br/>
|
||||
You can enable it by editing <b>php.ini</b> file.
|
||||
<?php return;
|
||||
}
|
||||
?>
|
||||
<iframe src="<?php echo BASE_URL; ?>admin/tools/phpinfo.php" width="1024" height="550"/>
|
897
admin/pages/admin/players.php
Normal file
897
admin/pages/admin/players.php
Normal file
@@ -0,0 +1,897 @@
|
||||
<?php
|
||||
/**
|
||||
* Players editor
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Player editor';
|
||||
$base = BASE_URL . 'admin/?p=players';
|
||||
|
||||
function echo_success($message)
|
||||
{
|
||||
echo '<p class="success">' . $message . '</p>';
|
||||
}
|
||||
|
||||
function echo_error($message)
|
||||
{
|
||||
global $error;
|
||||
echo '<p class="error">' . $message . '</p>';
|
||||
$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.');
|
||||
}
|
||||
|
||||
$skills = array(
|
||||
POT::SKILL_FIST => array('Fist fighting', 'fist'),
|
||||
POT::SKILL_CLUB => array('Club fighting', 'club'),
|
||||
POT::SKILL_SWORD => array('Sword fighting', 'sword'),
|
||||
POT::SKILL_AXE => array('Axe fighting', 'axe'),
|
||||
POT::SKILL_DIST => array('Distance fighting', 'dist'),
|
||||
POT::SKILL_SHIELD => array('Shielding', 'shield'),
|
||||
POT::SKILL_FISH => array('Fishing', 'fish')
|
||||
);
|
||||
|
||||
|
||||
$hasBlessingsColumn = $db->hasColumn('players', 'blessings');
|
||||
$hasBlessingColumn = $db->hasColumn('players', 'blessings1');
|
||||
$hasLookAddons = $db->hasColumn('players', 'lookaddons');
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
|
||||
<script src="<?php echo BASE_URL; ?>tools/js/jquery.datetimepicker.js"></script>
|
||||
|
||||
<?php
|
||||
$id = 0;
|
||||
if (isset($_REQUEST['id']))
|
||||
$id = (int)$_REQUEST['id'];
|
||||
else if (isset($_REQUEST['search_name'])) {
|
||||
if (strlen($_REQUEST['search_name']) < 3 && !Validator::number($_REQUEST['search_name'])) {
|
||||
echo 'Player name is too short.';
|
||||
} else {
|
||||
if (Validator::number($_REQUEST['search_name']))
|
||||
$id = $_REQUEST['search_name'];
|
||||
else {
|
||||
$query = $db->query('SELECT `id` FROM `players` 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 `players` WHERE `name` LIKE ' . $db->quote('%' . $_REQUEST['search_name'] . '%'));
|
||||
if ($query->rowCount() > 0 && $query->rowCount() <= 10) {
|
||||
echo 'Do you mean?<ul>';
|
||||
foreach ($query as $row)
|
||||
echo '<li><a href="' . $base . '&id=' . $row['id'] . '">' . $row['name'] . '</a></li>';
|
||||
echo '</ul>';
|
||||
} else if ($query->rowCount() > 10)
|
||||
echo 'Specified name resulted with too many players.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$groups = new OTS_Groups_List();
|
||||
if ($id > 0) {
|
||||
$player = new OTS_Player();
|
||||
$player->load($id);
|
||||
|
||||
if (isset($player) && $player->isLoaded() && isset($_POST['save'])) {// we want to save
|
||||
$error = false;
|
||||
|
||||
if ($player->isOnline())
|
||||
echo_error('This player is actually online. You can\'t edit online players.');
|
||||
|
||||
$name = $_POST['name'];
|
||||
$_error = '';
|
||||
if (!Validator::characterName($name))
|
||||
echo_error(Validator::getLastError());
|
||||
|
||||
//if(!Validator::newCharacterName($name)
|
||||
// echo_error(Validator::getLastError());
|
||||
|
||||
$player_db = new OTS_Player();
|
||||
$player_db->find($name);
|
||||
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);
|
||||
|
||||
$account_db = new OTS_Account();
|
||||
$account_db->load($account_id);
|
||||
if (!$account_db->isLoaded())
|
||||
echo_error('Account with this id doesn\'t exist.');
|
||||
|
||||
$group = $_POST['group'];
|
||||
if ($groups->getGroup($group) == false)
|
||||
echo_error('Group with this id doesn\'t exist');
|
||||
|
||||
$level = $_POST['level'];
|
||||
verify_number($level, 'Level', 11);
|
||||
|
||||
$experience = $_POST['experience'];
|
||||
verify_number($experience, 'Experience', 20);
|
||||
|
||||
$vocation = $_POST['vocation'];
|
||||
verify_number($vocation, 'Vocation id', 11);
|
||||
|
||||
if (!isset($config['vocations'][$vocation])) {
|
||||
echo_error("Vocation with this id doesn't exist.");
|
||||
}
|
||||
|
||||
// health
|
||||
$health = $_POST['health'];
|
||||
verify_number($health, 'Health', 11);
|
||||
$health_max = $_POST['health_max'];
|
||||
verify_number($health_max, 'Health max', 11);
|
||||
|
||||
// mana
|
||||
$magic_level = $_POST['magic_level'];
|
||||
verify_number($magic_level, 'Magic_level', 11);
|
||||
$mana = $_POST['mana'];
|
||||
verify_number($mana, 'Mana', 11);
|
||||
$mana_max = $_POST['mana_max'];
|
||||
verify_number($mana_max, 'Mana max', 11);
|
||||
$mana_spent = $_POST['mana_spent'];
|
||||
verify_number($mana_spent, 'Mana spent', 11);
|
||||
|
||||
// look
|
||||
$look_body = $_POST['look_body'];
|
||||
verify_number($look_body, 'Look body', 11);
|
||||
$look_feet = $_POST['look_feet'];
|
||||
verify_number($look_feet, 'Look feet', 11);
|
||||
$look_head = $_POST['look_head'];
|
||||
verify_number($look_head, 'Look head', 11);
|
||||
$look_legs = $_POST['look_legs'];
|
||||
verify_number($look_legs, 'Look legs', 11);
|
||||
$look_type = $_POST['look_type'];
|
||||
verify_number($look_type, 'Look type', 11);
|
||||
if ($hasLookAddons) {
|
||||
$look_addons = $_POST['look_addons'];
|
||||
verify_number($look_addons, 'Look addons', 11);
|
||||
}
|
||||
|
||||
// pos
|
||||
$pos_x = $_POST['pos_x'];
|
||||
verify_number($pos_x, 'Position x', 11);
|
||||
$pos_y = $_POST['pos_y'];
|
||||
verify_number($pos_y, 'Position y', 11);
|
||||
$pos_z = $_POST['pos_z'];
|
||||
verify_number($pos_z, 'Position z', 11);
|
||||
|
||||
$soul = $_POST['soul'];
|
||||
verify_number($soul, 'Soul', 10);
|
||||
$town = $_POST['town'];
|
||||
verify_number($town, 'Town', 11);
|
||||
|
||||
$capacity = $_POST['capacity'];
|
||||
verify_number($capacity, 'Capacity', 11);
|
||||
$sex = $_POST['sex'];
|
||||
verify_number($sex, 'Sex', 1);
|
||||
|
||||
$lastlogin = $_POST['lastlogin'];
|
||||
verify_number($lastlogin, 'Last login', 20);
|
||||
$lastlogout = $_POST['lastlogout'];
|
||||
verify_number($lastlogout, 'Last logout', 20);
|
||||
|
||||
$skull = $_POST['skull'];
|
||||
verify_number($skull, 'Skull', 1);
|
||||
$skull_time = $_POST['skull_time'];
|
||||
verify_number($skull_time, 'Skull time', 11);
|
||||
|
||||
if ($db->hasColumn('players', 'loss_experience')) {
|
||||
$loss_experience = $_POST['loss_experience'];
|
||||
verify_number($loss_experience, 'Loss experience', 11);
|
||||
$loss_mana = $_POST['loss_mana'];
|
||||
verify_number($loss_mana, 'Loss mana', 11);
|
||||
$loss_skills = $_POST['loss_skills'];
|
||||
verify_number($loss_skills, 'Loss skills', 11);
|
||||
$loss_containers = $_POST['loss_containers'];
|
||||
verify_number($loss_containers, 'Loss loss_containers', 11);
|
||||
$loss_items = $_POST['loss_items'];
|
||||
verify_number($loss_items, 'Loss items', 11);
|
||||
}
|
||||
if ($db->hasColumn('players', 'offlinetraining_time')) {
|
||||
$offlinetraining = $_POST['offlinetraining'];
|
||||
verify_number($offlinetraining, 'Offline Training time', 11);
|
||||
}
|
||||
|
||||
if ($hasBlessingsColumn) {
|
||||
$blessings = $_POST['blessings'];
|
||||
verify_number($blessings, 'Blessings', 2);
|
||||
}
|
||||
|
||||
$balance = $_POST['balance'];
|
||||
verify_number($balance, 'Balance', 20);
|
||||
if ($db->hasColumn('players', 'stamina')) {
|
||||
$stamina = $_POST['stamina'];
|
||||
verify_number($stamina, 'Stamina', 20);
|
||||
}
|
||||
|
||||
$deleted = (isset($_POST['deleted']) && $_POST['deleted'] == 'true');
|
||||
$hidden = (isset($_POST['hidden']) && $_POST['hidden'] == 'true');
|
||||
|
||||
$created = $_POST['created'];
|
||||
verify_number($created, 'Created', 11);
|
||||
|
||||
$comment = isset($_POST['comment']) ? htmlspecialchars(stripslashes(substr($_POST['comment'], 0, 2000))) : NULL;
|
||||
|
||||
foreach ($_POST['skills'] as $skill => $value)
|
||||
verify_number($value, $skills[$skill][0], 10);
|
||||
foreach ($_POST['skills_tries'] as $skill => $value)
|
||||
verify_number($value, $skills[$skill][0] . ' tries', 10);
|
||||
|
||||
if ($hasBlessingColumn) {
|
||||
$bless_count = $_POST['blesscount'];
|
||||
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);
|
||||
$player->setGroup($groups->getGroup($group));
|
||||
$player->setLevel($level);
|
||||
$player->setExperience($experience);
|
||||
$player->setVocation($vocation);
|
||||
$player->setHealth($health);
|
||||
$player->setHealthMax($health_max);
|
||||
$player->setMagLevel($magic_level);
|
||||
$player->setMana($mana);
|
||||
$player->setManaMax($mana_max);
|
||||
$player->setManaSpent($mana_spent);
|
||||
$player->setLookBody($look_body);
|
||||
$player->setLookFeet($look_feet);
|
||||
$player->setLookHead($look_head);
|
||||
$player->setLookLegs($look_legs);
|
||||
$player->setLookType($look_type);
|
||||
if ($hasLookAddons)
|
||||
$player->setLookAddons($look_addons);
|
||||
if ($db->hasColumn('players', 'offlinetraining_time'))
|
||||
$player->setCustomField('offlinetraining_time', $offlinetraining);
|
||||
$player->setPosX($pos_x);
|
||||
$player->setPosY($pos_y);
|
||||
$player->setPosZ($pos_z);
|
||||
$player->setSoul($soul);
|
||||
$player->setTownId($town);
|
||||
$player->setCap($capacity);
|
||||
$player->setSex($sex);
|
||||
$player->setLastLogin($lastlogin);
|
||||
$player->setLastLogout($lastlogout);
|
||||
//$player->setLastIP(ip2long($lastip));
|
||||
$player->setSkull($skull);
|
||||
$player->setSkullTime($skull_time);
|
||||
if ($db->hasColumn('players', 'loss_experience')) {
|
||||
$player->setLossExperience($loss_experience);
|
||||
$player->setLossMana($loss_mana);
|
||||
$player->setLossSkills($loss_skills);
|
||||
$player->setLossContainers($loss_containers);
|
||||
$player->setLossItems($loss_items);
|
||||
}
|
||||
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);
|
||||
if ($db->hasColumn('players', 'deletion'))
|
||||
$player->setCustomField('deletion', $deleted ? '1' : '0');
|
||||
else
|
||||
$player->setCustomField('deleted', $deleted ? '1' : '0');
|
||||
$player->setCustomField('hidden', $hidden ? '1' : '0');
|
||||
$player->setCustomField('created', $created);
|
||||
if (isset($comment))
|
||||
$player->setCustomField('comment', $comment);
|
||||
|
||||
foreach ($_POST['skills'] as $skill => $value) {
|
||||
$player->setSkill($skill, $value);
|
||||
}
|
||||
foreach ($_POST['skills_tries'] as $skill => $value) {
|
||||
$player->setSkillTries($skill, $value);
|
||||
}
|
||||
$player->save();
|
||||
echo_success('Player saved at: ' . date('G:i'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$search_name = '';
|
||||
if (isset($_REQUEST['search_name']))
|
||||
$search_name = $_REQUEST['search_name'];
|
||||
else if ($id > 0 && isset($player) && $player->isLoaded())
|
||||
$search_name = $player->getName();
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
|
||||
<?php
|
||||
if (isset($player) && $player->isLoaded()) {
|
||||
$account = $player->getAccount();
|
||||
?>
|
||||
|
||||
<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="nav-tabs-custom">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Player</a>
|
||||
</li>
|
||||
<li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Stats</a></li>
|
||||
<li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Skills</a></li>
|
||||
<li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Pos/Look</a></li>
|
||||
<li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Misc</a></li>
|
||||
<li class="pull-right"><a
|
||||
href="<?php echo ADMIN_URL; ?>?p=accounts&search_name=<?php echo $account->getId(); ?>"
|
||||
class="text-muted"><i class="fa fa-gear" title="Edit Account"></i></a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab_1">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="name" class="control-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name"
|
||||
autocomplete="off" style="cursor: auto;"
|
||||
value="<?php echo $player->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"
|
||||
value="<?php echo $account->getId(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 ">
|
||||
<label for="group" class="control-label">Group:</label>
|
||||
<select name="group" id="group" class="form-control">
|
||||
<?php foreach ($groups->getGroups() as $id => $group): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo($player->getGroup()->getId() == $id ? 'selected' : ''); ?>><?php echo $group->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="vocation" class="control-label">Vocation</label>
|
||||
<select name="vocation" id="vocation" class="form-control">
|
||||
<?php
|
||||
foreach ($config['vocations'] as $id => $name) {
|
||||
echo '<option value=' . $id . ($id == $player->getVocation() ? ' selected' : '') . '>' . $name . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="sex" class="control-label">Sex:</label>
|
||||
<select name="sex" id="sex" class="form-control">>
|
||||
<?php foreach ($config['genders'] as $id => $sex): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo($player->getSex() == $id ? 'selected' : ''); ?>><?php echo strtolower($sex); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="skull" class="control-label">Skull:</label>
|
||||
<select name="skull" id="skull" class="form-control">
|
||||
<?php
|
||||
$skull_type = array("None", "Yellow", "Green", "White", "Red", "Black", "Orange");
|
||||
foreach ($skull_type as $id => $s_name) {
|
||||
echo '<option value=' . $id . ($id == $player->getSkull() ? ' selected' : '') . '>' . $s_name . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="skull_time" class="control-label">Skull time:</label>
|
||||
<input type="text" class="form-control" id="skull_time" name="skull_time"
|
||||
autocomplete="off" maxlength="11"
|
||||
value="<?php echo $player->getSkullTime(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?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"
|
||||
autocomplete="off" maxlength="11"
|
||||
value="<?php echo $player->getBlessings(); ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<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(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="deleted" class="control-label">Deleted:</label>
|
||||
<input type="checkbox" name="deleted" id="deleted"
|
||||
value="true" <?php echo($player->getCustomField($db->hasColumn('players', 'deletion') ? 'deletion' : 'deleted') == '1' ? ' checked' : ''); ?>/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="hidden" class="control-label">Hidden:</label>
|
||||
<input type="checkbox" name="hidden" id="hidden"
|
||||
value="true" <?php echo($player->isHidden() ? ' checked' : ''); ?>/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab_2">
|
||||
<div class="row">
|
||||
<div class="col-xs-6 ">
|
||||
<label for="level" class="control-label">Level:</label>
|
||||
|
||||
<input type="text" class="form-control" id="level" name="level"
|
||||
autocomplete="off"
|
||||
style="cursor: auto;" value="<?php echo $player->getLevel(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="magic_level" class="control-label">Magic level:</label>
|
||||
<input type="text" class="form-control" id="magic_level" name="magic_level"
|
||||
autocomplete="off" size="8" maxlength="11" style="cursor: auto;"
|
||||
value="<?php echo $player->getMagLevel(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 ">
|
||||
<label for="experience" class="control-label">Experience:</label>
|
||||
<input type="text" class="form-control" id="experience" name="experience"
|
||||
autocomplete="off"
|
||||
style="cursor: auto;"
|
||||
value="<?php echo $player->getExperience(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="mana_spent" class="control-label">Mana spent:</label>
|
||||
<input type="text" class="form-control" id="mana_spent" name="mana_spent"
|
||||
autocomplete="off"
|
||||
size="3" maxlength="11" style="cursor: auto;"
|
||||
value="<?php echo $player->getManaSpent(); ?>"/>
|
||||
</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="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="health_max" class="control-label">Health 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="mana" class="control-label">Mana:</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="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;"
|
||||
value="<?php echo $player->getManaMax(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="capacity" class="control-label">Capacity:</label>
|
||||
<input type="text" class="form-control" id="capacity" name="capacity"
|
||||
autocomplete="off"
|
||||
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>
|
||||
<input type="text" class="form-control" id="stamina" name="stamina"
|
||||
autocomplete="off"
|
||||
maxlength="20" style="cursor: auto;"
|
||||
value="<?php echo $player->getStamina(); ?>"/>
|
||||
|
||||
</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">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($skills as $id => $info) {
|
||||
if ($i == 0 || $i++ == 2) {
|
||||
$i = 0;
|
||||
}
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-xs-6 ">
|
||||
<label for="skills[' . $id . ']" class="control-label">' . $info[0] . '</label>
|
||||
<input type="text" class="form-control" id="skills[' . $id . ']" name="skills[' . $id . ']" maxlength="10" autocomplete="off" style="cursor: auto;" value="' . $player->getSkill($id) . '"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="skills_tries[' . $id . ']" class="control-label">' . $info[0] . ' tries</label>
|
||||
<input type="text" class="form-control" id="skills_tries[' . $id . ']" name="skills_tries[' . $id . ']" maxlength="10" autocomplete="off" style="cursor: auto;" value="' . $player->getSkillTries($id) . '"/>
|
||||
</div>
|
||||
</div>';
|
||||
if ($i == 0)
|
||||
echo '';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab_4">
|
||||
<?php $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . ($hasLookAddons ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); ?>
|
||||
<div id="imgchar"
|
||||
style="width:64px;height:64px;position:absolute; top:30px; right:30px"><img id="player_outfit"
|
||||
style="margin-left:0;margin-top:0px;width:64px;height:64px;"
|
||||
src="<?php echo $outfit; ?>"
|
||||
alt="player outfit"/></div>
|
||||
<?php ?>
|
||||
<td>Position:</td>
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<label for="pos_x" class="control-label">X:</label>
|
||||
<input type="text" class="form-control" id="pos_x" name="pos_x"
|
||||
autocomplete="off"
|
||||
maxlength="11" style="cursor: auto;"
|
||||
value="<?php echo $player->getPosX(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label for="pos_y" class="control-label">Y:</label>
|
||||
<input type="text" class="form-control" id="pos_y" name="pos_y"
|
||||
autocomplete="off"
|
||||
maxlength="11" value="<?php echo $player->getPosY(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label for="pos_z" class="control-label">Z:</label>
|
||||
<input type="text" class="form-control" id="pos_z" name="pos_z"
|
||||
autocomplete="off"
|
||||
maxlength="11" value="<?php echo $player->getPosZ(); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<td>Look:</td>
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<label for="look_head" class="control-label">Head: <span
|
||||
id="look_head_val"></span></label>
|
||||
<input type="range" min="0" max="132"
|
||||
value="<?php echo $player->getLookHead(); ?>"
|
||||
class="slider form-control" id="look_head" name="look_head">
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<label for="look_body" class="control-label">Body: <span
|
||||
id="look_body_val"></span></label>
|
||||
<input type="range" min="0" max="132"
|
||||
value="<?php echo $player->getLookBody(); ?>"
|
||||
class="slider form-control" id="look_body" name="look_body">
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<label for="look_legs" class="control-label">Legs: <span
|
||||
id="look_legs_val"></span></label>
|
||||
<input type="range" min="0" max="132"
|
||||
value="<?php echo $player->getLookLegs(); ?>"
|
||||
class="slider form-control" id="look_legs" name="look_legs">
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<label for="look_feet" class="control-label">Feet: <span
|
||||
id="look_feet_val"></span></label>
|
||||
<input type="range" min="0" max="132"
|
||||
value="<?php echo $player->getLookBody(); ?>"
|
||||
class="slider form-control" id="look_feet" name="look_feet">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="look_type" class="control-label">Type:</label>
|
||||
<input type="text" class="form-control" id="look_type" name="look_type"
|
||||
autocomplete="off"
|
||||
maxlength="11" style="cursor: auto;"
|
||||
value="<?php echo $player->getLookType(); ?>"/>
|
||||
</div>
|
||||
<?php if ($hasLookAddons): ?>
|
||||
<div class="col-xs-6">
|
||||
<label for="look_addons" class="control-label">Addons:</label>
|
||||
<input type="text" class="form-control" id="look_addons"
|
||||
name="look_addons" autocomplete="off"
|
||||
maxlength="11" value="<?php echo $player->getLookAddons(); ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab_5">
|
||||
<div class="row">
|
||||
<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"
|
||||
autocomplete="off"
|
||||
maxlength="20" value="<?php echo $player->getLastLogin(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="lastlogout" class="control-label">Last logout:</label>
|
||||
<input type="text" class="form-control" id="lastlogout" name="lastlogout"
|
||||
autocomplete="off"
|
||||
maxlength="20" value="<?php echo $player->getLastLogout(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="lastip" class="control-label">Last IP:</label>
|
||||
<input type="text" class="form-control" id="lastip" name="lastip"
|
||||
autocomplete="off"
|
||||
maxlength="10" value="<?php echo longToIp($player->getLastIP()); ?>"
|
||||
readonly/>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($db->hasColumn('players', 'loss_experience')): ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="loss_experience" class="control-label">Experience
|
||||
Loss:</label>
|
||||
<input type="text" class="form-control" id="loss_experience"
|
||||
name="loss_experience" autocomplete="off"
|
||||
maxlength="11"
|
||||
value="<?php echo $player->getLossExperience(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="loss_mana" class="control-label">Mana Loss:</label>
|
||||
<input type="text" class="form-control" id="loss_mana"
|
||||
name="loss_mana" autocomplete="off"
|
||||
maxlength="11" value="<?php echo $player->getLossMana(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="loss_skills" class="control-label">Skills Loss:</label>
|
||||
<input type="text" class="form-control" id="loss_skills"
|
||||
name="loss_skills" autocomplete="off"
|
||||
maxlength="11" value="<?php echo $player->getLossSkills(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="loss_containers" class="control-label">Containers
|
||||
Loss:</label>
|
||||
<input type="text" class="form-control" id="loss_containers"
|
||||
name="loss_containers" autocomplete="off"
|
||||
maxlength="11"
|
||||
value="<?php echo $player->getLossContainers(); ?>"/>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<label for="loss_items" class="control-label">Items Loss:</label>
|
||||
<input type="text" class="form-control" id="loss_items"
|
||||
name="loss_items" autocomplete="off"
|
||||
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>
|
||||
<small>[max.
|
||||
length: 2000 chars, 50 lines (ENTERs)]
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="save" value="yes"/>
|
||||
<div class="box-footer">
|
||||
<a href="<?php echo ADMIN_URL; ?>?p=players"><span class="btn btn-danger">Cancel</span></a>
|
||||
<div class="pull-right">
|
||||
<input type="submit" class="btn btn-primary" value="Update">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<div class="col-md-4">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Search Player:</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<form action="<?php echo $base; ?>" method="post">
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" class="form-control" name="search_name" value="<?php echo $search_name; ?>"
|
||||
maxlength="32" size="32">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" type="button" class="btn btn-info btn-flat">Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($account) && $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)) {
|
||||
?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Character List:</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 10px">#</th>
|
||||
<th>Name</th>
|
||||
<th>Level</th>
|
||||
<th style="width: 40px">Edit</th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 1;
|
||||
foreach ($query as $p) {
|
||||
$account_players[] = $p;
|
||||
echo '<tr>
|
||||
<td>' . $i . '.</td>
|
||||
<td>' . $p['name'] . '</td>
|
||||
<td>' . $p['level'] . '</td>
|
||||
<td><a href="?p=players&search_name=' . $p['name'] . '"><span class="btn btn-success btn-sm edit btn-flat"><i class="fa fa-edit"></i></span></a></span></td>
|
||||
</tr>';
|
||||
$i++;
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#lastlogin').datetimepicker({
|
||||
format: 'unixtime'
|
||||
});
|
||||
$('#lastlogout').datetimepicker({
|
||||
format: 'unixtime'
|
||||
});
|
||||
$('#created').datetimepicker({
|
||||
format: 'unixtime'
|
||||
});
|
||||
|
||||
var slider_head = document.getElementById("look_head");
|
||||
var output_head = document.getElementById("look_head_val");
|
||||
|
||||
var slider_body = document.getElementById("look_body");
|
||||
var output_body = document.getElementById("look_body_val");
|
||||
|
||||
var slider_legs = document.getElementById("look_legs");
|
||||
var output_legs = document.getElementById("look_legs_val");
|
||||
|
||||
var slider_feet = document.getElementById("look_feet");
|
||||
var output_feet = document.getElementById("look_feet_val");
|
||||
output_head.innerHTML = slider_head.value;
|
||||
output_body.innerHTML = slider_body.value;
|
||||
output_legs.innerHTML = slider_legs.value;
|
||||
output_feet.innerHTML = slider_feet.value;
|
||||
|
||||
slider_head.oninput = function () {
|
||||
output_head.innerHTML = this.value;
|
||||
}
|
||||
slider_body.oninput = function () {
|
||||
output_body.innerHTML = this.value;
|
||||
}
|
||||
slider_legs.oninput = function () {
|
||||
output_legs.innerHTML = this.value;
|
||||
}
|
||||
slider_feet.oninput = function () {
|
||||
output_feet.innerHTML = this.value;
|
||||
}
|
||||
|
||||
$('#look_head').change(function() {updateOutfit()});
|
||||
$('#look_body').change(function() {updateOutfit()});
|
||||
$('#look_legs').change(function() {updateOutfit()});
|
||||
$('#look_feet').change(function() {updateOutfit()});
|
||||
$('#look_type').change(function() {updateOutfit()});
|
||||
<?php if($hasLookAddons): ?>
|
||||
$('#look_addons').change(function() {updateOutfit()});
|
||||
<?php endif; ?>
|
||||
|
||||
function updateOutfit()
|
||||
{
|
||||
var look_head = $('#look_head').val();
|
||||
var look_body = $('#look_body').val();
|
||||
var look_legs = $('#look_legs').val();
|
||||
var look_feet = $('#look_feet').val();
|
||||
var look_type = $('#look_type').val();
|
||||
|
||||
var look_addons = '';
|
||||
<?php if($hasLookAddons): ?>
|
||||
look_addons = '&addons=' + $('#look_addons').val();
|
||||
<?php endif; ?>
|
||||
|
||||
new_outfit = '<?= $config['outfit_images_url']; ?>?id=' + look_type + look_addons + '&head=' + look_head + '&body=' + look_body + '&legs=' + look_legs + '&feet=' + look_feet;
|
||||
$("#player_outfit").attr("src", new_outfit);
|
||||
console.log(new_outfit);
|
||||
}
|
||||
</script>
|
114
admin/pages/admin/plugins.php
Normal file
114
admin/pages/admin/plugins.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugins
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Plugin manager';
|
||||
|
||||
require_once LIBS . 'plugins.php';
|
||||
|
||||
$twig->display('admin.plugins.form.html.twig');
|
||||
|
||||
if (isset($_REQUEST['uninstall'])) {
|
||||
$uninstall = $_REQUEST['uninstall'];
|
||||
|
||||
if (Plugins::uninstall($uninstall)) {
|
||||
success('Successfully uninstalled plugin ' . $uninstall);
|
||||
} else {
|
||||
error('Error while uninstalling plugin ' . $uninstall . ': ' . Plugins::getError());
|
||||
}
|
||||
} else if (isset($_FILES["plugin"]["name"])) {
|
||||
$file = $_FILES["plugin"];
|
||||
$filename = $file["name"];
|
||||
$tmp_name = $file["tmp_name"];
|
||||
$type = $file["type"];
|
||||
|
||||
$name = explode(".", $filename);
|
||||
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed', 'application/octet-stream', 'application/zip-compressed');
|
||||
|
||||
if (isset($file['error'])) {
|
||||
$error = 'Error uploading file';
|
||||
switch ($file['error']) {
|
||||
case UPLOAD_ERR_OK:
|
||||
$error = false;
|
||||
break;
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$error .= ' - file too large (limit of ' . ini_get('upload_max_filesize') . ' bytes). You can enlarge the limits by changing "upload_max_filesize" in php.ini';
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$error .= ' - file upload was not completed.';
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$error .= ' - zero-length file uploaded.';
|
||||
break;
|
||||
default:
|
||||
$error .= ' - internal error #' . $file['error'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($error) && $error != false) {
|
||||
error($error);
|
||||
} else {
|
||||
if (is_uploaded_file($file['tmp_name'])) {
|
||||
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
if ($filetype == 'zip') // check if it is zipped/compressed file
|
||||
{
|
||||
$tmp_filename = pathinfo($filename, PATHINFO_FILENAME);
|
||||
$targetzip = BASE . 'plugins/' . $tmp_filename . '.zip';
|
||||
|
||||
if (move_uploaded_file($tmp_name, $targetzip)) { // move uploaded file
|
||||
if (Plugins::install($targetzip)) {
|
||||
foreach (Plugins::getWarnings() as $warning) {
|
||||
warning($warning);
|
||||
}
|
||||
|
||||
$info = Plugins::getPluginJson();
|
||||
success((isset($info['name']) ? '<strong>' . $info['name'] . '</strong> p' : 'P') . 'lugin has been successfully installed.');
|
||||
} else {
|
||||
$error = Plugins::getError();
|
||||
error(!empty($error) ? $error : 'Unexpected error happened while installing plugin. Please try again later.');
|
||||
}
|
||||
|
||||
unlink($targetzip); // delete the Zipped file
|
||||
} else
|
||||
error('There was a problem with the upload. Please try again.');
|
||||
} else {
|
||||
error('The file you are trying to upload is not a .zip file. Please try again.');
|
||||
}
|
||||
} else {
|
||||
error('Error uploading file - unknown error.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = array();
|
||||
foreach (get_plugins() as $plugin) {
|
||||
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
|
||||
$string = Plugins::removeComments($string);
|
||||
$plugin_info = json_decode($string, true);
|
||||
|
||||
if ($plugin_info == false) {
|
||||
warning('Cannot load plugin info ' . $plugin . '.json');
|
||||
} else {
|
||||
$plugins[] = array(
|
||||
'name' => isset($plugin_info['name']) ? $plugin_info['name'] : '',
|
||||
'description' => isset($plugin_info['description']) ? $plugin_info['description'] : '',
|
||||
'version' => isset($plugin_info['version']) ? $plugin_info['version'] : '',
|
||||
'author' => isset($plugin_info['author']) ? $plugin_info['author'] : '',
|
||||
'contact' => isset($plugin_info['contact']) ? $plugin_info['contact'] : '',
|
||||
'file' => $plugin,
|
||||
'uninstall' => isset($plugin_info['uninstall'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$twig->display('admin.plugins.html.twig', array(
|
||||
'plugins' => $plugins
|
||||
));
|
61
admin/pages/admin/reports.php
Normal file
61
admin/pages/admin/reports.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Reports
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Lee
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Report Viewer';
|
||||
|
||||
$files = array();
|
||||
$server_path_reports = $config['data_path'] . 'reports/';
|
||||
|
||||
if (file_exists($server_path_reports)) {
|
||||
foreach (scandir($server_path_reports, SCANDIR_SORT_ASCENDING) as $f) {
|
||||
if ($f[0] === '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($server_path_reports . $f)) {
|
||||
foreach (scandir($server_path_reports . $f, SCANDIR_SORT_ASCENDING) as $f2) {
|
||||
if ($f2[0] === '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = array($f . '/' . $f2, $server_path_reports);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = array($f, $server_path_reports);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as &$f) {
|
||||
$f['mtime'] = filemtime($f[1] . $f[0]);
|
||||
$f['name'] = $f[0];
|
||||
}
|
||||
|
||||
unset($f);
|
||||
|
||||
$twig->display('admin.reports.html.twig', array('files' => $files));
|
||||
|
||||
|
||||
$file = isset($_GET['file']) ? $_GET['file'] : NULL;
|
||||
if (!empty($file)) {
|
||||
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
||||
if (file_exists($server_path_reports . $file)) {
|
||||
$content = nl2br(file_get_contents($server_path_reports . $file));
|
||||
|
||||
$twig->display('admin.logs.view.html.twig', array('file' => $file, 'content' => $content));
|
||||
} else {
|
||||
echo 'Specified file does not exist.';
|
||||
}
|
||||
} else {
|
||||
echo 'Invalid file name specified.';
|
||||
}
|
||||
}
|
39
admin/pages/admin/statistics.php
Normal file
39
admin/pages/admin/statistics.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Statistics
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Statistics';
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `accounts`;');
|
||||
$query = $query->fetch();
|
||||
$total_accounts = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `players`;');
|
||||
$query = $query->fetch();
|
||||
$total_players = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `guilds`;');
|
||||
$query = $query->fetch();
|
||||
$total_guilds = $query['how_much'];
|
||||
|
||||
$query = $db->query('SELECT count(*) as `how_much` FROM `houses`;');
|
||||
$query = $query->fetch();
|
||||
$total_houses = $query['how_much'];
|
||||
|
||||
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
|
||||
|
||||
$twig->display('admin.statistics.html.twig', array(
|
||||
'total_accounts' => $total_accounts,
|
||||
'total_players' => $total_players,
|
||||
'total_guilds' => $total_guilds,
|
||||
'total_houses' => $total_houses,
|
||||
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
|
||||
'points' => $points
|
||||
));
|
||||
?>
|
27
admin/pages/admin/tools.php
Normal file
27
admin/pages/admin/tools.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Tools
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Tools';
|
||||
|
||||
$tool = $_GET['tool'];
|
||||
if (!isset($tool)) {
|
||||
echo 'Tool not set.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (preg_match("/[^A-z0-9_\-]/", $tool)) {
|
||||
echo 'Invalid tool.';
|
||||
return;
|
||||
}
|
||||
|
||||
$file = BASE . 'admin/pages/tools/' . $tool . '.php';
|
||||
if (!@file_exists($file))
|
||||
require $file;
|
||||
?>
|
50
admin/pages/admin/version.php
Normal file
50
admin/pages/admin/version.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Version check
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Version check';
|
||||
|
||||
// fetch version
|
||||
//$file = @fopen('https://my-aac.org/VERSION', 'r') or die('Error while fetching version.');
|
||||
//$myaac_version = fgets($file);
|
||||
$myaac_version = @file_get_contents('https://my-aac.org/VERSION');
|
||||
if (!$myaac_version) {
|
||||
warning('Error while fetching version info from https://my-aac.org<br/>
|
||||
Please try again later.');
|
||||
return;
|
||||
}
|
||||
|
||||
// compare them
|
||||
$version_compare = version_compare($myaac_version, MYAAC_VERSION);
|
||||
if ($version_compare == 0) {
|
||||
success('MyAAC latest version is ' . $myaac_version . '. You\'re using the latest version.
|
||||
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
|
||||
} else if ($version_compare < 0) {
|
||||
success('Woah, seems you\'re using newer version as latest released one! MyAAC latest released version is ' . $myaac_version . ', and you\'re using version ' . MYAAC_VERSION . '.
|
||||
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
|
||||
} else {
|
||||
warning('You\'re using outdated version.<br/>
|
||||
Your version: <b>' . MYAAC_VERSION . '</b><br/>
|
||||
Latest version: <b>' . $myaac_version . '</b><br/>
|
||||
Download available at: <a href="https://my-aac.org" target="_blank">www.my-aac.org</a>');
|
||||
}
|
||||
|
||||
/*
|
||||
function version_revert($version)
|
||||
{
|
||||
$major = floor($version / 10000);
|
||||
$version -= $major * 10000;
|
||||
|
||||
$minor = floor($version / 100);
|
||||
$version -= $minor * 100;
|
||||
|
||||
$release = $version;
|
||||
return $major . '.' . $minor . '.' . $release;
|
||||
}*/
|
||||
?>
|
36
admin/pages/admin/visitors.php
Normal file
36
admin/pages/admin/visitors.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Visitors viewer
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Visitors';
|
||||
|
||||
if (!$config['visitors_counter']): ?>
|
||||
Visitors counter is disabled.<br/>
|
||||
You can enable it by editing this configurable in <b>config.local.php</b> file:<br/>
|
||||
<p style="margin-left: 3em;"><b>$config['visitors_counter'] = true;</b></p>
|
||||
<?php
|
||||
return;
|
||||
endif;
|
||||
|
||||
require SYSTEM . 'libs/visitors.php';
|
||||
$visitors = new Visitors($config['visitors_counter_ttl']);
|
||||
|
||||
function compare($a, $b)
|
||||
{
|
||||
return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1;
|
||||
}
|
||||
|
||||
$tmp = $visitors->getVisitors();
|
||||
usort($tmp, 'compare');
|
||||
|
||||
$twig->display('admin.visitors.html.twig', array(
|
||||
'config_visitors_counter_ttl' => $config['visitors_counter_ttl'],
|
||||
'visitors' => $tmp
|
||||
));
|
||||
?>
|
Reference in New Issue
Block a user