Skip to content
Permalink
Browse files
Convert templates, panel templates, module install, alert purge to POST
  • Loading branch information
samerton committed Oct 25, 2021
1 parent ec1edbd commit 8031046109ee05cfee7211b24cace9c220999717
@@ -35,8 +35,11 @@
<div class="card shadow mb-4">
<div class="card-body">

<a class="btn btn-primary" style="margin-bottom: 15px;"
href="{$INSTALL_MODULE_LINK}">{$INSTALL_MODULE}</a>
<form style="display:inline" action="{$INSTALL_MODULE_LINK}" method="post">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary"
style="margin-bottom: 15px;">{$INSTALL_MODULE}</button>
</form>

<!-- Success and Error Alerts -->
{include file='includes/alerts.tpl'}
@@ -36,10 +36,16 @@
<div class="card shadow mb-4">
<div class="card-body">

<a class="btn btn-primary" style="margin-bottom: 15px;"
href="{$INSTALL_TEMPLATE_LINK}">{$INSTALL_TEMPLATE}</a>
<a class="btn btn-secondary" style="margin-bottom: 15px;"
href="{$CLEAR_CACHE_LINK}">{$CLEAR_CACHE}</a>
<form style="display:inline" action="{$INSTALL_TEMPLATE_LINK}" method="post">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary"
style="margin-bottom: 15px;">{$INSTALL_TEMPLATE}</button>
</form>
<form style="display:inline" action="{$CLEAR_CACHE_LINK}" method="post">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-secondary"
style="margin-bottom: 15px;">{$CLEAR_CACHE}</button>
</form>

<!-- Success and Error Alerts -->
{include file='includes/alerts.tpl'}
@@ -68,8 +74,12 @@
<div class="float-md-right">
{if $template.enabled}
{if $template.deactivate_link}
<a class="btn btn-danger btn-sm"
href="{$template.deactivate_link}">{$DEACTIVATE}</a>
<form action="{$template.deactivate_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-danger btn-sm">
{$DEACTIVATE}
</button>
</form>
{else}
<button role="button" class="btn btn-success btn-sm"
disabled>{$ACTIVE}</button>
@@ -79,12 +89,20 @@
<button role="button" class="btn btn-success btn-sm"
disabled>{$DEFAULT}</button>
{else}
<a class="btn btn-primary btn-sm"
href="{$template.default_link}">{$MAKE_DEFAULT}</a>
<form action="{$template.default_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary btn-sm">
{$MAKE_DEFAULT}
</button>
</form>
{/if}
{else}
<a class="btn btn-primary btn-sm"
href="{$template.activate_link}">{$ACTIVATE}</a>
<form action="{$template.activate_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary btn-sm">
{$ACTIVATE}
</button>
</form>
<button role="button"
onclick="showDeleteModal('{$template.delete_link}')"
class="btn btn-danger btn-sm">{$DELETE}</button>
@@ -175,7 +193,7 @@
<!-- End Content Wrapper -->
</div>

<!-- Delete error modal -->
<!-- Delete modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -189,8 +207,11 @@
{$CONFIRM_DELETE_TEMPLATE}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{$NO}</button>
<a href="#" id="deleteLink" class="btn btn-primary">{$YES}</a>
<form action="" id="deleteForm" method="post">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{$NO}</button>
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary">{$YES}</button>
</form>
</div>
</div>
</div>
@@ -203,7 +224,7 @@

<script type="text/javascript">
function showDeleteModal(id) {
$('#deleteLink').attr('href', id);
$('#deleteForm').attr('action', id);
$('#deleteModal').modal().show();
}
@@ -36,8 +36,11 @@
<div class="card shadow mb-4">
<div class="card-body">

<a class="btn btn-primary" style="margin-bottom: 15px;"
href="{$INSTALL_TEMPLATE_LINK}">{$INSTALL_TEMPLATE}</a>
<form style="display:inline" action="{$INSTALL_TEMPLATE_LINK}" method="post">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary"
style="margin-bottom: 15px;">{$INSTALL_TEMPLATE}</button>
</form>

<!-- Success and Error Alerts -->
{include file='includes/alerts.tpl'}
@@ -73,8 +76,12 @@
<div class="float-md-right">
{if $template.enabled}
{if $template.deactivate_link}
<a class="btn btn-danger btn-sm"
href="{$template.deactivate_link}">{$DEACTIVATE}</a>
<form action="{$template.deactivate_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-danger btn-sm">
{$DEACTIVATE}
</button>
</form>
{else}
<button role="button" class="btn btn-success btn-sm"
disabled>{$ACTIVE}</button>
@@ -84,12 +91,20 @@
<button role="button" class="btn btn-success btn-sm"
disabled>{$DEFAULT}</button>
{else}
<a class="btn btn-primary btn-sm"
href="{$template.default_link}">{$MAKE_DEFAULT}</a>
<form action="{$template.default_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary btn-sm">
{$MAKE_DEFAULT}
</button>
</form>
{/if}
{else}
<a class="btn btn-primary btn-sm"
href="{$template.activate_link}">{$ACTIVATE}</a>
<form action="{$template.activate_link}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary btn-sm">
{$ACTIVATE}
</button>
</form>
<button role="button"
onclick="showDeleteModal('{$template.delete_link}')"
class="btn btn-danger btn-sm">{$DELETE}</button>
@@ -190,7 +205,7 @@
<!-- End Content Wrapper -->
</div>

<!-- Delete error modal -->
<!-- Delete modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -204,8 +219,11 @@
{$CONFIRM_DELETE_TEMPLATE}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{$NO}</button>
<a href="#" id="deleteLink" class="btn btn-primary">{$YES}</a>
<form action="" id="deleteForm" method="post">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{$NO}</button>
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="btn btn-primary">{$YES}</button>
</form>
</div>
</div>
</div>
@@ -218,7 +236,7 @@

<script type="text/javascript">
function showDeleteModal(id) {
$('#deleteLink').attr('href', id);
$('#deleteForm').attr('action', id);
$('#deleteModal').modal().show();
}
@@ -15,9 +15,15 @@
<h3 class="ui header">
{$ALERTS}
<div class="res right floated">
<a class="ui mini negative button" href="{$DELETE_ALL_LINK}">{$DELETE_ALL}</a>
<form action="{$DELETE_ALL_LINK}" method="post" style="display:inline">
<input type="hidden" name="token" value="{$TOKEN}">
<button type="submit" class="ui mini negative button">{$DELETE_ALL}</button>
</form>
</div>
</h3>
{if isset($ERROR)}
<div class="ui negative message">{$ERROR}</div>
{/if}
<div class="ui middle aligned relaxed selection list">
{nocache}
{if count($ALERTS_LIST)}
@@ -269,35 +269,40 @@
die();

} else if($_GET['action'] == 'install'){
// Install any new modules
$directories = glob(ROOT_PATH . '/modules/*' , GLOB_ONLYDIR);
if (Token::check()) {
// Install any new modules
$directories = glob(ROOT_PATH . '/modules/*' , GLOB_ONLYDIR);

define('MODULE_INSTALL', true);
define('MODULE_INSTALL', true);

foreach($directories as $directory){
$folders = explode('/', $directory);
foreach($directories as $directory){
$folders = explode('/', $directory);

if(file_exists(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php')){
// Is it already in the database?
$exists = $queries->getWhere('modules', array('name', '=', Output::getClean($folders[count($folders) - 1])));
if(file_exists(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php')){
// Is it already in the database?
$exists = $queries->getWhere('modules', array('name', '=', Output::getClean($folders[count($folders) - 1])));

if(!count($exists)){
$module = null;
if(!count($exists)){
$module = null;

// No, add it now
require_once(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php');
// No, add it now
require_once(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php');

if($module instanceof Module){
$queries->create('modules', array(
'name' => Output::getClean($folders[count($folders) - 1])
));
$module->onInstall();
if($module instanceof Module){
$queries->create('modules', array(
'name' => Output::getClean($folders[count($folders) - 1])
));
$module->onInstall();
}
}
}
}

Session::flash('admin_modules', $language->get('admin', 'modules_installed_successfully'));
} else {
Session::flash('admin_modules_error', $language->get('general', 'invalid_token'));
}

Session::flash('admin_modules', $language->get('admin', 'modules_installed_successfully'));
Redirect::to(URL::build('/panel/core/modules'));
die();
}

0 comments on commit 8031046

Please sign in to comment.