mirror of
https://github.com/itflow-org/itflow
synced 2026-07-23 00:40:45 +00:00
Clean up admin post handler to match agent
- Anchor includes and glob to __DIR__ so loading doesn't depend on CWD - Replace _model.php regex check with str_ends_with()
This commit is contained in:
@@ -1,31 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Admin GET/POST request handler
|
||||
*/
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../functions.php";
|
||||
require_once "../includes/check_login.php";
|
||||
require_once __DIR__ . "/../config.php";
|
||||
require_once __DIR__ . "/../functions.php";
|
||||
require_once __DIR__ . "/../includes/check_login.php";
|
||||
|
||||
// Define a variable that we can use to only allow running post files via inclusion (prevents people/bots poking them)
|
||||
// Only allow running post files via inclusion (prevents people/bots poking them directly)
|
||||
define('FROM_POST_HANDLER', true);
|
||||
|
||||
// Dynamically load admin module POST logic
|
||||
// Every handler self-gates on its own if(isset($_POST['action'])) check,
|
||||
// so we load them all and let the matching one fire. The page filename is
|
||||
// irrelevant to dispatch - matches how agent/post.php works.
|
||||
// To add a new admin POST handler, drop a file in admin/post/.
|
||||
if (isset($session_is_admin) && $session_is_admin) {
|
||||
foreach (glob("post/*.php") as $admin_module) {
|
||||
if (!preg_match('/_model\.php$/', basename($admin_module))) {
|
||||
// Load all admin module POST logic
|
||||
if (!empty($session_is_admin)) {
|
||||
foreach (glob(__DIR__ . "/post/*.php") as $admin_module) {
|
||||
if (!str_ends_with($admin_module, '_model.php')) {
|
||||
require_once $admin_module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Logout is the same for user and admin
|
||||
require_once "../post/logout.php";
|
||||
|
||||
// TODO: Find a home for these
|
||||
require_once "../post/misc.php";
|
||||
// Logout is shared between portals
|
||||
require_once __DIR__ . "/../post/logout.php";
|
||||
require_once __DIR__ . "/../post/misc.php";
|
||||
|
||||
Reference in New Issue
Block a user