Extend method hook validation for deletes

This commit is contained in:
jekkos
2021-09-28 23:56:30 +02:00
committed by jekkos
parent 2b031e6466
commit e8f27f547b
3 changed files with 18 additions and 18 deletions

View File

@@ -28,8 +28,8 @@ $hook['post_controller'] = array(
$hook['pre_controller'][] = array(
'class' => '',
'function' => 'validate_save',
'filename' => 'save_hook.php',
'function' => 'validate_method',
'filename' => 'method_hook.php',
'filepath' => 'hooks'
);

View File

@@ -0,0 +1,16 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function validate_method()
{
$url = $_SERVER['REQUEST_URI'];
$post_required = preg_match('/(save|delete|delete_item)\/?\d*?/', $url);
if($post_required && $_SERVER["REQUEST_METHOD"] != "POST" && empty($_POST))
{
echo "Method not allowed";
die;
}
}

View File

@@ -1,16 +0,0 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function validate_save()
{
$url = $_SERVER['REQUEST_URI'];
$is_save = preg_match('/save\/\d*?/', $url);
if($is_save && $_SERVER["REQUEST_METHOD"] != "POST" && empty($_POST))
{
echo "Method not allowed";
die;
}
}