public function loadControllerBackend($controller_name, $request) { $ctrl_file = $this->cms_config->root_path . 'system/controllers/' . $controller_name . '/backend.php'; if (!file_exists($ctrl_file)) { cmsCore::error(sprintf(LANG_CP_ERR_BACKEND_NOT_FOUND, $controller_name)); } include_once $ctrl_file; $controller_class = 'backend' . ucfirst($controller_name); $backend = new $controller_class($request); // Устанавливаем корень для URL внутри бакенда $backend->setRootURL($this->name . '/controllers/edit/' . $controller_name); return $backend; }
/** * Выполняет запрос в базе * @param string $sql Строка запроса * @param array|string $params Аргументы запроса, которые будут переданы в vsprintf * @param bool $quiet В случае ошибки запроса отдавать false, а не "умирать" * @return boolean */ public function query($sql, $params = false, $quiet = false) { $start_time = microtime(true); $config = cmsConfig::getInstance(); $sql = str_replace(array('{#}{users}', '{users}', '{#}'), array($config->db_users_table, $config->db_users_table, $this->prefix), $sql); if ($params) { if (!is_array($params)) { $params = array($params); } foreach ($params as $index => $param) { if (!is_numeric($param)) { $params[$index] = $this->escape($param); } } $sql = vsprintf($sql, $params); } if (PHP_SAPI == 'cli' && time() - $this->init_start_time >= $this->reconnect_time) { $this->reconnect(); } $result = $this->mysqli->query($sql); if ($config->debug) { $this->query_count++; $trace = debug_backtrace(); if (isset($trace[1]['file']) && isset($trace[1]['function'])) { $src = $trace[1]['file'] . ' => ' . $trace[1]['line'] . ' => ' . $trace[1]['function'] . '()'; $src = str_replace($config->root_path, '', $src); } else { $src = ''; } $this->query_list[] = array('sql' => $sql, 'src' => $src, 'time' => microtime(true) - $start_time); } if (!$this->mysqli->errno) { return $result; } if ($quiet) { return false; } cmsCore::error(sprintf(ERR_DATABASE_QUERY, $this->error()), $sql); }
if (!$config->isReady()) { $root = str_replace(str_replace(DIRECTORY_SEPARATOR, '/', realpath(ROOT)), '', str_replace(DIRECTORY_SEPARATOR, '/', PATH)); header('location:' . $root . '/install/'); die; } // Загружаем локализацию cmsCore::loadLanguage(); // устанавливаем локаль языка if (function_exists('lang_setlocale')) { lang_setlocale(); } // Устанавливаем часовую зону date_default_timezone_set($config->time_zone); // Подключаем все необходимые классы и библиотеки cmsCore::loadLib('html.helper'); cmsCore::loadLib('strings.helper'); cmsCore::loadLib('files.helper'); cmsCore::loadLib('spyc.class'); // подключаем хелпер шаблона, если он есть if (!cmsCore::includeFile('templates/' . $config->template . '/assets/helper.php')) { cmsCore::loadLib('template.helper'); } // Инициализируем ядро $core = cmsCore::getInstance(); // Подключаем базу $core->connectDB(); if (!$core->db->ready()) { cmsCore::error(ERR_DATABASE_CONNECT, $core->db->connectError()); } // Запускаем кеш cmsCache::getInstance()->start();
/** * Выводит окончательный вид страницы в браузер */ public function renderPage() { $config = cmsConfig::getInstance(); $layout = $this->getLayout(); $template_file = $this->path . '/' . $layout . '.tpl.php'; if (file_exists($template_file)) { if (!$config->min_html) { include $template_file; } if ($config->min_html) { ob_start(); include $template_file; echo html_minify(ob_get_clean()); } } else { cmsCore::error(ERR_TEMPLATE_NOT_FOUND . ': ' . $this->name . ':' . $layout); } }
/** * Выводит окончательный вид страницы в браузер */ public function renderPage() { $config = $this->site_config; $layout = $this->getLayout(); $template_file = $this->getTplFilePath($layout . '.tpl.php'); $device_type = cmsRequest::getDeviceType(); if ($template_file) { if (!$config->min_html) { include $template_file; } if ($config->min_html) { ob_start(); include $template_file; echo html_minify(ob_get_clean()); } } else { cmsCore::error(ERR_TEMPLATE_NOT_FOUND . ': ' . $this->name . ':' . $layout); } }