Exemple #1
0
define('VB_API_VERSION_CURRENT', $api_version);
if ($api_version < VB5_API_VERSION_START || strstr("api_init", $api_m)) {
    $old_api_m = $api_m;
    define("VB4_MAPI_METHOD", $old_api_m);
    $api_m = vB_Api::map_vb4_input_to_vb5($api_m, $_REQUEST);
}
// $methodsegments[0] is the API class name
// $methodsegments[1] is the API function name
// $_REQUEST data as function named params
$methodsegments = explode(".", $api_m);
try {
    $apiobj = vB_Api::instanceInternal(strtolower($methodsegments[0]));
    $data = $apiobj->callNamed($methodsegments[1], array_merge($_REQUEST, $_FILES));
    if (!empty($data)) {
        if ($api_version < VB5_API_VERSION_START) {
            vB_Api::map_vb5_output_to_vb4($old_api_m, $data);
        }
        print_apioutput($data);
    }
} catch (Exception $e) {
    if ($e instanceof vB_Exception_Api) {
        print_apierror($e->get_errors(), $e->getMessage());
    } else {
        print_apierror($e->getMessage());
    }
}
function print_apierror($errors, $debugstr = '')
{
    if (!is_array($errors)) {
        $errors = array($errors);
    }