Exemple #1
0
 protected function _is_display()
 {
     $user = Loader::get_user();
     $access_zone = config(URL_AP, 'access', 'zone');
     $access_users = (array) config(URL_AP, 'access', 'user');
     $access_groups = (array) config(URL_AP, 'access', 'group');
     $controller_name = Buffer::get(URL_CONTROLLER);
     $controller_zone = config(URL_CONTROLLER, $controller_name, 'zone');
     $permissions = config(URL_AP, 'access', $controller_name, 'permissions') | config(URL_AP, 'access', 'permissions');
     $path_url = get_path_url();
     //Попытка доступа в области закрытые для посещения?
     if ($controller_zone == Z_CLOSED or $access_zone == Z_CLOSED) {
         return FALSE;
     }
     if ($access_zone != Z_PUBLIC and $user->is_visitor()) {
         return FALSE;
     }
     //Проверяем не заблокирован ли IP
     if (config(URL_AP, 'access', 'check_blocked_ip')) {
         Security::check_access_ip();
     }
     //разрешён ли вход этому типу пользователей?
     if (!in_array(User::T_ALL, $access_users) and !empty($access_users) and !in_array($user->get_type(), $access_users)) {
         return FALSE;
     }
     //Состоит ли пользователь в нужных для доступа группах?
     if (!$user->is_groups($access_groups)) {
         return FALSE;
     }
     //Проверка прав доступа при входе в закрытую зону сайта
     if ((bool) $permissions === TRUE and ($controller_zone == Z_PRIVATE or $access_zone == Z_PRIVATE) and !($user->check_permission($path_url) & $permissions)) {
         return FALSE;
     }
     return TRUE;
 }
Exemple #2
0
 public function browse($opt = NULL)
 {
     $interval = 1;
     $type = 'created';
     Builder::add_meta('robots', 'noindex', TRUE);
     Builder::add_css('pages/frontend-browse');
     Builder::set_title(get_string('pages', 'articles-browse') . ' — ' . get_string('url_naming', $type));
     if (!empty($opt)) {
         $type = reset($opt);
         $url_interval = next($opt);
         $interval = $url_interval === FALSE ? 1 : intval($url_interval);
     }
     $articles_model = $this->model('articles_model');
     $header = array();
     $header['type_list'] = $articles_model->get_type_list();
     $header['current'] = $type;
     $header = $this->view('article_types', $header, TRUE);
     $content = array();
     $content['data_list'] = $articles_model->get_articles_list($interval, $type);
     $content['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD) . '/' . $type), 'interval' => $articles_model->get_interval($type), 'selected' => $interval);
     if (empty($content['data_list'])) {
         throw new Exception_wx(4040004, $type, 'none');
     }
     $content = $this->view('article_list', $content, TRUE);
     $nav = array();
     $nav[get_string('url_naming', 'articles')] = 'articles/browse';
     $nav[get_string('url_naming', $type)] = 'articles/browse/' . $type;
     $page = array();
     $page['nav'] =& $nav;
     $page['submenu'] =& $header;
     $page['content'] =& $content;
     $this->view('frontend/frontend', $page);
 }
Exemple #3
0
 public function execute()
 {
     if (Session::get_state() != Session::ST_LIFE) {
         self::set_client_command('refresh', array('url' => 'self'));
         self::set_result(FALSE);
         return;
     }
     $additionally = Buffer::get(Identification_strategy::USER_TYPE) == User::T_ALL ? '' : 'AND `type` = "' . Buffer::get(Identification_strategy::USER_TYPE) . '"';
     $pass_hash_lib = Loader::get_library('pass_hash');
     $captcha_lib = Loader::get_library('captcha');
     $login = db::escape_string($this->login);
     $row = db::row(self::Q_GET_USER_BY_NAME, array('%login' => $login, '%additionally' => $additionally));
     $this->remember = (bool) $this->remember;
     if (empty($row)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введённый логин - не существует!');
     }
     if (!$captcha_lib->check($this->captcha)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный проверочный код!');
     }
     if (!$pass_hash_lib->check_password($row['password'], $this->password)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный пароль!');
     }
     //SELECT DATA_FREE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='db_test' AND TABLE_NAME = 'log_error'
     Session::set_user($row['id'], $this->remember);
     $user = Loader::get_user();
     $secret_key = $user->get_module('secret_key')->regenerate_secret_key();
     self::set_client_command('set_secret_key', array('secretKey' => $secret_key));
     self::set_client_command('refresh', array('url' => 'self'));
 }
Exemple #4
0
/**
 * Created by JetBrains PhpStorm.
 * User: Администратор
 * Date: 01.07.14
 * Time: 1:56
 * To change this template use File | Settings | File Templates.
 */
function menu__left(array $options)
{
    $header = '';
    $body = '';
    $selected = FALSE;
    if (!empty($options['logo'])) {
        $logo =& $options['logo'];
        $logo_img = base_url($logo['image']);
        $header = <<<EOT
        <header class="ml-logo-header">
        <img class="ml-logo" src="{$logo_img}" alt="logo" width="100%" /><h2 class="color-1">{$logo['title']}</h2><h5>{$logo['subtitle']}</h5>
        </header>
EOT;
    }
    $segment_url = Buffer::get(URL_CONTROLLER);
    $full_segment_url = Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD);
    if (!isset($options['items'])) {
        return '';
    }
    foreach ($options['items'] as $section => $items) {
        $body .= "<section><header class=\"ml-section-header\">{$section}</header>";
        foreach ($items as $name => $link) {
            $class = 'ml-item';
            if (empty($link)) {
                $link = $segment_url;
            }
            if (!$selected and strpos($link, $segment_url) !== FALSE) {
                $selected = TRUE;
                $class = 'ml-selected';
            }
            if (strpos($link, $full_segment_url) !== FALSE) {
                $selected = TRUE;
                $body = str_replace('ml-selected', 'ml-item', $body);
                $class = 'ml-selected';
            }
            if (isset($options['noindex']) and in_array($name, $options['noindex'])) {
                $body .= '<noindex><a class="' . $class . '" href="' . base_url($link) . '">' . $name . '</a></noindex>';
            } else {
                $body .= '<a class="' . $class . '" href="' . base_url($link) . '">' . $name . '</a>';
            }
        }
        $body .= '</section>';
    }
    $html = <<<EOT
    <menu class="menu-left">
        <header>
            {$header}
        </header>
        <br />
    {$body}
    </menu>
EOT;
    return $html;
}
Exemple #5
0
 public function execute()
 {
     $ap_name = Buffer::get(URL_AP);
     $controller_name = Buffer::get(URL_CONTROLLER);
     $query_param = Buffer::get(self::QUERY_PARAM, 'post');
     $command = Buffer::get('command', 'post');
     $client_format = Buffer::get('format', 'post');
     $action = Buffer::get('action', 'post');
     $access_zone = config(URL_AP, 'access', 'zone');
     $server_format = config('settings', 'web_format');
     if ($client_format != $server_format) {
         throw new Exception_wx(4060002, $client_format);
     }
     $command = Security::sanitize_string($command);
     $action = Security::sanitize_string($action);
     $command_path = APPPATH . 'commands/' . "{$ap_name}/{$command}" . EXT;
     if (!file_exists($command_path)) {
         $command_path = APPPATH . "modules/{$ap_name}/{$controller_name}/commands/{$command}" . EXT;
     }
     if (!file_exists($command_path)) {
         throw new Exception_wx(4040000, $command_path);
     }
     if ($access_zone != Z_PUBLIC and !Security::check_signature(Buffer::get_post('sig'))) {
         throw new Exception_wx(4030001);
     }
     include_once $command_path;
     if (!class_exists($action)) {
         throw new Exception_wx(4040002, $command_path, $action);
     }
     $query_param = Format::converter($query_param, $server_format, TRUE);
     $command_object = new $action($query_param);
     if (!is_a($command_object, self::COMMAND_CLASS)) {
         throw new Exception_wx(5000002, $command_path, $command_object);
     }
     $command_object->set_module(Buffer::get(URL_CONTROLLER));
     try {
         $command_object->execute();
     } catch (Command_exception $exc) {
         Command::set_result(FALSE);
         $message =& $exc->client_message;
         if (!empty($message)) {
             $options = array('message' => $message, 'type' => 'error');
             Command::set_client_command('show_message', $options);
         }
         Log::log_error($exc, 'command_exception');
         $this->_to_client();
     }
     if (!Command::isset_result()) {
         Command::set_result(TRUE);
     }
     $this->_to_client();
 }
Exemple #6
0
        }
        return "<img {$alt} src=\"{$link}\" {$class} />";
    }
}
//Deprecated
if (!function_exists('article_img')) {
    function article_img($img_name, $class = '', $alt = '')
    {
        $base = '/modules/images/';
        $base .= Buffer::get(URL_CONTROLLER) . '/articles_data/' . Buffer::get(ARTICLE_ID) . '/';
        $link = base_url($base . $img_name);
        if ($class) {
            $class = 'class="' . $class . '"';
 public function log($opt = array())
 {
     if (empty($opt)) {
         $model = $this->model('error_model');
     } else {
         $model = $this->model('cron_model');
     }
     Builder::add_css('pages/backend-error_list');
     $current_interval = 1;
     if (!empty($opt)) {
         $current_interval = intval(reset($opt));
     }
     $contents['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD), TRUE), 'interval' => $model->get_interval(), 'selected' => $current_interval);
     $contents['info_list'] = $model->get_list($current_interval);
     $page = array();
     $page['content'] = $this->view('system_browser', $contents, TRUE);
     $this->view('backend/backend', $page);
 }
Exemple #8
0
 public static function &get_controller($name)
 {
     $class_name = ucfirst($name);
     if (array_key_exists($class_name, self::$_controller_list)) {
         return self::$_controller_list[$class_name];
     }
     $ap_name = Buffer::get(URL_AP);
     $path = PATH_MODULES . "{$ap_name}/{$name}/controllers/{$name}" . EXT;
     if (!file_exists($path)) {
         throw new Exception_wx(4040000, $path);
     }
     include_once $path;
     if (!class_exists($class_name)) {
         throw new Exception_wx(5000001, $path, $class_name);
     }
     self::$_controller_list[$class_name] = new $class_name();
     self::$_controller_list[$class_name]->set_module($name);
     return self::$_controller_list[$class_name];
 }
 public function execute()
 {
     //Проверяем, нужно ли проверять ip адрес у страницы на которую пытаемся попасть
     if (config(URL_AP, 'access', 'check_blocked_ip')) {
         Security::check_access_ip();
     }
     if (!Loader::get_user()->is_visitor() or Buffer::get(URL_AP) == self::AP) {
         header('Location: ' . config('settings', 'base_url'));
         exit;
     }
     Buffer::set(self::USER_TYPE, config(URL_AP, 'access', 'user'));
     Buffer::set(URL_AP, self::AP);
     Buffer::set(URL_CONTROLLER, self::CONTROLLER);
     Buffer::set(URL_METHOD, self::METHOD);
     //Любую команду от пользователя перенаправляем в команду авторизации
     if (is_ajax()) {
         $this->_command();
     } else {
         $this->_display();
     }
 }
Exemple #10
0
            unset($words);
        }
        return $structures[$name];
    }
}
if (!function_exists('config')) {
    function config()
    {
        static $conf;
        $key_buffer = 'reloading_config_status';
        if (empty($conf) or !is_array($conf)) {
            include_once BASEPATH . 'config/config.php';
            if (!isset($config) or !is_array($config)) {
                exit('Config error');
            }
            $conf = $config;
            unset($config);
        }
        $status = Buffer::get($key_buffer);
        $ap_name = Buffer::get(URL_AP);
        if (!empty($ap_name) and $status != $ap_name) {
            if (!is_array($conf)) {
                $conf = array();
            }
            include_once APPPATH . "modules/{$ap_name}/config.php";
            if (array_key_exists(URL_AP, $conf)) {
                unset($conf[URL_AP]);
            }
            if (!isset($config)) {
                exit('Config error');
            }
            $conf[URL_AP] = $config;
            Buffer::set($key_buffer, $ap_name);
            unset($config);
        }
        $argv_list = func_get_args();
        $cursor =& $conf;
        foreach ($argv_list as $key) {
            if (!is_array($cursor) or !array_key_exists($key, $cursor)) {
Exemple #11
0
 public function article($opt = array())
 {
     $articles_model = $this->model('articles_model');
     $contents['type_list'] = $articles_model->get_all_types();
     $type = reset($contents['type_list']);
     $current_interval = 1;
     if (!empty($opt)) {
         $type = reset($opt);
         $current_interval = intval(next($opt));
     }
     if ($type == '_none-type') {
         $contents['info_list'] = $this->model('none_type_articles_model');
     } else {
         $contents['info_list'] = $articles_model->get_list($type, NULL, $current_interval);
     }
     $contents['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD), TRUE), 'interval' => $articles_model->get_interval($type), 'selected' => $current_interval);
     $page = array();
     if ($type == '_none-type') {
         $page['content'] = $this->view('none_type_article_list', $contents, TRUE);
     } else {
         $page['content'] = $this->view('article_list', $contents, TRUE);
     }
     $this->view('backend/backend', $page);
 }
Exemple #12
0
<header class="main-header">
    <menu class="main-header-menu">
        <?php 
$menu = get_structure('frontend/main-menu');
$controller = Buffer::get(URL_CONTROLLER);
$method = Buffer::get(URL_METHOD);
if ($method == 'about') {
    $controller = $method;
}
$isSelected = FALSE;
foreach ($menu as $name => $link) {
    $class = 'main-header-menu-item';
    if (!$isSelected and (strpos($link, $controller) or $method == 'index')) {
        $isSelected = TRUE;
        $class = 'main-header-menu-item-selected';
    }
    echo "<a class=\"{$class}\" href=\"{$link}\">{$name}</a>";
}
?>
    </menu>
    <div class="main-header-line"></div>
    <div class="main-header-green">
        <div class="main-header-state">
            <?php 
$this->widget('menu/path_dispatcher', isset($nav) ? $nav : array());
?>
        </div>
    </div>
    <div class="main-header-logo">
        <h1><?php 
echo get_string('pages', 'logo');
Exemple #13
0
    public static function build_page()
    {
        $is_mobile = (bool) config('web', 'is_mobile');
        $header_css =& self::$_header_css;
        $header_js =& self::$_header_js;
        $footer_js =& self::$_footer_js;
        $plugin_header =& self::$_plugin_header;
        $noscript =& self::$_noscript;
        $js_constants = implode(' ', self::$_js_constants);
        $doctype = $is_mobile ? config('web', 'doctype_mobile') : config('web', 'doctype_pc');
        $favicon_path = config('settings', 'base_url') . "modules/images/favicon.ico";
        $body_page = Buffer::get_output();
        $lang = Buffer::get(URL_LANG) ? Buffer::get(URL_LANG) : config('settings', 'default_lang');
        $meta = '';
        $title = self::$_title;
        //если включено кеширование стилей, то собираем стили страницы в один файл
        if (config(URL_AP, 'cache', 'page_header')) {
            $key = Cache::generate_key();
            $compiled_web = Cache::get_link($key, 'styles');
            //собираем CCS стили
            if (empty($compiled_web)) {
                $cache_content = '';
                foreach (self::$_attach_css as $item) {
                    $cache_content .= file_get_contents(FCPATH . 'modules/styles/' . $item . '.css');
                }
                Cache::set($key, $cache_content, config(URL_AP, 'cache', 'web_lifetime'), 'styles');
                $compiled_web = "./modules/styles/cache/{$key}.css";
            }
            $header_css = attach_css($compiled_web);
            $compiled_web = Cache::get_link($key, 'scripts');
            //собираем JS файлы
            if (empty($compiled_web)) {
                $cache_content = '';
                foreach (self::$_attach_js as $item) {
                    $cache_content .= file_get_contents(FCPATH . 'modules/scripts/' . $item . '.js');
                }
                Cache::set($key, $cache_content, config(URL_AP, 'cache', 'web_lifetime'), 'scripts');
                $compiled_web = "./modules/scripts/cache/{$key}.js";
            }
            $header_js = attach_js($compiled_web);
        }
        //Формируем метатеги
        foreach (self::$_meta_data as $key => &$value) {
            $meta .= "<meta name=\"{$key}\" content=\"{$value}\">";
        }
        $final_page = <<<HTML
        {$doctype}
        <html lang="{$lang}">
            <head>
                <script>
                    {$js_constants}
                </script>
                <title>{$title}</title>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                {$meta}
                <link rel="icon" type="image/x-icon" href="{$favicon_path}">
\t\t\t\t<link rel="shortcut icon" href="{$favicon_path}" type="image/x-icon"> 
                {$header_css}
                {$header_js}
                {$plugin_header}
                <noscript>
                    {$noscript}
                </noscript>
            </head>
            <body>
                {$body_page}
                <!-- system lib-->
                {$footer_js}
            </body>
        </html>
HTML;
        return $final_page;
    }
Exemple #14
0
     if ($return) {
         return $result;
     }
     echo $result;
     return '';
 }
 private function __get_module($storage_name, $place, $module_name)
 {
     $storage =& self::${$storage_name};
     if (!isset($storage[$this->__module])) {
         $storage[$this->__module] = array();
     }
     if (array_key_exists($module_name, $storage[$this->__module])) {
         return $storage[$this->__module][$module_name];
     }
     $ap_name = Buffer::get(URL_AP);
     $path = APPPATH . "modules/{$ap_name}/{$this->__module}/{$place}/{$module_name}" . EXT;
     if (!file_exists($path)) {
         return NULL;
     }
     require_once $path;
     $class_name = ucfirst(basename($module_name));
     if (!class_exists($class_name)) {
 public function get_interval($type = NULL)
 {
     if (!empty($type) and !in_array($type, $this->_special_type)) {
         $this->query['where'] = "`type` = '{$type}'";
     }
     $lang = Buffer::get(URL_LANG);
     if (!empty($lang)) {
         $this->query['where'] = empty($this->query['where']) ? "`lang` = '{$lang}'" : $this->query['where'] . " AND `lang` = '{$lang}'";
     }
     $this->query['select'] = 'count(*)';
     $row_count = (int) $this->scalar();
     $result = intval($row_count / $this->_count);
     if ($result <= 0) {
         $result = 1;
     } elseif ($row_count - $result * $this->_count > 0) {
         ++$result;
     }
     return $result;
 }
Exemple #16
0
 function base_url($path = '', $is_add_ap = FALSE)
 {
     if (empty($path)) {
         return config('settings', 'base_url');
     }
     if (strpos($path, './') !== FALSE) {
         $path = str_replace('./', '', $path);
     }
     $first_symbol = $path[0];
     if ($first_symbol == '/') {
         $path = substr($path, 1);
     }
     if ($is_add_ap) {
         $path = config('route', Buffer::get(URL_AP)) . '/' . $path;
     }
     if (config('settings', 'multilingualism')) {
         $path = Buffer::get(URL_LANG) . '/' . $path;
     }
     return config('settings', 'base_url') . $path;
 }