Beispiel #1
0
 public function getGlobals($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();
     haxe_Log::trace($param, _hx_anonymous(array("fileName" => "App.hx", "lineNumber" => 32, "className" => "model.App", "methodName" => "getGlobals")));
     while ($keys->hasNext()) {
         $k = $keys->next();
         $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_App_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);
     }
     $me = new model_Users($param);
     $me->get_info(null);
     $data = _hx_anonymous(array("fieldNames" => php_Lib::associativeArrayOfHash($fieldNames), "userMap" => $me->globals, "optionsMap" => $optionsMap, "typeMap" => $typeMap, "limit" => _hx_array_get(S::$conf->get("sql"), "LIMIT")));
     return $data;
 }
 public function delete($whichEntries)
 {
     $iii = new _hx_array($whichEntries);
     $_g = 0;
     while ($_g < $iii->length) {
         $thisEntry = $iii[$_g];
         ++$_g;
         $db = JFactory::getDbo();
         $a = $db->quoteName("#__joomlahaxe");
         $query = $db->getQuery(true);
         $query->from($a);
         $query->delete();
         $query->where("id = " . Std::string($thisEntry));
         $db->setQuery($query);
         try {
             $db->execute();
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             php_Lib::hprint($e);
             die;
             return false;
         }
         unset($thisEntry, $query, $e, $db, $a);
     }
     return true;
 }
Beispiel #3
0
 static function objectOfAssociativeArray($arr)
 {
     foreach ($arr as $key => $value) {
         if (is_array($value)) {
             $arr[$key] = php_Lib::objectOfAssociativeArray($value);
         }
     }
     return _hx_anonymous($arr);
 }
Beispiel #4
0
 static function getParams()
 {
     $a = array_merge($_GET, $_POST);
     if (get_magic_quotes_gpc()) {
         reset($a);
         while (list($k, $v) = each($a)) {
             $a[$k] = stripslashes((string) $v);
         }
     }
     return php_Lib::hashOfAssociativeArray($a);
 }
 public function readDatabase()
 {
     php_Lib::println("Connecting to database...");
     $cnx = php_db_Mysql::connect(_hx_anonymous(array("host" => "localhost", "port" => 8889, "user" => "root", "pass" => "root", "socket" => null, "database" => "RODictionary")));
     php_Lib::println("Connected succesfully!");
     $sourcesResult = $cnx->request("SELECT * FROM Source");
     $startTime = haxe_Timer::stamp();
     $rset = $cnx->request("SELECT * FROM Definition LIMIT 50");
     php_Lib::println("Found " . $rset->getLength() . " lexicons, and took " . (haxe_Timer::stamp() - $startTime) . " seconds");
     $this->writeXml($rset);
     $cnx->close();
 }
 public function display($tpl = null)
 {
     try {
         $this->i = $this->get("Items", null);
         $this->p = $this->get("Pagination", null);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         php_Lib::hprint($e);
         return false;
     }
     $this->items = $this->i;
     $this->pagination = $this->p;
     $this->addToolBar();
     parent::display($tpl);
     return null;
 }
 public function addToolBar($theItem, $theForm)
 {
     $input = JFactory::getApplication()->input;
     $input->set("hidemainmenu", true);
     $isNew = false;
     try {
         $isNew = !$theItem->id;
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         php_Lib::hprint($e);
         $isNew = false;
     }
     JToolbarHelper::title($isNew ? "New item" : "Edit item", null);
     JToolbarHelper::save("joomlahaxe.save", "Save");
     JToolbarHelper::cancel("joomlahaxe.cancel", $isNew ? "Cancel" : "Close");
     return true;
 }
Beispiel #8
0
 static function convertBeforeEncode($val)
 {
     $arr = null;
     if (is_object($val)) {
         $_g = get_class($val);
         switch ($_g) {
             case "_hx_anonymous":
             case "stdClass":
                 $arr = php_Lib::associativeArrayOfObject($val);
                 break;
             case "_hx_array":
                 $arr = php_Lib::toPhpArray($val);
                 break;
             case "Date":
                 return Std::string($val);
                 break;
             case "HList":
                 $arr = php_Lib::toPhpArray(Lambda::harray($val));
                 break;
             case "_hx_enum":
                 $e = $val;
                 return $e->index;
                 break;
             case "StringMap":
             case "IntMap":
                 $arr = php_Lib::associativeArrayOfHash($val);
                 break;
             default:
                 $arr = php_Lib::associativeArrayOfObject($val);
                 break;
         }
     } else {
         if (is_array($val)) {
             $arr = $val;
         } else {
             if (is_float($val) && !is_finite($val)) {
                 $val = null;
             }
             return $val;
         }
     }
     return array_map(isset(haxe_Json::$convertBeforeEncode) ? haxe_Json::$convertBeforeEncode : array("haxe_Json", "convertBeforeEncode"), $arr);
 }
Beispiel #9
0
 static function _trace($v, $i = null)
 {
     if (me_cunity_debug_Out::$suspended) {
         return;
     }
     $warned = false;
     if ($i !== null && _hx_has_field($i, "customParams")) {
         $i = $i->customParams[0];
     }
     $msg = null;
     if ($i !== null) {
         $msg = _hx_string_or_null($i->fileName) . ":" . _hx_string_or_null($i->methodName) . ":" . _hx_string_rec($i->lineNumber, "") . ":";
     } else {
         $msg = "";
     }
     $msg .= Std::string($v);
     if (me_cunity_debug_Out::$log !== null) {
         me_cunity_debug_Out::$log->writeString(_hx_string_or_null($msg) . "\n");
         me_cunity_debug_Out::$log->flush();
     } else {
         $_g = me_cunity_debug_Out::$traceTarget;
         switch ($_g->index) {
             case 2:
                 error_log($msg);
                 break;
             case 0:
                 php_Lib::hprint(_hx_string_or_null($msg) . "\r\n");
                 break;
             case 1:
                 php_Lib::hprint(_hx_string_or_null(StringTools::htmlEscape($msg, null)) . "<br/>");
                 break;
             case 3:
                 break;
         }
     }
     if (me_cunity_debug_Out::$once) {
         me_cunity_debug_Out::$once = false;
         me_cunity_debug_Out::_trace("i:" . Std::string(Type::typeof($i)), _hx_anonymous(array("fileName" => "Out.hx", "lineNumber" => 130, "className" => "me.cunity.debug.Out", "methodName" => "_trace")));
         me_cunity_debug_Out::dumpObject($i, _hx_anonymous(array("fileName" => "Out.hx", "lineNumber" => 131, "className" => "me.cunity.debug.Out", "methodName" => "_trace")));
     }
 }
 public function __construct()
 {
     if (!php_Boot::$skip_constructor) {
         $GLOBALS['%s']->push("MainAdmin::new");
         $__hx__spos = $GLOBALS['%s']->length;
         defined('_JEXEC') or die('no joomla here');
         $gc = JControllerLegacy::getInstance('Joomlahaxe');
         try {
             $gc->execute(JRequest::getCmd('task'));
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             $GLOBALS['%e'] = new _hx_array(array());
             while ($GLOBALS['%s']->length >= $__hx__spos) {
                 $GLOBALS['%e']->unshift($GLOBALS['%s']->pop());
             }
             $GLOBALS['%s']->push($GLOBALS['%e'][0]);
             php_Lib::hprint($e);
         }
         $gc->redirect();
         $GLOBALS['%s']->pop();
     }
 }
Beispiel #11
0
 static function main()
 {
     $files = sys_FileSystem::readDirectory("../images");
     $validimages = new _hx_array(array());
     $_g = 0;
     while ($_g < $files->length) {
         $it = $files[$_g];
         ++$_g;
         if (StringTools::endsWith($it, ".jpg") === true) {
             $validimages->push($it);
         } else {
             if (StringTools::endsWith($it, ".png") === true) {
                 $validimages->push($it);
             } else {
                 if (StringTools::endsWith($it, ".gif") === true) {
                     $validimages->push($it);
                 }
             }
         }
         unset($it);
     }
     php_Lib::println(haxe_Json::stringify($validimages, null));
 }
 public function get_clientHeaders()
 {
     if ($this->clientHeaders === null) {
         $this->clientHeaders = new haxe_ds_StringMap();
         $headers = php_Lib::hashOfAssociativeArray(apache_request_headers());
         if (null == $headers) {
             throw new HException('null iterable');
         }
         $__hx__it = $headers->keys();
         while ($__hx__it->hasNext()) {
             unset($name);
             $name = $__hx__it->next();
             $_g = 0;
             $_g1 = _hx_explode(",", $headers->get($name));
             while ($_g < $_g1->length) {
                 $val = $_g1[$_g];
                 ++$_g;
                 ufront_core__MultiValueMap_MultiValueMap_Impl_::add($this->clientHeaders, $name, trim($val));
                 unset($val);
             }
             unset($_g1, $_g);
         }
     }
     return $this->clientHeaders;
 }
Beispiel #13
0
 public function getEditorFields($table_name = null)
 {
     $sb = new StringBuf();
     $phValues = new _hx_array(array());
     $param = new haxe_ds_StringMap();
     $param->set("table", "fly_crm.editor_fields");
     $param->set("where", "field_cost|>-2" . _hx_string_or_null(Model_18($this, $param, $phValues, $sb, $table_name)));
     $param->set("fields", "field_name,field_label,field_type,field_options,table_name");
     $param->set("order", "table_name,field_rank,field_order");
     $param->set("limit", "100");
     $eFields = null;
     $a = $this->doSelect($param, $sb, $phValues);
     $eFields = new _hx_array($a);
     $ret = new haxe_ds_StringMap();
     $_g = 0;
     while ($_g < $eFields->length) {
         $ef = $eFields[$_g];
         ++$_g;
         $table = $ef["table_name"];
         if (!$ret->exists($table)) {
             $ret->set($table, new _hx_array(array()));
         }
         $a1 = $ret->get($table);
         $a1->push(php_Lib::hashOfAssociativeArray($ef));
         $ret->set($table, $a1);
         unset($table, $ef, $a1);
     }
     return $ret;
 }
Beispiel #14
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;
 }
 static function getClasses()
 {
     $path = null;
     $o = _hx_anonymous(array());
     reset(php_Boot::$qtypes);
     while (($path = key(php_Boot::$qtypes)) !== null) {
         php_Lib::appendType($o, _hx_explode(".", $path), php_Boot::$qtypes[$path]);
         next(php_Boot::$qtypes);
     }
     return $o;
 }
 static function rethrow($any)
 {
     php_Lib::rethrow($any);
     return $any;
 }
Beispiel #17
0
 public function save_pay_source($q)
 {
     $account = php_Lib::hashOfAssociativeArray($q->get("account"));
     haxe_Log::trace(Std::string($account) . ":" . Std::string(model_Clients_15($this, $account, $q)), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 676, "className" => "model.Clients", "methodName" => "save_pay_source")));
     $pIt = $account->keys();
     $user = S::$user;
     while ($pIt->hasNext()) {
         $pay_source_id = $pIt->next();
         $log_id = $this->save_pay_source_log($pay_source_id, null);
         if (!$log_id) {
             return false;
         }
         $sql = new StringBuf();
         $uFields = model_Clients::$pay_source_fields;
         $uFields->remove("pay_source_id");
         $bindTypes = "";
         $values2bind = null;
         $i = 0;
         $dbFieldTypes = php_Lib::hashOfAssociativeArray(php_Lib::associativeArrayOfObject(S::$conf->get("dbFieldTypes")));
         $sets = new _hx_array(array());
         $sql->add("UPDATE fly_crm.pay_source SET ");
         $_g = 0;
         while ($_g < $uFields->length) {
             $c = $uFields[$_g];
             ++$_g;
             haxe_Log::trace(_hx_string_or_null($c) . ":" . Std::string(Type::typeof($q->get($c))), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 699, "className" => "model.Clients", "methodName" => "save_pay_source")));
             $p = $q->get($c);
             $val = null;
             if ($p !== null) {
                 if (!Std::is($p, _hx_qtype("String"))) {
                     $valMap = php_Lib::hashOfAssociativeArray($q->get($c));
                     $val = $valMap->get(Std::string($pay_source_id));
                     unset($valMap);
                 } else {
                     $val = $p;
                 }
                 $values2bind[$i++] = $val;
                 $type = $dbFieldTypes->get($c);
                 if (Util::any2bool($type)) {
                     $bindTypes .= _hx_string_or_null($type);
                 } else {
                     $bindTypes .= "s";
                 }
                 $sets->push(_hx_string_or_null($c) . "=?");
                 unset($type);
             }
             unset($val, $p, $c);
         }
         unset($_g);
         if ($sets->length === 0) {
             continue;
         }
         $sql->add($sets->join(","));
         $sql->add(" WHERE pay_source_id=" . _hx_string_rec($pay_source_id, ""));
         $stmt = S::$my->stmt_init();
         haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 727, "className" => "model.Clients", "methodName" => "save_pay_source")));
         $success = $stmt->prepare($sql->b);
         if (!$success) {
             haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 731, "className" => "model.Clients", "methodName" => "save_pay_source")));
             return false;
         }
         haxe_Log::trace($values2bind, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 735, "className" => "model.Clients", "methodName" => "save_pay_source")));
         $success = myBindParam($stmt, $values2bind, $bindTypes);
         haxe_Log::trace("success:" . Std::string($success), _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 737, "className" => "model.Clients", "methodName" => "save_pay_source")));
         if ($success) {
             $success = $stmt->execute();
             if (!$success) {
                 haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "Clients.hx", "lineNumber" => 743, "className" => "model.Clients", "methodName" => "save_pay_source")));
                 return false;
             }
             $this->save_pay_source_log($pay_source_id, $log_id);
             if (!$pIt->hasNext()) {
                 return true;
             }
         }
         unset($values2bind, $uFields, $success, $stmt, $sql, $sets, $pay_source_id, $log_id, $i, $dbFieldTypes, $bindTypes);
     }
     return false;
 }
Beispiel #18
0
 static function println($v)
 {
     php_Lib::hprint($v);
     php_Lib::hprint("\n");
 }
Beispiel #19
0
 static function environment()
 {
     return php_Lib::hashOfAssociativeArray($_SERVER);
 }
 static function parseMultipart($onPart, $onData)
 {
     $a = $_POST;
     if (get_magic_quotes_gpc()) {
         reset($a);
         while (list($k, $v) = each($a)) {
             $a[$k] = stripslashes((string) $v);
         }
     }
     $post = php_Lib::hashOfAssociativeArray($a);
     if (null == $post) {
         throw new HException('null iterable');
     }
     $__hx__it = $post->keys();
     while ($__hx__it->hasNext()) {
         unset($key);
         $key = $__hx__it->next();
         call_user_func_array($onPart, array($key, ""));
         $v = $post->get($key);
         if (is_array($v)) {
             $map = php_Lib::hashOfAssociativeArray($v);
             $first = true;
             if (null == $map) {
                 throw new HException('null iterable');
             }
             $__hx__it2 = $map->iterator();
             while ($__hx__it2->hasNext()) {
                 unset($val);
                 $val = $__hx__it2->next();
                 if (!$first) {
                     call_user_func_array($onPart, array($key, ""));
                 }
                 call_user_func_array($onData, array(haxe_io_Bytes::ofString($val), 0, strlen($val)));
                 $first = false;
             }
             unset($map, $first);
         } else {
             call_user_func_array($onData, array(haxe_io_Bytes::ofString($v), 0, strlen($v)));
         }
         unset($v);
     }
     if (!isset($_FILES)) {
         return;
     }
     $parts = new _hx_array(array_keys($_FILES));
     $_g = 0;
     while ($_g < $parts->length) {
         $part = $parts[$_g];
         ++$_g;
         $info = $_FILES[$part];
         $tmp = $info["tmp_name"];
         $file = $info["name"];
         $err = $info["error"];
         if ($err > 0) {
             switch ($err) {
                 case 1:
                     throw new HException("The uploaded file exceeds the max size of " . _hx_string_or_null(ini_get("upload_max_filesize")));
                     break;
                 case 2:
                     throw new HException("The uploaded file exceeds the max file size directive specified in the HTML form (max is" . _hx_string_or_null(_hx_string_or_null(ini_get("post_max_size")) . ")"));
                     break;
                 case 3:
                     throw new HException("The uploaded file was only partially uploaded");
                     break;
                 case 4:
                     continue 2;
                     break;
                 case 6:
                     throw new HException("Missing a temporary folder");
                     break;
                 case 7:
                     throw new HException("Failed to write file to disk");
                     break;
                 case 8:
                     throw new HException("File upload stopped by extension");
                     break;
             }
         }
         call_user_func_array($onPart, array($part, $file));
         if ("" !== $file) {
             $h = fopen($tmp, "r");
             $bsize = 8192;
             while (!feof($h)) {
                 $buf = fread($h, $bsize);
                 $size = strlen($buf);
                 call_user_func_array($onData, array(haxe_io_Bytes::ofString($buf), 0, $size));
                 unset($size, $buf);
             }
             fclose($h);
             unset($h, $bsize);
         }
         unset($tmp, $part, $info, $file, $err);
     }
 }
 static function getCookies()
 {
     return php_Lib::hashOfAssociativeArray($_COOKIE);
 }
Beispiel #22
0
 public function save($q)
 {
     $lead_id = Std::parseInt($q->get("lead_id"));
     $user = S::$user;
     $log_id = false;
     if ($log_id = $this->saveLog($q, null)) {
         $cTable = "custom_" . Std::string($q->get("entry_list_id"));
         haxe_Log::trace(_hx_string_or_null($cTable) . " log_id:" . Std::string($log_id), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 162, "className" => "model.QC", "methodName" => "save")));
         $primary_id = S::$my->real_escape_string($q->get("primary_id"));
         $sql = new StringBuf();
         $sql->add("UPDATE " . _hx_string_or_null($cTable) . " SET ");
         $cFields = S::tableFields("" . _hx_string_or_null($cTable), null);
         haxe_Log::trace("" . _hx_string_or_null($cTable) . " fields:" . _hx_string_or_null($cFields->toString()), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 177, "className" => "model.QC", "methodName" => "save")));
         $cFields->remove($primary_id);
         $bindTypes = "";
         $values2bind = null;
         $i = 0;
         $dbFieldTypes = php_Lib::hashOfAssociativeArray(php_Lib::associativeArrayOfObject(S::$conf->get("dbFieldTypes")));
         $sets = new _hx_array(array());
         $_g = 0;
         while ($_g < $cFields->length) {
             $c = $cFields[$_g];
             ++$_g;
             $val = $q->get($c);
             if ($val !== null) {
                 if (Std::is($val, _hx_qtype("String"))) {
                     $values2bind[$i++] = $val;
                 } else {
                     $values2bind[$i++] = $val[0];
                 }
                 $type = $dbFieldTypes->get($c);
                 if (Util::any2bool($type)) {
                     $bindTypes .= _hx_string_or_null($type);
                 } else {
                     $bindTypes .= "s";
                 }
                 $sets->push(_hx_string_or_null($c) . "=?");
                 unset($type);
             }
             unset($val, $c);
         }
         $sql->add($sets->join(","));
         $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
         $stmt = S::$my->stmt_init();
         haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 199, "className" => "model.QC", "methodName" => "save")));
         $success = $stmt->prepare($sql->b);
         if (!$success) {
             haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 203, "className" => "model.QC", "methodName" => "save")));
             return false;
         }
         $success = myBindParam($stmt, $values2bind, $bindTypes);
         haxe_Log::trace("success:" . Std::string($success), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 207, "className" => "model.QC", "methodName" => "save")));
         if ($success) {
             $success = $stmt->execute();
             if (!$success) {
                 haxe_Log::trace($stmt->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 213, "className" => "model.QC", "methodName" => "save")));
                 return false;
             }
             $sql = new StringBuf();
             $uFields = model_QC::$vicdial_list_fields;
             $uFields->remove($primary_id);
             $bindTypes = "";
             $values2bind = null;
             $i = 0;
             $sql->add("UPDATE vicidial_list SET ");
             $sets = new _hx_array(array());
             $_g1 = 0;
             while ($_g1 < $uFields->length) {
                 $c1 = $uFields[$_g1];
                 ++$_g1;
                 $val1 = $q->get($c1);
                 if ($val1 !== null) {
                     if (Std::is($val1, _hx_qtype("String"))) {
                         $values2bind[$i++] = $val1;
                     } else {
                         $values2bind[$i++] = $val1[0];
                     }
                     $type1 = $dbFieldTypes->get($c1);
                     if (Util::any2bool($type1)) {
                         $bindTypes .= _hx_string_or_null($type1);
                     } else {
                         $bindTypes .= "s";
                     }
                     $sets->push(_hx_string_or_null($c1) . "=?");
                     unset($type1);
                 }
                 unset($val1, $c1);
             }
             $values2bind[$i++] = S::$user;
             $bindTypes .= "s";
             $sets->push("security_phrase=?");
             $values2bind[$i++] = "XX";
             $bindTypes .= "s";
             $sets->push("state=?");
             if (_hx_equal($q->get("status"), "QCOK") || _hx_equal($q->get("status"), "QCBAD")) {
                 $list_id = 10000;
                 if (_hx_equal($q->get("status"), "QCOK")) {
                     $mID = Std::parseInt($q->get("vendor_lead_code"));
                     if ($mID === null) {
                         $mID = S::newMemberID();
                         $values2bind[$i++] = $mID;
                         $bindTypes .= "s";
                         $sets->push("vendor_lead_code=?");
                     }
                 } else {
                     $list_id = 1800;
                 }
                 $entry_list_id = $q->get("entry_list_id");
                 $values2bind[$i++] = $q->get("status");
                 $bindTypes .= "s";
                 $sets->push("`status`=?");
                 $values2bind[$i++] = $list_id;
                 $bindTypes .= "s";
                 $sets->push("list_id=?");
                 $values2bind[$i++] = $entry_list_id;
                 $bindTypes .= "s";
                 $sets->push("entry_list_id=?");
                 $values2bind[$i++] = $q->get("owner");
                 $bindTypes .= "s";
                 $sets->push("owner=?");
             }
             $sql->add($sets->join(","));
             $sql->add(" WHERE lead_id=" . _hx_string_rec($lead_id, ""));
             $stmt1 = S::$my->stmt_init();
             haxe_Log::trace($sql->b, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 277, "className" => "model.QC", "methodName" => "save")));
             $success1 = $stmt1->prepare($sql->b);
             if (!$success1) {
                 haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 281, "className" => "model.QC", "methodName" => "save")));
                 return false;
             }
             $success1 = myBindParam($stmt1, $values2bind, $bindTypes);
             haxe_Log::trace("success:" . Std::string($success1), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 287, "className" => "model.QC", "methodName" => "save")));
             if ($success1) {
                 $success1 = $stmt1->execute();
                 if (!$success1) {
                     haxe_Log::trace($stmt1->error, _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 293, "className" => "model.QC", "methodName" => "save")));
                     return false;
                 } else {
                     return $this->saveLog($q, $log_id) !== false;
                 }
             }
             return false;
         }
     } else {
         haxe_Log::trace("oops", _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 306, "className" => "model.QC", "methodName" => "save")));
     }
     return false;
 }
Beispiel #23
0
 static function dump($d)
 {
     if (!S::$headerSent) {
         header("Content-Type" . ": " . "application/json");
         S::$headerSent = true;
     }
     php_Lib::println(haxe_Json::phpJsonEncode($d, null, null));
 }