public function handleRequest($httpContext) { $doneTrigger = new tink_core_FutureTrigger(); if (ufront_remoting_RemotingHandler_0($this, $doneTrigger, $httpContext)) { $r = $httpContext->response; $remotingResponse = null; $r->setOk(); $path = null; $args = null; try { $this->initializeContext($httpContext->injector); $params = $httpContext->request->get_params(); if (!$params->exists("__x")) { throw new HException("Remoting call did not have parameter `__x` which describes which API call to make. Aborting"); } $remotingCall = null; $s = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "__x"); $remotingCall = urldecode($s); $u = new haxe_Unserializer($remotingCall); $path = $u->unserialize(); $args = $u->unserialize(); $apiCallFinished = $this->executeApiCall($path, $args, $this->context, $httpContext->actionContext); $remotingResponse = tink_core__Future_Future_Impl_::map($apiCallFinished, array(new _hx_lambda(array(&$apiCallFinished, &$args, &$doneTrigger, &$httpContext, &$params, &$path, &$r, &$remotingCall, &$remotingResponse, &$u), "ufront_remoting_RemotingHandler_1"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $error = $e; $apiNotFoundMessages = new _hx_array(array("Invalid path", "No such object", "Can't access", "No such method")); if ($path !== null && $args !== null && Std::is($e, _hx_qtype("String")) && Lambda::exists($apiNotFoundMessages, array(new _hx_lambda(array(&$apiNotFoundMessages, &$args, &$doneTrigger, &$e, &$error, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_2"), 'execute'))) { $remotingResponse = tink_core__Future_Future_Impl_::sync("Unable to access " . _hx_string_or_null($path->join(".")) . " - API Not Found (" . _hx_string_or_null($error) . "). See " . Std::string($this->context->objects)); $r->setNotFound(); } else { $r->setInternalError(); $remotingResponse = tink_core__Future_Future_Impl_::sync($this->remotingError($e, $httpContext)); } } $remotingResponse(array(new _hx_lambda(array(&$args, &$doneTrigger, &$e, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_3"), 'execute')); } else { $result1 = tink_core_Outcome::Success(tink_core_Noise::$Noise); if ($doneTrigger->{"list"} === null) { false; } else { $list1 = $doneTrigger->{"list"}; $doneTrigger->{"list"} = null; $doneTrigger->result = $result1; tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1); tink_core__Callback_CallbackList_Impl_::clear($list1); true; } } return $doneTrigger->future; }
public function unserialize() { $_g = null; $p = $this->pos++; $_g = ord(substr($this->buf, $p, 1)); switch ($_g) { case 110: return null; break; case 116: return true; break; case 102: return false; break; case 122: return 0; break; case 105: return $this->readDigits(); break; case 100: $p1 = $this->pos; while (true) { $c = ord(substr($this->buf, $this->pos, 1)); if ($c >= 43 && $c < 58 || $c === 101 || $c === 69) { $this->pos++; } else { break; } unset($c); } return Std::parseFloat(_hx_substr($this->buf, $p1, $this->pos - $p1)); break; case 121: $len = $this->readDigits(); if (haxe_Unserializer_3($this, $_g, $len) !== 58 || $this->length - $this->pos < $len) { throw new HException("Invalid string length"); } $s = _hx_substr($this->buf, $this->pos, $len); $this->pos += $len; $s = urldecode($s); $this->scache->push($s); return $s; break; case 107: return Math::$NaN; break; case 109: return Math::$NEGATIVE_INFINITY; break; case 112: return Math::$POSITIVE_INFINITY; break; case 97: $buf = $this->buf; $a = new _hx_array(array()); $this->cache->push($a); while (true) { $c1 = ord(substr($this->buf, $this->pos, 1)); if ($c1 === 104) { $this->pos++; break; } if ($c1 === 117) { $this->pos++; $n = $this->readDigits(); $a[$a->length + $n - 1] = null; unset($n); } else { $a->push($this->unserialize()); } unset($c1); } return $a; break; case 111: $o = _hx_anonymous(array()); $this->cache->push($o); $this->unserializeObject($o); return $o; break; case 114: $n1 = $this->readDigits(); if ($n1 < 0 || $n1 >= $this->cache->length) { throw new HException("Invalid reference"); } return $this->cache[$n1]; break; case 82: $n2 = $this->readDigits(); if ($n2 < 0 || $n2 >= $this->scache->length) { throw new HException("Invalid string reference"); } return $this->scache[$n2]; break; case 120: throw new HException($this->unserialize()); break; case 99: $name = $this->unserialize(); $cl = $this->resolver->resolveClass($name); if ($cl === null) { throw new HException("Class not found " . _hx_string_or_null($name)); } $o1 = Type::createEmptyInstance($cl); $this->cache->push($o1); $this->unserializeObject($o1); return $o1; break; case 119: $name1 = $this->unserialize(); $edecl = $this->resolver->resolveEnum($name1); if ($edecl === null) { throw new HException("Enum not found " . _hx_string_or_null($name1)); } $e = $this->unserializeEnum($edecl, $this->unserialize()); $this->cache->push($e); return $e; break; case 106: $name2 = $this->unserialize(); $edecl1 = $this->resolver->resolveEnum($name2); if ($edecl1 === null) { throw new HException("Enum not found " . _hx_string_or_null($name2)); } $this->pos++; $index = $this->readDigits(); $tag = _hx_array_get(Type::getEnumConstructs($edecl1), $index); if ($tag === null) { throw new HException("Unknown enum index " . _hx_string_or_null($name2) . "@" . _hx_string_rec($index, "")); } $e1 = $this->unserializeEnum($edecl1, $tag); $this->cache->push($e1); return $e1; break; case 108: $l = new HList(); $this->cache->push($l); $buf1 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $l->add($this->unserialize()); } $this->pos++; return $l; break; case 98: $h = new haxe_ds_StringMap(); $this->cache->push($h); $buf2 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s1 = $this->unserialize(); $h->set($s1, $this->unserialize()); unset($s1); } $this->pos++; return $h; break; case 113: $h1 = new haxe_ds_IntMap(); $this->cache->push($h1); $buf3 = $this->buf; $c2 = null; $p3 = $this->pos++; $c2 = ord(substr($this->buf, $p3, 1)); while ($c2 === 58) { $i = $this->readDigits(); $h1->set($i, $this->unserialize()); $p4 = $this->pos++; $c2 = ord(substr($this->buf, $p4, 1)); unset($p4); unset($i); } if ($c2 !== 104) { throw new HException("Invalid IntMap format"); } return $h1; break; case 77: $h2 = new haxe_ds_ObjectMap(); $this->cache->push($h2); $buf4 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s2 = $this->unserialize(); $h2->set($s2, $this->unserialize()); unset($s2); } $this->pos++; return $h2; break; case 118: $d = Date::fromString(_hx_substr($this->buf, $this->pos, 19)); $this->cache->push($d); $this->pos += 19; return $d; break; case 115: $len1 = $this->readDigits(); $buf5 = $this->buf; if (haxe_Unserializer_4($this, $_g, $buf5, $len1) !== 58 || $this->length - $this->pos < $len1) { throw new HException("Invalid bytes length"); } $codes = haxe_Unserializer::$CODES; if ($codes === null) { $codes = haxe_Unserializer::initCodes(); haxe_Unserializer::$CODES = $codes; } $i1 = $this->pos; $rest = $len1 & 3; $size = null; $size = ($len1 >> 2) * 3 + haxe_Unserializer_5($this, $_g, $buf5, $codes, $i1, $len1, $rest, $size); $max = $i1 + ($len1 - $rest); $bytes = haxe_io_Bytes::alloc($size); $bpos = 0; while ($i1 < $max) { $c11 = $codes[haxe_Unserializer_6($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c21 = $codes[haxe_Unserializer_7($this, $_g, $bpos, $buf5, $bytes, $c11, $codes, $i1, $len1, $max, $rest, $size)]; $pos = $bpos++; $bytes->b[$pos] = chr($c11 << 2 | $c21 >> 4); unset($pos); $c3 = $codes[haxe_Unserializer_8($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $codes, $i1, $len1, $max, $rest, $size)]; $pos1 = $bpos++; $bytes->b[$pos1] = chr($c21 << 4 | $c3 >> 2); unset($pos1); $c4 = $codes[haxe_Unserializer_9($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $c3, $codes, $i1, $len1, $max, $rest, $size)]; $pos2 = $bpos++; $bytes->b[$pos2] = chr($c3 << 6 | $c4); unset($pos2); unset($c4, $c3, $c21, $c11); } if ($rest >= 2) { $c12 = $codes[haxe_Unserializer_10($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c22 = $codes[haxe_Unserializer_11($this, $_g, $bpos, $buf5, $bytes, $c12, $codes, $i1, $len1, $max, $rest, $size)]; $pos3 = $bpos++; $bytes->b[$pos3] = chr($c12 << 2 | $c22 >> 4); if ($rest === 3) { $c31 = $codes[haxe_Unserializer_12($this, $_g, $bpos, $buf5, $bytes, $c12, $c22, $codes, $i1, $len1, $max, $rest, $size)]; $pos4 = $bpos++; $bytes->b[$pos4] = chr($c22 << 4 | $c31 >> 2); } } $this->pos += $len1; $this->cache->push($bytes); return $bytes; break; case 67: $name3 = $this->unserialize(); $cl1 = $this->resolver->resolveClass($name3); if ($cl1 === null) { throw new HException("Class not found " . _hx_string_or_null($name3)); } $o2 = Type::createEmptyInstance($cl1); $this->cache->push($o2); $o2->hxUnserialize($this); if (haxe_Unserializer_13($this, $_g, $cl1, $name3, $o2) !== 103) { throw new HException("Invalid custom data"); } return $o2; break; default: break; } $this->pos--; throw new HException("Invalid char " . _hx_string_or_null(_hx_char_at($this->buf, $this->pos)) . " at position " . _hx_string_rec($this->pos, "")); }
public function doUnserializeSessionData($content) { if ($content !== null) { try { $this->sessionData = haxe_Unserializer::run($content); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $this->context->messages->push(_hx_anonymous(array("msg" => "Failed to unserialize session data: " . Std::string($e), "pos" => _hx_anonymous(array("fileName" => "FileSession.hx", "lineNumber" => 256, "className" => "ufront.web.session.FileSession", "methodName" => "doUnserializeSessionData")), "type" => ufront_log_MessageType::$MWarning))); } } return tink_core_Noise::$Noise; }
static function cached_query($sql_cmd, $args = null, $dirty_pages = null) { $s_args = $args->join(":"); $header = _hx_string_or_null($sql_cmd) . _hx_string_or_null($s_args); $filename = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_rec(system_base_Hashes::do_hash($header), ""); $resultset = null; $cached_results = null; $rows = new HList(); $data = null; $total_rows = null; $results = null; $return_data = _hx_anonymous(array("rows" => $rows, "total_rows" => 0)); if (strtoupper(_hx_substr(ltrim($sql_cmd), 0, 6)) !== "SELECT") { system_base_Database::get_instance(null, null, null, null, null, null, null, null); $resultset = system_base_Database::query($sql_cmd, $args, null); return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length())); } if (file_exists($filename)) { $fin = sys_io_File::read($filename, false); $results = $fin->readLine(); if ($results === $header) { $cached_results = $fin->readLine(); $return_data = haxe_Unserializer::run($cached_results); } else { $m = "Database cache collision running query: " . _hx_string_or_null($sql_cmd) . "\n"; $m = Std::string(Date::now()) . ": " . _hx_string_or_null($m); system_base_Database::get_instance(null, null, null, null, null, null, null, null); $resultset = system_base_Database::query($sql_cmd, $args, null); return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length())); } } else { system_base_Database::get_instance(null, null, null, null, null, null, null, null); $resultset = system_base_Database::query($sql_cmd, $args, null); $data = haxe_Serializer::run(_hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length()))); $fout = sys_io_File::write($filename, false); $fout->writeString(_hx_string_or_null($header) . "\n"); $fout->writeString(_hx_string_or_null($data) . "\n"); $fout->close(); } return $return_data; }
static function processResponse($response, $onResult, $errorHandler, $remotingCallString) { $ret = null; $stack = null; $hxrFound = false; $errors = new _hx_array(array()); $onError = ufront_remoting_RemotingUtil::wrapErrorHandler($errorHandler); if (_hx_substr($response, 0, 2) !== "hx") { call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response))); } else { $_g = 0; $_g1 = _hx_explode("\n", $response); while ($_g < $_g1->length) { $line = $_g1[$_g]; ++$_g; if ($line === "") { continue; } $_g2 = _hx_substr($line, 0, 3); switch ($_g2) { case "hxr": $s = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $ret = $s->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $ret = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e))); } $hxrFound = true; break; case "hxt": $s1 = new haxe_Unserializer(_hx_substr($line, 3, null)); $m = null; try { $m = $s1->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; $m = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e1))); } $m->pos->fileName = "[R]" . _hx_string_or_null($m->pos->fileName); haxe_Log::trace("[" . Std::string($m->type) . "]" . Std::string($m->msg), $m->pos); break; case "hxs": $s2 = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $stack = $s2->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e2 = $_ex_; $stack = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e2))); } break; case "hxe": $s3 = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $ret = $s3->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e3 = $_ex_; $ret = $errors->push(ufront_remoting_RemotingError::RServerSideException($remotingCallString, $e3, $stack)); } break; default: $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, $line, "Invalid line in response")); break; } unset($_g2); unset($line); } } if ($errors->length === 0) { if ($hxrFound) { try { call_user_func_array($onResult, array($ret)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e4 = $_ex_; call_user_func_array($onError, array(ufront_remoting_RemotingError::RClientCallbackException($remotingCallString, $e4))); } } else { call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response))); } } else { $_g3 = 0; while ($_g3 < $errors->length) { $err = $errors[$_g3]; ++$_g3; call_user_func_array($onError, array($err)); unset($err); } } }