static function checkAuth() { S::$user = php_Session::get("PHP_AUTH_USER"); haxe_Log::trace(S::$user, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 98, "className" => "S", "methodName" => "checkAuth"))); if (S::$user === null) { return false; } $pass = php_Session::get("PHP_AUTH_PW"); if ($pass === null) { return false; } $res = php_Lib::hashOfAssociativeArray(_hx_deref(new Model(null))->query("SELECT use_non_latin,webroot_writable,pass_hash_enabled,pass_key,pass_cost,hosted_settings FROM system_settings")); if (S_0($pass, $res) === "1") { S::hexit("ENCRYPTED PASSWORDS NOT IMPLEMENTED"); } $res = php_Lib::hashOfAssociativeArray(_hx_deref(new Model(null))->query("SELECT count(*) AS cnt FROM vicidial_users WHERE user=\"" . _hx_string_or_null(S::$user) . "\" and pass=\"" . _hx_string_or_null($pass) . "\" and user_level > 7 and active=\"Y\"")); return $res->exists("0") && S_1($pass, $res) === "1"; }
public function buildCond($whereParam, $sob, $phValues, $first = null) { if ($first === null) { $first = true; } $sb = new StringBuf(); $where = _hx_explode(",", $whereParam); if ($where->length === 0) { return false; } $_g = 0; while ($_g < $where->length) { $w = $where[$_g]; ++$_g; $wData = _hx_string_call($w, "split", array("|")); $values = $wData->slice(2, null); $filter_tables = null; if (Util::any2bool($this->param) && $this->param->exists("filter_tables") && Util::any2bool($this->param->get("filter_tables"))) { $jt = $this->param->get("filter_tables"); $filter_tables = _hx_explode(",", $jt); unset($jt); } haxe_Log::trace(Std::string($wData) . ":" . _hx_string_or_null($this->joinTable) . ":" . Std::string($filter_tables), _hx_anonymous(array("fileName" => "Model.hx", "lineNumber" => 386, "className" => "Model", "methodName" => "buildCond"))); if (_hx_deref(new EReg("^pay_[a-zA-Z_]+\\.", ""))->match($wData[0]) && _hx_array_get(_hx_explode(".", $wData[0]), 0) !== $this->joinTable) { continue; } if ($first) { $sb->add(" WHERE "); } else { $sb->add(" AND "); } $first = false; $_g1 = strtoupper($wData[1]); switch ($_g1) { case "BETWEEN": if (!($values->length === 2) && Lambda::hforeach($values, array(new _hx_lambda(array(&$_g, &$_g1, &$filter_tables, &$first, &$phValues, &$sb, &$sob, &$values, &$w, &$wData, &$where, &$whereParam), "Model_13"), 'execute'))) { S::hexit("BETWEEN needs 2 values - got only:" . _hx_string_or_null($values->join(","))); } $sb->add($this->quoteField($wData[0])); $sb->add(" BETWEEN ? AND ?"); $phValues->push(new _hx_array(array($wData[0], $values[0]))); $phValues->push(new _hx_array(array($wData[0], $values[1]))); break; case "IN": $sb->add($this->quoteField($wData[0])); $sb->add(" IN("); $sb->add($values->map(array(new _hx_lambda(array(&$_g, &$_g1, &$filter_tables, &$first, &$phValues, &$sb, &$sob, &$values, &$w, &$wData, &$where, &$whereParam), "Model_14"), 'execute'))->join(",")); $sb->add(")"); break; case "LIKE": $sb->add($this->quoteField($wData[0])); $sb->add(" LIKE ?"); $phValues->push(new _hx_array(array($wData[0], $wData[2]))); break; default: $sb->add($this->quoteField($wData[0])); if (_hx_deref(new EReg("^(<|>)", ""))->match($wData[1])) { $eR = new EReg("^(<|>)", ""); $eR->match($wData[1]); $val = Std::parseFloat($eR->matchedRight()); $sb->add(_hx_string_or_null($eR->matched(0)) . "?"); $phValues->push(new _hx_array(array($wData[0], $val))); continue 2; } if ($wData[1] === "NULL") { $sb->add(" IS NULL"); } else { $sb->add(" = ?"); $phValues->push(new _hx_array(array($wData[0], $wData[1]))); } break; } unset($_g1); unset($wData, $w, $values, $filter_tables); } $sob->add($sb->b); return true; }
public function checkOrCreateCustomTable($srcTable, $suffix = null) { if ($suffix === null) { $suffix = "log"; } $newTable = S::$my->real_escape_string(_hx_string_or_null($srcTable) . "_" . _hx_string_or_null($suffix)); $res = S::$my->query("SHOW TABLES LIKE \"" . _hx_string_or_null($newTable) . "\"", null); if (Util::any2bool($res) && $res->num_rows === 0) { haxe_Log::trace("CREATE TABLE `" . _hx_string_or_null($newTable) . "` like `" . _hx_string_or_null($srcTable) . "`", _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 254, "className" => "model.QC", "methodName" => "checkOrCreateCustomTable"))); $res1 = S::$my->query("CREATE TABLE `" . _hx_string_or_null($newTable) . "` like `" . _hx_string_or_null($srcTable) . "`", null); if (S::$my->error === "") { $res1 = S::$my->query("ALTER TABLE " . _hx_string_or_null($newTable) . " DROP PRIMARY KEY, ADD `log_id` INT(9) NOT NULL FIRST, ADD PRIMARY KEY (`log_id`)", null); if (S::$my->error !== "") { S::hexit(S::$my->error); } return true; } else { S::hexit(S::$my->error); } } else { haxe_Log::trace("num_rows:" . _hx_string_rec($res->num_rows, ""), _hx_anonymous(array("fileName" => "QC.hx", "lineNumber" => 265, "className" => "model.QC", "methodName" => "checkOrCreateCustomTable"))); } return true; }