public function getPrize($array) { $configs = Configs::readCfg("plugin_mmovote", tbuild); $q = ""; $contis = 0; $ai = new ArrayIterator($array); foreach ($ai as $ar) { if (!empty($ar) && isset($ar["vote"]) && isset($ar["acc"]) && isset($ar["date"]) && strlen(trim($ar["acc"])) <= 10) { $ar["vote"] = str_replace("\n", "", trim($ar["vote"])); $credist = str_replace(array("(votes)", "(account)"), array("{$ar["vote"]}", "'{$ar["acc"]}'"), $configs["mmo_price"]); $ar["date"] = date_::intransDate($ar["date"], true); $q .= "IF EXISTS (SELECT * FROM [MWC_MMO_TOP] WHERE col_memb_id = '{$ar["acc"]}')\r\nBEGIN\r\n IF EXISTS (SELECT * FROM [MWC_MMO_TOP] WHERE col_memb_id = '{$ar["acc"]}' AND DATEDIFF(HOUR,col_LastVote,'" . $ar["date"] . "')>=1)\r\n BEGIN\r\n UPDATE [MWC_MMO_TOP] SET col_votes = col_votes + {$ar["vote"]},col_LastVote='" . $ar["date"] . "' WHERE col_memb_id = '{$ar["acc"]}';\r\n INSERT INTO MWC_logs(col_ErrNum,col_msg,col_mname,col_createTime) VALUES(42,'Account {$ar["acc"]} add 1 vote from mmo top','vote',GETDATE());\r\n {$credist};\r\n END\r\nEND\r\nELSE\r\nBEGIN\r\n INSERT INTO [MWC_MMO_TOP] (col_memb_id, col_LastVote,col_votes) VALUES('{$ar["acc"]}','" . $ar["date"] . "',{$ar["vote"]});\r\n INSERT INTO mwce_settings.dbo.MWC_logs(col_ErrNum,col_msg,col_mname,col_createTime,tbuild) VALUES(15,'Account {$ar["acc"]} add {$ar["vote"]} vote from mmo top ','vote',GETDATE(),'" . tbuild . "');\r\n {$credist};\r\nEND "; $contis++; if ($contis > 99) { $this->db->query($q); $q = ""; $contis = 0; } } } if ($contis > 0) { $this->db->query($q); } $this->db->SQLog("Check mmo top complete... ", "mmovote", 42); }
public function applyChanges($params) { $maincfg = Configs::readCfg("main", tbuild); //читаем конфиг на предмет мд5 и не только //region мд5 да,не/иди нафиг if ((int) $maincfg["usemd5"] > 0) { $r_password = "******"memb_pwd"]}','{$_SESSION["mwcuser"]}')"; } else { $r_password = "******"memb_pwd"]}'"; } //endregion if (!empty($params["memb_newpwd"])) { if ((int) $maincfg["usemd5"] > 0) { $new_password = "******"memb_newpwd"]}','{$_SESSION["mwcuser"]}')"; } else { $new_password = "******"memb_newpwd"]}'"; } } else { $new_password = ""; } $this->db->query("UPDATE MEMB_INFO SET memb_name='{$params["memb_name"]}' {$new_password} WHERE memb___id='{$_SESSION["mwcuser"]}' AND memb__pwd = {$r_password}"); $this->db->SQLog("acount {$_SESSION["mwcuser"]} change self profile", "usercp", 11); if (!empty($params["memb_newpwd"])) { $_SESSION["mwcpwd"] = $params["memb_newpwd"]; } }
/** * Controller constructor. * @param Model $model * @param content $view * @param string $pages * @param int $server */ public function __construct(Model $model, content $view, $pages, $server) { $this->view = $view; $this->model = $model; $this->tick = microtime(); //для проверки времени генерации $this->pages = $pages; $this->serverNum = $server; if (!empty($_SESSION["mwcbuild"])) { $build = $_SESSION["mwcbuild"]; } else { if (!empty($_SESSION["whosconfig"])) { $build = $_SESSION["whosconfig"]; } else { if (!empty($_SESSION["mwcabuild"])) { $build = $_SESSION["mwcabuild"]; } else { $build = NULL; } } } if (!is_null($build)) { $this->configs = Configs::readCfg(get_class($this), $build); } //подгружаем конфиги модуля сразу self::validate(); }
/** * @param int $type * @param string $host * @param string $base * @param string $user * @param string $pwd * @throws Exception */ private function __construct($type = NULL, $host = NULL, $base = NULL, $user = NULL, $pwd = NULL) { if (is_null($type) && is_null($host) && is_null($base) && is_null($user) && is_null($pwd)) { if (empty($_SESSION["mwcserver"])) { $srv = 0; } else { $srv = $_SESSION["mwcserver"]; } $cfg = Configs::readCfg("main", tbuild); $type = $cfg["ctype"]; $host = $cfg["db_host"][$srv]; $base = $cfg["db_name"][$srv]; $user = $cfg["db_user"][$srv]; $pwd = $cfg["db_upwd"][$srv]; } $this->iserror = false; $this->btype = $type; global $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; switch ($type) { case "SQL": case 1: $this->mmsql($host, $base, $user, $pwd); $this->ntype = 1; break; //ms sql connection //ms sql connection case "MPDO": case 2: $this->pdo_mssql($host, $base, $user, $pwd); $this->ntype = 2; break; //pdo ms sql connection //pdo ms sql connection case "ODBC": case 3: $this->odbc_mmsql($host, $base, $user, $pwd); $this->ntype = 3; break; //odbc mssql connection //odbc mssql connection case "MYSQL": case 4: $this->mysql($host, $base, $user, $pwd); $this->ntype = 4; break; // mysql connection // mysql connection case "PDO": case 5: $this->pdo_mysql($host, $base, $user, $pwd); $this->ntype = 5; break; //pdo mysql connection //pdo mysql connection default: throw new Exception("Unknown connect Type '{$type}'"); } }
public function __construct(Model $model, content $view, $plugins, $server) { parent::__construct($model, $view, $plugins, $server); $this->view->add_dict("plugin_" . get_class($this)); $this->view->add_dict("admin"); if (!empty($_SESSION["mwcabuild"])) { $this->configs = Configs::readCfg(get_class($this), $_SESSION["mwcabuild"]); } //подгружаем конфиги модуля сразу); }
public function __construct(Model $model, content $view, $pages, $server) { parent::__construct($model, $view, $pages, $server); $cfg = Configs::readCfg("main", tbuild); if (!empty($cfg["snames"][0])) { $this->view->set("sname", $cfg["snames"][0]); } $this->view->add_dict(get_class($this))->add_dict("titles")->replace($this->pages[get_class($this)]["title"], "title"); //выставляем заголовок текущего модуля заместо |title| }
public function saveAcc($params) { if (!empty($params["memb__pwd"])) { $cfg = Configs::readCfg("main", $_SESSION["mwccfgread"]); if ((int) $cfg["usemd5"] == 1) { $r_password = "******"memb__pwd"]}','{$params["account"]}')"; } else { $r_password = "******"memb__pwd"]}'"; } } else { $r_password = ""; } $this->db->query("UPDATE {$this->dbase}.dbo.MEMB_INFO SET memb_name = '{$params["memb_name"]}', mail_addr = '{$params["mail_addr"]}', bloc_code = '{$params["bloc_code"]}', mwc_bankZ = {$params["mwc_bankZ"]}, mwc_credits = {$params["mwc_credits"]} {$r_password} WHERE memb___id='{$params["account"]}'"); $this->db->SQLog("{$_SESSION["mwcauser"]} edit account {{$params["account"]}}", "m_editchars", 7); }
/** * аунтификация * @param string $login * @param string $password * @return bool * @throws ADODB_Exception * @throws Exception */ public function auth($login, $password) { if ($this->isLoged) { return true; } $maincfg = Configs::readCfg("main", tbuild); //читаем конфиг на предмет мд5 и не только $this->cfg = $maincfg; //region мд5 да,не/иди нафиг if ((int) $maincfg["usemd5"] > 0) { $r_password = "******"; } else { $r_password = "******"; } //endregion $login = substr($login, 0, 10); $result = $this->db->query("SELECT bloc_code FROM MEMB_INFO WHERE memb___id='{$login}' AND memb__pwd = {$r_password}")->FetchRow(); $about = self::aboutUser($login); //узнаем все о пользователе в любом случае if (!empty($result)) { if ((int) $result["bloc_code"] > 0 && $about["mwc_timeban"] != "0" && strtotime($about["mwc_timeban"]) > time()) { //если юзверь забаненный и время бана не истекло и бан не был навсегда return false; } $this->db->query("UPDATE MEMB_INFO SET mwc_tryes = 0, mwc_timeban = NULL WHERE memb___id='{$login}'"); //раз есть логин удачный, снимаем усе и сразу $this->user["login"] = $_SESSION["mwcuser"] = $login; $this->user["pwd"] = $_SESSION["mwcpwd"] = $password; $_SESSION["mwcpoints"] = $about["MWCpoints"]; //делаем пользователя пользователем $this->isLoged = true; return true; } elseif (!empty($about) && (int) $about["bloc_code"] == 0) { if ($about["mwc_tryes"] >= $maincfg["tryCount"]) { $this->db->query("UPDATE MEMB_INFO SET mwc_tryes =0,mwc_timeban =DATEADD(HOUR,{$maincfg["banMin"]},GETDATE()) WHERE memb___id='{$login}'"); $this->db->SQLog("Account {$login} baned for {$maincfg["banMin"]} min for wrong password", 'muonlineUser', 6); //сообщаем одминчегам ^_^ } else { $this->db->query("UPDATE MEMB_INFO SET mwc_tryes +=1 WHERE memb___id='{$login}'"); } } return false; }
public function action_index() { if (!empty($_REQUEST["f_rename"])) { if ($this->model->valid($_POST["f_mail"], $_POST["f_login"]) > 0) { $maincfg = Configs::readCfg("main", tbuild); if ($maincfg["usemd5"] == 0) { $pwd = $this->model->viewPwd($_POST["f_login"]); } else { $pwd = $this->model->getNewPwd($_POST["f_login"], 1); } if ($this->configs["useMail"] != 1) { echo "<script>alert('password is: {$pwd}');</script>"; } else { $c_mail = Configs::readCfg("mail", tbuild); require "libraries/PHPMailer/PHPMailerAutoload.php"; $pop = new POP3(); $pop->Authorise($c_mail["mailhost"], $c_mail["mailport"], $c_mail["mailtmout"], $c_mail["mailboxf"], $c_mail["mailpbf"], $c_mail["maildlvl"]); $mail = new PHPMailer(); $mail->CharSet = "UTF-8"; $mail->Host = $c_mail["mailhost"]; $mail->SMTPAuth = true; $mail->Username = $c_mail["mailboxf"]; $mail->Password = $c_mail["mailpbf"]; $mail->SetFrom($c_mail["mailboxf"], $c_mail["mailnamefrom"]); $mail->AddReplyTo($c_mail["mailboxf"], $c_mail["mailnib"]); $mail->Subject = "Register"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $this->view->set("fl_login", $_POST["f_login"])->set("fl_pwd", $pwd); $mail->MsgHTML($this->view->out("register", "mail", 2)); $mail->AddAddress($_POST['f_mail']); if (!$mail->Send()) { $this->model->toLog("Mail error:" . $mail->ErrorInfo, "register", 13); } echo "<script>alert('Password was send to your e-mail');</script>"; } } } $this->view->out("forgotpwd"); }
public function __construct(Model $model, content $view, $plugins, $server) { parent::__construct($model, $view, $plugins, $server); $this->view->add_dict("plugin_" . get_class($this)); $this->configs = Configs::readCfg("plugin_" . get_class($this), tbuild); }
private function __construct() { $mainpath = "configs" . DIRECTORY_SEPARATOR . "configs.php"; if (file_exists($mainpath)) { require_once $mainpath; } else { die("main cfg error!"); } $globalcfg = Configs::readCfg("main", $cfg["defaultabuild"]); if (empty($_SESSION["mwcabuild"])) { $_SESSION["mwcabuild"] = $cfg["defaultabuild"]; } define("tbuild", $cfg["defaultabuild"]); //$baseDir = substr(dirname( __FILE__ ),0,-4); if (empty($_SESSION["mwcserver"])) { //сервер $_SESSION["mwcserver"] = 0; } if (empty($_SESSION["mwclang"])) { //язык $_SESSION["mwclang"] = $globalcfg["dlang"]; } if (empty($_SESSION["mwcapoints"])) { //группа в админке $_SESSION["mwcapoints"] = $globalcfg["defgrp"]; } $adres = $globalcfg["address"]; //для редактирования билдов (подгрузка всего и вся (настроек) if (isset($_POST["whosconfig"])) { $builds = Tools::getAllBuilds(); if (!empty($builds[$_POST["whosconfig"]])) { $_SESSION["mwccfgread"] = $_POST["whosconfig"]; } } else { if (empty($_SESSION["whosconfig"])) { $_SESSION["whosconfig"] = "admin"; } } $content = new content($adres, $globalcfg["theme"], $_SESSION["mwclang"]); $isBackground = isset($_GET["bg"]) ? 1 : NULL; //если идет обращение к серверу try { $db = connect::start(); $builder = new builder(tbuild, $_SESSION["mwclang"], $_SESSION["mwcserver"]); // проверяем наличие списка модулей и плагинов $action_name = "action_index"; //region плагины $plugin = ""; require_once "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "_dat" . DIRECTORY_SEPARATOR . $_SESSION["mwcserver"] . "_" . $_SESSION["mwclang"] . "_plugins.php"; if (is_array($plugin) && is_null($isBackground)) { $aplugin = new ArrayIterator($plugin); foreach ($aplugin as $name => $param) { if ($param["pstate"] == 2) { $contoller_path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "controller" . DIRECTORY_SEPARATOR . $name . ".php"; if (file_exists($contoller_path) && !empty($param["groups"])) { $paccess = explode(",", $param["groups"]); if (!empty($param["mname"])) { $model_path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "model" . DIRECTORY_SEPARATOR . $param["mname"] . ".php"; if (file_exists($model_path)) { require $model_path; } require $contoller_path; if (in_array($_SESSION["mwcapoints"], $paccess) || in_array(4, $paccess) && class_exists($param["mname"])) { $tmp = $param["mname"]; $model = new $tmp(); $pcontoller = new $name($model, $content, $plugin, $_SESSION["mwcserver"]); if (method_exists($name, "action_index")) { $pcontoller->init(); $pcontoller->action_index(); $pcontoller->parentOut(); } } } else { if (in_array($_SESSION["mwcapoints"], $paccess) || in_array(4, $paccess)) { $model = new $globalcfg["defModel"](); $pcontoller = new PController($model, $content, $plugin, $_SESSION["mwcserver"]); $pcontoller->genNonMVC($contoller_path); $pcontoller->parentOut($name); } } } } } } //endregion //region страницы //region получение контроллера и экшена if (!isset($_GET["p"])) { $controller = $globalcfg["defpage"]; } else { $controller = htmlspecialchars($_GET["p"], ENT_QUOTES); if ($controller == "index") { $controller = $globalcfg["defpage"]; } } if (isset($_GET["a"])) { $action_name = "action_" . $_GET["a"]; } //endregion require_once "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "_dat" . DIRECTORY_SEPARATOR . $_SESSION["mwcserver"] . "_" . $_SESSION["mwclang"] . "_pages.php"; if (empty($page)) { $page = array(); } if (isset($page[$controller])) { $path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . $page[$controller]["ppath"] . DIRECTORY_SEPARATOR . $controller . ".php"; if (file_exists($path)) { $access = explode(",", $page[$controller]["groups"]); if (in_array($_SESSION["mwcapoints"], $access) || $_SESSION["mwcapoints"] == 1) { if (!empty($page[$controller]["mname"]) && !empty($page[$controller]["mpath"])) { $modelpath = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . $page[$controller]["mpath"] . DIRECTORY_SEPARATOR . $page[$controller]["mname"] . ".php"; require_once $path; if (file_exists($modelpath)) { require_once $modelpath; $modelname = $page[$controller]["mname"]; } else { $modelname = "Model"; $action_name = "showError"; $db->SQLog("model {$modelpath} wasn't found", "arouter", 3); } $model = new $modelname($db); $contolinst = new $controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); if (method_exists($controller, $action_name)) { $contolinst->{$action_name}(); } else { $contolinst->action_index(); $db->SQLog("action {$action_name} wasn't found for {$controller}", "arouter", 3); } $contolinst->parentOut($isBackground); } else { $model = new $globalcfg["defModel"](); $contolinst = new $globalcfg["defController"]($model, $content, $page, $_SESSION["mwcserver"]); if (method_exists($contolinst, $action_name) && $action_name != "action_index" && (in_array($_SESSION["mwcapoints"], $access) || $_SESSION["mwcapoints"] == 1)) { $contolinst->{$action_name}(); } else { $contolinst->genNonMVC($path); } $contolinst->parentOut($isBackground); } } else { $model = new Model($db); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(2); $contolinst->parentOut($isBackground); if (!empty($_SESSION["mwcuid"])) { $theGuy = $_SESSION["mwcuid"]; } else { $theGuy = "?"; } if (!empty($_SESSION["mwcauid"])) { $theGuy = $_SESSION["mwcauid"]; } $db->SQLog("user ({$theGuy}) try access to {$controller} but he hasn't access", "arouter", 6); } } else { $model = new Model(); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(3); $contolinst->parentOut($isBackground); $db->SQLog("controller '{$path}' wasn't found", "arouter", 1); } } else { $model = new Model(); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(3); $contolinst->parentOut($isBackground); $db->SQLog("controller '{$controller}' does't register in system", "arouter", 1); } //endregion } catch (Exception $ex) { $stack = $ex->getTrace(); $msg = $ex->getMessage() . " in file: " . basename($stack[3]["file"]) . " line: " . $stack[3]["line"]; self::addlog(tbuild . "_error", $msg, "log"); content::showError("Something went wrong", "please, check logs."); } }
/** * добавляем новый параметр */ public function action_addparam() { if (!empty($_GET["cid"]) && !empty($_POST["pname"]) && isset($_POST["pval"]) && !empty($_POST["id"])) { $id_ = (int) $_GET["cid"]; $name = $_POST["pname"]; $val = $_POST["pval"]; $cid = $_POST["id"]; $dirInfo = scandir("build" . DIRECTORY_SEPARATOR . $_SESSION["mwccfgread"] . DIRECTORY_SEPARATOR . "configs"); $adirInfo = new ArrayIterator($dirInfo); foreach ($adirInfo as $id => $fname) { if ($id == $id_) { $tm_ = substr($fname, 0, -4); break; } } if ($tm_ == $cid) { $cfg = Configs::readCfg($tm_, $_SESSION["mwccfgread"]); if (!is_array($cfg)) { $cfg = array(); } $cfg[$name] = $val; Configs::writeCfg($cfg, $tm_, $_SESSION["mwccfgread"]); if (!empty($_POST["ldesc"])) { $path = "build" . DIRECTORY_SEPARATOR . $_SESSION["mwccfgread"] . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $_SESSION["mwclang"] . DIRECTORY_SEPARATOR . "cfg_{$cid}.php"; if (file_exists($path)) { require $path; $lang[$name] = $_POST["ldesc"]; $ai = new ArrayIterator($lang); $content = '<?php '; foreach ($ai as $id => $val) { $content .= '$lang["' . $id . '"]="' . $val . '"; '; } $fh = fopen($path, "w"); fwrite($fh, $content); fclose($fh); } } } } }
public function init() { parent::init(); $this->configs += Configs::readCfg("unic", tbuild); }
public function action_buy() { if (!empty($_GET["get"])) { $inom = (int) $_GET["get"]; $harm_ = "build/" . tbuild . "/_dat/items/harmony.php"; if (file_exists($harm_)) { require $harm_; } else { $harm = array(); } if (file_exists("build/" . tbuild . "/_dat/items/items.php")) { require "build/" . tbuild . "/_dat/items/items.php"; } else { $item = array(); } $cfg = Configs::readCfg("webshop", tbuild); $emptyItem = str_pad("", $cfg["hexLen"], "F", STR_PAD_BOTH); $item_ = $this->model->getInfo($inom); if ($item_["col_hex"] != $emptyItem) { $user = $this->model->aboutUser($_SESSION["mwcuser"]); if ($user["mwc_bankZ"] >= $item_["col_prise"]) { $_item = rItem::Read($item_["col_hex"], $harm); $wh = $this->model->getWH($_SESSION["mwcuser"], $cfg["hexLen"]); $place = rItem::search($wh, $_item["x"], $_item["y"], $item, $cfg["hexLen"], 120); if ($place >= 0) { if ($this->model->buyItm($place, $cfg["hexLen"], $inom, $item_["col_hex"])) { echo $user["mwc_bankZ"] - $item_["col_prise"]; } else { echo "0"; } } } } } }
public function init() { $this->unicCfg = Configs::readCfg("unic", tbuild); }
private function __construct() { /** * если не установлен билд, то сначала грузим главный конфиг. в нем читаем билд, * устанавливаем и далее вычитываем конфиг конкретного билда. */ $mainpath = "configs" . DIRECTORY_SEPARATOR . "configs.php"; if (file_exists($mainpath)) { require_once $mainpath; } else { die("main cfg error!"); } if (empty($_SESSION["mwcbuild"])) { $_SESSION["mwcbuild"] = $cfg["defaultbuild"]; } define("tbuild", $_SESSION["mwcbuild"]); $globalcfg = Configs::readCfg("main", $_SESSION["mwcbuild"]); if (empty($_SESSION["mwcserver"])) { //сервер $_SESSION["mwcserver"] = 0; } if (empty($_SESSION["mwcbuild"])) { //сервер $_SESSION["mwcbuild"] = $globalcfg["tbuild"]; } if (empty($_SESSION["mwclang"])) { //язык $_SESSION["mwclang"] = $globalcfg["dlang"]; } if (empty($_SESSION["mwcpoints"])) { //группа $_SESSION["mwcpoints"] = $globalcfg["defgrp"]; } $adres = $globalcfg["address"]; try { $content = new content($adres, $globalcfg["theme"], $_SESSION["mwclang"]); } catch (Exception $e) { echo $e->getMessage(); die; } $isBackground = isset($_GET["bg"]) ? 1 : NULL; //если идет обращение к серверу try { $db = connect::start(); if (empty($_SESSION["mwcuid"])) { $uid = 0; } else { $uid = $_SESSION["mwcuid"]; } $builder = new builder(tbuild, $_SESSION["mwclang"], $_SESSION["mwcserver"]); // проверяем наличие списка модулей и плагинов //region плагины $plugin = ""; require_once "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "_dat" . DIRECTORY_SEPARATOR . $_SESSION["mwcserver"] . "_" . $_SESSION["mwclang"] . "_plugins.php"; if (is_array($plugin) && is_null($isBackground)) { foreach ($plugin as $name => $param) { if ($param["pstate"] == 1) { $contoller_path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "controller" . DIRECTORY_SEPARATOR . $name . ".php"; //region проверка на пользователя (если есть) $ccfg = Configs::readCfg("plugin_" . $name, $_SESSION["mwcbuild"]); if (!empty($ccfg["allowedUsrs"])) { $usrs = explode(",", $ccfg["allowedUsrs"]); if (!in_array($uid, $usrs)) { $err = 2; } else { $err = 0; } } else { $err = 2; } //endregion if (file_exists($contoller_path) && (!empty($param["groups"]) || $err == 0)) { if (empty($param["groups"])) { $paccess = array(); } else { $paccess = explode(",", $param["groups"]); } try { if (!empty($param["mname"])) { $model_path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "model" . DIRECTORY_SEPARATOR . $param["mname"] . ".php"; if (file_exists($model_path)) { require $model_path; } require $contoller_path; if ((in_array($_SESSION["mwcpoints"], $paccess) || in_array(4, $paccess) || $err == 0) && class_exists($param["mname"])) { $tmp = $param["mname"]; $model = new $tmp(); $pcontoller = new $name($model, $content, $plugin, $_SESSION["mwcserver"]); if (method_exists($name, "action_index")) { $pcontoller->init(); $pcontoller->action_index(); $pcontoller->parentOut(); } } } else { if (in_array($_SESSION["mwcpoints"], $paccess) || in_array(4, $paccess)) { $model = new $globalcfg["defModel"](); $pcontoller = new PController($model, $content, $plugin, $_SESSION["mwcserver"]); $pcontoller->genNonMVC($contoller_path); $pcontoller->parentOut($name); } } } catch (Exception $e) { $content->error(1); $content->setFContainer("plugin_{$name}", true); } } } } } //endregion //region страницы //region получение контроллера и экшена $action_name = "action_index"; if (!isset($_GET["p"])) { $controller = $globalcfg["defpage"]; } else { $controller = htmlspecialchars($_GET["p"], ENT_QUOTES); if ($controller == "index") { $controller = $globalcfg["defpage"]; } } if (isset($_GET["a"])) { $action_name = "action_" . $_GET["a"]; } //endregion require_once "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . "_dat" . DIRECTORY_SEPARATOR . $_SESSION["mwcserver"] . "_" . $_SESSION["mwclang"] . "_pages.php"; if (isset($page[$controller])) { $path = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . $page[$controller]["ppath"] . DIRECTORY_SEPARATOR . $controller . ".php"; if (file_exists($path)) { $access = explode(",", $page[$controller]["groups"]); //region проверка на пользователя (если есть) $ccfg = Configs::readCfg($controller, $_SESSION["mwcbuild"]); if (!empty($ccfg["allowedUsrs"])) { $usrs = explode(",", $ccfg["allowedUsrs"]); if (!in_array($uid, $usrs)) { $err = 2; } else { $err = 0; } } else { $err = 2; } //endregion try { if (in_array($_SESSION["mwcpoints"], $access) || in_array(4, $access) || $err == 0) { if (!empty($page[$controller]["mname"]) && !empty($page[$controller]["mpath"])) { $modelpath = "build" . DIRECTORY_SEPARATOR . tbuild . DIRECTORY_SEPARATOR . $page[$controller]["mpath"] . DIRECTORY_SEPARATOR . $page[$controller]["mname"] . ".php"; require_once $path; if (file_exists($modelpath)) { require_once $modelpath; $modelname = $page[$controller]["mname"]; } else { $modelname = "Model"; $action_name = "showError"; $db->SQLog("model {$modelpath} wasn't found", "router", 2); } $model = new $modelname($db); $contolinst = new $controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); if (method_exists($controller, $action_name)) { $contolinst->{$action_name}(); } else { $contolinst->action_index(); $db->SQLog("{$controller} hasn't action {$action_name}", "router", 3); } $contolinst->parentOut($isBackground); } else { $model = new $globalcfg["defModel"](); $contolinst = new $globalcfg["defController"]($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->genNonMVC($path); $contolinst->parentOut($isBackground); } } else { $model = new Model($db); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(2); $contolinst->parentOut($isBackground); if (!empty($_SESSION["mwcuid"])) { $theGuy = $_SESSION["mwcuid"]; } else { $theGuy = "?"; } $db->SQLog("user({$theGuy}) try access to {$controller} but he hasn't access", "router", 6); } } catch (Exception $e) { $model = new Model($db); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showErrorText($e->getMessage()); $contolinst->parentOut($isBackground); } } else { $model = new Model($db); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(3); $contolinst->parentOut($isBackground); $db->SQLog("controller {$path} ({$controller}) wasn't found", "router", 1, true); } } else { $model = new Model($db); $contolinst = new Controller($model, $content, $page, $_SESSION["mwcserver"]); $contolinst->init(); $contolinst->showError(3); $contolinst->parentOut($isBackground); $db->SQLog("controller {$controller} wasn't register", "router", 1); } //endregion } catch (Exception $ex) { $stack = $ex->getTrace(); $msg = $ex->getMessage() . " in file: " . basename($stack[3]["file"]) . " line: " . $stack[3]["line"]; self::addlog(tbuild . "_error", $msg, "log"); content::showError("Something went wrong", "please, check logs."); } }
public function action_setregister() { if ($this->configs["useCaptcha"] == 1 && empty($_POST["rcaptch"])) { echo "0::" . $this->view->getVal("l_err4"); return; } if (!empty($_POST["rlogin"]) && !empty($_POST["rpwd"]) && !empty($_POST["rrpwd"]) && !empty($_POST["rmail"])) { $login = $_POST["rlogin"]; if (!preg_match("#^[aA-zZ0-9\\-_]+\$#", $login)) { echo "0::" . $this->view->getVal("l_err1"); return; } $pwd = $_POST["rpwd"]; if (!preg_match("#^[aA-zZ0-9\\-_]+\$#", $pwd)) { echo "0::" . $this->view->getVal("l_err2"); return; } $rpwd = $_POST["rrpwd"]; if ($pwd != $rpwd) { echo "0::" . $this->view->getVal("l_err3"); return; } $email = $_POST["rmail"]; if ($this->configs["useCaptcha"] != 0) { $cp = $_POST["rcaptch"]; if ($cp != $_SESSION["captcha_keystring"]) { echo "0::" . $this->view->getVal("l_err4"); return; } unset($_SESSION["captcha_keystring"]); } if (!$this->model->checkLogin($login)) { echo "0::" . $this->view->getVal("l_err5"); return; } //l_err7 if ($this->configs["useMail"] == 0) { $this->model->reg($login, $pwd, $email); echo "1::" . $this->view->getVal("l_err6"); } else { $id = $this->model->regM($login, $pwd, $email, $this->configs["defGrp"]); if ($id > 0) { //region отсылаем почту $hash = md5($id . "-=-" . $email); $c_mail = Configs::readCfg("mail", tbuild); require "libraries/PHPMailer/PHPMailerAutoload.php"; $pop = new POP3(); $pop->Authorise($c_mail["mailhost"], $c_mail["mailport"], $c_mail["mailtmout"], $c_mail["mailboxf"], $c_mail["mailpbf"], $c_mail["maildlvl"]); $mail = new PHPMailer(); $mail->CharSet = "UTF-8"; // $mail->IsSMTP(); //$mail->SMTPDebug = $c_mail["maildlvl"]; $mail->Host = $c_mail["mailhost"]; $mail->SMTPAuth = true; $mail->Username = $c_mail["mailboxf"]; $mail->Password = $c_mail["mailpbf"]; $mail->SetFrom($c_mail["mailboxf"], $c_mail["mailnamefrom"]); $mail->AddReplyTo($c_mail["mailboxf"], $c_mail["mailnib"]); $mail->Subject = "Register"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $this->view->set("hash", $hash . "_" . $id); $mail->MsgHTML($this->view->out("register", "mail", 2)); $mail->AddAddress($email); if (!$mail->Send()) { $this->model->toLog("Mail error:" . $mail->ErrorInfo, "register", 13); } //endregion echo "1::" . $this->view->getVal("l_err7"); } else { echo "0::" . $this->view->getVal("l_err5"); } } } }