示例#1
0
 public function update_fields_x($param)
 {
     $state = $param->get("state");
     $lead_id = Std::parseInt($param->get("lead_id"));
     $agcResponse = S::$my->query("UPDATE vicidial_list SET state=\"" . _hx_string_or_null($state) . "\" WHERE lead_id=" . Std::string($lead_id), null);
     return $this->json_response(model_AgcApi_0($this, $agcResponse, $lead_id, $param, $state));
 }
示例#2
0
 public function edit($param)
 {
     $fieldNames = new haxe_ds_StringMap();
     $typeMap = new haxe_ds_StringMap();
     $optionsMap = new haxe_ds_StringMap();
     $eF = $this->getEditorFields(null);
     $keys = $eF->keys();
     $tableNames = new _hx_array(array());
     $tableFields = new haxe_ds_StringMap();
     while ($keys->hasNext()) {
         $k = $keys->next();
         haxe_Log::trace($k, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 55, "className" => "model.Clients", "methodName" => "edit")));
         $tableNames->push($k);
         $aFields = $eF->get($k);
         $cFields = $aFields->map(array(new _hx_lambda(array(&$aFields, &$eF, &$fieldNames, &$k, &$keys, &$optionsMap, &$param, &$tableFields, &$tableNames, &$typeMap), "model_Clients_0"), 'execute'));
         $tableFields->set($k, $cFields);
         $_g1 = 0;
         $_g = $cFields->length;
         while ($_g1 < $_g) {
             $f = $_g1++;
             $fieldNames->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_name"));
             if (_hx_array_get($aFields, $f)->get("field_options") !== null) {
                 $optionsMap->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_options"));
             }
             $typeMap->set($cFields[$f], _hx_array_get($aFields, $f)->get("field_type"));
             unset($f);
         }
         unset($_g1, $_g);
         unset($k, $cFields, $aFields);
     }
     $editTables = new haxe_ds_StringMap();
     $ti = 0;
     $_g2 = 0;
     while ($_g2 < $tableNames->length) {
         $table = $tableNames[$_g2];
         ++$_g2;
         $p = new haxe_ds_StringMap();
         $sb = new StringBuf();
         $phValues = new _hx_array(array());
         $p->set("primary_id", $param->get("primary_id"));
         if ($table === "clients") {
             $p->set("table", "vicidial_list");
             $p->set("jointable", "fly_crm." . _hx_string_or_null($table));
             $p->set("joincond", "ON vicidial_list.lead_id=fly_crm.clients.lead_id");
             $p->set("fields", Std::string(_hx_string_call($param->get("fields"), "split", array(","))->map(array(new _hx_lambda(array(&$_g2, &$eF, &$editTables, &$fieldNames, &$keys, &$optionsMap, &$p, &$param, &$phValues, &$sb, &$table, &$tableFields, &$tableNames, &$ti, &$typeMap), "model_Clients_1"), 'execute'))->join(",")) . "," . _hx_string_or_null($tableFields->get($table)->map(array(new _hx_lambda(array(&$_g2, &$eF, &$editTables, &$fieldNames, &$keys, &$optionsMap, &$p, &$param, &$phValues, &$sb, &$table, &$tableFields, &$tableNames, &$ti, &$typeMap), "model_Clients_2"), 'execute'))->join(",")));
             $p->set("where", "vicidial_list.lead_id|" . Std::string($param->get("lead_id")));
             $editTables->set($table, php_Lib::hashOfAssociativeArray($this->doJoin($p, $sb, $phValues)));
         } else {
             $p->set("table", "fly_crm." . _hx_string_or_null($table));
             $p->set("fields", $tableFields->get($table)->join(","));
             $p->set("where", "client_id|" . Std::string($param->get("client_id")));
             $editTables->set($table, php_Lib::hashOfAssociativeArray($this->doSelect($p, $sb, $phValues)));
         }
         haxe_Log::trace($p, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 105, "className" => "model.Clients", "methodName" => "edit")));
         unset($table, $sb, $phValues, $p);
     }
     $this->data = _hx_anonymous(array("fieldNames" => php_Lib::associativeArrayOfHash($fieldNames), "editData" => php_Lib::associativeArrayOfHash($editTables), "typeMap" => php_Lib::associativeArrayOfHash($typeMap), "optionsMap" => php_Lib::associativeArrayOfHash($optionsMap), "recordings" => $this->getRecordings(Std::parseInt($param->get("lead_id")))));
     return $this->json_encode();
 }
示例#3
0
 public function hpOfString($s)
 {
     $parts = _hx_explode(":", $s);
     if ($parts->length === 2) {
         return _hx_anonymous(array("host" => new sys_net_Host($parts[0]), "port" => Std::parseInt($parts[1])));
     } else {
         return _hx_anonymous(array("host" => new sys_net_Host(_hx_substr($parts[1], 2, null)), "port" => Std::parseInt($parts[2])));
     }
 }
 static function extractVersion($searchString, $s)
 {
     $index = _hx_index_of($s, $searchString, null);
     if ($index < 0) {
         return null;
     }
     $re = new EReg("(\\d+)\\.(\\d+)[^ ();]*", "");
     if (!$re->match(_hx_substr($s, $index + strlen($searchString) + 1, null))) {
         return null;
     }
     return _hx_anonymous(array("version" => $re->matched(0), "majorVersion" => Std::parseInt($re->matched(1)), "minorVersion" => Std::parseInt($re->matched(2))));
 }
 public function addProxy($h)
 {
     $conf = $this->getConfiguration();
     $proxyEnabled = $conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HTTPPROXY, "false");
     if ($proxyEnabled === "true") {
         $host = $conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HTTPPROXY_HOST, null);
         $port = Std::parseInt($conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HTTPPROXY_PORT, "80"));
         if ($host !== null && strlen($host) > 0) {
             $user = $conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HTTPPROXY_USER, null);
             $pass = $conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HTTPPROXY_PASS, null);
             $h->setProxy(com_wiris_std_system_HttpProxy::newHttpProxy($host, $port, $user, $pass));
         }
     }
 }
示例#6
0
 public function get_value()
 {
     $v = null;
     if ($this->table->_values !== null) {
         if (_hx_has_field($this->table->_values, $this->refName)) {
             if ($this->isInt) {
                 $v = Std::parseInt(Reflect::field($this->table->_values, $this->refName));
             } else {
                 if ($this->isFloat) {
                     $v = Std::parseFloat(Reflect::field($this->table->_values, $this->refName));
                 } else {
                     $v = Reflect::field($this->table->_values, $this->refName);
                 }
             }
         }
     } else {
         $v = $this->value;
     }
     return $v;
 }
示例#7
0
 static function parse($str)
 {
     $ylength = _hx_index_of($str, "-", null);
     if ($ylength < 1 || strlen($str) - $ylength !== 6 && strlen($str) - $ylength !== 15) {
         throw new HException("`" . _hx_string_or_null($str) . "` - incorrect date/time format. Should be either `YYYY-MM-DD hh:mm:ss` or `YYYY-MM-DD`");
     }
     if (strlen($str) - $ylength === 6) {
         $str .= " 00:00:00";
     }
     $year = Std::parseInt(_hx_substr($str, 0, $ylength));
     $month = Std::parseInt(_hx_substr($str, $ylength + 1, 2));
     $day = Std::parseInt(_hx_substr($str, $ylength + 4, 2));
     $hour = Std::parseInt(_hx_substr($str, $ylength + 7, 2));
     $minute = Std::parseInt(_hx_substr($str, $ylength + 10, 2));
     $second = Std::parseInt(_hx_substr($str, $ylength + 13, 2));
     if ($year === null || $month === null || $day === null || $hour === null || $minute === null || $second === null) {
         throw new HException("`" . _hx_string_or_null($str) . "` - incorrect date/time format. Should be either `YYYY-MM-DD hh:mm:ss` or `YYYY-MM-DD`");
     }
     $time = datetime_utils_DateTimeUtils::yearToStamp($year) + datetime_utils_DateTimeMonthUtils::toSeconds($month, _hx_mod($year, 4) === 0 ? datetime_utils_DateTimeUtils_0($day, $hour, $minute, $month, $second, $str, $year, $ylength) : false) + ($day - 1) * 86400 + $hour * 3600 + $minute * 60 + $second - 62135596800.0;
     return $time + 62135596800.0;
 }
示例#8
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;
 }
示例#9
0
 static function greek2Latin($g)
 {
     $index = -1;
     if ($g < 100) {
         $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@00" . _hx_string_rec($g, "") . "@", null);
     } else {
         if ($g < 1000) {
             $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@0" . _hx_string_rec($g, "") . "@", null);
         } else {
             $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@" . _hx_string_rec($g, "") . "@", null);
         }
     }
     if ($index !== -1) {
         $s = _hx_substr(com_wiris_util_xml_WCharacterBase::$latinLetters, $index + 1, 4);
         return Std::parseInt($s);
     }
     return $g;
 }
示例#10
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;
 }
示例#11
0
 public function decodeString()
 {
     $sb = new StringBuf();
     $d = $this->c;
     $this->nextToken();
     while ($this->c !== $d) {
         if ($this->c === 92) {
             $this->nextToken();
             if ($this->c === 110) {
                 $sb->add("\n");
             } else {
                 if ($this->c === 114) {
                     $sb->add("\r");
                 } else {
                     if ($this->c === 34) {
                         $sb->add("\"");
                     } else {
                         if ($this->c === 39) {
                             $sb->add("'");
                         } else {
                             if ($this->c === 116) {
                                 $sb->add("\t");
                             } else {
                                 if ($this->c === 92) {
                                     $sb->add("\\");
                                 } else {
                                     if ($this->c === 117) {
                                         $this->nextToken();
                                         $code = com_wiris_util_json_JSon_2($this, $d, $sb);
                                         $this->nextToken();
                                         $code .= com_wiris_util_json_JSon_3($this, $code, $d, $sb);
                                         $this->nextToken();
                                         $code .= com_wiris_util_json_JSon_4($this, $code, $d, $sb);
                                         $this->nextToken();
                                         $code .= com_wiris_util_json_JSon_5($this, $code, $d, $sb);
                                         $dec = Std::parseInt("0x" . $code);
                                         $sb->add(com_wiris_util_json_JSon_6($this, $code, $d, $dec, $sb));
                                         unset($dec, $code);
                                     } else {
                                         throw new HException("Unknown scape sequence '\\" . com_wiris_util_json_JSon_7($this, $d, $sb) . "'");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $sb->add(com_wiris_util_json_JSon_8($this, $d, $sb));
         }
         $this->nextToken();
     }
     $this->nextToken();
     return $sb->b;
 }
示例#12
0
function php_Web_0(&$param, &$reg, &$res, $data)
{
    if ($data === null || strlen($data) === 0) {
        return;
    }
    $_g = 0;
    $_g1 = _hx_explode("&", $data);
    while ($_g < $_g1->length) {
        $part = $_g1[$_g];
        ++$_g;
        if ($reg->match($part)) {
            $idx = $reg->matched(2);
            $val = urldecode($reg->matched(4));
            if ($idx === "") {
                $res->push($val);
            } else {
                $res[Std::parseInt($idx)] = $val;
            }
            unset($val, $idx);
        }
        unset($part);
    }
}
 public function execute()
 {
     $uriParts = $this->context->actionContext->get_uriParts();
     $this->setBaseUri($uriParts);
     $params = $this->context->request->get_params();
     $method = $this->context->request->get_httpMethod();
     $this->context->actionContext->controller = $this;
     $this->context->actionContext->action = "execute";
     try {
         if (0 === $uriParts->length) {
             $this->context->actionContext->action = "index";
             $this->context->actionContext->args = new _hx_array(array());
             $this->context->actionContext->get_uriParts()->splice(0, 0);
             $wrappingRequired = null;
             $i = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->index->wrapResult[0];
             $wrappingRequired = $i;
             $result = $this->wrapResult($this->index(), $wrappingRequired);
             $this->setContextActionResultWhenFinished($result);
             return $result;
         } else {
             if (1 === $uriParts->length && $uriParts[0] === "querystring") {
                 $this->context->actionContext->action = "queryString";
                 $this->context->actionContext->args = new _hx_array(array());
                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                 $wrappingRequired1 = null;
                 $i1 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->queryString->wrapResult[0];
                 $wrappingRequired1 = $i1;
                 $result1 = $this->wrapResult($this->queryString(), $wrappingRequired1);
                 $this->setContextActionResultWhenFinished($result1);
                 return $result1;
             } else {
                 if (1 === $uriParts->length && $uriParts[0] === "poststring") {
                     $this->context->actionContext->action = "postString";
                     $this->context->actionContext->args = new _hx_array(array());
                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                     $wrappingRequired2 = null;
                     $i2 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->postString->wrapResult[0];
                     $wrappingRequired2 = $i2;
                     $result2 = $this->wrapResult($this->postString(), $wrappingRequired2);
                     $this->setContextActionResultWhenFinished($result2);
                     return $result2;
                 } else {
                     if (1 === $uriParts->length && $uriParts[0] === "query") {
                         $this->context->actionContext->action = "query";
                         $this->context->actionContext->args = new _hx_array(array());
                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                         $wrappingRequired3 = null;
                         $i3 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->query->wrapResult[0];
                         $wrappingRequired3 = $i3;
                         $result3 = $this->wrapResult($this->query(), $wrappingRequired3);
                         $this->setContextActionResultWhenFinished($result3);
                         return $result3;
                     } else {
                         if (1 === $uriParts->length && $uriParts[0] === "post") {
                             $this->context->actionContext->action = "post";
                             $this->context->actionContext->args = new _hx_array(array());
                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                             $wrappingRequired4 = null;
                             $i4 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->post->wrapResult[0];
                             $wrappingRequired4 = $i4;
                             $result4 = $this->wrapResult($this->post(), $wrappingRequired4);
                             $this->setContextActionResultWhenFinished($result4);
                             return $result4;
                         } else {
                             if (1 === $uriParts->length && $uriParts[0] === "cookies") {
                                 $this->context->actionContext->action = "cookies";
                                 $this->context->actionContext->args = new _hx_array(array());
                                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                                 $wrappingRequired5 = null;
                                 $i5 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->cookies->wrapResult[0];
                                 $wrappingRequired5 = $i5;
                                 $result5 = $this->wrapResult($this->cookies(), $wrappingRequired5);
                                 $this->setContextActionResultWhenFinished($result5);
                                 return $result5;
                             } else {
                                 if (1 === $uriParts->length && $uriParts[0] === "clientheaders") {
                                     $this->context->actionContext->action = "clientHeaders";
                                     $this->context->actionContext->args = new _hx_array(array());
                                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                                     $wrappingRequired6 = null;
                                     $i6 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->clientHeaders->wrapResult[0];
                                     $wrappingRequired6 = $i6;
                                     $result6 = $this->wrapResult($this->clientHeaders(), $wrappingRequired6);
                                     $this->setContextActionResultWhenFinished($result6);
                                     return $result6;
                                 } else {
                                     if (1 === $uriParts->length && $uriParts[0] === "hostname") {
                                         $this->context->actionContext->action = "hostname";
                                         $this->context->actionContext->args = new _hx_array(array());
                                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                                         $wrappingRequired7 = null;
                                         $i7 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->hostname->wrapResult[0];
                                         $wrappingRequired7 = $i7;
                                         $result7 = $this->wrapResult($this->hostname(), $wrappingRequired7);
                                         $this->setContextActionResultWhenFinished($result7);
                                         return $result7;
                                     } else {
                                         if (1 === $uriParts->length && $uriParts[0] === "clientip") {
                                             $this->context->actionContext->action = "clientIP";
                                             $this->context->actionContext->args = new _hx_array(array());
                                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                                             $wrappingRequired8 = null;
                                             $i8 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->clientIP->wrapResult[0];
                                             $wrappingRequired8 = $i8;
                                             $result8 = $this->wrapResult($this->clientIP(), $wrappingRequired8);
                                             $this->setContextActionResultWhenFinished($result8);
                                             return $result8;
                                         } else {
                                             if (1 <= $uriParts->length && $uriParts[0] === "uri") {
                                                 $this->context->actionContext->action = "uri";
                                                 $this->context->actionContext->args = new _hx_array(array());
                                                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                 $wrappingRequired9 = null;
                                                 $i9 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->uri->wrapResult[0];
                                                 $wrappingRequired9 = $i9;
                                                 $result9 = $this->wrapResult($this->uri(), $wrappingRequired9);
                                                 $this->setContextActionResultWhenFinished($result9);
                                                 return $result9;
                                             } else {
                                                 if (1 === $uriParts->length && $uriParts[0] === "httpmethod") {
                                                     $this->context->actionContext->action = "httpMethod";
                                                     $this->context->actionContext->args = new _hx_array(array());
                                                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                     $wrappingRequired10 = null;
                                                     $i10 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->httpMethod->wrapResult[0];
                                                     $wrappingRequired10 = $i10;
                                                     $result10 = $this->wrapResult($this->httpMethod(), $wrappingRequired10);
                                                     $this->setContextActionResultWhenFinished($result10);
                                                     return $result10;
                                                 } else {
                                                     if (1 === $uriParts->length && $uriParts[0] === "scriptdirectory") {
                                                         $this->context->actionContext->action = "scriptDir";
                                                         $this->context->actionContext->args = new _hx_array(array());
                                                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                         $wrappingRequired11 = null;
                                                         $i11 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->scriptDir->wrapResult[0];
                                                         $wrappingRequired11 = $i11;
                                                         $result11 = $this->wrapResult($this->scriptDir(), $wrappingRequired11);
                                                         $this->setContextActionResultWhenFinished($result11);
                                                         return $result11;
                                                     } else {
                                                         if (1 === $uriParts->length && $uriParts[0] === "authorization") {
                                                             $this->context->actionContext->action = "authorization";
                                                             $this->context->actionContext->args = new _hx_array(array());
                                                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                             $wrappingRequired12 = null;
                                                             $i12 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->authorization->wrapResult[0];
                                                             $wrappingRequired12 = $i12;
                                                             $result12 = $this->wrapResult($this->authorization(), $wrappingRequired12);
                                                             $this->setContextActionResultWhenFinished($result12);
                                                             return $result12;
                                                         } else {
                                                             if (3 === $uriParts->length && $uriParts[0] === "testresponse" && strlen($uriParts[1]) > 0 && strlen($uriParts[2]) > 0) {
                                                                 $status = Std::parseInt($uriParts[1]);
                                                                 if ($status === null) {
                                                                     throw new HException(testsite_Routes_0($this, $method, $params, $status, $uriParts));
                                                                 }
                                                                 $charset = $uriParts[2];
                                                                 $_param_tmp_language = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "language");
                                                                 $_param_tmp_contentType = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "contentType");
                                                                 $_param_tmp_content = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "content");
                                                                 $_param_tmp_cookieName = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "cookieName");
                                                                 $_param_tmp_cookieVal = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "cookieVal");
                                                                 $args = _hx_anonymous(array("language" => $_param_tmp_language, "contentType" => $_param_tmp_contentType, "content" => $_param_tmp_content, "cookieName" => $_param_tmp_cookieName, "cookieVal" => $_param_tmp_cookieVal));
                                                                 $this->context->actionContext->action = "testResponse";
                                                                 $this->context->actionContext->args = new _hx_array(array($status, $charset, $args));
                                                                 $this->context->actionContext->get_uriParts()->splice(0, 3);
                                                                 $wrappingRequired13 = null;
                                                                 $i13 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->testResponse->wrapResult[0];
                                                                 $wrappingRequired13 = $i13;
                                                                 $result13 = $this->wrapResult($this->testResponse($status, $charset, $args), $wrappingRequired13);
                                                                 $this->setContextActionResultWhenFinished($result13);
                                                                 return $result13;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         throw new HException(ufront_web_HttpError::pageNotFound(_hx_anonymous(array("fileName" => "ControllerMacros.hx", "lineNumber" => 442, "className" => "testsite.Routes", "methodName" => "execute"))));
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return ufront_core_SurpriseTools::asSurpriseError($e, "Uncaught error while executing " . Std::string($this->context->actionContext->controller) . "." . _hx_string_or_null($this->context->actionContext->action) . "()", _hx_anonymous(array("fileName" => "ControllerMacros.hx", "lineNumber" => 445, "className" => "testsite.Routes", "methodName" => "execute")));
     }
 }
示例#14
0
 public function decodeNumber()
 {
     $sb = new StringBuf();
     $hex = false;
     $floating = false;
     do {
         $sb->add(com_wiris_util_json_JSon_0($this, $floating, $hex, $sb));
         $this->nextToken();
         if ($this->c === 120) {
             $hex = true;
             $sb->add(com_wiris_util_json_JSon_1($this, $floating, $hex, $sb));
             $this->nextToken();
         }
         if ($this->c === 46 || $this->c === 69 || $this->c === 101) {
             $floating = true;
         }
     } while ($this->c >= 48 && $this->c <= 58 || $hex && $this->isHexDigit($this->c) || $floating && ($this->c === 46 || $this->c === 69 || $this->c === 101 || $this->c === 45));
     if ($floating) {
         return Std::parseFloat($sb->b);
     } else {
         return Std::parseInt($sb->b);
     }
 }
 public function makeConst($v)
 {
     haxe_Template::$expr_trim->match($v);
     $v = haxe_Template::$expr_trim->matched(1);
     if (_hx_char_code_at($v, 0) === 34) {
         $str = _hx_substr($v, 1, strlen($v) - 2);
         return array(new _hx_lambda(array("str" => &$str, "v" => &$v), null, array(), "{\n\t\t\t\treturn \$str;\n\t\t\t}"), 'execute0');
     }
     if (haxe_Template::$expr_int->match($v)) {
         $i = Std::parseInt($v);
         return array(new _hx_lambda(array("i" => &$i, "str" => &$str, "v" => &$v), null, array(), "{\n\t\t\t\treturn \$i;\n\t\t\t}"), 'execute0');
     }
     if (haxe_Template::$expr_float->match($v)) {
         $f = Std::parseFloat($v);
         return array(new _hx_lambda(array("f" => &$f, "i" => &$i, "str" => &$str, "v" => &$v), null, array(), "{\n\t\t\t\treturn \$f;\n\t\t\t}"), 'execute0');
     }
     $me = $this;
     return array(new _hx_lambda(array("f" => &$f, "i" => &$i, "me" => &$me, "str" => &$str, "v" => &$v), null, array(), "{\n\t\t\treturn \$me->resolve(\$v);\n\t\t}"), 'execute0');
 }
示例#16
0
 public function run($args, $io = null)
 {
     if ($io === null) {
         $io = new coopy_TableIO();
     }
     if ($io === null) {
         haxe_Log::trace("No system interface available", _hx_anonymous(array("fileName" => "Coopy.hx", "lineNumber" => 693, "className" => "coopy.Coopy", "methodName" => "run")));
         return 1;
     }
     $this->init();
     $this->io = $io;
     $more = true;
     $output = null;
     $inplace = false;
     $git = false;
     $this->flags = new coopy_CompareFlags();
     $this->flags->always_show_header = true;
     while ($more) {
         $more = false;
         $_g1 = 0;
         $_g = $args->length;
         while ($_g1 < $_g) {
             $i = $_g1++;
             $tag = $args[$i];
             if ($tag === "--output") {
                 $more = true;
                 $output = $args[$i + 1];
                 $args->splice($i, 2);
                 break;
             } else {
                 if ($tag === "--css") {
                     $more = true;
                     $this->fragment = true;
                     $this->css_output = $args[$i + 1];
                     $args->splice($i, 2);
                     break;
                 } else {
                     if ($tag === "--fragment") {
                         $more = true;
                         $this->fragment = true;
                         $args->splice($i, 1);
                         break;
                     } else {
                         if ($tag === "--plain") {
                             $more = true;
                             $this->pretty = false;
                             $args->splice($i, 1);
                             break;
                         } else {
                             if ($tag === "--all") {
                                 $more = true;
                                 $this->flags->show_unchanged = true;
                                 $this->flags->show_unchanged_columns = true;
                                 $args->splice($i, 1);
                                 break;
                             } else {
                                 if ($tag === "--all-rows") {
                                     $more = true;
                                     $this->flags->show_unchanged = true;
                                     $args->splice($i, 1);
                                     break;
                                 } else {
                                     if ($tag === "--all-columns") {
                                         $more = true;
                                         $this->flags->show_unchanged_columns = true;
                                         $args->splice($i, 1);
                                         break;
                                     } else {
                                         if ($tag === "--act") {
                                             $more = true;
                                             if ($this->flags->acts === null) {
                                                 $this->flags->acts = new haxe_ds_StringMap();
                                             }
                                             $this->flags->acts->set($args[$i + 1], true);
                                             true;
                                             $args->splice($i, 2);
                                             break;
                                         } else {
                                             if ($tag === "--context") {
                                                 $more = true;
                                                 $context = Std::parseInt($args[$i + 1]);
                                                 if ($context >= 0) {
                                                     $this->flags->unchanged_context = $context;
                                                 }
                                                 $args->splice($i, 2);
                                                 break;
                                                 unset($context);
                                             } else {
                                                 if ($tag === "--inplace") {
                                                     $more = true;
                                                     $inplace = true;
                                                     $args->splice($i, 1);
                                                     break;
                                                 } else {
                                                     if ($tag === "--git") {
                                                         $more = true;
                                                         $git = true;
                                                         $args->splice($i, 1);
                                                         break;
                                                     } else {
                                                         if ($tag === "--unordered") {
                                                             $more = true;
                                                             $this->flags->ordered = false;
                                                             $this->flags->unchanged_context = 0;
                                                             $this->order_set = true;
                                                             $args->splice($i, 1);
                                                             break;
                                                         } else {
                                                             if ($tag === "--ordered") {
                                                                 $more = true;
                                                                 $this->flags->ordered = true;
                                                                 $this->order_set = true;
                                                                 $args->splice($i, 1);
                                                                 break;
                                                             } else {
                                                                 if ($tag === "--color") {
                                                                     $more = true;
                                                                     $this->flags->terminal_format = "ansi";
                                                                     $args->splice($i, 1);
                                                                     break;
                                                                 } else {
                                                                     if ($tag === "--no-color") {
                                                                         $more = true;
                                                                         $this->flags->terminal_format = "plain";
                                                                         $args->splice($i, 1);
                                                                         break;
                                                                     } else {
                                                                         if ($tag === "--input-format") {
                                                                             $more = true;
                                                                             $this->setFormat($args[$i + 1]);
                                                                             $args->splice($i, 2);
                                                                             break;
                                                                         } else {
                                                                             if ($tag === "--output-format") {
                                                                                 $more = true;
                                                                                 $this->output_format = $args[$i + 1];
                                                                                 $this->output_format_set = true;
                                                                                 $args->splice($i, 2);
                                                                                 break;
                                                                             } else {
                                                                                 if ($tag === "--id") {
                                                                                     $more = true;
                                                                                     if ($this->flags->ids === null) {
                                                                                         $this->flags->ids = new _hx_array(array());
                                                                                     }
                                                                                     $this->flags->ids->push($args[$i + 1]);
                                                                                     $args->splice($i, 2);
                                                                                     break;
                                                                                 } else {
                                                                                     if ($tag === "--ignore") {
                                                                                         $more = true;
                                                                                         $this->flags->ignoreColumn($args[$i + 1]);
                                                                                         $args->splice($i, 2);
                                                                                         break;
                                                                                     } else {
                                                                                         if ($tag === "--index") {
                                                                                             $more = true;
                                                                                             $this->flags->always_show_order = true;
                                                                                             $this->flags->never_show_order = false;
                                                                                             $args->splice($i, 1);
                                                                                             break;
                                                                                         } else {
                                                                                             if ($tag === "--www") {
                                                                                                 $more = true;
                                                                                                 $this->output_format = "www";
                                                                                                 $this->output_format_set = true;
                                                                                                 $args->splice($i, 1);
                                                                                             } else {
                                                                                                 if ($tag === "--table") {
                                                                                                     $more = true;
                                                                                                     $this->flags->addTable($args[$i + 1]);
                                                                                                     $args->splice($i, 2);
                                                                                                     break;
                                                                                                 } else {
                                                                                                     if ($tag === "-w" || $tag === "--ignore-whitespace") {
                                                                                                         $more = true;
                                                                                                         $this->flags->ignore_whitespace = true;
                                                                                                         $args->splice($i, 1);
                                                                                                         break;
                                                                                                     } else {
                                                                                                         if ($tag === "-i" || $tag === "--ignore-case") {
                                                                                                             $more = true;
                                                                                                             $this->flags->ignore_case = true;
                                                                                                             $args->splice($i, 1);
                                                                                                             break;
                                                                                                         } else {
                                                                                                             if ($tag === "--padding") {
                                                                                                                 $more = true;
                                                                                                                 $this->flags->padding_strategy = $args[$i + 1];
                                                                                                                 $args->splice($i, 2);
                                                                                                                 break;
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             unset($tag, $i);
         }
         unset($_g1, $_g);
     }
     $cmd = $args[0];
     if ($args->length < 2) {
         if ($cmd === "version") {
             $io->writeStdout(_hx_string_or_null(coopy_Coopy::$VERSION) . "\n");
             return 0;
         }
         if ($cmd === "git") {
             $io->writeStdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n");
             $io->writeStdout("\n");
             $io->writeStdout("Automatic setup\n");
             $io->writeStdout("---------------\n\n");
             $io->writeStdout("Run:\n");
             $io->writeStdout("  daff git csv\n");
             $io->writeStdout("\n");
             $io->writeStdout("Manual setup\n");
             $io->writeStdout("------------\n\n");
             $io->writeStdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n");
             $io->writeStdout("  *.csv diff=daff-csv\n");
             $io->writeStdout("  *.csv merge=daff-csv\n");
             $io->writeStdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n");
             $io->writeStdout("  [diff \"daff-csv\"]\n");
             $io->writeStdout("  command = daff diff --git\n");
             $io->writeStderr("\n");
             $io->writeStdout("  [merge \"daff-csv\"]\n");
             $io->writeStdout("  name = daff tabular merge\n");
             $io->writeStdout("  driver = daff merge --output %A %O %A %B\n\n");
             $io->writeStderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it. Add --no-color if your terminal does not support ANSI colors.");
             $io->writeStderr("\n");
             return 0;
         }
         $io->writeStderr("daff can produce and apply tabular diffs.\n");
         $io->writeStderr("Call as:\n");
         $io->writeStderr("  daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.html] a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n");
         $io->writeStderr("  daff [--www] a.csv b.csv\n");
         $io->writeStderr("  daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n");
         $io->writeStderr("  daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n");
         $io->writeStderr("  daff trim [--output OUTPUT.csv] source.csv\n");
         $io->writeStderr("  daff render [--output OUTPUT.html] diff.csv\n");
         $io->writeStderr("  daff copy in.csv out.tsv\n");
         $io->writeStderr("  daff git\n");
         $io->writeStderr("  daff version\n");
         $io->writeStderr("\n");
         $io->writeStderr("The --inplace option to patch and merge will result in modification of a.csv.\n");
         $io->writeStderr("\n");
         $io->writeStderr("If you need more control, here is the full list of flags:\n");
         $io->writeStderr("  daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n");
         $io->writeStderr("     --act ACT:     show only a certain kind of change (update, insert, delete)\n");
         $io->writeStderr("     --all:         do not prune unchanged rows or columns\n");
         $io->writeStderr("     --all-rows:    do not prune unchanged rows\n");
         $io->writeStderr("     --all-columns: do not prune unchanged columns\n");
         $io->writeStderr("     --color:       highlight changes with terminal colors (default in terminals)\n");
         $io->writeStderr("     --context NUM: show NUM rows of context\n");
         $io->writeStderr("     --id:          specify column to use as primary key (repeat for multi-column key)\n");
         $io->writeStderr("     --ignore:      specify column to ignore completely (can repeat)\n");
         $io->writeStderr("     --index:       include row/columns numbers from original tables\n");
         $io->writeStderr("     --input-format [csv|tsv|ssv|json]: set format to expect for input\n");
         $io->writeStderr("     --no-color:    make sure terminal colors are not used\n");
         $io->writeStderr("     --ordered:     assume row order is meaningful (default for CSV)\n");
         $io->writeStderr("     --output-format [csv|tsv|ssv|json|copy|html]: set format for output\n");
         $io->writeStderr("     --padding [dense|sparse|smart]: set padding method for aligning columns\n");
         $io->writeStderr("     --table NAME:  compare the named table, used with SQL sources\n");
         $io->writeStderr("     --unordered:   assume row order is meaningless (default for json formats)\n");
         $io->writeStderr("     -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n");
         $io->writeStderr("     -i / --ignore-case: ignore differences in case\n");
         $io->writeStderr("\n");
         $io->writeStderr("  daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n");
         $io->writeStderr("     --css CSS.css: generate a suitable css file to go with the html\n");
         $io->writeStderr("     --fragment:    generate just a html fragment rather than a page\n");
         $io->writeStderr("     --plain:       do not use fancy utf8 characters to make arrows prettier\n");
         $io->writeStderr("     --www:         send output to a browser\n");
         return 1;
     }
     $cmd1 = $args[0];
     $offset = 1;
     if (!Lambda::has(new _hx_array(array("diff", "patch", "merge", "trim", "render", "git", "version", "copy")), $cmd1)) {
         if (_hx_index_of($cmd1, ".", null) !== -1 || _hx_index_of($cmd1, "--", null) === 0) {
             $cmd1 = "diff";
             $offset = 0;
         }
     }
     if ($cmd1 === "git") {
         $types = $args->splice($offset, $args->length - $offset);
         return $this->installGitDriver($io, $types);
     }
     if ($git) {
         $ct = $args->length - $offset;
         if ($ct !== 7 && $ct !== 9) {
             $io->writeStderr("Expected 7 or 9 parameters from git, but got " . _hx_string_rec($ct, "") . "\n");
             return 1;
         }
         $git_args = $args->splice($offset, $ct);
         $args->splice(0, $args->length);
         $offset = 0;
         $old_display_path = $git_args[0];
         $new_display_path = $git_args[0];
         $old_file = $git_args[1];
         $new_file = $git_args[4];
         if ($ct === 9) {
             $io->writeStdout($git_args[8]);
             $new_display_path = $git_args[7];
         }
         $io->writeStdout("--- a/" . _hx_string_or_null($old_display_path) . "\n");
         $io->writeStdout("+++ b/" . _hx_string_or_null($new_display_path) . "\n");
         $args->push($old_file);
         $args->push($new_file);
     }
     $parent = null;
     if ($args->length - $offset >= 3) {
         $parent = $this->loadTable($args[$offset]);
         $offset++;
     }
     $aname = $args[$offset];
     $a = $this->loadTable($aname);
     $b = null;
     if ($args->length - $offset >= 2) {
         if ($cmd1 !== "copy") {
             $b = $this->loadTable($args[1 + $offset]);
         } else {
             $output = $args[1 + $offset];
         }
     }
     $this->flags->diff_strategy = $this->strategy;
     if ($inplace) {
         if ($output !== null) {
             $io->writeStderr("Please do not use --inplace when specifying an output.\n");
         }
         $output = $aname;
         return 1;
     }
     if ($output === null) {
         $output = "-";
     }
     $ok = true;
     if ($cmd1 === "diff") {
         if (!$this->order_set) {
             $this->flags->ordered = $this->order_preference;
             if (!$this->flags->ordered) {
                 $this->flags->unchanged_context = 0;
             }
         }
         $this->flags->allow_nested_cells = $this->nested_output;
         $this->runDiff($parent, $a, $b, $this->flags, $output);
     } else {
         if ($cmd1 === "patch") {
             $patcher = new coopy_HighlightPatch($a, $b, null);
             $patcher->apply();
             $this->saveTable($output, $a, null);
         } else {
             if ($cmd1 === "merge") {
                 $merger = new coopy_Merger($parent, $a, $b, $this->flags);
                 $conflicts = $merger->apply();
                 $ok = $conflicts === 0;
                 if ($conflicts > 0) {
                     $io->writeStderr(_hx_string_rec($conflicts, "") . " conflict" . _hx_string_or_null($conflicts > 1 ? "s" : "") . "\n");
                 }
                 $this->saveTable($output, $a, null);
             } else {
                 if ($cmd1 === "trim") {
                     $this->saveTable($output, $a, null);
                 } else {
                     if ($cmd1 === "render") {
                         $this->renderTable($output, $a);
                     } else {
                         if ($cmd1 === "copy") {
                             $this->saveTable($output, $a, null);
                         }
                     }
                 }
             }
         }
     }
     if ($ok) {
         return 0;
     } else {
         return 1;
     }
 }
示例#17
0
 public function parseString()
 {
     $start = $this->pos;
     $buf = new StringBuf();
     while (true) {
         $c = null;
         $index = $this->pos++;
         $c = ord(substr($this->str, $index, 1));
         unset($index);
         if ($c === 34) {
             break;
         }
         if ($c === 92) {
             $buf->b .= _hx_string_or_null(_hx_substr($this->str, $start, $this->pos - $start - 1));
             $index1 = $this->pos++;
             $c = ord(substr($this->str, $index1, 1));
             unset($index1);
             switch ($c) {
                 case 114:
                     $buf->b .= "\r";
                     break;
                 case 110:
                     $buf->b .= "\n";
                     break;
                 case 116:
                     $buf->b .= "\t";
                     break;
                 case 98:
                     $buf->b .= "";
                     break;
                 case 102:
                     $buf->b .= "\f";
                     break;
                 case 47:
                 case 92:
                 case 34:
                     $buf->b .= _hx_string_or_null(chr($c));
                     break;
                 case 117:
                     $uc = Std::parseInt("0x" . _hx_string_or_null(_hx_substr($this->str, $this->pos, 4)));
                     $this->pos += 4;
                     if ($uc <= 127) {
                         $buf->b .= _hx_string_or_null(chr($uc));
                     } else {
                         if ($uc <= 2047) {
                             $buf->b .= _hx_string_or_null(chr(192 | $uc >> 6));
                             $buf->b .= _hx_string_or_null(chr(128 | $uc & 63));
                         } else {
                             if ($uc <= 65535) {
                                 $buf->b .= _hx_string_or_null(chr(224 | $uc >> 12));
                                 $buf->b .= _hx_string_or_null(chr(128 | $uc >> 6 & 63));
                                 $buf->b .= _hx_string_or_null(chr(128 | $uc & 63));
                             } else {
                                 $buf->b .= _hx_string_or_null(chr(240 | $uc >> 18));
                                 $buf->b .= _hx_string_or_null(chr(128 | $uc >> 12 & 63));
                                 $buf->b .= _hx_string_or_null(chr(128 | $uc >> 6 & 63));
                                 $buf->b .= _hx_string_or_null(chr(128 | $uc & 63));
                             }
                         }
                     }
                     break;
                 default:
                     throw new HException("Invalid escape sequence \\" . _hx_string_or_null(chr($c)) . " at position " . _hx_string_rec($this->pos - 1, ""));
                     break;
             }
             $start = $this->pos;
         } else {
             if ($c >= 128) {
                 $this->pos++;
                 if ($c >= 252) {
                     $this->pos += 4;
                 } else {
                     if ($c >= 248) {
                         $this->pos += 3;
                     } else {
                         if ($c >= 240) {
                             $this->pos += 2;
                         } else {
                             if ($c >= 224) {
                                 $this->pos++;
                             }
                         }
                     }
                 }
             } else {
                 if ($c === 0) {
                     throw new HException("Unclosed string");
                 }
             }
         }
         unset($c);
     }
     $buf->b .= _hx_string_or_null(_hx_substr($this->str, $start, $this->pos - $start - 1));
     return $buf->b;
 }
示例#18
0
function system_base_Paginator_30(&$»this, &$config, &$cur_tag_close, &$cur_tag_open, &$elipses, &$first_link, &$first_link_id, &$first_tag_close, &$first_tag_open, &$full_tag_close, &$full_tag_open, &$hints, &$last_link, &$last_link_id, &$last_tag_close, &$last_tag_open, &$link_class, &$next_link, &$next_link_id, &$next_tag_close, &$next_tag_open, &$nolink_class, &$num_tag_close, &$num_tag_open, &$number_class, &$option_value, &$options, &$prev_link, &$prev_link_id, &$prev_tag_close, &$prev_tag_open, &$router_params, &$sband, &$separator, &$sideband_width, &$uri_segment, &$urls)
{
    if ($router_params[$uri_segment] === null) {
        return 1;
    } else {
        return Std::parseInt($router_params[$uri_segment]);
    }
}
示例#19
0
 public function decodeInteger()
 {
     $sb = new StringBuf();
     $hex = null;
     $hex = false;
     do {
         $sb->add(com_wiris_util_json_JSon_0($this, $hex, $sb));
         $this->nextToken();
         if ($this->c === 120) {
             $hex = true;
             $sb->add(com_wiris_util_json_JSon_1($this, $hex, $sb));
             $this->nextToken();
         }
     } while ($this->c >= 48 && $this->c <= 58 || $hex && $this->isHexDigit($this->c));
     return Std::parseInt($sb->b);
 }
示例#20
0
 public function __construct($dbtype = null, $host = null, $port = null, $socket = null, $user = null, $pass = null, $database = null, $trase = null)
 {
     if (!php_Boot::$skip_constructor) {
         $timer = null;
         $stoptime = null;
         $profiler = system_base_Profiler::get_instance();
         $db_config = "";
         $config_path = _hx_string_or_null(system_base_Wet_base::$conf_path) . "database.xml";
         try {
             $db_config = sys_io_File::getContent($config_path);
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             throw new HException(new system_base_NoFileError(_hx_string_or_null($config_path) . " does not exist or cannot be opened for reading"));
         }
         $xml = Xml::parse($db_config);
         $config = new haxe_xml_Fast($xml->firstElement());
         if ($dbtype === null) {
             $dbtype = $config->node->resolve("type")->get_innerHTML();
         } else {
             $dbtype = $dbtype;
         }
         if ($user === null) {
             $user = $config->node->resolve("user")->get_innerHTML();
         } else {
             $user = $user;
         }
         if ($pass === null) {
             $pass = $config->node->resolve("pass")->get_innerHTML();
         } else {
             $pass = $pass;
         }
         if ($port === null) {
             $port = Std::parseInt($config->node->resolve("port")->get_innerHTML());
         } else {
             $port = $port;
         }
         if ($socket === null) {
             $socket = $config->node->resolve("socket")->get_innerHTML();
         } else {
             $socket = $socket;
         }
         if ($database === null) {
             $database = $config->node->resolve("schema")->get_innerHTML();
         } else {
             $database = $database;
         }
         $timer = new system_base_Timers(null);
         switch ($dbtype) {
             case "mysql":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "MySQL " . _hx_string_or_null($user) . "@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 115, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 try {
                     if (system_base_Database::$cnx === null) {
                         system_base_Database::$cnx = sys_db_Mysql::connect(_hx_anonymous(array("host" => $host, "port" => $port, "user" => $user, "pass" => $pass, "socket" => $socket, "database" => $database)));
                     }
                 } catch (Exception $__hx__e) {
                     $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                     $e1 = $_ex_;
                     throw new HException(new system_base_NoConnectionError($e1));
                     return;
                 }
                 $stoptime = $timer->stop();
                 break;
             case "sqlite":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if (_hx_index_of($host, "/", null) === -1) {
                     $host = _hx_string_or_null(system_base_Wet_base::$datastore_path) . _hx_string_or_null($host);
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "SQLite@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 150, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 system_base_Database::$cnx = sys_db_Sqlite::open($host);
                 $stoptime = $timer->stop();
                 break;
             default:
                 throw new HException(new system_base_NoSuchDbexception($dbtype));
                 break;
         }
         $profiler->increment("CON", $stoptime, null);
     }
 }
示例#21
0
 public function find($param)
 {
     $sb = new StringBuf();
     $phValues = new _hx_array(array());
     haxe_Log::trace($param, _hx_anonymous(array("fileName" => "ClientHistory.hx", "lineNumber" => 227, "className" => "model.ClientHistory", "methodName" => "find")));
     $count = $this->countJoin($param, $sb, $phValues);
     $sb = new StringBuf();
     $phValues = new _hx_array(array());
     haxe_Log::trace(_hx_string_or_null($param->get("joincond")) . " count:" . _hx_string_rec($count, "") . ":" . _hx_string_or_null($param->get("page")) . ": " . _hx_string_or_null($param->exists("page") ? "Y" : "N"), _hx_anonymous(array("fileName" => "ClientHistory.hx", "lineNumber" => 232, "className" => "model.ClientHistory", "methodName" => "find")));
     $this->data = _hx_anonymous(array("count" => $count, "page" => $param->exists("page") ? Std::parseInt($param->get("page")) : 1, "rows" => $this->doJoin($param, $sb, $phValues)));
     return $this->json_encode();
 }
示例#22
0
 static function parseHex($str)
 {
     return Std::parseInt("0x" . $str);
 }
示例#23
0
 public function buildLimit($limitParam, $sb)
 {
     $sb->add(" LIMIT " . _hx_string_or_null(_hx_index_of($limitParam, ",", null) > -1 ? _hx_explode(",", $limitParam)->map(array(new _hx_lambda(array(&$limitParam, &$sb), "Model_17"), 'execute'))->join(",") : Std::string(Std::parseInt($limitParam))));
     return true;
 }
 public function makeConst($v)
 {
     haxe_Template::$expr_trim->match($v);
     $v = haxe_Template::$expr_trim->matched(1);
     if (_hx_char_code_at($v, 0) === 34) {
         $str = _hx_substr($v, 1, strlen($v) - 2);
         return array(new _hx_lambda(array(&$str, &$v), "haxe_Template_1"), 'execute');
     }
     if (haxe_Template::$expr_int->match($v)) {
         $i = Std::parseInt($v);
         return array(new _hx_lambda(array(&$i, &$v), "haxe_Template_2"), 'execute');
     }
     if (haxe_Template::$expr_float->match($v)) {
         $f = Std::parseFloat($v);
         return array(new _hx_lambda(array(&$f, &$v), "haxe_Template_3"), 'execute');
     }
     $me = $this;
     return array(new _hx_lambda(array(&$me, &$v), "haxe_Template_4"), 'execute');
 }
示例#25
0
 static function isXmlEntity($ent)
 {
     if (_hx_char_code_at($ent, 0) === 35) {
         $c = null;
         if (_hx_char_code_at($ent, 1) === 120) {
             $c = Std::parseInt("0x" . _hx_substr($ent, 2, null));
         } else {
             $c = Std::parseInt(_hx_substr($ent, 1, null));
         }
         return $c === 34 || $c === 38 || $c === 39 || $c === 60 || $c === 62;
     } else {
         return $ent === "amp" || $ent === "lt" || $ent === "gt" || $ent === "quot" || $ent === "apos";
     }
 }
 public function addClassToInfo($forClass, $info, $injected)
 {
     $meta = haxe_rtti_Meta::getType($forClass);
     $fields = $meta->rtti;
     if ($fields !== null) {
         $_g = 0;
         while ($_g < $fields->length) {
             $field = $fields[$_g];
             ++$_g;
             $name = $field[0];
             if ($injected->indexOf($name, null) > -1) {
                 continue;
             }
             $injected->push($name);
             if ($field->length === 3) {
                 $info->fields->push(new minject_point_PropertyInjectionPoint($name, $field[1], $field[2]));
             } else {
                 if ($name === "new") {
                     $info->ctor = new minject_point_ConstructorInjectionPoint($field->slice(2, null));
                 } else {
                     $orderStr = $field[1];
                     if ($orderStr === "") {
                         $info->fields->push(new minject_point_MethodInjectionPoint($name, $field->slice(2, null)));
                     } else {
                         $order = Std::parseInt($orderStr);
                         $info->fields->push(new minject_point_PostInjectionPoint($name, $field->slice(2, null), $order));
                         unset($order);
                     }
                     unset($orderStr);
                 }
             }
             unset($name, $field);
         }
     }
     $superClass = Type::getSuperClass($forClass);
     if ($superClass !== null) {
         $this->addClassToInfo($superClass, $info, $injected);
     }
 }
示例#27
0
 public function lastInsertId()
 {
     return Std::parseInt($this->pdo->lastInsertId(null));
 }
示例#28
0
 static function newMemberID()
 {
     $res = S::$my->query("SELECT  MAX(CAST(vendor_lead_code AS UNSIGNED)) FROM vicidial_list WHERE list_id=10000", null);
     if ($res->num_rows === 0) {
         return 1;
     } else {
         return Std::parseInt(_hx_array_get($res->fetch_array(2), 0)) + 1;
     }
 }
示例#29
0
 public function customRequest($post, $api, $sock = null, $method = null)
 {
     $url_regexp = new EReg("^(https?://)?([a-zA-Z\\.0-9-]+)(:[0-9]+)?(.*)\$", "");
     if (!$url_regexp->match($this->url)) {
         $this->onError("Invalid URL");
         return;
     }
     $secure = $url_regexp->matched(1) === "https://";
     if ($sock === null) {
         if ($secure) {
             $sock = new php_net_SslSocket();
         } else {
             $sock = new sys_net_Socket();
         }
     }
     $host = $url_regexp->matched(2);
     $portString = $url_regexp->matched(3);
     $request = $url_regexp->matched(4);
     if ($request === "") {
         $request = "/";
     }
     $port = $portString === null || $portString === "" ? $secure ? 443 : 80 : Std::parseInt(_hx_substr($portString, 1, strlen($portString) - 1));
     $data = null;
     $multipart = _hx_field($this, "file") !== null;
     $boundary = null;
     $uri = null;
     if ($multipart) {
         $post = true;
         $boundary = Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000));
         while (strlen($boundary) < 38) {
             $boundary = "-" . $boundary;
         }
         $b = new StringBuf();
         if (null == $this->params) {
             throw new HException('null iterable');
         }
         $»it = $this->params->keys();
         while ($»it->hasNext()) {
             $p = $»it->next();
             $b->add("--");
             $b->add($boundary);
             $b->add("\r\n");
             $b->add("Content-Disposition: form-data; name=\"");
             $b->add($p);
             $b->add("\"");
             $b->add("\r\n");
             $b->add("\r\n");
             $b->add($this->params->get($p));
             $b->add("\r\n");
         }
         $b->add("--");
         $b->add($boundary);
         $b->add("\r\n");
         $b->add("Content-Disposition: form-data; name=\"");
         $b->add($this->file->param);
         $b->add("\"; filename=\"");
         $b->add($this->file->filename);
         $b->add("\"");
         $b->add("\r\n");
         $b->add("Content-Type: " . "application/octet-stream" . "\r\n" . "\r\n");
         $uri = $b->b;
     } else {
         if (null == $this->params) {
             throw new HException('null iterable');
         }
         $»it = $this->params->keys();
         while ($»it->hasNext()) {
             $p = $»it->next();
             if ($uri === null) {
                 $uri = "";
             } else {
                 $uri .= "&";
             }
             $uri .= rawurlencode($p) . "=" . rawurlencode($this->params->get($p));
         }
     }
     $b = new StringBuf();
     if ($method !== null) {
         $b->add($method);
         $b->add(" ");
     } else {
         if ($post) {
             $b->add("POST ");
         } else {
             $b->add("GET ");
         }
     }
     if (_hx_field(_hx_qtype("haxe.Http"), "PROXY") !== null) {
         $b->add("http://");
         $b->add($host);
         if ($port !== 80) {
             $b->add(":");
             $b->add($port);
         }
     }
     $b->add($request);
     if (!$post && $uri !== null) {
         if (_hx_index_of($request, "?", 0) >= 0) {
             $b->add("&");
         } else {
             $b->add("?");
         }
         $b->add($uri);
     }
     $b->add(" HTTP/1.1\r\nHost: " . $host . "\r\n");
     if ($this->postData !== null) {
         $b->add("Content-Length: " . _hx_string_rec(strlen($this->postData), "") . "\r\n");
     } else {
         if ($post && $uri !== null) {
             if ($multipart || $this->headers->get("Content-Type") === null) {
                 $b->add("Content-Type: ");
                 if ($multipart) {
                     $b->add("multipart/form-data");
                     $b->add("; boundary=");
                     $b->add($boundary);
                 } else {
                     $b->add("application/x-www-form-urlencoded");
                 }
                 $b->add("\r\n");
             }
             if ($multipart) {
                 $b->add("Content-Length: " . _hx_string_rec(strlen($uri) + $this->file->size + strlen($boundary) + 6, "") . "\r\n");
             } else {
                 $b->add("Content-Length: " . _hx_string_rec(strlen($uri), "") . "\r\n");
             }
         }
     }
     if (null == $this->headers) {
         throw new HException('null iterable');
     }
     $»it = $this->headers->keys();
     while ($»it->hasNext()) {
         $h = $»it->next();
         $b->add($h);
         $b->add(": ");
         $b->add($this->headers->get($h));
         $b->add("\r\n");
     }
     $b->add("\r\n");
     if ($this->postData !== null) {
         $b->add($this->postData);
     } else {
         if ($post && $uri !== null) {
             $b->add($uri);
         }
     }
     try {
         if (_hx_field(_hx_qtype("haxe.Http"), "PROXY") !== null) {
             $sock->connect(new sys_net_Host(haxe_Http::$PROXY->host), haxe_Http::$PROXY->port);
         } else {
             $sock->connect(new sys_net_Host($host), $port);
         }
         $sock->write($b->b);
         if ($multipart) {
             $bufsize = 4096;
             $buf = haxe_io_Bytes::alloc($bufsize);
             while ($this->file->size > 0) {
                 $size = haxe_Http_4($this, $api, $b, $boundary, $buf, $bufsize, $data, $host, $method, $multipart, $port, $portString, $post, $request, $secure, $sock, $uri, $url_regexp);
                 $len = 0;
                 try {
                     $len = $this->file->io->readBytes($buf, 0, $size);
                 } catch (Exception $»e) {
                     $_ex_ = $»e instanceof HException ? $»e->e : $»e;
                     if (($e = $_ex_) instanceof haxe_io_Eof) {
                         break;
                     } else {
                         throw $»e;
                     }
                 }
                 $sock->output->writeFullBytes($buf, 0, $len);
                 $this->file->size -= $len;
                 unset($size, $len, $e);
             }
             $sock->write("\r\n");
             $sock->write("--");
             $sock->write($boundary);
             $sock->write("--");
         }
         $this->readHttpResponse($api, $sock);
         $sock->close();
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $e = $_ex_;
         try {
             $sock->close();
         } catch (Exception $»e) {
             $_ex_ = $»e instanceof HException ? $»e->e : $»e;
             $e1 = $_ex_;
         }
         $this->onError(Std::string($e));
     }
 }
示例#30
0
 public function readChunk($chunk_re, $api, $buf, $len)
 {
     if ($this->chunk_size === null) {
         if ($this->chunk_buf !== null) {
             $b = new haxe_io_BytesBuffer();
             $b->b .= _hx_string_or_null($this->chunk_buf->b);
             if ($len < 0 || $len > $buf->length) {
                 throw new HException(haxe_io_Error::$OutsideBounds);
             }
             $b->b .= _hx_string_or_null(substr($buf->b, 0, $len));
             $buf = $b->getBytes();
             $len += $this->chunk_buf->length;
             $this->chunk_buf = null;
         }
         if ($chunk_re->match($buf->toString())) {
             $p = $chunk_re->matchedPos();
             if ($p->len <= $len) {
                 $cstr = $chunk_re->matched(1);
                 $this->chunk_size = Std::parseInt("0x" . _hx_string_or_null($cstr));
                 if ($cstr === "0") {
                     $this->chunk_size = null;
                     $this->chunk_buf = null;
                     return false;
                 }
                 $len -= $p->len;
                 return $this->readChunk($chunk_re, $api, $buf->sub($p->len, $len), $len);
             }
         }
         if ($len > 10) {
             $this->onError("Invalid chunk");
             return false;
         }
         $this->chunk_buf = $buf->sub(0, $len);
         return true;
     }
     if ($this->chunk_size > $len) {
         $this->chunk_size -= $len;
         $api->writeBytes($buf, 0, $len);
         return true;
     }
     $end = $this->chunk_size + 2;
     if ($len >= $end) {
         if ($this->chunk_size > 0) {
             $api->writeBytes($buf, 0, $this->chunk_size);
         }
         $len -= $end;
         $this->chunk_size = null;
         if ($len === 0) {
             return true;
         }
         return $this->readChunk($chunk_re, $api, $buf->sub($end, $len), $len);
     }
     if ($this->chunk_size > 0) {
         $api->writeBytes($buf, 0, $this->chunk_size);
     }
     $this->chunk_size -= $len;
     return true;
 }