* reverted removing base href in html head

* added anonymous usage statistics reporting
* (fix) don't show templates that doesn't exist in Menus option in Admin Panel
* (fix) menu ordering by category
* (fix) showing changelog with urls in Admin Panel
* (internal) moved uninstall logic to Plugins class
This commit is contained in:
slawkens
2017-11-03 09:43:47 +01:00
parent ac9c43e280
commit 9aa4e308c1
16 changed files with 175 additions and 97 deletions

View File

@@ -17,10 +17,12 @@ if(!file_exists(BASE . 'CHANGELOG')) {
}
$changelog = file_get_contents(BASE . 'CHANGELOG');
$changelog = nl2br(htmlspecialchars($changelog));
$changelog = htmlspecialchars($changelog);
// replace URLs with <a href...> elements
$changelog = preg_replace('/\s(\w+:\/\/)(\S+)/', ' <a href="\\1\\2" target="_blank">\\1\\2</a>', $changelog);
$changelog = nl2br($changelog);
echo '<div>' . $changelog . '</div>';
?>

View File

@@ -29,16 +29,16 @@ if(isset($_REQUEST['template'])) {
}
$db->query('DELETE FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template));
foreach($post_menu as $id => $menus) {
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[$id][$i], 'category' => $id, 'ordering' => $i));
$db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'category' => $category, 'ordering' => $i));
}
catch(PDOException $error) {
warning('Error while adding menu item (' . $name . '): ' . $error->getMessage());
warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage());
}
}
}
@@ -97,6 +97,12 @@ if(isset($_REQUEST['template'])) {
}
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]);
}
}
echo $twig->render('admin.menus.form.html.twig', array(
'templates' => $templates

View File

@@ -14,67 +14,16 @@ $title = 'Plugin manager';
require(SYSTEM . 'hooks.php');
require(LIBS . 'plugins.php');
function deleteDirectory($dir) {
if(!file_exists($dir)) {
return true;
}
if(!is_dir($dir)) {
return unlink($dir);
}
foreach(scandir($dir) as $item) {
if($item == '.' || $item == '..') {
continue;
}
if(!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
return rmdir($dir);
}
echo $twig->render('admin.plugins.form.html.twig');
if(isset($_REQUEST['uninstall'])){
$uninstall = $_REQUEST['uninstall'];
$filename = BASE . 'plugins/' . $uninstall . '.json';
if(!file_exists($filename)) {
error('Plugin ' . $uninstall . ' does not exist.');
if(Plugins::uninstall($uninstall)) {
success('Successfully uninstalled plugin ' . $uninstall);
}
else {
$string = file_get_contents($filename);
$plugin_info = json_decode($string, true);
if($plugin_info == false) {
error('Cannot load plugin info ' . $uninstall . '.json');
}
else {
if(!isset($plugin_info['uninstall'])) {
error("Plugin doesn't have uninstall options defined. Skipping...");
}
else {
$success = true;
foreach($plugin_info['uninstall'] as $file) {
$file = BASE . $file;
if(!deleteDirectory($file)) {
$success = false;
}
}
if($success) {
if($cache->enabled()) {
$cache->delete('templates');
}
success('Successfully uninstalled plugin ' . $uninstall);
}
else {
error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last());
}
}
}
error('Error while uninstalling plugin ' . $plugin_name . ': ' . Plugins::getError());
}
}
else if(isset($_FILES["plugin"]["name"]))

View File

@@ -83,7 +83,7 @@ $showed = $post = $reply = false;
echo '</TABLE>';
}
if($bug[2]['status'] != 3)
echo '<br><a href="index.php?subtopic=bugtracker&control=true&id='.$_REQUEST['id'].'&acc='.$_REQUEST['acc'].'&reply=true"><b>[REPLY]</b></a>';
echo '<br><a href="?subtopic=bugtracker&control=true&id='.$_REQUEST['id'].'&acc='.$_REQUEST['acc'].'&reply=true"><b>[REPLY]</b></a>';
}
else
{
@@ -112,7 +112,7 @@ $showed = $post = $reply = false;
$type = 2;
$INSERT = $db->query('INSERT INTO `' . TABLE_PREFIX . 'bugtracker` (`account`,`id`,`text`,`reply`,`type`, `who`) VALUES ('.$db->quote($_REQUEST['acc']).','.$db->quote($_REQUEST['id']).','.$db->quote($_POST['text']).','.$db->quote($reply).','.$db->quote($type).','.$db->quote(1).')');
$UPDATE = $db->query('UPDATE `' . TABLE_PREFIX . 'bugtracker` SET `status` = '.$_POST['status'].' where `account` = '.$_REQUEST['acc'].' and `id` = '.$_REQUEST['id'].'');
header('Location: index.php?subtopic=bugtracker&control=true&id='.$_REQUEST['id'].'&acc='.$_REQUEST['acc'].'');
header('Location: ?subtopic=bugtracker&control=true&id='.$_REQUEST['id'].'&acc='.$_REQUEST['acc'].'');
}
}
echo '<br><form method="post" action=""><table><tr><td><i>Description</i></td><td><textarea name="text" rows="15" cols="35"></textarea></td></tr><tr><td>Status[OPEN]</td><td><input type=radio name=status value=2></td></tr><tr><td>Status[CLOSED]</td><td><input type=radio name=status value=3></td></tr></table><br><input type="submit" name="finish" value="Submit" class="input2"/></form>';
@@ -138,7 +138,7 @@ $showed = $post = $reply = false;
elseif($report['status'] == 1)
$value = "<font color=blue>[NEW ANSWER]</font>";
echo '<TR BGCOLOR="' . getStyle($i) . '"><td width=75%><a href="index.php?subtopic=bugtracker&control=true&id='.$report['id'].'&acc='.$report['account'].'">'.$tags[$report['tag']].' '.$report['subject'].'</a></td><td>'.$value.'</td></tr>';
echo '<TR BGCOLOR="' . getStyle($i) . '"><td width=75%><a href="?subtopic=bugtracker&control=true&id='.$report['id'].'&acc='.$report['account'].'">'.$tags[$report['tag']].' '.$report['subject'].'</a></td><td>'.$value.'</td></tr>';
$showed=true;
$i++;
@@ -202,7 +202,7 @@ $showed = $post = $reply = false;
echo '</TABLE>';
}
if($bug[2]['status'] != 3)
echo '<br><a href="index.php?subtopic=bugtracker&id='.$id.'&reply=true"><b>[REPLY]</b></a>';
echo '<br><a href="?subtopic=bugtracker&id='.$id.'&reply=true"><b>[REPLY]</b></a>';
}
else
{
@@ -231,7 +231,7 @@ $showed = $post = $reply = false;
$type = 2;
$INSERT = $db->query('INSERT INTO `myaac_bugtracker` (`account`,`id`,`text`,`reply`,`type`) VALUES ('.$db->quote($acc).','.$db->quote($id).','.$db->quote($_POST['text']).','.$db->quote($reply).','.$db->quote($type).')');
$UPDATE = $db->query('UPDATE `myaac_bugtracker` SET `status` = 1 where `account` = '.$acc.' and `id` = '.$id.'');
header('Location: index.php?subtopic=bugtracker&id='.$id.'');
header('Location: ?subtopic=bugtracker&id='.$id.'');
}
}
echo '<br><form method="post" action=""><table><tr><td><i>Description</i></td><td><textarea name="text" rows="15" cols="35"></textarea></td></tr></table><br><input type="submit" name="finish" value="Submit" class="input2"/></form>';
@@ -275,7 +275,7 @@ $showed = $post = $reply = false;
$bgcolor = $light;
}
echo '<TR BGCOLOR="'.$bgcolor.'"><td width=75%><a href="index.php?subtopic=bugtracker&id='.$report['id'].'">'.$tags[$report['tag']].' '.$report['subject'].'</a></td><td>'.$value.'</td></tr>';
echo '<TR BGCOLOR="'.$bgcolor.'"><td width=75%><a href="?subtopic=bugtracker&id='.$report['id'].'">'.$tags[$report['tag']].' '.$report['subject'].'</a></td><td>'.$value.'</td></tr>';
$showed=true;
}
@@ -286,7 +286,7 @@ $showed = $post = $reply = false;
}
echo '</TABLE>';
echo '<br><a href="index.php?subtopic=bugtracker&add=true"><b>[ADD REPORT]</b></a>';
echo '<br><a href="?subtopic=bugtracker&add=true"><b>[ADD REPORT]</b></a>';
}
elseif(isset($_REQUEST['add']) && $_REQUEST['add'] == TRUE)
{
@@ -320,7 +320,7 @@ $showed = $post = $reply = false;
$type = 1;
$status = 1;
$INSERT = $db->query('INSERT INTO `' . TABLE_PREFIX . 'bugtracker` (`account`,`id`,`text`,`type`,`subject`, `reply`,`status`,`tag`) VALUES ('.$db->quote($acc).','.$db->quote($id_next).','.$db->quote($_POST['text']).','.$db->quote($type).','.$db->quote($_POST['subject']).', 0,'.$db->quote($status).','.$db->quote($_POST['tags']).')');
header('Location: index.php?subtopic=bugtracker&id='.$id_next.'');
header('Location: ?subtopic=bugtracker&id='.$id_next.'');
}
}
@@ -338,6 +338,6 @@ $showed = $post = $reply = false;
if(admin() and empty($_REQUEST['control']))
{
echo '<br><br><a href="index.php?subtopic=bugtracker&control=true">[ADMIN PANEL]</a>';
echo '<br><br><a href="?subtopic=bugtracker&control=true">[ADMIN PANEL]</a>';
}
?>

View File

@@ -38,7 +38,7 @@ if(isset($_POST['reload_monsters']) && $canEdit)
if($canEdit)
{
?>
<form method="post" action="index.php?subtopic=creatures">
<form method="post" action="<?php echo getLink('creatures'); ?>">
<input type="hidden" name="reload_monsters" value="yes"/>
<input type="submit" value="(admin) Reload monsters"/>
</form>