Files
opensourcepos/application/hooks/method_hook.php
jekkos 730ec1292d Use anchor in supplier regex (#3402)
Adding a unit test to check the url patterns allowed/disallowed would be a good idea. I should practice what I preach.
2022-01-12 00:34:16 +01:00

17 lines
363 B
PHP

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