Ejemplo n.º 1
0
 static function instance($value, $c)
 {
     if (Std::is($value, $c)) {
         return $value;
     } else {
         return null;
     }
 }
Ejemplo n.º 2
0
 static function rethrow($e)
 {
     if (Std::is($e, _hx_qtype("php.Exception"))) {
         $__rtex__ = $e;
         throw $__rtex__;
     } else {
         throw new HException($e);
     }
 }
Ejemplo n.º 3
0
 static function _trace($v, $i = null)
 {
     $info = null;
     if ($i !== null) {
         $info = _hx_string_or_null($i->fileName) . ":" . _hx_string_or_null($i->methodName) . ":" . _hx_string_rec($i->lineNumber, "") . ":";
     } else {
         $info = "";
     }
     file_put_contents(me_cunity_php_Debug::$logFile, _hx_string_or_null($info) . ":" . _hx_string_or_null(Std::is($v, _hx_qtype("String")) || Std::is($v, _hx_qtype("Int")) || Std::is($v, _hx_qtype("Float")) ? $v : print_r($v, 1)) . "\n", FILE_APPEND);
 }
Ejemplo n.º 4
0
 static function evalValue($v)
 {
     $str = null;
     if (Std::is($v, _hx_qtype("String"))) {
         $str = "'" . Std::string($v) . "'";
     } else {
         $str = Std::string($v);
     }
     return $str;
 }
 static function wrap($e, $msg = null, $pos = null)
 {
     if ($msg === null) {
         $msg = "Internal Server Error";
     }
     if (Std::is($e, _hx_qtype("tink.core.TypedError"))) {
         return $e;
     } else {
         return tink_core_TypedError::withData(500, $msg, $e, $pos);
     }
 }
Ejemplo n.º 6
0
 static function rethrow($e)
 {
     if (isset($__e__)) {
         throw $__e__;
     }
     if (Std::is($e, Exception)) {
         $__rtex__ = $e;
         throw $__rtex__;
     } else {
         throw new HException($e);
     }
 }
 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;
 }
Ejemplo n.º 8
0
 public function call()
 {
     $obj = Type::createEmptyInstance($this->scope);
     $method = Reflect::field($obj, $this->func);
     if ($method === null) {
         throw new HException($obj . " does not contain " . $this->func);
     }
     if (!Reflect::isFunction($method)) {
         throw new HException($this->func . " is not a method of " . $obj);
     }
     $ret = Reflect::callMethod($obj, $method, new _hx_array(array()));
     haxe_Log::trace("Returned: " . $ret, _hx_anonymous(array("fileName" => "Route.hx", "lineNumber" => 28, "className" => "sinatra.Route", "methodName" => "call")));
     return Std::is($ret, _hx_qtype("String")) ? new sinatra_View($ret, null) : eval("if(isset(\$this)) \$»this =& \$this;\$tmp = \$ret;\n\t\t\t\$»r = (Std::is(\$tmp, _hx_qtype(\"sinatra.View\")) ? \$tmp : eval(\"if(isset(\\\$this)) \\\$»this =& \\\$this;throw new HException(\\\"Class cast error\\\");\n\t\t\t\treturn \\\$»r2;\n\t\t\t\"));\n\t\t\treturn \$»r;\n\t\t");
 }
Ejemplo n.º 9
0
 static function setProperty($o, $field, $value)
 {
     if (null === $o) {
         null;
         return;
     }
     $cls = Std::is($o, _hx_qtype("Class")) ? $o->__tname__ : get_class($o);
     $cls_vars = get_class_vars($cls);
     if (isset($cls_vars['__properties__']) && isset($cls_vars['__properties__']['set_' . $field]) && ($field = $cls_vars['__properties__']['set_' . $field])) {
         $o->{$field}($value);
         return;
     } else {
         $o->{$field} = $value;
         return;
     }
 }
 static function sure($outcome)
 {
     switch ($outcome->index) {
         case 0:
             $data = _hx_deref($outcome)->params[0];
             return $data;
             break;
         case 1:
             $failure = _hx_deref($outcome)->params[0];
             if (Std::is($failure, _hx_qtype("tink.core.TypedError"))) {
                 return $failure->throwSelf();
             } else {
                 throw new HException($failure);
             }
             break;
     }
 }
Ejemplo n.º 11
0
 public function unserializeObject($o)
 {
     while (true) {
         if ($this->pos >= $this->length) {
             throw new HException("Invalid object");
         }
         if (ord(substr($this->buf, $this->pos, 1)) === 103) {
             break;
         }
         $k = $this->unserialize();
         if (!Std::is($k, _hx_qtype("String"))) {
             throw new HException("Invalid object key");
         }
         $v = $this->unserialize();
         $o->{$k} = $v;
         unset($v, $k);
     }
     $this->pos++;
 }
 public function getModulesThatRequireInit()
 {
     $moduleSets = new _hx_array(array($this->requestMiddleware, $this->requestHandlers, $this->responseMiddleware, $this->logHandlers, $this->errorHandlers));
     $modules = new _hx_array(array());
     $_g = 0;
     while ($_g < $moduleSets->length) {
         $set = $moduleSets[$_g];
         ++$_g;
         $_g1 = 0;
         while ($_g1 < $set->length) {
             $module = $set[$_g1];
             ++$_g1;
             if (Std::is($module, _hx_qtype("ufront.app.UFInitRequired"))) {
                 $modules->push($module);
             }
             unset($module);
         }
         unset($set, $_g1);
     }
     return $modules;
 }
Ejemplo n.º 13
0
function _hx_cast($v, $type)
{
    if (Std::is($v, $type)) {
        return $v;
    } else {
        throw new HException('Class cast error');
    }
}
Ejemplo n.º 14
0
 static function isHash($o)
 {
     return Std::is($o, _hx_qtype("Hash"));
 }
Ejemplo n.º 15
0
 public function save($q)
 {
     $lead_id = Std::parseInt($q->get("lead_id"));
     $res = S::$my->query("INSERT INTO vicidial_lead_log SELECT * FROM (SELECT NULL AS log_id," . _hx_string_rec($lead_id, "") . " AS lead_id,NOW() AS entry_date) AS ll JOIN (SELECT modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM `vicidial_list`WHERE `lead_id`=" . _hx_string_rec($lead_id, "") . ")AS vl", null);
     $log_id = S::$my->insert_id;
     if ($log_id > 0) {
         $cTable = "custom_" . Std::string($q->get("entry_list_id"));
         haxe_Log::trace(_hx_string_or_null($cTable) . " log_id:" . _hx_string_rec($log_id, ""), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 110, "className" => "model.QC", "methodName" => "save")));
         if ($this->checkOrCreateCustomTable($cTable, null)) {
             $cLogTable = _hx_string_or_null($cTable) . "_log";
             $res = S::$my->query("INSERT INTO " . _hx_string_or_null($cLogTable) . " SELECT * FROM (SELECT " . _hx_string_rec($log_id, "") . " AS log_id) AS ll JOIN (SELECT * FROM `" . _hx_string_or_null($cTable) . "`WHERE `lead_id`=" . _hx_string_rec($lead_id, "") . ")AS cl", null);
             haxe_Log::trace("INSERT INTO " . _hx_string_or_null($cLogTable) . " ..." . _hx_string_or_null(S::$my->error) . "<", _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 117, "className" => "model.QC", "methodName" => "save")));
             if (S::$my->error === "") {
                 $primary_id = S::$my->real_escape_string($q->get("primary_id"));
                 $sql = new StringBuf();
                 $sql->add("UPDATE " . _hx_string_or_null($cTable) . " SET ");
                 $cFields = S::tableFields("" . _hx_string_or_null($cTable), null);
                 haxe_Log::trace("" . _hx_string_or_null($cTable) . " fields:" . _hx_string_or_null($cFields->toString()), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 125, "className" => "model.QC", "methodName" => "save")));
                 $cFields->remove($primary_id);
                 $bindTypes = "";
                 $values2bind = null;
                 $i = 0;
                 $dbFieldTypes = php_Lib::hashOfAssociativeArray(php_Lib::associativeArrayOfObject(S::$conf->get("dbFieldTypes")));
                 $sets = new _hx_array(array());
                 $_g = 0;
                 while ($_g < $cFields->length) {
                     $c = $cFields[$_g];
                     ++$_g;
                     $val = $q->get($c);
                     if ($val !== null) {
                         if (Std::is($val, _hx_qtype("String"))) {
                             $values2bind[$i++] = $val;
                         } else {
                             $values2bind[$i++] = $val[0];
                         }
                         $type = $dbFieldTypes->get($c);
                         if (Util::any2bool($type)) {
                             $bindTypes .= _hx_string_or_null($type);
                         } else {
                             $bindTypes .= "s";
                         }
                         $sets->push(_hx_string_or_null($c) . "=?");
                         unset($type);
                     }
                     unset($val, $c);
                 }
                 $sql->add($sets->join(","));
                 $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
                 $stmt = S::$my->stmt_init();
                 haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 147, "className" => "model.QC", "methodName" => "save")));
                 $success = $stmt->prepare($sql->b);
                 if (!$success) {
                     haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 151, "className" => "model.QC", "methodName" => "save")));
                     return false;
                 }
                 $success = myBindParam($stmt, $values2bind, $bindTypes);
                 haxe_Log::trace("success:" . Std::string($success), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 155, "className" => "model.QC", "methodName" => "save")));
                 if ($success) {
                     $success = $stmt->execute();
                     if (!$success) {
                         haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 161, "className" => "model.QC", "methodName" => "save")));
                         return false;
                     }
                     $sql = new StringBuf();
                     $uFields = model_QC::$vicdial_list_fields;
                     $uFields->remove($primary_id);
                     $bindTypes = "";
                     $values2bind = null;
                     $i = 0;
                     $sql->add("UPDATE vicidial_list SET ");
                     $sets = new _hx_array(array());
                     $_g1 = 0;
                     while ($_g1 < $uFields->length) {
                         $c1 = $uFields[$_g1];
                         ++$_g1;
                         $val1 = $q->get($c1);
                         if ($val1 !== null) {
                             if (Std::is($val1, _hx_qtype("String"))) {
                                 $values2bind[$i++] = $val1;
                             } else {
                                 $values2bind[$i++] = $val1[0];
                             }
                             $type1 = $dbFieldTypes->get($c1);
                             if (Util::any2bool($type1)) {
                                 $bindTypes .= _hx_string_or_null($type1);
                             } else {
                                 $bindTypes .= "s";
                             }
                             $sets->push(_hx_string_or_null($c1) . "=?");
                             unset($type1);
                         }
                         unset($val1, $c1);
                     }
                     $values2bind[$i++] = S::$user;
                     $bindTypes .= "s";
                     $sets->push("security_phrase=?");
                     if (_hx_equal($q->get("status"), "MITGL")) {
                         $list_id = 10000;
                         $mID = Std::parseInt($q->get("vendor_lead_code"));
                         if ($mID === null) {
                             $mID = S::newMemberID();
                             $values2bind[$i++] = $mID;
                             $bindTypes .= "s";
                             $sets->push("vendor_lead_code=?");
                         }
                         $entry_list_id = $q->get("entry_list_id");
                         $values2bind[$i++] = $q->get("status");
                         $bindTypes .= "s";
                         $sets->push("`status`=?");
                         $values2bind[$i++] = $list_id;
                         $bindTypes .= "s";
                         $sets->push("list_id=?");
                         $values2bind[$i++] = $entry_list_id;
                         $bindTypes .= "s";
                         $sets->push("entry_list_id=?");
                         $values2bind[$i++] = $q->get("user");
                         $bindTypes .= "s";
                         $sets->push("owner=?");
                     }
                     $sql->add($sets->join(","));
                     $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
                     $stmt1 = S::$my->stmt_init();
                     haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 216, "className" => "model.QC", "methodName" => "save")));
                     $success1 = $stmt1->prepare($sql->b);
                     if (!$success1) {
                         haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 220, "className" => "model.QC", "methodName" => "save")));
                         return false;
                     }
                     $success1 = myBindParam($stmt1, $values2bind, $bindTypes);
                     haxe_Log::trace("success:" . Std::string($success1), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 224, "className" => "model.QC", "methodName" => "save")));
                     if ($success1) {
                         $success1 = $stmt1->execute();
                         if (!$success1) {
                             haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 230, "className" => "model.QC", "methodName" => "save")));
                             return false;
                         }
                         return true;
                     }
                     return false;
                 }
             } else {
                 haxe_Log::trace("oops", _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 240, "className" => "model.QC", "methodName" => "save")));
             }
         }
     }
     return false;
 }
Ejemplo n.º 16
0
 static function compare($a, $b, $eps)
 {
     if (com_wiris_system_TypeTools::isHash($a)) {
         $isBHash = com_wiris_system_TypeTools::isHash($b);
         if (!$isBHash) {
             return false;
         }
         $ha = $a;
         $hb = $b;
         $it = $ha->keys();
         while ($it->hasNext()) {
             $key = $it->next();
             if (!$hb->exists($key) || !com_wiris_util_json_JSon::compare($ha->get($key), $hb->get($key), $eps)) {
                 return false;
             }
             unset($key);
         }
         return true;
     } else {
         if (com_wiris_system_TypeTools::isArray($a)) {
             $isBArray = com_wiris_system_TypeTools::isArray($b);
             if (!$isBArray) {
                 return false;
             }
             $aa = $a;
             $ab = $b;
             if ($aa->length !== $ab->length) {
                 return false;
             }
             $i = null;
             $_g1 = 0;
             $_g = $aa->length;
             while ($_g1 < $_g) {
                 $i1 = $_g1++;
                 if (!com_wiris_util_json_JSon::compare($aa[$i1], $ab[$i1], $eps)) {
                     return false;
                 }
                 unset($i1);
             }
             return true;
         } else {
             if (Std::is($a, _hx_qtype("String"))) {
                 if (!Std::is($b, _hx_qtype("String"))) {
                     return false;
                 }
                 return _hx_equal($a, $b);
             } else {
                 if (Std::is($a, _hx_qtype("Int"))) {
                     if (!Std::is($b, _hx_qtype("Int"))) {
                         return false;
                     }
                     return _hx_equal($a, $b);
                 } else {
                     if (Std::is($a, _hx_qtype("haxe.Int64"))) {
                         $isBLong = Std::is($b, _hx_qtype("haxe.Int64"));
                         if (!$isBLong) {
                             return false;
                         }
                         return _hx_equal($a, $b);
                     } else {
                         if (Std::is($a, _hx_qtype("com.wiris.util.json.JSonIntegerFormat"))) {
                             if (!Std::is($b, _hx_qtype("com.wiris.util.json.JSonIntegerFormat"))) {
                                 return false;
                             }
                             $ja = $a;
                             $jb = $b;
                             return $ja->toString() === $jb->toString();
                         } else {
                             if (Std::is($a, _hx_qtype("Bool"))) {
                                 if (!Std::is($b, _hx_qtype("Bool"))) {
                                     return false;
                                 }
                                 return _hx_equal($a, $b);
                             } else {
                                 if (Std::is($a, _hx_qtype("Float"))) {
                                     if (!Std::is($b, _hx_qtype("Float"))) {
                                         return false;
                                     }
                                     $da = com_wiris_util_json_JSon::getFloat($a);
                                     $db = com_wiris_util_json_JSon::getFloat($b);
                                     return $da >= $db - $eps && $da <= $db + $eps;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
 public function serialize($v)
 {
     $_g = Type::typeof($v);
     switch ($_g->index) {
         case 0:
             $this->buf->add("n");
             break;
         case 1:
             $v1 = $v;
             if ($v1 === 0) {
                 $this->buf->add("z");
                 return;
             }
             $this->buf->add("i");
             $this->buf->add($v1);
             break;
         case 2:
             $v2 = $v;
             if (Math::isNaN($v2)) {
                 $this->buf->add("k");
             } else {
                 if (!Math::isFinite($v2)) {
                     $this->buf->add($v2 < 0 ? "m" : "p");
                 } else {
                     $this->buf->add("d");
                     $this->buf->add($v2);
                 }
             }
             break;
         case 3:
             $this->buf->add($v ? "t" : "f");
             break;
         case 6:
             $c = _hx_deref($_g)->params[0];
             if (is_object($_t = $c) && !$_t instanceof Enum ? $_t === _hx_qtype("String") : $_t == _hx_qtype("String")) {
                 $this->serializeString($v);
                 return;
             }
             if ($this->useCache && $this->serializeRef($v)) {
                 return;
             }
             switch ($c) {
                 case _hx_qtype("Array"):
                     $ucount = 0;
                     $this->buf->add("a");
                     $l = _hx_len($v);
                     $_g1 = 0;
                     while ($_g1 < $l) {
                         $i = $_g1++;
                         if ($v[$i] === null) {
                             $ucount++;
                         } else {
                             if ($ucount > 0) {
                                 if ($ucount === 1) {
                                     $this->buf->add("n");
                                 } else {
                                     $this->buf->add("u");
                                     $this->buf->add($ucount);
                                 }
                                 $ucount = 0;
                             }
                             $this->serialize($v[$i]);
                         }
                         unset($i);
                     }
                     if ($ucount > 0) {
                         if ($ucount === 1) {
                             $this->buf->add("n");
                         } else {
                             $this->buf->add("u");
                             $this->buf->add($ucount);
                         }
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("List"):
                     $this->buf->add("l");
                     $v3 = $v;
                     if (null == $v3) {
                         throw new HException('null iterable');
                     }
                     $__hx__it = $v3->iterator();
                     while ($__hx__it->hasNext()) {
                         unset($i1);
                         $i1 = $__hx__it->next();
                         $this->serialize($i1);
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("Date"):
                     $d = $v;
                     $this->buf->add("v");
                     $this->buf->add($d->getTime());
                     break;
                 case _hx_qtype("haxe.ds.StringMap"):
                     $this->buf->add("b");
                     $v4 = $v;
                     if (null == $v4) {
                         throw new HException('null iterable');
                     }
                     $__hx__it = $v4->keys();
                     while ($__hx__it->hasNext()) {
                         unset($k);
                         $k = $__hx__it->next();
                         $this->serializeString($k);
                         $this->serialize($v4->get($k));
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("haxe.ds.IntMap"):
                     $this->buf->add("q");
                     $v5 = $v;
                     if (null == $v5) {
                         throw new HException('null iterable');
                     }
                     $__hx__it = $v5->keys();
                     while ($__hx__it->hasNext()) {
                         unset($k1);
                         $k1 = $__hx__it->next();
                         $this->buf->add(":");
                         $this->buf->add($k1);
                         $this->serialize($v5->get($k1));
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("haxe.ds.ObjectMap"):
                     $this->buf->add("M");
                     $v6 = $v;
                     $__hx__it = new _hx_array_iterator(array_values($v6->hk));
                     while ($__hx__it->hasNext()) {
                         unset($k2);
                         $k2 = $__hx__it->next();
                         $this->serialize($k2);
                         $this->serialize($v6->get($k2));
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("haxe.io.Bytes"):
                     $v7 = $v;
                     $i2 = 0;
                     $max = $v7->length - 2;
                     $charsBuf = new StringBuf();
                     $b64 = haxe_Serializer::$BASE64;
                     while ($i2 < $max) {
                         $b1 = null;
                         $pos = $i2++;
                         $b1 = ord($v7->b[$pos]);
                         unset($pos);
                         $b2 = null;
                         $pos1 = $i2++;
                         $b2 = ord($v7->b[$pos1]);
                         unset($pos1);
                         $b3 = null;
                         $pos2 = $i2++;
                         $b3 = ord($v7->b[$pos2]);
                         unset($pos2);
                         $charsBuf->add(_hx_char_at($b64, $b1 >> 2));
                         $charsBuf->add(_hx_char_at($b64, ($b1 << 4 | $b2 >> 4) & 63));
                         $charsBuf->add(_hx_char_at($b64, ($b2 << 2 | $b3 >> 6) & 63));
                         $charsBuf->add(_hx_char_at($b64, $b3 & 63));
                         unset($b3, $b2, $b1);
                     }
                     if ($i2 === $max) {
                         $b11 = null;
                         $pos3 = $i2++;
                         $b11 = ord($v7->b[$pos3]);
                         $b21 = null;
                         $pos4 = $i2++;
                         $b21 = ord($v7->b[$pos4]);
                         $charsBuf->add(_hx_char_at($b64, $b11 >> 2));
                         $charsBuf->add(_hx_char_at($b64, ($b11 << 4 | $b21 >> 4) & 63));
                         $charsBuf->add(_hx_char_at($b64, $b21 << 2 & 63));
                     } else {
                         if ($i2 === $max + 1) {
                             $b12 = null;
                             $pos5 = $i2++;
                             $b12 = ord($v7->b[$pos5]);
                             $charsBuf->add(_hx_char_at($b64, $b12 >> 2));
                             $charsBuf->add(_hx_char_at($b64, $b12 << 4 & 63));
                         }
                     }
                     $chars = $charsBuf->b;
                     $this->buf->add("s");
                     $this->buf->add(strlen($chars));
                     $this->buf->add(":");
                     $this->buf->add($chars);
                     break;
                 default:
                     if ($this->useCache) {
                         $this->cache->pop();
                     }
                     if (_hx_field($v, "hxSerialize") !== null) {
                         $this->buf->add("C");
                         $this->serializeString(Type::getClassName($c));
                         if ($this->useCache) {
                             $this->cache->push($v);
                         }
                         $v->hxSerialize($this);
                         $this->buf->add("g");
                     } else {
                         $this->buf->add("c");
                         $this->serializeString(Type::getClassName($c));
                         if ($this->useCache) {
                             $this->cache->push($v);
                         }
                         $this->serializeFields($v);
                     }
                     break;
             }
             break;
         case 4:
             if (Std::is($v, _hx_qtype("Class"))) {
                 $className = Type::getClassName($v);
                 $this->buf->add("A");
                 $this->serializeString($className);
             } else {
                 if (Std::is($v, _hx_qtype("Enum"))) {
                     $this->buf->add("B");
                     $this->serializeString(Type::getEnumName($v));
                 } else {
                     if ($this->useCache && $this->serializeRef($v)) {
                         return;
                     }
                     $this->buf->add("o");
                     $this->serializeFields($v);
                 }
             }
             break;
         case 7:
             $e = _hx_deref($_g)->params[0];
             if ($this->useCache) {
                 if ($this->serializeRef($v)) {
                     return;
                 }
                 $this->cache->pop();
             }
             $this->buf->add($this->useEnumIndex ? "j" : "w");
             $this->serializeString(Type::getEnumName($e));
             if ($this->useEnumIndex) {
                 $this->buf->add(":");
                 $this->buf->add($v->index);
             } else {
                 $this->serializeString($v->tag);
             }
             $this->buf->add(":");
             $l1 = count($v->params);
             if ($l1 === 0 || _hx_field($v, "params") === null) {
                 $this->buf->add(0);
             } else {
                 $this->buf->add($l1);
                 $_g11 = 0;
                 while ($_g11 < $l1) {
                     $i3 = $_g11++;
                     $this->serialize($v->params[$i3]);
                     unset($i3);
                 }
             }
             if ($this->useCache) {
                 $this->cache->push($v);
             }
             break;
         case 5:
             throw new HException("Cannot serialize function");
             break;
         default:
             throw new HException("Cannot serialize " . Std::string($v));
             break;
     }
 }
Ejemplo n.º 18
0
 public function encodeImpl($sb, $o)
 {
     if (com_wiris_system_TypeTools::isHash($o)) {
         $this->encodeHash($sb, $o);
     } else {
         if (com_wiris_system_TypeTools::isArray($o)) {
             $this->encodeArray($sb, $o);
         } else {
             if (Std::is($o, _hx_qtype("String"))) {
                 $this->encodeString($sb, $o);
             } else {
                 if (Std::is($o, _hx_qtype("Int"))) {
                     $this->encodeInteger($sb, $o);
                 } else {
                     if (Std::is($o, _hx_qtype("haxe.Int64"))) {
                         $this->encodeLong($sb, $o);
                     } else {
                         if (Std::is($o, _hx_qtype("com.wiris.util.json.JSonIntegerFormat"))) {
                             $this->encodeIntegerFormat($sb, $o);
                         } else {
                             throw new HException("Impossible to convert to json object of type " . Std::string(Type::getClass($o)));
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
 static function getValueType($value)
 {
     if (Std::is($value, _hx_qtype("String"))) {
         return "String";
     }
     if (Std::is($value, _hx_qtype("Class"))) {
         return Type::getClassName($value);
     }
     if (Std::is($value, _hx_qtype("Enum"))) {
         return Type::getEnumName($value);
     }
     $name = null;
     $_g = Type::typeof($value);
     switch ($_g->index) {
         case 1:
             $name = "Int";
             break;
         case 3:
             $name = "Bool";
             break;
         case 6:
             $c = _hx_deref($_g)->params[0];
             $name = Type::getClassName($c);
             break;
         case 7:
             $e = _hx_deref($_g)->params[0];
             $name = Type::getEnumName($e);
             break;
         default:
             $name = null;
             break;
     }
     if ($name !== null) {
         return $name;
     }
     throw new HException("Could not determine type name of " . Std::string($value));
 }
Ejemplo n.º 20
0
 public function save_pay_source($q)
 {
     $account = php_Lib::hashOfAssociativeArray($q->get("account"));
     haxe_Log::trace(Std::string($account) . ":" . Std::string(model_Clients_15($this, $account, $q)), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 676, "className" => "model.Clients", "methodName" => "save_pay_source")));
     $pIt = $account->keys();
     $user = S::$user;
     while ($pIt->hasNext()) {
         $pay_source_id = $pIt->next();
         $log_id = $this->save_pay_source_log($pay_source_id, null);
         if (!$log_id) {
             return false;
         }
         $sql = new StringBuf();
         $uFields = model_Clients::$pay_source_fields;
         $uFields->remove("pay_source_id");
         $bindTypes = "";
         $values2bind = null;
         $i = 0;
         $dbFieldTypes = php_Lib::hashOfAssociativeArray(php_Lib::associativeArrayOfObject(S::$conf->get("dbFieldTypes")));
         $sets = new _hx_array(array());
         $sql->add("UPDATE fly_crm.pay_source SET ");
         $_g = 0;
         while ($_g < $uFields->length) {
             $c = $uFields[$_g];
             ++$_g;
             haxe_Log::trace(_hx_string_or_null($c) . ":" . Std::string(Type::typeof($q->get($c))), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 699, "className" => "model.Clients", "methodName" => "save_pay_source")));
             $p = $q->get($c);
             $val = null;
             if ($p !== null) {
                 if (!Std::is($p, _hx_qtype("String"))) {
                     $valMap = php_Lib::hashOfAssociativeArray($q->get($c));
                     $val = $valMap->get(Std::string($pay_source_id));
                     unset($valMap);
                 } else {
                     $val = $p;
                 }
                 $values2bind[$i++] = $val;
                 $type = $dbFieldTypes->get($c);
                 if (Util::any2bool($type)) {
                     $bindTypes .= _hx_string_or_null($type);
                 } else {
                     $bindTypes .= "s";
                 }
                 $sets->push(_hx_string_or_null($c) . "=?");
                 unset($type);
             }
             unset($val, $p, $c);
         }
         unset($_g);
         if ($sets->length === 0) {
             continue;
         }
         $sql->add($sets->join(","));
         $sql->add(" WHERE pay_source_id=" . _hx_string_rec($pay_source_id, ""));
         $stmt = S::$my->stmt_init();
         haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 727, "className" => "model.Clients", "methodName" => "save_pay_source")));
         $success = $stmt->prepare($sql->b);
         if (!$success) {
             haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 731, "className" => "model.Clients", "methodName" => "save_pay_source")));
             return false;
         }
         haxe_Log::trace($values2bind, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 735, "className" => "model.Clients", "methodName" => "save_pay_source")));
         $success = myBindParam($stmt, $values2bind, $bindTypes);
         haxe_Log::trace("success:" . Std::string($success), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 737, "className" => "model.Clients", "methodName" => "save_pay_source")));
         if ($success) {
             $success = $stmt->execute();
             if (!$success) {
                 haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 743, "className" => "model.Clients", "methodName" => "save_pay_source")));
                 return false;
             }
             $this->save_pay_source_log($pay_source_id, $log_id);
             if (!$pIt->hasNext()) {
                 return true;
             }
         }
         unset($values2bind, $uFields, $success, $stmt, $sql, $sets, $pay_source_id, $log_id, $i, $dbFieldTypes, $bindTypes);
     }
     return false;
 }
Ejemplo n.º 21
0
 public function isHash($h)
 {
     return Std::is($h, _hx_qtype("haxe.ds.StringMap"));
 }
Ejemplo n.º 22
0
 public function save($q)
 {
     $lead_id = Std::parseInt($q->get("lead_id"));
     $user = S::$user;
     $log_id = false;
     if ($log_id = $this->saveLog($q, null)) {
         $cTable = "custom_" . Std::string($q->get("entry_list_id"));
         haxe_Log::trace(_hx_string_or_null($cTable) . " log_id:" . Std::string($log_id), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 162, "className" => "model.QC", "methodName" => "save")));
         $primary_id = S::$my->real_escape_string($q->get("primary_id"));
         $sql = new StringBuf();
         $sql->add("UPDATE " . _hx_string_or_null($cTable) . " SET ");
         $cFields = S::tableFields("" . _hx_string_or_null($cTable), null);
         haxe_Log::trace("" . _hx_string_or_null($cTable) . " fields:" . _hx_string_or_null($cFields->toString()), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 177, "className" => "model.QC", "methodName" => "save")));
         $cFields->remove($primary_id);
         $bindTypes = "";
         $values2bind = null;
         $i = 0;
         $dbFieldTypes = php_Lib::hashOfAssociativeArray(php_Lib::associativeArrayOfObject(S::$conf->get("dbFieldTypes")));
         $sets = new _hx_array(array());
         $_g = 0;
         while ($_g < $cFields->length) {
             $c = $cFields[$_g];
             ++$_g;
             $val = $q->get($c);
             if ($val !== null) {
                 if (Std::is($val, _hx_qtype("String"))) {
                     $values2bind[$i++] = $val;
                 } else {
                     $values2bind[$i++] = $val[0];
                 }
                 $type = $dbFieldTypes->get($c);
                 if (Util::any2bool($type)) {
                     $bindTypes .= _hx_string_or_null($type);
                 } else {
                     $bindTypes .= "s";
                 }
                 $sets->push(_hx_string_or_null($c) . "=?");
                 unset($type);
             }
             unset($val, $c);
         }
         $sql->add($sets->join(","));
         $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
         $stmt = S::$my->stmt_init();
         haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 199, "className" => "model.QC", "methodName" => "save")));
         $success = $stmt->prepare($sql->b);
         if (!$success) {
             haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 203, "className" => "model.QC", "methodName" => "save")));
             return false;
         }
         $success = myBindParam($stmt, $values2bind, $bindTypes);
         haxe_Log::trace("success:" . Std::string($success), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 207, "className" => "model.QC", "methodName" => "save")));
         if ($success) {
             $success = $stmt->execute();
             if (!$success) {
                 haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 213, "className" => "model.QC", "methodName" => "save")));
                 return false;
             }
             $sql = new StringBuf();
             $uFields = model_QC::$vicdial_list_fields;
             $uFields->remove($primary_id);
             $bindTypes = "";
             $values2bind = null;
             $i = 0;
             $sql->add("UPDATE vicidial_list SET ");
             $sets = new _hx_array(array());
             $_g1 = 0;
             while ($_g1 < $uFields->length) {
                 $c1 = $uFields[$_g1];
                 ++$_g1;
                 $val1 = $q->get($c1);
                 if ($val1 !== null) {
                     if (Std::is($val1, _hx_qtype("String"))) {
                         $values2bind[$i++] = $val1;
                     } else {
                         $values2bind[$i++] = $val1[0];
                     }
                     $type1 = $dbFieldTypes->get($c1);
                     if (Util::any2bool($type1)) {
                         $bindTypes .= _hx_string_or_null($type1);
                     } else {
                         $bindTypes .= "s";
                     }
                     $sets->push(_hx_string_or_null($c1) . "=?");
                     unset($type1);
                 }
                 unset($val1, $c1);
             }
             $values2bind[$i++] = S::$user;
             $bindTypes .= "s";
             $sets->push("security_phrase=?");
             $values2bind[$i++] = "XX";
             $bindTypes .= "s";
             $sets->push("state=?");
             if (_hx_equal($q->get("status"), "QCOK") || _hx_equal($q->get("status"), "QCBAD")) {
                 $list_id = 10000;
                 if (_hx_equal($q->get("status"), "QCOK")) {
                     $mID = Std::parseInt($q->get("vendor_lead_code"));
                     if ($mID === null) {
                         $mID = S::newMemberID();
                         $values2bind[$i++] = $mID;
                         $bindTypes .= "s";
                         $sets->push("vendor_lead_code=?");
                     }
                 } else {
                     $list_id = 1800;
                 }
                 $entry_list_id = $q->get("entry_list_id");
                 $values2bind[$i++] = $q->get("status");
                 $bindTypes .= "s";
                 $sets->push("`status`=?");
                 $values2bind[$i++] = $list_id;
                 $bindTypes .= "s";
                 $sets->push("list_id=?");
                 $values2bind[$i++] = $entry_list_id;
                 $bindTypes .= "s";
                 $sets->push("entry_list_id=?");
                 $values2bind[$i++] = $q->get("owner");
                 $bindTypes .= "s";
                 $sets->push("owner=?");
             }
             $sql->add($sets->join(","));
             $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
             $stmt1 = S::$my->stmt_init();
             haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 277, "className" => "model.QC", "methodName" => "save")));
             $success1 = $stmt1->prepare($sql->b);
             if (!$success1) {
                 haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 281, "className" => "model.QC", "methodName" => "save")));
                 return false;
             }
             $success1 = myBindParam($stmt1, $values2bind, $bindTypes);
             haxe_Log::trace("success:" . Std::string($success1), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 287, "className" => "model.QC", "methodName" => "save")));
             if ($success1) {
                 $success1 = $stmt1->execute();
                 if (!$success1) {
                     haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 293, "className" => "model.QC", "methodName" => "save")));
                     return false;
                 } else {
                     return $this->saveLog($q, $log_id) !== false;
                 }
             }
             return false;
         }
     } else {
         haxe_Log::trace("oops", _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 306, "className" => "model.QC", "methodName" => "save")));
     }
     return false;
 }
Ejemplo n.º 23
0
 static function getInt($n)
 {
     if (Std::is($n, _hx_qtype("Float"))) {
         return Math::round($n);
     } else {
         if (Std::is($n, _hx_qtype("Int"))) {
             return $n;
         } else {
             return 0;
         }
     }
 }
function ufront_remoting_RemotingUtil_0(&$errorHandler, $e)
{
    if (Std::is($e, _hx_qtype("ufront.remoting.RemotingError"))) {
        call_user_func_array($errorHandler, array($e));
    } else {
        call_user_func_array($errorHandler, array(ufront_remoting_RemotingError::RUnknownException($e)));
    }
}
Ejemplo n.º 25
0
 public function isTable($t)
 {
     return Std::is($t, _hx_qtype("coopy.Table"));
 }