예제 #1
0
파일: json.php 프로젝트: cjbayliss/alloc
singleton("errors_haltdb", true);
function g($var)
{
    $rtn = $_GET[$var] or $rtn = $_POST[$var] or $rtn = $_REQUEST[$var];
    $var == "options" and $rtn = alloc_json_decode($_POST[$var]);
    return $rtn;
}
if (g("get_server_version")) {
    die(alloc_json_encode(array("version" => get_alloc_version())));
}
if (!version_compare(g("client_version"), get_alloc_version(), ">=")) {
    die("Your alloc client needs to be upgraded.");
}
$sessID = g("sessID");
if (g("authenticate") && g("username") && g("password")) {
    $sessID = services::authenticate(g("username"), g("password"));
    die(alloc_json_encode(array("sessID" => $sessID)));
}
$services = new services($sessID);
$current_user =& singleton("current_user");
if (!$current_user || !is_object($current_user) || !$current_user->get_id()) {
    die(alloc_json_encode(array("reauthenticate" => "true")));
}
if ($sessID) {
    if (method_exists($services, g("method"))) {
        $modelReflector = new ReflectionClass('services');
        $method = $modelReflector->getMethod(g("method"));
        $parameters = $method->getParameters();
        foreach ((array) $parameters as $v) {
            $a[] = g((string) $v->name);
        }