Code clean up + datatables (#64)

* Reformat Code

Reformat Code
- spaces + tabs

* Code cleanup

removed duplicated datatables code

* Datatables

replace spells, monsters tables with JavaScript Sortable Tables (DataTables?)
This commit is contained in:
Lee 2018-12-02 05:30:36 +00:00 committed by slawkens
parent e3bcbc4da9
commit 876b1b988a
38 changed files with 2396 additions and 2510 deletions

View File

@ -33,11 +33,12 @@
}
td.details-control {
text-align:center;
color:forestgreen;
text-align: center;
color: forestgreen;
cursor: pointer;
}
tr.shown td.details-control {
text-align:center;
color:red;
text-align: center;
color: red;
}

View File

@ -10,8 +10,8 @@
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/ionicons.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo $template_path; ?>style.css" />
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo $template_path; ?>style.css"/>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
@ -21,15 +21,15 @@
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php if($page != 'tools'): ?>
<div class="wrapper">
<?php if ($page != 'tools'): ?>
<?php
if($logged && admin()) {
if ($logged && admin()) {
?>
<header class="main-header">
<a href="." class="logo">
<span class="logo-mini"><b>M</b>A</span>
<span class="logo-lg"><b>My</b>ACC</span>
<span class="logo-lg"><b>My</b>AAC</span>
</a>
<nav class="navbar navbar-static-top" role="navigation">
@ -79,32 +79,32 @@
);
$i = 0;
foreach($menus as $_name => $_page) {
foreach ($menus as $_name => $_page) {
$has_child = is_array($_page);
if(!$has_child) {
if (!$has_child) {
echo '<li ';
if($page == $_page) echo ' class="active"';
echo">";
echo '<a href="?p=' . $_page . '"><i class="fa fa-' . (isset($icons_a[$i]) ? $icons_a[$i] : 'link') . '"></i> <span>'. $_name .'</span></a></li>';
if ($page == $_page) echo ' class="active"';
echo ">";
echo '<a href="?p=' . $_page . '"><i class="fa fa-' . (isset($icons_a[$i]) ? $icons_a[$i] : 'link') . '"></i> <span>' . $_name . '</span></a></li>';
}
if($has_child) {
if ($has_child) {
$used_menu = "";
$nav_construct = '';
foreach($_page as $__name => $__page) {
foreach ($_page as $__name => $__page) {
$nav_construct = $nav_construct . '<li';
if ($page == $__page) {
$nav_construct = $nav_construct. ' class="active"';
$nav_construct = $nav_construct . ' class="active"';
$used_menu = true;
}
$nav_construct = $nav_construct. '><a href="?p=' . $__page . '"><i class="fa fa-circle-o"></i> ' . $__name . '</a></li>';
$nav_construct = $nav_construct . '><a href="?p=' . $__page . '"><i class="fa fa-circle-o"></i> ' . $__name . '</a></li>';
}
echo '<li class="treeview'. (($used_menu) ? ' menu-open': '') .'">
<a href="#"><i class="fa fa-'.(isset($icons_a[$i]) ? $icons_a[$i] : 'link').'"></i> <span>'.$_name.'</span>
echo '<li class="treeview' . (($used_menu) ? ' menu-open' : '') . '">
<a href="#"><i class="fa fa-' . (isset($icons_a[$i]) ? $icons_a[$i] : 'link') . '"></i> <span>' . $_name . '</span>
<span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span></a>
<ul class="treeview-menu" style="'. (($used_menu) ? ' display: block': ' display: none') .'">';
<ul class="treeview-menu" style="' . (($used_menu) ? ' display: block' : ' display: none') . '">';
echo $nav_construct;
echo '</ul>
</li>';
@ -114,12 +114,12 @@
$query = $db->query('SELECT `name`, `page`, `flags` FROM `' . TABLE_PREFIX . 'admin_menu` ORDER BY `ordering`');
$menu_db = $query->fetchAll();
foreach($menu_db as $item) {
if($item['flags'] == 0 || hasFlag($item['flags'])) {
foreach ($menu_db as $item) {
if ($item['flags'] == 0 || hasFlag($item['flags'])) {
echo '<li ';
if($page == $item['page']) echo ' class="active"';
echo">";
echo '<a href="?p=' . $item['page'] . '"><i class="fa fa-link"></i> <span>'. $item['name'] .'</span></a></li>';
if ($page == $item['page']) echo ' class="active"';
echo ">";
echo '<a href="?p=' . $item['page'] . '"><i class="fa fa-link"></i> <span>' . $item['name'] . '</span></a></li>';
}
}
?>
@ -129,9 +129,10 @@
<div class="content-wrapper">
<section class="content-header">
<h1><?php echo (isset($title) ? $title : ''); ?><small> - Admin Panel</small>
<h1><?php echo(isset($title) ? $title : ''); ?>
<small> - Admin Panel</small>
<div class="pull-right">
<span class="label label-<?php echo (($status['online']) ? 'success' : 'danger'); ?>"><?php echo $config['lua']['serverName'] ?></span>
<span class="label label-<?php echo(($status['online']) ? 'success' : 'danger'); ?>"><?php echo $config['lua']['serverName'] ?></span>
</div>
</h1>
</section>
@ -145,7 +146,7 @@
<div class="pull-right hidden-xs">
<div id="status">
<?php if($status['online']): ?>
<?php if ($status['online']): ?>
<p class="success" style="width: 120px; text-align: center;">Server Online</p>
<?php else: ?>
<p class="error" style="width: 120px; text-align: center;">Server Offline</p>
@ -169,7 +170,8 @@
<i class="menu-icon fa fa-sign-out bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Log out</h4>
<p>This will log you out of <?php echo (USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()); ?></p>
<p>This will log you out
of <?php echo(USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()); ?></p>
</div>
</a>
</li>
@ -203,19 +205,18 @@
</div>
</aside>
<div class="control-sidebar-bg"></div>
</div>
</div>
<?php } endif;
if(!$logged && !admin()) {
<?php } endif;
if (!$logged && !admin()) {
echo $content;
}
?>
}
?>
<script src="<?php echo BASE_URL; ?>tools/js/bootstrap.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery-ui.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/dataTables.bootstrap.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/adminlte.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/bootstrap.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery-ui.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/adminlte.min.js"></script>
</body>
</html>

View File

@ -96,7 +96,7 @@ if ($id > 0) {
$group = $_POST['group'];
$password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null));
if(!Validator::password($password)) {
if (!Validator::password($password)) {
$errors['password'] = Validator::getLastError();
}
@ -106,7 +106,7 @@ if ($id > 0) {
$key = $_POST['key'];
$email = $_POST['email'];
if(!Validator::email($email))
if (!Validator::email($email))
$errors['email'] = Validator::getLastError();
// prem days
@ -114,7 +114,7 @@ if ($id > 0) {
verify_number($p_days, 'Prem days', 11);
//tibia coins
if($hasCoinsColumn) {
if ($hasCoinsColumn) {
$t_coins = $_POST['t_coins'];
verify_number($t_coins, 'Tibia coins', 12);
}
@ -152,7 +152,7 @@ if ($id > 0) {
$account->setCustomField('key', $key);
$account->setEMail($email);
$account->setPremDays($p_days);
if($hasCoinsColumn) {
if ($hasCoinsColumn) {
$account->setCustomField('coins', $t_coins);
}
@ -160,13 +160,13 @@ if ($id > 0) {
$account->setLocation($rl_loca);
$account->setCountry($rl_country);
if ($db->hasColumn('accounts', 'premium_points')){
$account->setCustomField('premium_points', $p_points);}
if ($db->hasColumn('accounts', 'premium_points')) {
$account->setCustomField('premium_points', $p_points);
}
if (isset($password)) {
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
if($config_salt_enabled)
{
if ($config_salt_enabled) {
$salt = generateRandomString(10, false, true, true);
$password = $salt . $password;
$account_logged->setCustomField('salt', $salt);
@ -205,7 +205,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
?>
<?php $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post" class="form-horizontal">
<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">
@ -276,7 +277,7 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
autocomplete="off" maxlength="11"
value="<?php echo $account->getPremDays(); ?>"/>
</div>
<?php if($hasCoinsColumn): ?>
<?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"
@ -382,7 +383,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
</div>
<div class="box-body no-padding">
<table class="table table-striped">
<tbody><tr>
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Name</th>
<th>Level</th>
@ -393,9 +395,9 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
foreach ($query as $p) {
$account_players[] = $p;
echo '<tr>
<td>'.$i.'.</td>
<td>'.$p['name'] . '</td>
<td>'.$p['level'].'</td>
<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++;
@ -405,17 +407,17 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
</div>
</div>
<?php
<?php
};
};
?>
};
?>
</div>
<script type="text/javascript">
$('#lastlogin').datetimepicker({ format: 'unixtime' });
$('#lastlogout').datetimepicker({ format: 'unixtime' });
$('#created').datetimepicker({ format: 'unixtime' });
$('#web_lastlogin').datetimepicker({ format: 'unixtime' });
$('#lastlogin').datetimepicker({format: 'unixtime'});
$('#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;

View File

@ -10,7 +10,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'MyAAC Changelog';
if(!file_exists(BASE . 'CHANGELOG')) {
if (!file_exists(BASE . 'CHANGELOG')) {
echo 'File CHANGELOG doesn\'t exist.';
return;
}

View File

@ -16,13 +16,13 @@ require LIBS . 'weapons.php';
$twig->display('admin.items.html.twig');
$reload = isset($_REQUEST['reload']) && (int)$_REQUEST['reload'] == 1;
if($reload) {
if(Items::loadFromXML(true))
if ($reload) {
if (Items::loadFromXML(true))
success('Successfully loaded items.');
else
error(Items::getError());
if(Weapons::loadFromXML(true))
if (Weapons::loadFromXML(true))
success('Successfully loaded weapons.');
else
error(Weapons::getError());

View File

@ -10,15 +10,15 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Login';
$logout = '';
if($action == 'logout') {
if ($action == 'logout') {
$logout = "You have been logged out!";
}
$search_errors[] = 'Character <b></b> does not exist or has been deleted.';
if(isset($errors)) {
foreach($errors as $error) {
if (isset($errors)) {
foreach ($errors as $error) {
error($error);
$twig->display('admin.error.html.twig', array('errors' => $error));
}
@ -29,4 +29,4 @@ $twig->display('admin.login.html.twig', array(
'errors' => $search_errors,
'logout' => $logout,
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
));
));

View File

@ -10,14 +10,12 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Mailer';
if(!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) {
echo 'Access denied.';
return;
}
if(!$config['mail_enabled'])
{
if (!$config['mail_enabled']) {
echo 'Mail support disabled.';
return;
}
@ -27,11 +25,11 @@ $mail_subject = isset($_POST['mail_subject']) ? stripslashes($_POST['mail_subjec
$preview = isset($_REQUEST['preview']);
$preview_done = false;
if($preview) {
if(!empty($mail_content) && !empty($mail_subject)) {
if ($preview) {
if (!empty($mail_content) && !empty($mail_subject)) {
$preview_done = _mail($account_logged->getCustomField('email'), $mail_subject, $mail_content);
if(!$preview_done)
if (!$preview_done)
error('Error while sending preview mail: ' . $mailer->ErrorInfo);
}
}
@ -43,31 +41,29 @@ $twig->display('admin.mailer.html.twig', array(
'preview_done' => $preview_done
));
if(empty($mail_content) || empty($mail_subject) || $preview)
if (empty($mail_content) || empty($mail_subject) || $preview)
return;
$success = 0;
$failed = 0;
$add = '';
if($config['account_mail_verify']) {
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))
foreach ($query as $email) {
if (_mail($email['email'], $mail_subject, $mail_content))
$success++;
else
{
else {
$failed++;
echo '<br />';
error('An error occorred while sending email to <b>' . $email['email'] . '</b>. Error: ' . $mailer->ErrorInfo);
}
}
success('Mailing finished.');
success("$success emails delivered.");
warning("$failed emails failed.");
success('Mailing finished.');
success("$success emails delivered.");
warning("$failed emails failed.");

View File

@ -10,35 +10,33 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Menus';
if(!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin()) {
echo 'Access denied.';
return;
}
if(isset($_REQUEST['template'])) {
if (isset($_REQUEST['template'])) {
$template = $_REQUEST['template'];
if(isset($_REQUEST['menu'])) {
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)) {
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
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) {
} catch (PDOException $error) {
warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage());
}
}
@ -48,15 +46,14 @@ if(isset($_REQUEST['template'])) {
}
$file = TEMPLATES . $template . '/config.php';
if(file_exists($file)) {
if (file_exists($file)) {
require_once $file;
}
else {
} else {
echo 'Cannot find template config.php file.';
return;
}
if(!isset($config['menu_categories'])) {
if (!isset($config['menu_categories'])) {
echo "No menu categories set in template config.php.<br/>This template doesn't support dynamic menus.";
return;
}
@ -67,26 +64,26 @@ if(isset($_REQUEST['template'])) {
<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) {
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) {
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>
<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])) {
if (isset($menus[$id])) {
$i = 0;
foreach($menus[$id] as $menu) {
foreach ($menus[$id] as $menu) {
echo '<li class="ui-state-default" id="list-' . $id . '-' . $i . '"><input type="text" name="menu[' . $id . '][]" value="' . $menu['name'] . '"/>
<input type="text" name="menu_link[' . $id . '][]" value="' . $menu['link'] . '"/>
<input type="hidden" name="menu_blank[' . $id . '][]" value="0" />
@ -120,12 +117,11 @@ if(isset($_REQUEST['template'])) {
?>
<?php
}
else {
} else {
$templates = $db->query('SELECT `template` FROM `' . TABLE_PREFIX . 'menu` GROUP BY `template`;')->fetchAll();
foreach($templates as $key => $value) {
foreach ($templates as $key => $value) {
$file = TEMPLATES . $value['template'] . '/config.php';
if(!file_exists($file)) {
if (!file_exists($file)) {
unset($templates[$key]);
}
}

View File

@ -11,19 +11,16 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Notepad';
$notepad_content = Notepad::get($account_logged->getId());
if(isset($_POST['content']))
{
if (isset($_POST['content'])) {
$_content = html_entity_decode(stripslashes($_POST['content']));
if(!$notepad_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)
} else {
if ($notepad_content !== false)
$_content = $notepad_content;
}
@ -35,7 +32,7 @@ class Notepad
{
global $db;
$query = $db->select(TABLE_PREFIX . 'notepad', array('account_id' => $account_id));
if($query !== false)
if ($query !== false)
return $query['content'];
return false;

View File

@ -10,8 +10,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Pages';
if(!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
echo 'Access denied.';
return;
}
@ -24,66 +23,59 @@ $groups = new OTS_Groups_List();
$php = false;
$access = 0;
if(!empty($action))
{
if($action == 'delete' || $action == 'edit' || $action == 'hide')
if (!empty($action)) {
if ($action == 'delete' || $action == 'edit' || $action == 'hide')
$id = $_REQUEST['id'];
if(isset($_REQUEST['name']))
if (isset($_REQUEST['name']))
$name = $_REQUEST['name'];
if(isset($_REQUEST['title']))
if (isset($_REQUEST['title']))
$p_title = $_REQUEST['title'];
$php = isset($_REQUEST['php']) && $_REQUEST['php'] == 1;
if($php)
if ($php)
$body = $_REQUEST['body'];
else if(isset($_REQUEST['body'])) {
else if (isset($_REQUEST['body'])) {
//$body = $_REQUEST['body'];
$body = html_entity_decode(stripslashes($_REQUEST['body']));
}
if(isset($_REQUEST['access']))
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, $access, $errors))
{
if ($action == 'add') {
if (Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors)) {
$name = $p_title = $body = '';
$player_id = $access = 0;
$php = false;
}
}
else if($action == 'delete') {
if(Pages::delete($id, $errors))
} 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'])) {
} 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';
$access = $_page['access'];
}
else {
} else {
Pages::update($id, $name, $p_title, $body, $player_id, $php, $access);
$action = $name = $p_title = $body = '';
$player_id = 1;
$access = 0;
$php = false;
}
}
else if($action == 'hide') {
} else if ($action == 'hide') {
Pages::toggleHidden($id, $errors);
}
if(!empty($errors))
if (!empty($errors))
$twig->display('admin.error.html.twig', array('errors' => $errors));
}
@ -91,7 +83,7 @@ $query =
$db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'pages'));
$pages = array();
foreach($query as $_page) {
foreach ($query as $_page) {
$pages[] = array(
'link' => getFullLink($_page['name'], $_page['name'], true),
'title' => substr($_page['title'], 0, 20),
@ -121,7 +113,7 @@ class Pages
{
global $db;
$query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id));
if($query !== false)
if ($query !== false)
return $query;
return false;
@ -130,21 +122,20 @@ class Pages
static public function add($name, $title, $body, $player_id, $php, $access, &$errors)
{
global $db;
if(isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0)
{
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)
if ($query === false)
$db->insert(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access));
else
$errors[] = 'Page with this link already exists.';
}
else
} else
$errors[] = 'Please fill all inputs.';
return !count($errors);
}
static public function update($id, $name, $title, $body, $player_id, $php, $access) {
static public function update($id, $name, $title, $body, $player_id, $php, $access)
{
global $db;
$db->update(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access), array('id' => $id));
}
@ -152,14 +143,12 @@ class Pages
static public function delete($id, &$errors)
{
global $db;
if(isset($id))
{
if($db->select(TABLE_PREFIX . 'pages', array('id' => $id)) !== false)
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
} else
$errors[] = 'id not set';
return !count($errors);
@ -168,18 +157,17 @@ class Pages
static public function toggleHidden($id, &$errors)
{
global $db;
if(isset($id))
{
if (isset($id)) {
$query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id));
if($query !== false)
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
} else
$errors[] = 'id not set';
return !count($errors);
}
}
?>

View File

@ -10,10 +10,10 @@
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;
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" />
<iframe src="<?php echo BASE_URL; ?>admin/tools/phpinfo.php" width="1024" height="550"/>

View File

@ -330,7 +330,9 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<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>
<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">
@ -785,7 +787,8 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<!-- /.box-header -->
<div class="box-body no-padding">
<table class="table table-striped">
<tbody><tr>
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Name</th>
<th>Level</th>
@ -796,9 +799,9 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
foreach ($query as $p) {
$account_players[] = $p;
echo '<tr>
<td>'.$i.'.</td>
<td>'.$p['name'] . '</td>
<td>'.$p['level'].'</td>
<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++;
@ -816,7 +819,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div>
<script type="text/javascript">
<script type="text/javascript">
$('#lastlogin').datetimepicker({
format: 'unixtime'
});
@ -855,4 +858,4 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
slider_feet.oninput = function () {
output_feet.innerHTML = this.value;
}
</script>
</script>

View File

@ -14,18 +14,15 @@ require LIBS . 'plugins.php';
$twig->display('admin.plugins.form.html.twig');
if(isset($_REQUEST['uninstall'])){
if (isset($_REQUEST['uninstall'])) {
$uninstall = $_REQUEST['uninstall'];
if(Plugins::uninstall($uninstall)) {
if (Plugins::uninstall($uninstall)) {
success('Successfully uninstalled plugin ' . $uninstall);
}
else {
} else {
error('Error while uninstalling plugin ' . $uninstall . ': ' . Plugins::getError());
}
}
else if(isset($_FILES["plugin"]["name"]))
{
} else if (isset($_FILES["plugin"]["name"])) {
$file = $_FILES["plugin"];
$filename = $file["name"];
$tmp_name = $file["tmp_name"];
@ -34,15 +31,15 @@ else if(isset($_FILES["plugin"]["name"]))
$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'])) {
if (isset($file['error'])) {
$error = 'Error uploading file';
switch($file['error']) {
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).';
$error .= ' - file too large (limit of ' . ini_get('upload_max_filesize') . ' bytes).';
break;
case UPLOAD_ERR_PARTIAL:
$error .= ' - file upload was not completed.';
@ -56,56 +53,49 @@ else if(isset($_FILES["plugin"]["name"]))
}
}
if(isset($error) && $error != false) {
if (isset($error) && $error != false) {
error($error);
}
else {
if(is_uploaded_file($file['tmp_name']) ) {
} else {
if (is_uploaded_file($file['tmp_name'])) {
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if($filetype == 'zip') // check if it is zipped/compressed file
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) {
if (move_uploaded_file($tmp_name, $targetzip)) { // move uploaded file
if (Plugins::install($targetzip)) {
foreach (Plugins::getWarnings() as $warning) {
warning($warning);
}
$info = Plugins::getPlugin();
success((isset($info['name']) ? '<strong>' . $info['name'] . '</strong> p' : 'P') . 'lugin has been successfully installed.');
}
else {
} 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
} else
error('There was a problem with the upload. Please try again.');
}
else {
} else {
error('The file you are trying to upload is not a .zip file. Please try again.');
}
}
else {
} else {
error('Error uploading file - unknown error.');
}
}
}
$plugins = array();
foreach(get_plugins() as $plugin)
{
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) {
if ($plugin_info == false) {
warning('Cannot load plugin info ' . $plugin . '.json');
}
else {
} else {
$plugins[] = array(
'name' => isset($plugin_info['name']) ? $plugin_info['name'] : '',
'description' => isset($plugin_info['description']) ? $plugin_info['description'] : '',

View File

@ -11,19 +11,17 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Tools';
$tool = $_GET['tool'];
if(!isset($tool))
{
if (!isset($tool)) {
echo 'Tool not set.';
return;
}
if(preg_match("/[^A-z0-9_\-]/", $tool))
{
if (preg_match("/[^A-z0-9_\-]/", $tool)) {
echo 'Invalid tool.';
return;
}
$file = BASE . 'admin/pages/tools/' . $tool . '.php';
if(!@file_exists($file))
if (!@file_exists($file))
require $file;
?>

View File

@ -14,7 +14,7 @@ $title = 'Version check';
//$file = @fopen('http://my-aac.org/VERSION', 'r') or die('Error while fetching version.');
//$myaac_version = fgets($file);
$myaac_version = @file_get_contents('http://my-aac.org/VERSION');
if(!$myaac_version) {
if (!$myaac_version) {
warning('Error while fetching version info from http://my-aac.org<br/>
Please try again later.');
return;
@ -22,15 +22,13 @@ if(!$myaac_version) {
// compare them
$version_compare = version_compare($myaac_version, MYAAC_VERSION);
if($version_compare == 0) {
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) {
} else if ($version_compare < 0) {
echo 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 {
} else {
warning('You\'re using outdated version.<br/>
Your version: <b>' . MYAAC_VERSION . '</b><br/>
Latest version: <b>' . $myaac_version . '</b><br/>

View File

@ -10,18 +10,19 @@
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;
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) {
function compare($a, $b)
{
return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1;
}

View File

@ -14,202 +14,126 @@ $title = "Creatures";
?>
<script type="text/javascript" src="tools/js/tipped.js"></script>
<link rel="stylesheet" type="text/css" href="tools/css/tipped.css"/>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<script>
$(document).ready(function() {
$(document).ready(function () {
Tipped.create('.tooltip');
});
</script>
<?php
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
if(isset($_POST['reload_monsters']) && $canEdit)
{
if (isset($_POST['reload_monsters']) && $canEdit) {
require LIBS . 'creatures.php';
if(Creatures::loadFromXML(true)) {
if (Creatures::loadFromXML(true)) {
if (Creatures::getMonstersList()->hasErrors())
error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
}
else {
} else {
error(Creatures::getLastError());
}
}
if($canEdit)
{
?>
if ($canEdit) {
?>
<form method="post" action="<?php echo getLink('creatures'); ?>">
<input type="hidden" name="reload_monsters" value="yes"/>
<input type="submit" value="(admin) Reload monsters"/>
</form>
<?php
<?php
}
if(empty($_REQUEST['creature']))
{
$allowed_order_by = array('name', 'exp', 'health', 'summonable', 'convinceable', 'race');
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'name';
//generate sql query
$desc = '';
if(isset($_REQUEST['desc']) && $_REQUEST['desc'] == 1) {
$desc = " DESC";
}
if($order == 'name') {
$whereandorder = ' ORDER BY name'.$desc;
}
elseif($order == 'exp') {
$whereandorder = ' ORDER BY exp'.$desc.', name';
}
elseif($order == 'health') {
$whereandorder = ' ORDER BY health'.$desc.', name';
}
elseif($order == 'summonable') {
$whereandorder = ' AND summonable = 1 ORDER BY mana'.$desc;
}
elseif($order == 'convinceable') {
$whereandorder = ' AND convinceable = 1 ORDER BY mana'.$desc;
}
elseif($order == 'race') {
$whereandorder = ' ORDER BY race'.$desc.', name';
}
else {
$whereandorder = ' ORDER BY name';
}
if (empty($_REQUEST['creature'])) {
//send query to database
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1'.$whereandorder);
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'>';
if($order == 'name' && !isset($_REQUEST['desc'])) {
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name&desc=1"><span class="white">Name DESC</span></a></B></TD>';
} else {
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name"><span class="white">Name</span></a></B></TD>';
}
if($order == 'health' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=health&desc=1"><span class="white">Health<br/>DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=health"><span class="white">Health</span></a></B></TD>';
}
if($order == 'exp' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=exp&desc=1"><span class="white">Experience<br/>DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=exp"><span class="white">Experience</span></a></B></TD>';
}
if($order == 'summonable' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=summonable&desc=1"><span class="white">Summonable<br/>Mana DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=summonable"><span class="white">Summonable<br/>Mana</span></a></B></TD>';
}
if($order == 'convinceable' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=convinceable&desc=1"><span class="white">Convinceable<br/>Mana DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=convinceable"><span class="white">Convinceable<br/>Mana</span></a></B></TD>';
}
if($order == 'race' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=race&desc=1"><span class="white">Race<br/>DESC</span></a></B></TD></TR>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=race"><span class="white">Race</span></a></B></TD></TR>';
}
$number_of_rows = 0;
foreach($monsters as $monster) {
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><TD><a href="?subtopic=creatures&creature='.urlencode($monster['name']).'">'.$monster['name'].'</a></TD><TD>'.$monster['health'].'</TD><TD>'.$monster['exp'].'</TD>';
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc');
echo '<table id="creaturestb" class=""><thead>
<tr role="row"><th>Name</th><th>Health</th><th>Experience</th>
<th>Summonable Mana</th><th>Convinceable Mana</th><th>Race</th></tr>
</thead><tbody>';
if($monster['summonable']) {
echo '<TD>'.$monster['mana'].'</TD>';
}
else {
echo '<TD>---</TD>';
foreach ($monsters as $monster) {
echo '<tr><td><a href="?subtopic=creatures&creature=' . urlencode($monster['name']) . '">' . $monster['name'] . '</a></td>
<td>' . $monster['health'] . '</td>
<td>' . $monster['exp'] . '</td>
<td>' . ($monster['summonable'] ? $monster['mana'] : "---") . '</td>
<td>' . ($monster['convinceable'] ? $monster['mana'] : "---") . '</td>
<td>' . ucwords($monster['race']) . '</td></tr>';
}
echo '</tbody></table>';
if($monster['convinceable']) {
echo '<TD>'.$monster['mana'].'</TD>';
}
else {
echo '<TD>---</TD>';
}
echo '<td>'.ucwords($monster['race']).'</td></tr>';
}
echo '</table>';
return;
}
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
$monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = '.$db->quote($monster_name).';')->fetch();
if(isset($monster['name']))
{
} else {
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
$monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch();
if (isset($monster['name'])) {
$title = $monster['name'] . " - Creatures";
echo '<div style="text-align:center"><h2>'.$monster['name'].'</h2></div>';
echo '<div style="text-align:center"><h2>' . $monster['name'] . '</h2></div>';
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=60%>';
$number_of_rows = 0;
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Health: </b></td><td>'.$monster['health'].'</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Health: </b></td><td>' . $monster['health'] . '</td></tr>';
$number_of_rows++;
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Experience: </b></td><td>'.$monster['exp'].'</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Experience: </b></td><td>' . $monster['exp'] . '</td></tr>';
$number_of_rows++;
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Speed like: </b></td><td>'.$monster['speed_lvl'].' level';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Speed like: </b></td><td>' . $monster['speed_lvl'] . ' level';
$number_of_rows++;
if($monster['use_haste'])
if ($monster['use_haste'])
echo ' (Can use haste)';
echo '</td></tr>';
$number_of_rows++;
if($monster['summonable'] == 1)
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Summon: </b></td><td>'.$monster['mana'].' mana</td></tr>';
if ($monster['summonable'] == 1)
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
else {
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Summon: </b></td><td>Impossible</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>Impossible</td></tr>';
}
$number_of_rows++;
if($monster['convinceable'] == 1)
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Convince: </b></td><td>'.$monster['mana'].' mana</td></tr>';
if ($monster['convinceable'] == 1)
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
else
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Convince: </b></td><td>Impossible</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>Impossible</td></tr>';
echo '</TABLE></td><td align=left>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
<tr><td align=left>';
$monster['gfx_name'] = trim(strtolower($monster['name'])).".gif";
if(!file_exists('images/monsters/'.$monster['gfx_name'])) {
$monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
if (!file_exists('images/monsters/' . $monster['gfx_name'])) {
$gfx_name = str_replace(" ", "", $monster['gfx_name']);
if(file_exists('images/monsters/' . $gfx_name))
echo '<img src="images/monsters/'.$gfx_name.'" height="128" width="128">';
if (file_exists('images/monsters/' . $gfx_name))
echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
else
echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
}
else
} else
echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';
echo '</td></tr>
</TABLE></td></tr><tr><td>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
$immunities = json_decode($monster['immunities'], true);
if(count($immunities) > 0)
{
if (count($immunities) > 0) {
$number_of_rows++;
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Immunities: </b></td><td width="100%">'.implode(', ', $immunities).'</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Immunities: </b></td><td width="100%">' . implode(', ', $immunities) . '</td></tr>';
}
$voices = json_decode($monster['voices'], true);
if(count($voices) > 0)
{
foreach($voices as &$voice) {
if (count($voices) > 0) {
foreach ($voices as &$voice) {
$voice = '"' . $voice . '"';
}
$number_of_rows++;
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Voices: </b></td><td width="100%">'.implode(', ', $voices).'</td></tr>';
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Voices: </b></td><td width="100%">' . implode(', ', $voices) . '</td></tr>';
}
echo '</TABLE></td></tr>';
$loot = json_decode($monster['loot'], true);
if($loot)
{
if ($loot) {
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';
function sort_by_chance($a, $b)
{
if($a['chance'] == $b['chance']) {
if ($a['chance'] == $b['chance']) {
return 0;
}
return ($a['chance'] > $b['chance']) ? -1 : 1;
@ -218,11 +142,11 @@ if(isset($monster['name']))
usort($loot, 'sort_by_chance');
$i = 0;
foreach($loot as $item) {
foreach ($loot as $item) {
$name = getItemNameById($item['id']);
$tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];
echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="tooltip" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' .$name . '" />';
echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="tooltip" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
$i++;
}
@ -231,12 +155,20 @@ if(isset($monster['name']))
echo '</td></tr>';
echo '</TABLE>';
}
else
{
} else {
echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
}
}
//back button
$twig->display('creatures.back_button.html.twig');
$twig->display('creatures.back_button.html.twig');
}
?>
<script>
$(document).ready(function () {
$('#creaturestb').DataTable();
});
</script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

View File

@ -41,15 +41,8 @@ else {
}
}
$order = 'words';
if(isset($_REQUEST['order']))
$order = $_REQUEST['order'];
if(!in_array($order, array('words', 'type', 'mana', 'level', 'maglevel', 'soul')))
$order = 'level';
$spells = array();
$spells_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY ' . $order . ', level');
$spells_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY name, level');
if((string)$vocation_id != 'all') {
foreach($spells_db->fetchAll() as $spell) {
@ -76,11 +69,23 @@ else {
}
}
?>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<?php
$twig->display('spells.html.twig', array(
'canEdit' => $canEdit,
'post_vocation_id' => $vocation_id,
'post_vocation' => $vocation,
'post_order' => $order,
'spells' => $spells,
));
?>
<script>
$(document).ready( function () {
$('#spellstb').DataTable();
} );
</script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

View File

@ -1,4 +1,4 @@
<form method="post" action="{{ constant('ADMIN_URL') }}?p=items">
<input type="hidden" name="reload" value="1" />
<input type="submit" value="Reload items and weapons (it may take some time to finish)" />
<input type="hidden" name="reload" value="1"/>
<input type="submit" value="Reload items and weapons (it may take some time to finish)"/>
</form>

View File

@ -5,33 +5,33 @@
{% for cat, menu in menus %}
last_id[{{ cat }}] = {{ last_id[cat] }};
{% endfor %}
$( function() {
$(function () {
$(".sortable").sortable();
$(".sortable").disableSelection();
$(".remove-button").click(function() {
$(".remove-button").click(function () {
var id = $(this).attr("id");
$('#list-' + id.replace('remove-button-', '')).remove();
});
$(".add-button").click(function() {
$(".add-button").click(function () {
var cat = $(this).attr("id").replace('add-button-', '');
var id = last_id[cat];
last_id[cat]++;
$('#sortable-' + cat).append('<li class="ui-state-default" id="list-' + cat + '-' + id + '"><input type="text" name="menu[' + cat + '][]" value=""/> <input type="text" name="menu_link[' + cat + '][]" value=""/><input type="hidden" name="menu_blank[' + cat + '][]" value="0" /> <label><input class="blank-checkbox" type="checkbox"/><span title="Open in New Window">Blank</span></label> <input class="color-picker" type="text" name="menu_color[' + cat + '][]" value="#ffffff" /><a class="remove-button" id="remove-button-' + cat + '-' + id + '"><img src="{{ constant('BASE_URL') }}images/del.png"/></a></li>'); //add input bo
$('#remove-button-' + cat + '-' + id).click(function() {
$('#remove-button-' + cat + '-' + id).click(function () {
$('#list-' + $(this).attr("id").replace('remove-button-', '')).remove();
});
initialiceSpectrum();
});
$("#menus-form").submit(function(e) {
$('.blank-checkbox:not(:checked)').each(function(i, obj) {
$("#menus-form").submit(function (e) {
$('.blank-checkbox:not(:checked)').each(function (i, obj) {
$(obj).parent().prev().val("off");
});
$('.blank-checkbox:checked').each(function(i, obj) {
$('.blank-checkbox:checked').each(function (i, obj) {
$(obj).parent().prev().val("on");
});
});
@ -39,16 +39,23 @@
});
</script>
<style type="text/css">
.sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
.sortable {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
.remove-button, .add-button {
cursor: pointer;
}
</style>
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/js/spectrum.js"></script>
<link type="text/css" rel="stylesheet" href="{{ constant('BASE_URL') }}tools/css/spectrum.css" />
<link type="text/css" rel="stylesheet" href="{{ constant('BASE_URL') }}tools/css/spectrum.css"/>
<script type="text/javascript">
initialiceSpectrum();
function initialiceSpectrum() {
initialiceSpectrum();
function initialiceSpectrum() {
$(".color-picker").spectrum({
preferredFormat: "hex",
showInput: true,
@ -59,5 +66,5 @@ function initialiceSpectrum() {
['red', 'yellow', 'green', 'blue', 'violet']
]
});
}
}
</script>

View File

@ -19,7 +19,8 @@
<th class="sorting" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1"
aria-sort="ascending" aria-label="Title: activate to sort column descending">Title
</th>
<th class="" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1" style="width: 150px;">Options
<th class="" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1"
style="width: 150px;">Options
</th>
</tr>
</thead>
@ -38,9 +39,11 @@
<a href="?p=pages&action=hide&id={{ page.id }}" class="ico"
title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %}">
{% if page.hidden != 1 %}
<span class="btn btn-primary btn-sm btn-flat"><i class="fa fa-eye"></i></span>
<span class="btn btn-primary btn-sm btn-flat"><i
class="fa fa-eye"></i></span>
{% else %}
<span class="btn btn-default btn-sm btn-flat"><i class="fa fa-eye-slash"></i></span>
<span class="btn btn-default btn-sm btn-flat"><i
class="fa fa-eye-slash"></i></span>
{% endif %}
</a>
</td>

View File

@ -2,10 +2,12 @@
<a href="admin/?p=pages&action=edit&id={{ page.id }}" title="Edit in Admin Panel" target="_blank">
<img src="images/edit.png"/>Edit
</a>
<a id="delete" href="admin/?p=pages&action=delete&id={{ page.id }}" onclick="return confirm('Are you sure?');" title="Delete in Admin Panel" target="_blank">
<a id="delete" href="admin/?p=pages&action=delete&id={{ page.id }}" onclick="return confirm('Are you sure?');"
title="Delete in Admin Panel" target="_blank">
<img src="images/del.png"/>Delete
</a>
<a href="admin/?p=pages&action=hide&id={{ page.id }}" title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %} in Admin Panel" target="_blank">
<a href="admin/?p=pages&action=hide&id={{ page.id }}"
title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %} in Admin Panel" target="_blank">
<img src="images/{% if page.hidden != 1 %}success{% else %}error{% endif %}.png"/>{% if page.hidden != 1 %}Hide{% else %}Show{% endif %}
</a>
<br/>

View File

@ -1,3 +1,4 @@
{% if canEdit %}
<form method="post" action="{{ getLink('spells') }}">
<input type="hidden" name="reload_spells" value="yes"/>
@ -20,7 +21,6 @@
<option value="{{ id }}"{% if id == post_vocation_id and post_vocation_id != "all" and post_vocation_id != '' %} selected{% endif %}>{{ vocation }}</option>
{% endfor %}
</select>
<input type="hidden" name="order" value="{{ post_order }}">
</td>
<td>
{{ include('buttons.submit.html.twig') }}
@ -32,40 +32,14 @@
</table>
</form>
<br/>
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr bgcolor="{{ config.vdarkborder }}">
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/spell' }}"><span class="white">Name</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/words' }}"><span class="white">Words</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/type' }}"><span class="white">Type<br/>(count)</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/mana' }}"><span class="white">Mana</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/level' }}"><span class="white">Level</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/maglevel' }}"><span class="white">Magic<br/>Level</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/soul' }}"><span class="white">Soul</span></a></b>
</td>
<td class="white">
<b>Premium</b>
</td>
<td class="white">
<b>Vocations:</b>
</td>
</tr>
<table id="spellstb" class=""><thead>
<tr role="row"><th>Name</th><th>Words</th><th>Type<br/>(count)</th>
<th>Mana</th><th>Level</th><th>Magic Level</th><th>Soul</th><th>Premium</th><th>Vocations</th></tr>
</thead><tbody>
{% set i = 0 %}
{% for spell in spells %}
{% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}">
<tr>
<td>{{ spell.name }}</td>
<td>{{ spell.words }}</td>
<td>
@ -93,4 +67,4 @@
</td>
</tr>
{% endfor %}
</table>
</tbody></table>

View File

@ -1 +0,0 @@
table.dataTable{clear:both;margin-top:6px !important;margin-bottom:6px !important;max-width:none !important;border-collapse:separate !important}table.dataTable td,table.dataTable th{-webkit-box-sizing:content-box;box-sizing:content-box}table.dataTable td.dataTables_empty,table.dataTable th.dataTables_empty{text-align:center}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}div.dataTables_wrapper div.dataTables_length label{font-weight:normal;text-align:left;white-space:nowrap}div.dataTables_wrapper div.dataTables_length select{width:75px;display:inline-block}div.dataTables_wrapper div.dataTables_filter{text-align:right}div.dataTables_wrapper div.dataTables_filter label{font-weight:normal;white-space:nowrap;text-align:left}div.dataTables_wrapper div.dataTables_filter input{margin-left:0.5em;display:inline-block;width:auto}div.dataTables_wrapper div.dataTables_info{padding-top:8px;white-space:nowrap}div.dataTables_wrapper div.dataTables_paginate{margin:0;white-space:nowrap;text-align:right}div.dataTables_wrapper div.dataTables_paginate ul.pagination{margin:2px 0;white-space:nowrap}div.dataTables_wrapper div.dataTables_processing{position:absolute;top:50%;left:50%;width:200px;margin-left:-100px;margin-top:-26px;text-align:center;padding:1em 0}table.dataTable thead>tr>th.sorting_asc,table.dataTable thead>tr>th.sorting_desc,table.dataTable thead>tr>th.sorting,table.dataTable thead>tr>td.sorting_asc,table.dataTable thead>tr>td.sorting_desc,table.dataTable thead>tr>td.sorting{padding-right:30px}table.dataTable thead>tr>th:active,table.dataTable thead>tr>td:active{outline:none}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc_disabled{cursor:pointer;position:relative}table.dataTable thead .sorting:after,table.dataTable thead .sorting_asc:after,table.dataTable thead .sorting_desc:after,table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{position:absolute;bottom:8px;right:8px;display:block;font-family:'Glyphicons Halflings';opacity:0.5}table.dataTable thead .sorting:after{opacity:0.2;content:"\e150"}table.dataTable thead .sorting_asc:after{content:"\e155"}table.dataTable thead .sorting_desc:after{content:"\e156"}table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{color:#eee}div.dataTables_scrollHead table.dataTable{margin-bottom:0 !important}div.dataTables_scrollBody table{border-top:none;margin-top:0 !important;margin-bottom:0 !important}div.dataTables_scrollBody table thead .sorting:after,div.dataTables_scrollBody table thead .sorting_asc:after,div.dataTables_scrollBody table thead .sorting_desc:after{display:none}div.dataTables_scrollBody table tbody tr:first-child th,div.dataTables_scrollBody table tbody tr:first-child td{border-top:none}div.dataTables_scrollFoot table{margin-top:0 !important;border-top:none}@media screen and (max-width: 767px){div.dataTables_wrapper div.dataTables_length,div.dataTables_wrapper div.dataTables_filter,div.dataTables_wrapper div.dataTables_info,div.dataTables_wrapper div.dataTables_paginate{text-align:center}}table.dataTable.table-condensed>thead>tr>th{padding-right:20px}table.dataTable.table-condensed .sorting:after,table.dataTable.table-condensed .sorting_asc:after,table.dataTable.table-condensed .sorting_desc:after{top:6px;right:6px}table.table-bordered.dataTable th,table.table-bordered.dataTable td{border-left-width:0}table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable td:last-child,table.table-bordered.dataTable td:last-child{border-right-width:0}table.table-bordered.dataTable tbody th,table.table-bordered.dataTable tbody td{border-bottom-width:0}div.dataTables_scrollHead table.table-bordered{border-bottom-width:0}div.table-responsive>div.dataTables_wrapper>div.row{margin:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:first-child{padding-left:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:last-child{padding-right:0}

1
tools/css/jquery.dataTables.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,8 +0,0 @@
/*!
DataTables Bootstrap 3 integration
©2011-2015 SpryMedia Ltd - datatables.net/license
*/
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d,m){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",renderer:"bootstrap"});b.extend(f.ext.classes,
{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm",sProcessing:"dataTables_processing panel panel-default"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,s,j,n){var o=new f.Api(a),t=a.oClasses,k=a.oLanguage.oPaginate,u=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault();!b(a.currentTarget).hasClass("disabled")&&o.page()!=a.data.action&&o.page(a.data.action).draw("page")};
l=0;for(h=f.length;l<h;l++)if(c=f[l],b.isArray(c))q(d,c);else{g=e="";switch(c){case "ellipsis":e="&#x2026;";g="disabled";break;case "first":e=k.sFirst;g=c+(0<j?"":" disabled");break;case "previous":e=k.sPrevious;g=c+(0<j?"":" disabled");break;case "next":e=k.sNext;g=c+(j<n-1?"":" disabled");break;case "last":e=k.sLast;g=c+(j<n-1?"":" disabled");break;default:e=c+1,g=j===c?"active":""}e&&(i=b("<li>",{"class":t.sPageButton+" "+g,id:0===r&&"string"===typeof c?a.sTableId+"_"+c:null}).append(b("<a>",{href:"#",
"aria-controls":a.sTableId,"aria-label":u[c],"data-dt-idx":p,tabindex:a.iTabIndex}).html(e)).appendTo(d),a.oApi._fnBindAction(i,{action:c},m),p++)}},i;try{i=b(h).find(d.activeElement).data("dt-idx")}catch(v){}q(b(h).empty().html('<ul class="pagination"/>').children("ul"),s);i!==m&&b(h).find("[data-dt-idx="+i+"]").focus()};return f});