1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-07-31 18:30:20 +02:00

System Plugin: csrf vulnerability resolved

This commit is contained in:
Awilum
2012-10-03 14:28:43 +03:00
parent 3f7b10592f
commit af47159990
2 changed files with 30 additions and 17 deletions

39
plugins/box/system/system.admin.php Normal file → Executable file
View File

@@ -66,20 +66,27 @@
// Create Sitemap
// -------------------------------------
if (Request::get('sitemap')) {
if ('create' == Request::get('sitemap')) {
if (Request::get('sitemap') == 'create') {
if (Security::check(Request::get('token'))) {
Notification::set('success', __('Sitemap created', 'system'));
Sitemap::create();
Request::redirect('index.php?id=system');
}
Request::redirect('index.php?id=system');
} else { die('csrf detected!'); }
}
// Delete temporary files
// -------------------------------------
if (Request::get('temporary_files')) {
if ('delete' == Request::get('temporary_files')) {
if (Request::get('temporary_files') == 'delete') {
if (Security::check(Request::get('token'))) {
$namespaces = Dir::scan(CACHE);
if (count($namespaces) > 0) {
foreach ($namespaces as $namespace) {
@@ -104,13 +111,19 @@
// Set maintenance state on or off
// -------------------------------------
if (Request::get('maintenance')) {
if ('on' == Request::get('maintenance')) {
Option::update('maintenance_status', 'on');
Request::redirect('index.php?id=system');
}
if ('off' == Request::get('maintenance')) {
Option::update('maintenance_status', 'off');
Request::redirect('index.php?id=system');
if (Security::check(Request::get('token'))) {
if ('on' == Request::get('maintenance')) {
Option::update('maintenance_status', 'on');
Request::redirect('index.php?id=system');
}
if ('off' == Request::get('maintenance')) {
Option::update('maintenance_status', 'off');
Request::redirect('index.php?id=system');
}
}
}

8
plugins/box/system/views/backend/index.view.php Normal file → Executable file
View File

@@ -4,12 +4,12 @@
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
<?php echo Html::anchor(__('Create sitemap', 'system'), 'index.php?id=system&sitemap=create', array('class' => 'btn')).Html::nbsp(2); ?>
<?php echo Html::anchor(__('Delete temporary files', 'system'), 'index.php?id=system&temporary_files=delete', array('class' => 'btn')).Html::nbsp(2); ?>
<?php echo Html::anchor(__('Create sitemap', 'system'), 'index.php?id=system&sitemap=create&token='.Security::token(), array('class' => 'btn')).Html::nbsp(2); ?>
<?php echo Html::anchor(__('Delete temporary files', 'system'), 'index.php?id=system&temporary_files=delete&token='.Security::token(), array('class' => 'btn')).Html::nbsp(2); ?>
<?php if ('off' == Option::get('maintenance_status', 'system')) { ?>
<?php echo Html::anchor(__('Maintenance Mode On', 'system'), 'index.php?id=system&maintenance=on', array('class' => 'btn')); ?>
<?php echo Html::anchor(__('Maintenance Mode On', 'system'), 'index.php?id=system&maintenance=on&token='.Security::token(), array('class' => 'btn')); ?>
<?php } else { ?>
<?php echo Html::anchor(__('Maintenance Mode Off', 'system'), 'index.php?id=system&maintenance=off', array('class' => 'btn btn-danger')); ?>
<?php echo Html::anchor(__('Maintenance Mode Off', 'system'), 'index.php?id=system&maintenance=off&token='.Security::token(), array('class' => 'btn btn-danger')); ?>
<?php } ?>
<?php Action::run('admin_system_extra_buttons'); ?>