* some changes

* moved some admin html code from php to twig templates (.html files)
* minimum PHP version required by installer is now 5.1.2, cause of spl_autoload_register functon.
* depracated Twig to version 1.20.0 cause of Autoloader
* removed unused admin stylish template
This commit is contained in:
slawkens
2017-08-28 10:02:49 +02:00
parent 603c2175e3
commit 15961f0c17
418 changed files with 15624 additions and 4322 deletions

View File

@@ -18,14 +18,6 @@ if($cache->enabled()) {
else
error('Error while clearing cache.');
}
?>
<table class="table">
<tr>
<th><a href="?p=dashboard&clear_cache" onclick="return confirm('Are you sure?');">Clear cache</a></th>
</tr>
</table>
<?php
}
if(isset($_GET['maintenance'])) {
$_status = (int)$_POST['status'];
@@ -55,82 +47,12 @@ $closed_message = 'Server is under maintenance, please visit later.';
$tmp = '';
if(fetchDatabaseConfig('site_closed_message', $tmp))
$closed_message = $tmp;
?>
<form action="?p=dashboard&maintenance" method="post">
<table class="table">
<tr>
<th colspan="2">Maintenance
</th>
</tr>
<tr>
<td>Site status:</td>
<td>
<select name="status">
<option value="0"<?php echo (!$is_closed ? ' selected' : ''); ?>>Open</option>
<option value="1"<?php echo ($is_closed ? ' selected' : ''); ?>>Closed</option>
</select>
</td>
</tr>
<tr>
<td>Message: (only if closed)</td>
<td>
<textarea name="message" maxlength="255" cols="40" rows="5"><?php echo $closed_message; ?></textarea>
<td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="button" value="Update"/>
</td>
</table>
</form>
<br/>
<div>
<?php if($status['online']): ?>
<p class="success" style="width: 150px; text-align: center;">Status: Online<br/>
<?php echo $status['uptimeReadable'] . ', ' . $status['players'] . '/' . $status['playersMax']; ?><br/>
<?php echo $config['lua']['ip'] . ' : ' . $config['lua']['loginPort']; ?>
<br/><br/><u><a id="more-button" href="#"></a></u>
<span id="status-more">
<br/>
<b>Server</b>:<br/> <?php echo $status['server'] . ' ' . $status['serverVersion']; ?><br/>
<b>Version</b>: <?php echo $status['clientVersion']; ?><br/><br/>
<b>Monsters</b>: <?php echo $status['monsters']; ?><br/>
<b>Map</b>: <?php echo $status['mapName']; ?>, <b>author</b>: <?php echo $status['mapAuthor']; ?>, <b>size</b>: <?php echo $status['mapWidth'] . ' x ' . $status['mapHeight']; ?><br/>
<b>MOTD</b>:<br/> <?php echo $status['motd']; ?><br/><br/>
<b>Last updated</b>: <?php echo date("H:i:s", $status['lastCheck']); ?>
</span>
</p>
<?php else: ?>
<p class="error" style="width: 120px; text-align: center;">Status: Offline</p>
<?php endif; ?>
</div>
<!--div>
Version: <?php echo MYAAC_VERSION; ?> (<a id="update" href="#">Check for updates</a>)
</div-->
<?php if($status['online']): ?>
<script type="text/javascript">
$(document).ready(function() {
$("#status-more").hide();
$("#more-button").text("More");
});
$("#more-button").click(function() {
if($("#status-more").is(":hidden")) {
$("#more-button").text("Hide");
$("#status-more").show();
}
else {
$("#more-button").text("More");
$("#status-more").hide();
}
return false;
});
</script>
<?php endif;
echo $twig->render('admin.dashboard.html', array(
'is_closed' => $is_closed,
'closed_message' => $closed_message,
'status' => $status
));
function clearCache()
{

View File

@@ -19,14 +19,6 @@ if(isset($errors)) {
error($error);
}
}
?>
Please login.
<form method="post">
<input type="password" name="account_login" id="account-name-input" size="30" maxlength="30" autofocus/><br/>
<input type="password" name="password_login" size="30" maxlength="29"/><br/>
<input type="checkbox" id="remember_me" name="remember_me" value="true"/>
<label for="remember_me"> Remember me</label><br/>
<input type="hidden" name="admin" value="1"/>
<input type="submit" class="button" value="Login"/>
</form>
echo $twig->render('admin.login.html');
?>

View File

@@ -29,82 +29,43 @@ $preview = isset($_REQUEST['preview']);
$preview_done = false;
if($preview) {
if(!empty($mail_content) && !empty($mail_subject))
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: ' . $mailer->ErrorInfo);
if(!$preview_done)
error('Error while sending preview mail: ' . $mailer->ErrorInfo);
}
}
?>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins: "safari,advimage,emotions,insertdatetime,preview,wordcount",
relative_urls : false,
remove_script_host : false,
document_base_url : "<?php echo BASE_URL; ?>",
echo $twig->render('admin.mailer.html', array(
'mail_subject' => $mail_subject,
'mail_content' => $mail_content,
'preview_done' => $preview_done
));
theme_advanced_buttons3_add : "emotions,insertdate,inserttime,preview,|,forecolor,backcolor",
if(empty($mail_content) || empty($mail_subject) || $preview)
return;
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
});
</script>
<table width="800" cellspacing="1" cellpadding="2" border="0" align="center">
<form method="post">
<tr>
<td colspan="2" align="center">
<p class="note note-image" style="width: 80%;">Sending mails may take some time if there are much users in db.</p>
</td>
</tr>
<tr>
<td align="right">
<label for="mail_subject">Subject:</label>
</td>
<td align="left">
<input type="text" id="mail_subject" name="mail_subject" value="<?php echo $mail_subject; ?>" size="30" maxlength="30" />
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="mail_content" name="mail_content" style="width: 100%" class="tinymce"><?php echo $mail_content; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="checkbox" name="preview" id="preview" value="1"/><label for="preview">Just send test email to me (preview)</label><?php echo ($preview_done ? ' - <b>Done.</b>' : ''); ?><br/><input type="submit" name="submit" value="Send" />
</td>
</tr>
</form>
</table>
<?php
if(empty($mail_content) || empty($mail_subject) || $preview)
return;
$success = 0;
$failed = 0;
$success = 0;
$failed = 0;
$add = '';
if($config['account_mail_verify'])
$add = ' AND ' . $db->fieldName('email_verified') . ' = 1';
$add = '';
if($config['account_mail_verify'])
$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)
$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
{
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>. Error: ' . $mailer->ErrorInfo);
}
$failed++;
echo '<br />';
error('An error occorred while sending email to <b>' . $email['email'] . '</b>. Error: ' . $mailer->ErrorInfo);
}
}
?>
Mailing finished.<br/>
<p class="success"><?php echo $success; ?> emails delivered.</p><br/>

View File

@@ -27,61 +27,9 @@ else
if($notepad_content !== false)
$_content = $notepad_content;
}
?>
<table width="700" cellspacing="1" cellpadding="2" border="0" align="center">
<form method="post">
<tr>
<td align="center">
<p>This is your personal notepad. Be sure to save it each time you modify something.</p>
</td>
</tr>
<tr>
<td align="center">
<textarea style="text-align: left;" name="content" cols="50" rows="15" onchange="notepad_onchange(this);"><?php echo isset($_content) ? htmlentities($_content, ENT_COMPAT, 'UTF-8') : ''; ?></textarea>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="submit" onclick="notepad_save(this);" value="Save" />
</td>
</tr>
</form>
</table>
echo $twig->render('admin.notepad.html', array('content' => $_content));
<?php
// confirm leaving current page if content of the notepad has been modified
?>
<script type="text/javascript">
var original_value = document.getElementsByName("content")[0].value;
function confirm_exit(e) {
var e = e || window.event;
var message = 'Are you sure you want to quit? Remaining changes will be unsaved.';
// for IE and Firefox prior to version 4
if (e) {
e.returnValue = message;
}
// for Safari
return message;
};
function notepad_onchange(e) {
if(original_value != e.value) {
window.onbeforeunload = confirm_exit;
}
return true;
};
function notepad_save(e) {
window.onbeforeunload = function(e) {};
return true;
};
</script>
<?php
class Notepad
{
static public function get($account_id)

View File

@@ -12,26 +12,9 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Plugin manager';
require(SYSTEM . 'hooks.php');
?>
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="upload_plugin" />
<table cellspacing="3" border="0">
<tr>
<td colspan="2">Install plugin:</td>
</tr>
<tr>
<td>
<input type="file" name="plugin" />
</td>
<td>
<input type="submit" value="Upload" />
</td>
</tr>
</table>
</form>
<br/><br/>
<?php
echo $twig->render('admin.plugins.form.html');
$message = '';
if(isset($_FILES["plugin"]["name"]))
{
@@ -136,35 +119,30 @@ if(isset($_FILES["plugin"]["name"]))
}
echo $message;
?>
<b>Installed plugins:</b>
<table class="table" border="0" align="center">
<tr>
<th>Plugin name (Description on hover)</th>
<th>Filename</th>
<th>Version</th>
<th>Author</th>
<th>Contact</th>
<?php
$plugins = array();
$path = PLUGINS;
foreach(scandir($path) as $file)
{
$file_info = explode('.', $file);
if($file == '.' || $file == '..' || $file == 'disabled' || $file == 'example.json' || is_dir($path . $file) || !$file_info[1] || $file_info[1] != 'json')
continue;
$string = file_get_contents(BASE . 'plugins/' . $file_info[0] . '.json');
$plugin_info = json_decode($string, true);
echo '<tr>
<td><div title="' . $plugin_info['description'] . '">' . $plugin_info['name'] . '</div></td>
<td>' . $file . '</td>
<td>' . $plugin_info['version'] . '</td>
<td>' . $plugin_info['author'] . '</td>
<td>' . $plugin_info['contact'] . '</td>
</tr>';
}
$plugins = array();
$rows = array();
?>
</table>
$path = PLUGINS;
foreach(scandir($path) as $file)
{
$file_info = explode('.', $file);
if($file == '.' || $file == '..' || $file == 'disabled' || $file == 'example.json' || is_dir($path . $file) || !$file_info[1] || $file_info[1] != 'json')
continue;
$string = file_get_contents(BASE . 'plugins/' . $file_info[0] . '.json');
$plugin_info = json_decode($string, true);
$rows[] = array(
'name' => $plugin_info['name'],
'description' => $plugin_info['description'],
'version' => $plugin_info['version'],
'author' => $plugin_info['author'],
'contact' => $plugin_info['contact'],
'file' => $file,
);
}
echo $twig->render('admin.plugins.html', array(
'plugins' => $rows
));
?>

View File

@@ -10,51 +10,31 @@
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Statistics';
?>
<table>
<tr>
<td>
<table class="table">
<tr><th colspan="2">Statistics</th></tr>
<tr><td>Total accounts:</td>
<?php
$query = $db->query('SELECT count(*) as `how_much` FROM `accounts`;');
$query = $query->fetch();
echo '<td>' . $query['how_much'] . '</td></tr>';
?>
<tr><td>Total players:</td>
<?php
$query = $db->query('SELECT count(*) as `how_much` FROM `players`;');
$query = $query->fetch();
echo '<td>' . $query['how_much'] . '</td></tr>';
?>
<tr><td>Total guilds:</td>
<?php
$query = $db->query('SELECT count(*) as `how_much` FROM `guilds`;');
$query = $query->fetch();
echo '<td>' . $query['how_much'] . '</td></tr>';
?>
<tr><td>Total houses:</td>
<?php
$query = $db->query('SELECT count(*) as `how_much` FROM `houses`;');
$query = $query->fetch();
echo '<td>' . $query['how_much'] . '</td></tr>';
?>
</table>
</td>
<td>
<table class="table">
<tr><th colspan="3">TOP 10 - Most wealth accounts</th></tr>
<tr><th>#</th><th>Account <?php echo (USE_ACCOUNT_NAME ? 'name' : 'number'); ?></th><th>Premium points</th></tr>
<?php
$query = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
$i = 0;
foreach($query as $result)
{
echo '<tr><td>' . ++$i . '.</td><td>' . $result['name'] . '</td><td>' . $result['premium_points'] . '</td></tr>';
}
?>
</table>
</td>
</tr>
</table>
$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;');
echo $twig->render('admin.statistics.html', 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
));
?>

View File

@@ -21,15 +21,6 @@ endif;
require(SYSTEM . 'libs/visitors.php');
$visitors = new Visitors($config['visitors_counter_ttl']);
?>
Users being active within last <?php echo $config['visitors_counter_ttl']; ?> minutes.<br/><br/>
<table class="table" width="100%" border="0">
<tr>
<th><b>IP</b></th>
<th><b>Last visit</b></th>
<th><b>Page</b></th>
</tr>
<?php
function compare($a, $b) {
return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1;
@@ -38,16 +29,8 @@ function compare($a, $b) {
$tmp = $visitors->getVisitors();
usort($tmp, 'compare');
$i = 0;
foreach($tmp as $visitor)
{
echo $twig->render('admin.visitors.html', array(
'config_visitors_counter_ttl' => $config['visitors_counter_ttl'],
'visitors' => $tmp
));
?>
<tr>
<td><?php echo $visitor['ip']; ?></td>
<td><?php echo date("H:i:s", $visitor['lastvisit']); ?></td>
<td><a href="<?php echo $visitor['page']; ?>"><?php echo substr($visitor['page'], 0, 50); ?></a></td>
</tr>
<?php
}
?>
</table>