mirror of
https://github.com/itflow-org/itflow
synced 2026-08-15 12:05:11 +00:00
Clean up agent post handler
- Remove dead referer/module parsing (unused since modules are glob-loaded) - 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,43 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ITFlow - User GET/POST request handler
|
* ITFlow - Agent GET/POST request handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once "../config.php";
|
require_once __DIR__ . "/../config.php";
|
||||||
require_once "../functions.php";
|
require_once __DIR__ . "/../functions.php";
|
||||||
require_once "../includes/check_login.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);
|
define('FROM_POST_HANDLER', true);
|
||||||
|
|
||||||
|
// Load all agent module POST logic
|
||||||
// Determine which files we should load
|
// TODO: selectively load per-module like admin does, keyed off request path (not referer)
|
||||||
|
foreach (glob(__DIR__ . "/post/*.php") as $user_module) {
|
||||||
// Parse URL & get the path
|
if (!str_ends_with($user_module, '_model.php')) {
|
||||||
$path = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
|
|
||||||
|
|
||||||
// Get the base name (the page name)
|
|
||||||
$module = explode(".", basename($path))[0];
|
|
||||||
|
|
||||||
// Strip off any _details bits
|
|
||||||
$module = str_ireplace('_details', '', $module);
|
|
||||||
|
|
||||||
// Dynamically load admin-related module POST logic
|
|
||||||
|
|
||||||
// Load all module POST logic
|
|
||||||
// Loads everything in post
|
|
||||||
// Eventually, it would be nice to only specifically load what we need like we do for admins
|
|
||||||
|
|
||||||
foreach (glob("post/*.php") as $user_module) {
|
|
||||||
if (!preg_match('/_model\.php$/', basename($user_module))) {
|
|
||||||
require_once $user_module;
|
require_once $user_module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logout is shared between portals
|
||||||
// Logout is the same for user and admin
|
require_once __DIR__ . "/../post/logout.php";
|
||||||
require_once "../post/logout.php";
|
require_once __DIR__ . "/../post/misc.php";
|
||||||
|
|
||||||
// TODO: Find a home for these
|
|
||||||
require_once "../post/misc.php";
|
|
||||||
|
|||||||
Reference in New Issue
Block a user