Beispiel #1
0
 public static function SetCacheTimeout($scope, $timeout)
 {
     if (is_integer($timeout)) {
         return phoxy::SetCacheTimeout($scope, "{$timeout}s");
     }
     phoxy_return_worker::NewCache([$scope => $timeout]);
 }
Beispiel #2
0
 public function __call($name, $arguments)
 {
     $ret = $this->Call($name, $arguments);
     phoxy_protected_assert(!empty($ret['data']), "Probably internal inconsistence inside phoxy, please bug report");
     // raw calls do not affects restrictions
     if ($this->ShouldSkipPostProcess($name)) {
         return $ret;
     } else {
         phoxy_return_worker::NewCache($ret['cache']);
     }
     if (!isset($ret['data'])) {
         return phoxy_protected_assert(empty($ret['error']), $ret);
     }
     $d = $ret['data'];
     // Reverse public method translation
     if (is_array($d) && !empty($d[$name])) {
         $d = $d[$name];
     }
     if ($this->expect_simple_result && is_array($d) && count($d) === 1 && !isset($d[0])) {
         return reset($d);
     }
     return $d;
 }
Beispiel #3
0
<?php

require_once 'vendor/autoload.php';
if (!PRODUCTION) {
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
}
function phoxy_conf()
{
    $ret = phoxy_default_conf();
    $ret["api_xss_prevent"] = PRODUCTION;
    return $ret;
}
function default_addons()
{
    $ret = ["cache" => PRODUCTION ? ['global' => '10m'] : "no", "result" => "canvas"];
    return $ret;
}
include 'phoxy/phoxy_return_worker.php';
phoxy_return_worker::$add_hook_cb = function ($that) {
    global $USER_SENSITIVE;
    if ($USER_SENSITIVE) {
        $that->obj['cache'] = 'no';
    }
};
phpsql\OneLineConfig(conf()->db->connection_string);
db::Query("INSERT INTO requests(url, get, post, headers, server) VALUES (\$1, \$2, \$3, \$4, \$5)", [$_SERVER['QUERY_STRING'], json_encode($_GET), json_encode($_POST), json_encode(getallheaders()), json_encode($_SERVER)]);
include 'phoxy/load.php';
Beispiel #4
0
{
    $ret = ["cache" => PRODUCTION ? ['global' => '10m'] : "no", "result" => "canvas"];
    return $ret;
}
ob_start();
function append_warnings_to_object($that)
{
    $buffer = ob_get_contents();
    ob_end_clean();
    if (!empty($buffer)) {
        $that->obj["warnings"] = $buffer;
    }
}
include 'phoxy/server/phoxy_return_worker.php';
phoxy_return_worker::$add_hook_cb = function ($that) {
    global $USER_SENSITIVE;
    if ($USER_SENSITIVE) {
        $that->obj['cache'] = 'no';
    }
    $that->hooks[] = append_warnings_to_object;
};
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
include 'phoxy/load.php';
phoxy::Load("user/store/db");
try {
    \phoxy::Start();
} catch (Exception $e) {
    $message = ["error" => $e->getMessage(), "warnings" => ob_get_contents()];
    ob_end_clean();
    die(json_encode($message, true));
}