php-func fix

This commit is contained in:
myvesta 2023-03-26 14:58:10 +02:00 committed by GitHub
parent dd1efc58a1
commit beccead388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 14 deletions

View file

@ -1,6 +1,6 @@
<?php
if (!isset($argv)) exit;
if (!isset($argv)) exit 5;
include ("/usr/local/vesta/func/main.php");
include ("/usr/local/vesta/func/string.php");
@ -8,8 +8,11 @@ include ("/usr/local/vesta/func/string.php");
$counter=count($argv);
if ($counter<2) myvesta_throw_error(2, 'Function is missing');
$func="myvesta_".$argv[1];
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
$func=$argv[1];
if (!function_exists($func)) {
$func="myvesta_".$argv[1];
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
}
$params=array();
@ -17,5 +20,15 @@ for ($i=2; $i<$counter; $i++) {
$argv[$i]=myvesta_fix_backslashes($argv[$i]);
$params[]=$argv[$i];
}
// echo $func."\n"; print_r($params);
$r=call_user_func_array($func, $params);
if (is_bool($r)) {
if ($r) {
exit(0);
} else {
exit(MYVESTA_ERROR_GENERAL);
}
} else {
echo $r;
exit(0);
}