示例#1
0
 static function get_PARAMS_STRING()
 {
     if (zcale_core_path_targets_ServerPath::$paramsString === null) {
         zcale_core_path_targets_ServerPath::$paramsString = php_Web::getParamsString();
         if (strlen(zcale_core_path_targets_ServerPath::$paramsString) > 0) {
             zcale_core_path_targets_ServerPath::$paramsString = "?" . _hx_string_or_null(zcale_core_path_targets_ServerPath::$paramsString);
         }
     }
     return zcale_core_path_targets_ServerPath::$paramsString;
 }
 public function flush()
 {
     if (!$this->_flushedStatus) {
         $this->_flushedStatus = true;
         php_Web::setReturnCode($this->status);
     }
     if (!$this->_flushedCookies) {
         $this->_flushedCookies = true;
         try {
             if (null == $this->_cookies) {
                 throw new HException('null iterable');
             }
             $__hx__it = $this->_cookies->iterator();
             while ($__hx__it->hasNext()) {
                 unset($cookie);
                 $cookie = $__hx__it->next();
                 php_Web::setCookie($cookie->name, $cookie->value, $cookie->expires, $cookie->domain, $cookie->path, $cookie->secure, $cookie->httpOnly);
             }
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             throw new HException(ufront_web_HttpError::internalServerError("Failed to set cookie on response", $e, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 34, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush"))));
         }
     }
     if (!$this->_flushedHeaders) {
         $this->_flushedHeaders = true;
         if (null == $this->_headers) {
             throw new HException('null iterable');
         }
         $__hx__it = $this->_headers->keys();
         while ($__hx__it->hasNext()) {
             unset($key);
             $key = $__hx__it->next();
             $val = $this->_headers->get($key);
             if ($key === "Content-type" && null !== $this->charset && StringTools::startsWith($val, "text/")) {
                 $val .= "; charset=" . _hx_string_or_null($this->charset);
             }
             try {
                 header(_hx_string_or_null($key) . ": " . _hx_string_or_null($val));
             } catch (Exception $__hx__e) {
                 $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                 $e1 = $_ex_;
                 throw new HException(ufront_web_HttpError::internalServerError("Invalid header: \"" . _hx_string_or_null($key) . ": " . _hx_string_or_null($val) . "\", or output already sent", $e1, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 50, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush"))));
             }
             unset($val, $e1);
         }
     }
     if (!$this->_flushedContent) {
         $this->_flushedContent = true;
         Sys::hprint($this->_buff->b);
     }
 }
示例#3
0
 public function __construct()
 {
     if (!php_Boot::$skip_constructor) {
         $s = null;
         $s1 = php_Web::getParamsString();
         $s = urldecode($s1);
         if (_hx_char_at($s, strlen($s) - 1) === "/") {
             $s = _hx_substr($s, 0, strlen($s) - 1);
         }
         $this->query_string = $s;
         if (strlen($this->query_string) >= 255) {
             throw new HException(new system_base_Http_exception("Query string malformed or too long", 414, _hx_anonymous(array("fileName" => "Router.hx", "lineNumber" => 28, "className" => "system.base.Router", "methodName" => "new"))));
         }
         $this->query_hash = haxe_crypto_Md5::encode($this->query_string);
     }
 }
 public function __construct($message, $Http_Code, $info = null)
 {
     if (!php_Boot::$skip_constructor) {
         parent::__construct(null, _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 50, "className" => "system.base.Http_exception", "methodName" => "new")));
         while (!system_base_Cache::$cookie_buffer->isEmpty()) {
             system_base_Wet_base::send_cookie(system_base_Cache::$cookie_buffer->pop());
         }
         header("X-Powered-By" . ": " . "Webrathea/0.4 (PHP)");
         $value = DateTools::format(Date::now(), "%a, %d %b %Y %X %Z");
         header("Date" . ": " . _hx_string_or_null($value));
         header("X-Frame-Options" . ": " . "sameorigin");
         header("X-XSS-Protection" . ": " . "1; mode=block");
         php_Web::setReturnCode($Http_Code);
         $message1 = null;
         $message1 = Std::string($message);
         haxe_Log::trace("DEPRECATED FUNCTION: " . _hx_string_or_null($message1), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 449, "className" => "system.base.Wet_base", "methodName" => "echo")));
     }
 }
示例#5
0
 static function main()
 {
     haxe_Log::$trace = isset(me_cunity_php_Debug::$_trace) ? me_cunity_php_Debug::$_trace : array("me_cunity_php_Debug", "_trace");
     S::$conf = Config::load("appData.js");
     php_Session::start();
     $pd = php_Web::getPostData();
     haxe_Log::trace($pd, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 54, "className" => "S", "methodName" => "main")));
     $params = php_Web::getParams();
     if ($params->get("debug") === "1") {
         header("Content-Type" . ": " . "text/html; charset=utf-8");
         S::$headerSent = true;
         php_Lib::println("<div><pre>");
         php_Lib::println($params);
     }
     haxe_Log::trace(Date::now()->toString(), _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 63, "className" => "S", "methodName" => "main")));
     haxe_Log::trace($params, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 64, "className" => "S", "methodName" => "main")));
     $action = $params->get("action");
     if (strlen($action) === 0 || $params->get("className") === null) {
         S::dump(_hx_anonymous(array("error" => "required params missing")));
         return;
     }
     S::$my = new MySQLi("localhost", S::$dbUser, S::$dbPass, S::$db, null, null);
     $auth = S::checkAuth();
     haxe_Log::trace(_hx_string_or_null($action) . ":" . Std::string($auth), _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 77, "className" => "S", "methodName" => "main")));
     if (!$auth) {
         S::hexit("AUTH FAILURE");
         return;
     }
     $result = Model::dispatch($params);
     haxe_Log::trace($result, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 85, "className" => "S", "methodName" => "main")));
     if (!S::$headerSent) {
         header("Content-Type" . ": " . "application/json");
         S::$headerSent = true;
     }
     php_Lib::println($result);
 }
 public function sendError($num, $message)
 {
     php_Web::setReturnCode($num);
     $this->writeString($message);
     $this->close();
 }
 public function get_authorization()
 {
     if (_hx_field($this, "authorization") === null) {
         $this->authorization = php_Web::getAuthorization();
         if (_hx_field($this, "authorization") === null) {
             $this->authorization = _hx_anonymous(array("user" => null, "pass" => null));
         }
     }
     return $this->authorization;
 }
示例#8
0
 static function getURI()
 {
     return php_Web::getURI();
 }
示例#9
0
function Index_0(&$base, &$cache, &$cl, &$params, &$profiler, &$route, &$user_class, &$user_method)
{
    $router = null;
    if (system_base_Router::$instance === null) {
        system_base_Router::$instance = new system_base_Router();
    }
    $router = system_base_Router::$instance;
    $hash = $router->query_hash;
    $fullpath = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_or_null($hash) . ".htm";
    if (!file_exists($fullpath)) {
        return false;
    } else {
        $r_query = $router->query_string;
        $fin = sys_io_File::read($fullpath, false);
        $query = $fin->readLine();
        if ($r_query === $query) {
            $etag = null;
            if (file_exists($fullpath)) {
                $stats = sys_FileSystem::stat($fullpath);
                $etag = _hx_string_or_null(StringTools::hex($stats->size, null)) . "-" . _hx_string_or_null(StringTools::hex($stats->ino, null)) . "-" . _hx_string_or_null(_hx_string_call(_hx_string_call($stats->mtime, "toString", array()), "substr", array(17, 2)));
            } else {
                $etag = "";
            }
            if (php_Web::getClientHeader("If-none-match") === $etag) {
                php_Web::setReturnCode(304);
                $fin->close();
                return true;
            } else {
                while (!system_base_Cache::$cookie_buffer->isEmpty()) {
                    system_base_Wet_base::send_cookie(system_base_Cache::$cookie_buffer->pop());
                }
                header("X-Powered-By" . ": " . "Webrathea/0.4 (PHP)");
                $value = DateTools::format(Date::now(), "%a, %d %b %Y %X %Z");
                header("Date" . ": " . _hx_string_or_null($value));
                header("X-Frame-Options" . ": " . "sameorigin");
                header("X-XSS-Protection" . ": " . "1; mode=block");
                php_Web::setReturnCode(200);
                $value1 = Std::string(sys_FileSystem::stat($fullpath)->size);
                header("Content-Length" . ": " . _hx_string_or_null($value1));
                header("ETag" . ": " . _hx_string_or_null($etag));
                $m = null;
                $pos = strlen($query);
                $fin1 = sys_io_File::read($fullpath, false);
                $size = sys_FileSystem::stat($fullpath)->size;
                $fin1->seek($pos, sys_io_FileSeek::$SeekBegin);
                $output = $fin1->readString($size - $pos);
                $fin1->close();
                $m = $output;
                $message = null;
                $message = Std::string($m);
                haxe_Log::trace("DEPRECATED FUNCTION: " . _hx_string_or_null($message), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 449, "className" => "system.base.Wet_base", "methodName" => "echo")));
                $fin->close();
                return true;
            }
            unset($etag);
        } else {
            $fin->close();
            return false;
        }
        unset($r_query, $query, $fin);
    }
    unset($router, $hash, $fullpath);
}
示例#10
0
        if ($secure === null) {
            $secure = false;
        }
        if ($httpOnly === null) {
            $httpOnly = false;
        }
        setcookie($key, $value, $t, $path, $domain, $secure, $httpOnly);
    }
    static function getAuthorization()
    {
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
            return null;
        }
        return _hx_anonymous(array("user" => $_SERVER['PHP_AUTH_USER'], "pass" => $_SERVER['PHP_AUTH_PW']));
    }
    static function getMethod()
    {
        if (isset($_SERVER['REQUEST_METHOD'])) {
            return $_SERVER['REQUEST_METHOD'];
        } else {
            return null;
        }
    }
    static $isModNeko;
    function __toString()
    {
        return 'php.Web';
    }
}
php_Web::$isModNeko = !php_Lib::isCli();
示例#11
0
 static function getMultipart($maxSize)
 {
     $h = new Hash();
     $buf = null;
     $curname = null;
     php_Web::parseMultipart(array(new _hx_lambda(array(&$buf, &$curname, &$h, &$maxSize), "php_Web_1"), 'execute'), array(new _hx_lambda(array(&$buf, &$curname, &$h, &$maxSize), "php_Web_2"), 'execute'));
     if ($curname !== null) {
         $h->set($curname, $buf->b);
     }
     return $h;
 }
示例#12
0
 static function set_return_code($r)
 {
     php_Web::setReturnCode($r);
 }
示例#13
0
 static function send_basic_headers($return_code)
 {
     while (!system_base_Cache::$cookie_buffer->isEmpty()) {
         system_base_Wet_base::send_cookie(system_base_Cache::$cookie_buffer->pop());
     }
     header("X-Powered-By" . ": " . "Webrathea/0.4 (PHP)");
     $value = DateTools::format(Date::now(), "%a, %d %b %Y %X %Z");
     header("Date" . ": " . _hx_string_or_null($value));
     header("X-Frame-Options" . ": " . "sameorigin");
     header("X-XSS-Protection" . ": " . "1; mode=block");
     php_Web::setReturnCode($return_code);
 }
示例#14
0
 static function getClientHeaders()
 {
     if (php_Web::$_client_headers === null) {
         php_Web::$_client_headers = new HList();
         $h = php_Lib::hashOfAssociativeArray($_SERVER);
         if (null == $h) {
             throw new HException('null iterable');
         }
         $__hx__it = $h->keys();
         while ($__hx__it->hasNext()) {
             $k = $__hx__it->next();
             if (_hx_substr($k, 0, 5) === "HTTP_") {
                 php_Web::$_client_headers->add(_hx_anonymous(array("header" => _hx_substr($k, 5, null), "value" => $h->get($k))));
             } else {
                 if (_hx_substr($k, 0, 8) === "CONTENT_") {
                     php_Web::$_client_headers->add(_hx_anonymous(array("header" => $k, "value" => $h->get($k))));
                 }
             }
         }
     }
     return php_Web::$_client_headers;
 }
示例#15
0
 static function getMultipart($maxSize)
 {
     $h = new Hash();
     $buf = null;
     $curname = null;
     php_Web::parseMultipart(array(new _hx_lambda(array("buf" => &$buf, "curname" => &$curname, "h" => &$h, "maxSize" => &$maxSize), null, array('p', '_'), "{\n\t\t\tif(\$curname !== null) {\n\t\t\t\t\$h->set(\$curname, \$buf->b);\n\t\t\t}\n\t\t\t\$curname = \$p;\n\t\t\t\$buf = new StringBuf();\n\t\t\t\$maxSize -= strlen(\$p);\n\t\t\tif(\$maxSize < 0) {\n\t\t\t\tthrow new HException(\"Maximum size reached\");\n\t\t\t}\n\t\t}"), 'execute2'), array(new _hx_lambda(array("buf" => &$buf, "curname" => &$curname, "h" => &$h, "maxSize" => &$maxSize), null, array('str', 'pos', 'len'), "{\n\t\t\t\$maxSize -= \$len;\n\t\t\tif(\$maxSize < 0) {\n\t\t\t\tthrow new HException(\"Maximum size reached\");\n\t\t\t}\n\t\t\t\$buf->b .= _hx_substr(\$str, \$pos, \$len);\n\t\t}"), 'execute3'));
     if ($curname !== null) {
         $h->set($curname, $buf->b);
     }
     return $h;
 }
示例#16
0
 public function redirect($route)
 {
     php_Web::redirect($route);
 }