Exemple #1
0
        if ($classInfo) {
            $val = eval("return new " . $classInfo->getName() . "('{$val}');");
        }
        $args[] = $val;
    }
    return $args;
}
try {
    list($module, $method) = explode('.', cf\param::get('method'));
    require_once \cf\Config::path . "api/{$module}.php";
    $method = "cf\\api\\{$module}\\{$method}";
    if (!function_exists($method)) {
        throw new Exception("Invalid method - {$method}");
    }
    $returnHTML = false;
    $res = call_user_func_array($method, params2MethodArgs($method, cf\param::toArray()));
    if (cf\param::exist('return')) {
        $retVarName = cf\param::get('return');
        ${$retVarName} = $res;
    }
    if (cf\param::exist('forward')) {
        $url = cf\param::get('forward');
        if ('referer' == $url) {
            $url = $_SERVER['HTTP_REFERER'];
        } else {
            eval('$url="' . $url . '";');
        }
        forward($url);
    }
    if (!$returnHTML) {
        header('Content-Type: application/json');