Files
testprojekt/rss/php/handler.php

56 lines
1.3 KiB
PHP
Raw Normal View History

2026-04-06 16:49:17 -04:00
<?php
define('BASE', realpath(dirname(__FILE__) . '/../../'));
require_once(BASE . '/rss/php/autoload.php');
use Vor\core\Sys;
Sys::start();
$classMap = [
// Add public allowed classes
'Frontend' => \Vor\application\Frontend::class,
];
$methodMap = [
// Add public allowed methods
'Frontend' => ['clean'],
];
$target = trim((string)($_POST['target'] ?? ''));
$method = trim((string)($_POST['method'] ?? ''));
if($target === '' || $method === ''){
Sys::json(['status' => 'fail', 'message' => 'Missing target'], 400);
}
if(!isset($classMap[$target])){
Sys::json(['status' => 'fail', 'message' => 'Invalid class'], 404);
}
if(!in_array($method, $methodMap[$target] ?? [], true)){
Sys::json(['status' => 'fail', 'message' => 'Invalid method'], 404);
}
$obj = new $classMap[$target];
foreach($_POST as $k => $v){
if($k === 'target' || $k === 'method'){
continue;
}
if(property_exists($obj, $k)){
$obj->$k = $v;
}
}
foreach(($_FILES ?? []) as $k => $v){
if(property_exists($obj, $k)){
$obj->$k = $v;
}
}
try{
$resp = $obj->$method();
Sys::json(['status' => $resp ? 'success' : 'fail', 'message' => $resp], 200);
}catch(\Throwable $e){
error_log($e->getMessage());
Sys::json(['status' => 'fail', 'message' => 'Server error'], 500);
}