mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
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:
@@ -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'] : '',
|
||||
|
Reference in New Issue
Block a user