public static function linkCss($link) { if (strstr($link, 'css/') == 0) { $link = CApp::settings("APPLICATION")->template_path . $link; } return '<link href="' . $link . '" type="text/css" rel="stylesheet">'; }
public function __construct($class, $msg = NULL) { if ($msg != NULL) { $this->message = $msg . " в файле " . $this->file . " в строке #" . $this->line; } if (CApp::settings("APPLICATION")->settings['logs_on']) { $log = new CLog(); $log->logging($class, $this->message); } }
public function deleteAction($id) { if ($_SESSION["userRole"] == CApp::settings("USER_ROLES")->ADMIN && $_GET["view"] == "delete" && !empty($_GET["id"])) { $model = new UserModel(); $model->deleteById($id); CApp::redirect(CApp::getLink(array("controller" => "user", "view" => "index"))); } else { CApp::redirect("/"); } }
public static function getTranslateAll($key = null) { $jsonStr = file_get_contents($_SERVER["DOCUMENT_ROOT"] . CApp::settings('APPLICATION')->template_path . "lang/" . CApp::settings('APPLICATION')->lang . "/lang.json"); $arrLang = json_decode($jsonStr, true); $result = ""; if (isset($arrLang[$key]) && !empty($arrLang[$key])) { $result = $arrLang[$key]; } else { $result = $arrLang; } return $result; }
public static function getInstance() { if (self::$instance == null) { $dsn = CApp::settings('APPLICATION')->db['dsn']; $user = CApp::settings('APPLICATION')->db['db_user']; $pass = CApp::settings('APPLICATION')->db['db_pass']; self::$instance = new CModelConnectDB($dsn, $user, $pass); return self::$instance->getDBConnection(); } else { /** * Using the one connection to Database for all * * if it need, it may return false to deny for all other except one */ return false; } }
public function indexAction() { // debug($_SESSION); if ($_SESSION["GMVC_AUTH"] != "Y") { if ($_POST["enter"] && !empty($_POST["password"])) { $pass = filterGetValue($_POST["password"]); // debug($_SESSION); if ($pass == CApp::settings("APPLICATION")->components['gmvc']['gmvc_pass']) { $_SESSION["GMVC_AUTH"] = "Y"; CApp::redirect(""); } } $this->render("login"); } else { $this->render("index"); } }
public function settingsAction() { if ($_SESSION["userRole"] == CApp::settings("USER_ROLES")->ADMIN) { CApp::setTitle(CApp::getAppName() . " | " . CApp::getTranslate('settings')); $arrResult = CApp::getSettingsArray(); if (!empty($_POST["SETTINGS"])) { $settingsArray = array(); foreach ($_POST["SETTINGS"] as $key => $value) { $settingsArray[$key] = filterGetValue($value); } $model = new SiteModel(); $arrResult = $model->update($settingsArray); } $this->render("settings", "site", $arrResult); } else { CApp::redirect("/"); } }
protected function render($view, $controller = "site", $arrResult = [], $template = null) { if ($template == null) { $template = CApp::settings('APPLICATION')->templates['default']; } $cache = new CCache(604800); $flagCache = false; if (!$cache->cacheExists(CApp::getHashCurPage()) && CApp::settings("APPLICATION")->settings['cache_on']) { $flagCache = true; $cache->startCache(); } include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/header.php"; include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/views/" . strtolower($controller) . "/" . $view . ".php"; include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/footer.php"; if ($flagCache) { $cache->writeCache(filterGetValue(CApp::getHashCurPage())); } }
<tr> <td><?php echo CApp::getTranslate("role"); ?> </td> <td> <select name="user[role]"> <option value="1" <?php echo $arrResult["role"] == CApp::settings("USER_ROLES")->ADMIN ? "selected" : ""; ?> ><?php echo CApp::getTranslate("admin"); ?> </option> <option value="0" <?php echo $arrResult["role"] == CApp::settings("USER_ROLES")->GUEST ? "selected" : ""; ?> ><?php echo CApp::getTranslate("user"); ?> </option> </select> </td> </tr> <tr> <td><?php echo CApp::getTranslate("name"); ?> </td> <td><input type="text" name="user[name]" value="<?php echo $arrResult["name"];
"><?php echo $arItem["date_register"]; ?> </a></td> <td><a href="<?php echo $linkView; ?> "><?php echo $arItem["phone"]; ?> </a></td> <td><a href="<?php echo $linkView; ?> "><?php echo $arItem["email"]; ?> </a></td> <td><a href="<?php echo $linkDelete; ?> "><img src="<?php echo CApp::settings("APPLICATION")->template_path . "img"; ?> /del.gif" /></a></td> </tr> <?php } ?> </table> </div>
public function isAdmin() { return $this->user['role'] == CApp::settings("USER_ROLES")->ADMIN ? true : false; }
<?php include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/base/CFiles.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/exceptions/CException.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/cache/CCache.php"; // it is required files CFiles::includeAllDir($_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/base"); // if db enabled in file /protected/config/config.php then it is include files from protected/core/db if (CApp::settings("APPLICATION")->db['db_enabled']) { CFiles::includeAllDir($_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/db"); } spl_autoload_register(function ($className) { $classInfo = []; $autoloadClasses = []; $autoloadClasses = (include $_SERVER["DOCUMENT_ROOT"] . "/engine/protected/core/system/system.php"); $classType = CFiles::getClassType($className); CFiles::autoInclude($className, $autoloadClasses[$classType]); }); function debug($var) { echo "<pre>"; print_r($var); echo "</pre>"; } function filterGetValue($var) { return trim(strip_tags(addslashes($var))); } $settings = CApp::getSettingsArray(); session_start();