/** * 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(); }
public function uploadPicture() { if (isset($_FILES['book_picture']) && $_FILES['book_picture']['tmp_name']) { $file = $_FILES['book_picture']; } else { return false; } $size = getimagesize($file['tmp_name']); if ($size[0] > 200 && $size[1] > 200) { $this->_errors[] = 'Не верный размер загружаемого изображения. Размеры картинки должны быть ограничены 200x200px'; return false; } $validTypes = array("image/jpg" => 'jpg', "image/jpeg" => 'jpeg', "image/gif" => 'gif', "image/png" => 'png'); if (in_array($size['mime'], array_keys($validTypes))) { $extension = $validTypes[$size['mime']]; } else { $this->_errors[] = 'Не верный формат загружаемого изображения. Разрешено загружать форматы jpg, jpeg, gif, png'; return false; } $config = Configs::getBlock('upload'); $uploadDir = $config->dir; $fileName = md5(time() . $file['name']) . "." . $extension; $uploadFile = $uploadDir . $fileName; if (move_uploaded_file($file['tmp_name'], $uploadFile)) { if ($this->picture && file_exists($uploadDir . $this->picture)) { unlink($uploadDir . $this->picture); } $this->picture = $fileName; return true; } else { $this->picture = ''; $this->_errors[] = 'Не удалось загрузить картинку.'; return false; } }
/** * Update a specific email campaign * @param string $accessToken - Constant Contact OAuth2 access token * @param Campaign $campaign - Campaign to be updated * @return Campaign */ public function updateCampaign($accessToken, Campaign $campaign) { $baseUrl = Configs::get('endpoints.base_url') . sprintf(Configs::get('endpoints.campaign'), $campaign->id); $url = $this->buildUrl($baseUrl); $response = parent::getRestClient()->put($url, parent::getHeaders($accessToken), $campaign->toJson()); return Campaign::create(json_decode($response->body, true)); }
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"]; } }
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 static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * @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 static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public static function get_by_key($key) { $config = Configs::get(NULL, NULL, "security_key", $key); if (!is_array($config)) { return $config->get_location(); } else { return false; } }
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 init() { date_default_timezone_set("Asia/Ho_Chi_Minh"); parent::init(); $this->pageTitle = "POS NAIL"; if (Yii::app()->session['guestLogin']) { $this->guestLogin = Yii::app()->session['guestLogin']; } $this->configs = Configs::getConfigs(); }
public function __construct() { $this->_dbhost = Configs::get('mysql/host'); $this->_dbuser = Configs::get('mysql/user'); $this->_dbpasswd = Configs::get('mysql/password'); $this->_dbname = Configs::get('mysql/dbname'); @($this->con = @mysqli_connect($this->_dbhost, $this->_dbuser, $this->_dbpasswd, $this->_dbname)); if (!$this->con) { @die('Database connect error! please, see again informaiton about database config of you!' . mysqli_error($this->con)); } }
public static function init() { // Carrega as variaveis de confiruracao para toda a aplicacao Configs::load(); // Define o modulo self::$moduleName = Routes::get('module'); // Define o controller self::setController(); // Define o metodo self::setMethod(); }
public function __construct() { $ldap_host = Configs::get_system_param("ldap_host"); $ldap_port = Configs::get_system_param("ldap_port"); $this->ldap_filter = Configs::get_system_param("ldap_filter"); $this->ldap_dn = Configs::get_system_param("ldap_dn"); $this->link_identifier = @ldap_connect("ldap://" . $ldap_host . ":" . $ldap_port); if (!$this->link_identifier) { trigger_error("LDAP Connection failure", E_USER_ERROR); } ldap_set_option($this->link_identifier, LDAP_OPT_PROTOCOL_VERSION, 3); $this->connection = true; }
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); }
private function __construct() { self::$_dbParams = Configs::getBlock('database'); if (!self::$_dbParams) { throw new Exception('Error: Empty database connection params.'); } $dbParams = self::$_dbParams; $connection = mysqli_connect($dbParams->host, $dbParams->user, $dbParams->password); if (!$connection) { throw new Exception('Error: Unable to connect to MySQL.'); } $db = mysqli_select_db($connection, $dbParams->database); if (!$db) { throw new Exception('Error: Unable to connect to MySQL.'); } mysqli_set_charset($connection, "utf8"); self::$_connection = $connection; self::$_db = $db; }
/** * аунтификация * @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; }
private static function defineRoute() { self::$route = Configs::load('route'); if (strrpos($_SERVER['REQUEST_URI'], '/') > 0) { $routeString = str_replace("?{$_SERVER['QUERY_STRING']}", '', $_SERVER['REQUEST_URI']); $module = reset(array_filter(explode('/', $routeString))); self::$route['module'] = self::getModuleTranslations($module); $routeFile = __MODULES__ . self::$route['module'] . '/route.php'; if (file_exists($routeFile)) { require_once $routeFile; if (isset(self::$routes[$routeString])) { foreach (self::$routes[$routeString] as $routesParamName => $routesParamValue) { self::$route[$routesParamName] = $routesParamValue; } } } if (count($_REQUEST) > 0) { self::$route['params'] = $_REQUEST; } } }
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 path($name, $vars = array()) { //$name es el nombre de nuestra plantilla, por ej, listado.php //$vars es el contenedor de nuestras variables, es un arreglo del tipo llave => valor, opcional. //Traemos una instancia de nuestra clase de configuracion. $config = Configs::getInstance(); //Armamos la ruta a la plantilla $path = $config->get('carpetaVista') . $name; //$path = 'views/'. $name; //Si no existe el fichero en cuestion, mostramos un 404 if (file_exists($path) == false) { trigger_error('Template `' . $path . '` does not exist.', E_USER_NOTICE); return false; } //Si hay variables para asignar, las pasamos una a una. /*if(is_array($vars)){ foreach ($vars as $key => $value){ $key = $value; } }*/ //Finalmente, incluimos la plantilla. return $path; }
<?php Output::set_title("System Configuration"); MainTemplate::set_subtitle("View and edit system configuration settings"); echo "\n\t<table class=\"table table-striped table-hover\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th class=\"title\">Setting</th>\n\t\t\t\t<th class=\"icon\">Value</th>\n\t\t\t\t<th class=\"icon\"></th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>"; $settings = Configs::get(NULL, -1); foreach ($settings as $setting) { echo "<tr>\n\t\t\t\t<td>\n\t\t\t\t\t" . $setting->get_parameter() . "\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<strong>" . $setting->get_val() . "</strong> <br />\n\t\t\t\t</td>\n\t\t\t\t<td class=\"icon\">\n\t\t\t\t\t\n\t\t\t\t\t <!-- Button trigger modal -->\n\t\t\t\t\t <a data-toggle=\"modal\" href=\"#" . $setting->get_parameter() . "\"><span class='glyphicon glyphicon-edit'></span></a>\n\n\t\t\t\t\t <!-- Modal -->\n\t\t\t\t\t <div class=\"modal fade\" id=\"" . $setting->get_parameter() . "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n\t\t\t\t\t <div class=\"modal-dialog\">\n\t\t\t\t\t <div class=\"modal-content\">\n\t\t\t\t\t <div class=\"modal-header\">\n\t\t\t\t\t <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n\t\t\t\t\t <h4 class=\"modal-title\">Change Value for " . $setting->get_parameter() . "</h4>\n\t\t\t\t\t </div>\n\t\t\t\t\t <div class=\"modal-body\">\n\t\t\t\t\t <form role=\"form\">\n\t\t\t\t\t\t\t\t <div class=\"form-group\">\n\t\t\t\t\t\t\t\t <label for=\"settingUpdateText\">Value for " . $setting->get_parameter() . "</label>\n\t\t\t\t\t\t\t\t <input type=\"text\" class=\"form-control\" id=\"settingUpdateText\" placeholder=\"Enter new value\" value=\"" . $setting->get_val() . "\">\n\t\t\t\t\t\t\t\t </div>\n\t\t\t\t\t </div>\n\t\t\t\t\t <div class=\"modal-footer\">\n\t\t\t\t\t <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n\t\t\t\t\t <button type=\"button\" class=\"btn btn-primary\">Save changes</button>\n\t\t\t\t\t </div>\n\t\t\t\t\t </form>\n\t\t\t\t\t </div><!-- /.modal-content -->\n\t\t\t\t\t </div><!-- /.modal-dialog -->\n\t\t\t\t\t </div><!-- /.modal -->\n\t\t\t\t</td>\n\t\t\t</tr>"; } echo "\t\t</tbody>\n\t</table>";
/** * Get all contacts from an individual list * @param string $accessToken - Constant Contact OAuth2 access token * @param string $list_id - list id to retrieve contacts for * @param array $params - query params to attach to request * @return ResultSet */ public function getContactsFromList($accessToken, $list_id, $params = null) { $baseUrl = Configs::get('endpoints.base_url') . sprintf(Configs::get('endpoints.list_contacts'), $list_id); $url = $this->buildUrl($baseUrl, $params); $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken)); $body = json_decode($response->body, true); $contacts = array(); foreach ($body['results'] as $contact) { $contacts[] = Contact::create($contact); } //return new ResultSet($contacts, $body['meta']); return $contacts; }
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."); } }
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."); } }
$pwd = md5($_POST["apw"]); $db->query("INSERT INTO mwc_admin (name,pwd,nick,sacc,access) VALUES ('{$name}','{$pwd}','{$name}','{$name}',1)"); //одмин пошел! $config = array("ctype" => $_SESSION["installmwcct"], "address" => $gaddress, "dlang" => "ru", "theme" => "admin", "db_host" => array($_SESSION["installmwcdb_host"]), "db_name" => array($_SESSION["installmwcdb_name"]), "db_user" => array($_SESSION["installmwcdb_usr"]), "db_upwd" => array($_SESSION["installmwcdb_pwd"]), "licecount" => 1, "defgrp" => 2, "defpage" => "admin", "defController" => "aController", "defModel" => "ausermodel"); $mainpath = "configs" . DIRECTORY_SEPARATOR . "configs.php"; if (file_exists($mainpath)) { require_once $mainpath; } else { die("main cfg error!"); } Configs::writeCfg($config, "main", $cfg["defaultabuild"]); rename("install.php", "configs/install.php"); //убираем модуль админки, юольше не нужен //region for muonline //admin $config = array("ctype" => $_SESSION["installmwcct"], "address" => $gaddress, "dlang" => "ru", "theme" => "muadmin", "db_host" => array($_SESSION["installmwcdb_host"]), "db_name" => array($_SESSION["installmwcdb_name"]), "db_user" => array($_SESSION["installmwcdb_usr"]), "db_upwd" => array($_SESSION["installmwcdb_pwd"]), "licecount" => 1, "defgrp" => 2, "defpage" => "admin", "defController" => "aController", "defModel" => "ausermodel"); Configs::writeCfg($config, "main", "muadmin"); //muonline site $config = array("ctype" => $_SESSION["installmwcct"], "address" => $gaddress, "dlang" => "ru", "theme" => "espada-legend", "usemd5" => 0, "db_host" => array($_SESSION["installmwcdb_host"]), "db_name" => array($_SESSION["installamwcdb_name"]), "db_user" => array($_SESSION["installmwcdb_usr"]), "db_upwd" => array($_SESSION["installmwcdb_pwd"]), "licecount" => 1, "defgrp" => 2, "defpage" => "news", "tryCount" => 5, "banMin" => 15, "defController" => "muController", "defModel" => "MuonlineUser"); Configs::writeCfg($config, "main", "muonline"); //endregion session_unset(); session_destroy(); echo "<tr><td colspan='2' style='font-weight: bold;'>Congratulation! Core installation completed! Please, replace install.php from root directory, if it doesn't. We remind you, that was core install. Next step - build install.\n Core Admin-panel <a href='{$gaddress}control.php'>here</a></td></tr>"; } } catch (Exception $ex) { echo $ex->getMessage(); } break; } }
/** * Constroi array do RouteBuilder * * @param string $routeBuilderFilePath * @return array|null */ public static function getRoutesBuilder($routeBuilderFilePath) { //Pega configurações salvas no arquivo route builder em um array return Configs::getConfig($routeBuilderFilePath, null); }
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); }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new Configs(); } return self::$instance; }
public static function getConfigs() { //$configs = Yii::app()->db->createCommand('SELECT * FROM configs WHERE status = 1')->queryAll(); $configs = Configs::model()->findAll('status = 1'); $arr = array(); if ($configs != null) { foreach ($configs as $r) { if ($r->alias == 'nuumber-mobile' || $r->alias == 'number-tablets' || $r->alias == 'number-laptop') { $configMobile = explode("|", $r->value); if (count($configMobile) == 1) { $configMobile[1] = 0; } if (time() - strtotime($r->updated) > 86400) { $configMobile[0] = $configMobile[0] + $configMobile[1]; $r->value = $configMobile[0] . " | " . $configMobile[1]; $r->save(); } $arr[$r->alias] = $configMobile[0]; } else { $arr[$r->alias] = $r->value; } } } return $arr; }