Admin Panel (#61)

Thank you Lee for this awesome, Bootstrap Admin Panel!
This commit is contained in:
Lee
2018-11-22 06:12:14 +00:00
committed by slawkens
parent 89f24c631c
commit 6dab50cbd8
58 changed files with 8636 additions and 1264 deletions

View File

@@ -0,0 +1,463 @@
<?php
/**
* Account editor
*
* @package MyAAC
* @author Lee
* @copyright 2018 MyAAC
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Account editor';
$base = BASE_URL . 'admin/?p=accounts';
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.');
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/jquery.datetimepicker.css"/ >
<script src="<?php echo BASE_URL; ?>tools/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.';
}
}
}
}
if ($id > 0) {
$account = new OTS_Account();
$account->load($id);
if (isset($account) && $account->isLoaded() && isset($_POST['save'])) {// we want to save
$error = false;
$name = $_POST['name'];
$_error = '';
//if (!Validator::check_account_name($name))
// echo_error(Validator::getLastError());
$account_db = new OTS_Account();
$account_db->find($name);
if ($account_db->isLoaded() && $account->getName() != $name)
echo_error('This name is already used. Please choose another name!');
$account_db->load($id);
if (!$account_db->isLoaded())
echo_error('Account with this id doesn\'t exist.');
//type
$group = $_POST['group'];
$password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null));
if(!Validator::password($password)) {
$errors['password'] = Validator::getLastError();
}
//secret
$secret = $_POST['secret'];
//key
$key = $_POST['key'];
$email = $_POST['email'];
if(!Validator::email($email))
$errors['email'] = Validator::getLastError();
// prem days
$p_days = $_POST['p_days'];
verify_number($p_days, 'Prem days', 11);
//tibia coins
$t_coins = $_POST['t_coins'];
verify_number($t_coins, 'Tibia coins', 12);
//prem points
$p_points = $_POST['p_points'];
verify_number($p_points, 'Prem Points', 11);
//rl name
$rl_name = $_POST['rl_name'];
//location
$rl_loca = $_POST['rl_loca'];
//country
$rl_country = $_POST['rl_country'];
//created
$created = $_POST['created'];
verify_number($created, 'Created', 20);
//last login
$lastlogin = $_POST['lastlogin'];
verify_number($lastlogin, 'Last login', 20);
//web last login
$web_lastlogin = $_POST['web_lastlogin'];
verify_number($web_lastlogin, 'Web Last logout', 20);
if (!$error) {
$account->setName($name);
$account->setCustomField('type', $group);
$account->setCustomField('secret', $secret);
$account->setCustomField('key', $key);
$account->setEMail($email);
$account->setPremDays($p_days);
$account->setCustomField('coins', $t_coins);
$account->setRLName($rl_name);
$account->setLocation($rl_loca);
$account->setCountry($rl_country);
if ($db->hasColumn('accounts', 'premium_points')){
$account->setCustomField('premium_points', $p_points);}
if (isset($password)) {
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
if($config_salt_enabled)
{
$salt = generateRandomString(10, false, true, true);
$password = $salt . $password;
$account_logged->setCustomField('salt', $salt);
}
$password = encrypt($password);
$account->setPassword($password);
if ($config_salt_enabled)
$account->setCustomField('salt', $salt);
}
$account->setEMail($email);
//$account->setCustomField('created', time());
$account->save();
echo_success('Account saved at: ' . date('G:i'));
}
}
}
$search_name = '';
$search_account = '';
if (isset($_REQUEST['search_name']))
$search_name = $_REQUEST['search_name'];
else if (isset($_REQUEST['search_account']))
$search_account = $_REQUEST['search_account'];
else if ($id > 0 && isset($account) && $account->isLoaded())
$search_name = $account->getName();
?>
<div class="row">
<?php
if (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">
<div class="col-md-8">
<div class="box box-primary">
<div class="box-body">
<div class="row">
<div class="col-xs-6">
<label for="name" class="control-label">Account Name</label>
<input type="text" class="form-control" id="name" name="name"
autocomplete="off" style="cursor: auto;"
value="<?php echo $account->getName(); ?>"/>
</div>
<div class="col-xs-6">
<label for="account_id" class="control-label">Account id:</label>
<input type="text" class="form-control" id="account_id" name="account_id"
autocomplete="off" style="cursor: auto;" size="8" maxlength="11" disabled
value="<?php echo $account->getId(); ?>"/>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label for="group" class="control-label">Type</label>
<select name="group" id="group" class="form-control">
<?php foreach ($acc_type as $id => $a_type): ?>
<option value="<?php echo($id + 1); ?>" <?php echo($account->getCustomField('type') == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-xs-6">
<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>
<div class="row">
<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>
<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>
<div class="col-xs-6">
<label for="p_days" class="control-label">Prem Days:</label>
<input type="text" class="form-control" id="p_days" name="p_days"
autocomplete="off" maxlength="11"
value="<?php echo $account->getPremDays(); ?>"/>
</div>
<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 if ($db->hasColumn('players', 'blessings')): ?>
<div class="col-xs-6">
<label for="p_points" class="control-label">Prem 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>
<input type="text" class="form-control" id="rl_country" name="rl_country"
autocomplete="off" maxlength="8"
value="<?php echo $account->getCountry(); ?>"/>
</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="lastlogin" class="control-label">Last Login:</label>
<input type="text" class="form-control" id="lastlogin" name="lastlogin"
autocomplete="off" maxlength="20"
value="<?php echo $account->getLastLogin(); ?>"/>
</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>
<!-- nav-tabs-custom -->
<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>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<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>
<!-- /.box-body -->
</div>
<!-- /.box -->
<?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>
<!-- /.box-header -->
<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>
<!-- /.box-body -->
</div>
<?php
};
};
?>
</div>
<div class="row">
<?php if (isset($accoun1t) && $account->isLoaded()) {
?>
<div class="col-md-4">
<?php
$tableToDescribe = 'accounts';
$statement = $db->query('DESCRIBE ' . $tableToDescribe);
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
$val = 0;
foreach ($result as $column) {
// IF val = 2 MAKE <TR> TODO
($val == 2) ? "<tr>" : "";
?>
<td><?php echo $column['Field'] ?></td>
<td><input type="text" name="lastip" size="8" maxlength="10"
value="<?php echo $account->getCustomField($column['Field']); ?>"/></td>
<?php
echo $column['Field'] . ' - ' . $column['Type'], '<br>';
if ($val == 2) {
echo "</tr>";
$val = 1;
} else {
++$val;
}
} ?>
</div>
<?php } ?>
</div>
<script type="text/javascript">
$('#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;
$('input[name=pass]')[0].value = '';
}).change();
});
</script>

View File

@@ -24,4 +24,3 @@ $changelog = preg_replace('/\s(\w+:\/\/)(\S+)/', ' <a href="\\1\\2" target="_bla
$changelog = nl2br($changelog);
echo '<div>' . $changelog . '</div>';
?>

View File

@@ -48,12 +48,40 @@ $tmp = '';
if(fetchDatabaseConfig('site_closed_message', $tmp))
$closed_message = $tmp;
$twig->display('admin.dashboard.html.twig', array(
'is_closed' => $is_closed,
'closed_message' => $closed_message,
'status' => $status
$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;');
$coins = $db->query('SELECT `coins`, `' . (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
));
$twig->display('admin.dashboard.html.twig', array(
'is_closed' => $is_closed,
'closed_message' => $closed_message,
'status' => $status,
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
'points' => $points,
'coins' => $coins
));
function clearCache()
{
global $template_name;

View File

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

View File

@@ -11,73 +11,114 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Logs viewer';
?>
<table class="table" width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<th><b>Log name</b></td>
<th><b>Last updated</b></td>
</tr>
<?php
<div class="box">
<div class="box-header">
<h3 class="box-title">Logs:</h3>
</div>
<div class="box-body">
<div id="logs_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
<div class="row">
<div class="col-sm-12">
<table id="logs" class="table table-bordered table-striped dataTable" role="grid"
aria-describedby="logs_info">
<thead>
<tr role="row">
<th class="sorting_asc" tabindex="0" aria-controls="logs" rowspan="1" colspan="1"
aria-sort="ascending" aria-label="Log name: activate to sort column descending"
style="width: 297px;">Log name
</th>
<th class="sorting" tabindex="0" aria-controls="logs" rowspan="1" colspan="1"
aria-label="Last updated: activate to sort column ascending" style="width: 361px;">Last
updated
</th>
</tr>
</thead>
<tbody>
<?php
$files = array();
$aac_path_logs = BASE . 'system/logs/';
foreach (scandir($aac_path_logs) as $f) {
if ($f[0] == '.' || $f == '..' || is_dir($aac_path_logs . $f))
continue;
$files = array();
$aac_path_logs = BASE . 'system/logs/';
foreach(scandir($aac_path_logs) as $f) {
if($f[0] == '.' || $f == '..' || is_dir($aac_path_logs . $f))
continue;
$files[] = array($f, $aac_path_logs);
}
$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/';
}
$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) as $f) {
if ($f[0] == '.' || $f == '..')
continue;
if(file_exists($server_path_logs)) {
foreach(scandir($server_path_logs) as $f) {
if($f[0] == '.' || $f == '..')
continue;
if (is_dir($server_path_logs . $f)) {
foreach (scandir($server_path_logs . $f) as $f2) {
if ($f2[0] == '.' || $f2 == '..')
continue;
$files[] = array($f . '/' . $f2, $server_path_logs);
}
if(is_dir($server_path_logs . $f)) {
foreach(scandir($server_path_logs . $f) as $f2) {
if($f2[0] == '.' || $f2 == '..')
continue;
$files[] = array($f . '/' . $f2, $server_path_logs);
}
continue;
}
continue;
}
$files[] = array($f, $server_path_logs);
}
}
$files[] = array($f, $server_path_logs);
}
}
$i = 0;
foreach ($files as $f) {
?>
<tr>
<td>
<a href="<?php echo ADMIN_URL . '?p=logs&file=' . $f[0]; ?>"><?php echo $f[0]; ?></a>
</td>
<td><?php echo date("Y-m-d H:i:s", filemtime($f[1] . $f[0])); ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<th>Log name</th>
<th>Last updated</th>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
$i = 0;
foreach($files as $f) {
?>
<tr>
<td><a href="<?php echo ADMIN_URL . '?p=logs&file=' . $f[0]; ?>"><?php echo $f[0]; ?></a></td>
<td><?php echo date("Y-m-d H:i:s", filemtime($f[1] . $f[0])); ?></td>
</tr>
<?php
}
?>
</table>
<?php
$file = isset($_GET['file']) ? $_GET['file'] : NULL;
if(!empty($file))
{
if(!preg_match('/[^A-z0-9\' _\/\-\.]/', $file))
{
if(file_exists($aac_path_logs . $file))
echo str_repeat('<br/>', 3) . '<b>' . $file . ':</b><br/><br/>' . nl2br(file_get_contents($aac_path_logs . $file));
else if(file_exists($server_path_logs . $file))
echo str_repeat('<br/>', 3) . '<b>' . $file . ':</b><br/><br/>' . nl2br(file_get_contents($server_path_logs . $file));
else
echo 'Specified file does not exist.';
}
else
echo 'Invalid file name specified.';
if (!empty($file)) {
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
if (file_exists($aac_path_logs . $file)) {
echo '
<div class="box">
<div class="box-header">
<h3 class="box-title"><b>' . $file . '</b></h3>
</div>
<div class="box-body">';
echo nl2br(file_get_contents($aac_path_logs . $file));
echo '</div>
</div>';
} else if (file_exists($server_path_logs . $file)) {
echo '<div class="box"><div class="box-header"><h3 class="box-title"><b>' . $file . '</b></h3></div><div class="box-body">';
echo nl2br(file_get_contents($server_path_logs . $file));
echo '</div></div>';
} else
echo 'Specified file does not exist.';
} else
echo 'Invalid file name specified.';
}
?>
<script>
$(function () {
$('#logs').DataTable()
})
</script>

View File

@@ -12,75 +12,82 @@ $title = 'Menus';
if(!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin())
{
echo 'Access denied.';
return;
echo 'Access denied.';
return;
}
if(isset($_REQUEST['template'])) {
$template = $_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;
}
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;
$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());
}
}
}
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());
}
}
}
success('Saved at ' . date('H:i'));
}
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;
}
$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;
}
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/>
echo 'Hint: You can drag menu items.<br/>
Hint: Add links to external sites using: <b>http://</b> prefix.<br/>
Not all templates support blank and colorful links.<br/>
Editing: ' . $template . ' template.';
$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']);
}
<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 '<h2>' . $cat['name'] . '<img class="add-button" id="add-button-' . $id . '" src="' . BASE_URL . 'images/plus.png" width="16" height="16"/></h2>';
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 . '"><input type="text" name="menu[' . $id . '][]" value="' . $menu['name'] . '"/>
$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 . '"><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" />
<label><input class="blank-checkbox" type="checkbox" ' . ($menu['blank'] == 1 ? 'checked' : '') . '/><span title="Open in New Window">Blank</span></label>
@@ -89,34 +96,41 @@ if(isset($_REQUEST['template'])) {
<a class="remove-button" id="remove-button-' . $id . '-' . $i . '"><img src="' . BASE_URL . 'images/del.png"/></a></li>';
$i++;
$last_id[$id] = $i;
}
}
$i++;
$last_id[$id] = $i;
}
}
echo '</ul>';
}
echo '</ul>';
echo ' </div>
</div>
</div>
';
}
echo ' </div><div class="row"><div class="col-md-6">';
echo '<input type="submit" class="button" value="Update">';
echo '<input type="button" class="button" value="Cancel" onclick="window.location = \'' . ADMIN_URL . '?p=menus&template=' . $template . '\';">';
echo '</div></div>';
echo '</form>';
echo '<input type="submit" class="button" value="Update">';
echo '<input type="button" class="button" value="Cancel" onclick="window.location = \'' . ADMIN_URL . '?p=menus&template=' . $template . '\';">';
echo '</form>';
$twig->display('admin.menus.js.html.twig', array(
'menus' => $menus,
'last_id' => $last_id
));
?>
$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]);
}
}
$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
));
}
?>
$twig->display('admin.menus.form.html.twig', array(
'templates' => $templates
));
}

View File

@@ -52,4 +52,4 @@ class Notepad
global $db;
$db->update(TABLE_PREFIX . 'notepad', array('content' => $content), array('account_id' => $account_id));
}
}
}

View File

@@ -84,7 +84,7 @@ if(!empty($action))
}
if(!empty($errors))
$twig->display('error_box.html.twig', array('errors' => $errors));
$twig->display('admin.error.html.twig', array('errors' => $errors));
}
$query =

File diff suppressed because it is too large Load Diff