Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     // Создаем и настраиваем Смарти
     $this->smarty = new Smarty();
     $this->smarty->compile_check = $this->config->smarty_compile_check;
     $this->smarty->caching = $this->config->smarty_caching;
     $this->smarty->cache_lifetime = $this->config->smarty_cache_lifetime;
     $this->smarty->debugging = $this->config->smarty_debugging;
     $this->smarty->error_reporting = E_ALL & ~E_NOTICE;
     // Берем тему из настроек
     $theme = $this->settings->theme;
     $this->smarty->compile_dir = $this->config->root_dir . '/compiled/' . $theme;
     $this->smarty->template_dir = $this->config->root_dir . '/design/' . $theme . '/html';
     // Создаем папку для скомпилированных шаблонов текущей темы
     if (!is_dir($this->smarty->compile_dir)) {
         mkdir($this->smarty->compile_dir, 0777);
     }
     $this->smarty->cache_dir = 'cache';
     $this->smarty->registerPlugin('modifier', 'resize', array($this, 'resize_modifier'));
     $this->smarty->registerPlugin('modifier', 'token', array($this, 'token_modifier'));
     $this->smarty->registerPlugin('modifier', 'plural', array($this, 'plural_modifier'));
     $this->smarty->registerPlugin('function', 'url', array($this, 'url_modifier'));
     $this->smarty->registerPlugin('modifier', 'first', array($this, 'first_modifier'));
     $this->smarty->registerPlugin('modifier', 'cut', array($this, 'cut_modifier'));
     $this->smarty->registerPlugin('modifier', 'date', array($this, 'date_modifier'));
     $this->smarty->registerPlugin('modifier', 'time', array($this, 'time_modifier'));
     $this->smarty->registerPlugin('function', 'api', array($this, 'api_plugin'));
     if ($this->config->smarty_html_minify) {
         $this->smarty->loadFilter('output', 'trimwhitespace');
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     $this->yandex_metrika_token = $this->settings->yandex_metrika_token;
     $this->yandex_metrika_app_id = $this->settings->yandex_metrika_app_id;
     $this->yandex_metrika_counter_id = $this->settings->yandex_metrika_counter_id;
 }
Ejemplo n.º 3
0
 public function __get($name)
 {
     if ($res = parent::__get($name)) {
         return $res;
     }
     if (isset($this->vars[$name])) {
         return $this->vars[$name];
     } else {
         return null;
     }
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     if (isset($this->settings->price_decimals_point)) {
         $this->decimals_point = $this->settings->price_decimals_point;
     }
     if (isset($this->settings->price_thousands_separator)) {
         $this->thousands_separator = $this->settings->price_thousands_separator;
     }
     $this->design->smarty->registerPlugin('modifier', 'convert', array($this, 'convert'));
     $this->init_currencies();
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     // Вызываем конструктор базового класса
     parent::__construct();
     $p = 13;
     $g = 3;
     $x = 5;
     $r = '';
     $s = $x;
     $bs = explode(' ', $this->config->license);
     foreach ($bs as $bl) {
         for ($i = 0, $m = ''; $i < strlen($bl) && isset($bl[$i + 1]); $i += 2) {
             $a = base_convert($bl[$i], 36, 10) - ($i / 2 + $s) % 27;
             $b = base_convert($bl[$i + 1], 36, 10) - ($i / 2 + $s) % 24;
             $m .= $b * pow($a, $p - $x - 5) % $p;
         }
         $m = base_convert($m, 10, 16);
         $s += $x;
         for ($a = 0; $a < strlen($m); $a += 2) {
             $r .= @chr(hexdec($m[$a] . $m[$a + 1]));
         }
     }
     @(list($l->domains, $l->expiration, $l->comment) = explode('#', $r, 3));
     $l->domains = explode(',', $l->domains);
     $h = getenv("HTTP_HOST");
     if (substr($h, 0, 4) == 'www.') {
         $h = substr($h, 4);
     }
     if ((!in_array($h, $l->domains) || strtotime($l->expiration) < time() && $l->expiration != '*') && $this->request->get('module') != 'LicenseAdmin') {
         header('location: ' . $this->config->root_url . '/backend/index.php?module=LicenseAdmin');
     } else {
         $l->valid = true;
         $this->design->assign('license', $l);
     }
     $this->design->assign('license', $l);
     $this->design->set_templates_dir('backend/design/html');
     $this->design->set_compiled_dir('backend/design/compiled');
     $this->design->assign('settings', $this->settings);
     $this->design->assign('config', $this->config);
     // Язык
     $languages = $this->languages->languages();
     $this->design->assign('languages', $languages);
     if (count($languages)) {
         $post_lang_id = $this->request->post('lang_id', 'integer');
         $admin_lang_id = $post_lang_id ? $post_lang_id : $this->request->get('lang_id', 'integer');
         if ($admin_lang_id) {
             $_SESSION['admin_lang_id'] = $admin_lang_id;
         }
         if (!isset($_SESSION['admin_lang_id'])) {
             $l = reset($languages);
             $_SESSION['admin_lang_id'] = $l->id;
         }
         $this->languages->set_lang_id($_SESSION['admin_lang_id']);
     }
     $lang_id = $this->languages->lang_id();
     $this->design->assign('lang_id', $lang_id);
     $lang_label = '';
     $lang_link = '';
     if ($lang_id && $languages) {
         $lang_label = $languages[$lang_id]->label;
         $first_lang = $this->languages->languages();
         $first_lang = reset($first_lang);
         if ($first_lang->id != $lang_id) {
             $lang_link = $lang_label . '/';
         }
     }
     $this->design->assign('lang_label', $lang_label);
     $this->design->assign('lang_link', $lang_link);
     // Администратор
     $this->manager = $this->managers->get_manager();
     $this->design->assign('manager', $this->manager);
     // Берем название модуля из get-запроса
     $module = $this->request->get('module', 'string');
     $module = preg_replace("/[^A-Za-z0-9]+/", "", $module);
     // Если не запросили модуль - используем модуль первый из разрешенных
     if (empty($module) || !is_file('backend/' . $module . '.php')) {
         foreach ($this->modules_permissions as $m => $p) {
             if ($this->managers->access($p)) {
                 $module = $m;
                 break;
             }
         }
     }
     if (empty($module)) {
         $module = 'ProductsAdmin';
     }
     // Подключаем файл с необходимым модулем
     require_once 'backend/' . $module . '.php';
     // Создаем соответствующий модуль
     if (class_exists($module)) {
         $this->module = new $module();
     } else {
         die("Error creating {$module} class");
     }
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     parent::__construct();
     if (!defined('IS_CLIENT')) {
         define('IS_CLIENT', true);
     }
     // Если инстанс класса уже существует - просто используем уже существующие переменные
     if (self::$view_instance) {
         $this->currency =& self::$view_instance->currency;
         $this->currencies =& self::$view_instance->currencies;
         $this->user =& self::$view_instance->user;
         $this->group =& self::$view_instance->group;
         $this->page =& self::$view_instance->page;
         $this->language =& self::$view_instance->language;
         $this->lang_link =& self::$view_instance->lang_link;
     } else {
         // Сохраняем свой инстанс в статической переменной,
         // чтобы в следующий раз использовать его
         self::$view_instance = $this;
         // Язык
         $languages = $this->languages->languages();
         $lang_link = '';
         if (!empty($languages)) {
             if ($_GET['lang_label']) {
                 $this->language = $this->languages->languages(array('id' => $this->languages->lang_id()));
                 if (!is_object($this->language)) {
                     $_GET['page_url'] = '404';
                     $_GET['module'] = 'PageView';
                 }
                 $lang_link = $this->language->label . '/';
             } else {
                 $this->language = reset($languages);
                 $this->languages->set_lang_id($this->language->id);
             }
             $first_lang = reset($languages);
             $ruri = $_SERVER['REQUEST_URI'];
             if (strlen($this->config->subfolder) > 1) {
                 $pos = strpos($_SERVER['REQUEST_URI'], $this->config->subfolder);
                 if ($pos === 1 || $pos === 0) {
                     $sf = $this->config->subfolder;
                     $ruri = preg_replace("~{$sf}~", '', $ruri);
                 }
             }
             $ruri = explode('/', $ruri);
             $as = $first_lang->id !== $this->languages->lang_id() ? 2 : 1;
             if (is_array($ruri) && $first_lang->id == $this->languages->lang_id() && $ruri[1] == $first_lang->label) {
                 header("HTTP/1.1 301 Moved Permanently");
                 header('Location: ' . $this->config->root_url . '/' . implode('/', array_slice($ruri, 2)));
                 exit;
             }
             foreach ($languages as $l) {
                 // основному языку не нужна метка
                 if ($first_lang->id !== $l->id) {
                     $l->url = $l->label . ($ruri ? '/' . implode('/', array_slice($ruri, $as)) : '');
                 } else {
                     $l->url = $ruri ? implode('/', array_slice($ruri, $as)) : '';
                 }
             }
         }
         $this->design->assign('lang_link', $lang_link);
         $this->lang_link = $lang_link;
         // Все валюты
         $this->currencies = $this->money->get_currencies(array('enabled' => 1));
         // Выбор текущей валюты
         if ($currency_id = $this->request->get('currency_id', 'integer')) {
             $_SESSION['currency_id'] = $currency_id;
             header("Location: " . $this->request->url(array('currency_id' => null)));
         }
         // Берем валюту из сессии
         if (isset($_SESSION['currency_id'])) {
             $this->currency = $this->money->get_currency($_SESSION['currency_id']);
         } else {
             $this->currency = reset($this->currencies);
         }
         // Пользователь, если залогинен
         if (isset($_SESSION['user_id'])) {
             $u = $this->users->get_user(intval($_SESSION['user_id']));
             if ($u && $u->enabled) {
                 $this->user = $u;
                 $this->group = $this->users->get_group($this->user->group_id);
             }
         }
         // Текущая страница (если есть)
         $subdir = substr(dirname(dirname(__FILE__)), strlen($_SERVER['DOCUMENT_ROOT']));
         $page_url = trim(substr($_SERVER['REQUEST_URI'], strlen($subdir)), "/");
         if (strpos($page_url, '?') !== false) {
             $page_url = substr($page_url, 0, strpos($page_url, '?'));
         }
         if (!empty($languages) && !empty($first_lang)) {
             $strlen = $first_lang->id == $this->language->id ? "" : $first_lang->label;
             $page_url = trim(substr($page_url, strlen($strlen)), "/");
         }
         if (in_array($_GET['page_url'], array('all-products', 'discounted', 'bestsellers'))) {
             $page_url = $_GET['page_url'];
         }
         $this->design->assign('language', $this->language);
         $this->design->assign('languages', $languages);
         $this->design->assign('lang', $this->translations);
         $this->design->assign('translate_id', $this->translations->get_labels_ids());
         $this->page = $this->pages->get_page((string) $page_url);
         $this->design->assign('page', $this->page);
         // Передаем в дизайн то, что может понадобиться в нем
         $this->design->assign('currencies', $this->currencies);
         $this->design->assign('currency', $this->currency);
         $this->design->assign('user', $this->user);
         $this->design->assign('group', $this->group);
         $this->design->assign('config', $this->config);
         $this->design->assign('settings', $this->settings);
         // Настраиваем плагины для смарти
         $this->design->smarty->registerPlugin('modifier', 'printa', array($this, 'printa'));
         $this->design->smarty->registerPlugin("function", "get_posts", array($this, 'get_posts_plugin'));
         $this->design->smarty->registerPlugin("function", "get_brands", array($this, 'get_brands_plugin'));
         $this->design->smarty->registerPlugin("function", "get_browsed_products", array($this, 'get_browsed_products'));
         $this->design->smarty->registerPlugin("function", "get_featured_products", array($this, 'get_featured_products_plugin'));
         $this->design->smarty->registerPlugin("function", "get_new_products", array($this, 'get_new_products_plugin'));
         $this->design->smarty->registerPlugin("function", "get_discounted_products", array($this, 'get_discounted_products_plugin'));
         $this->design->smarty->registerPlugin("function", "get_categories", array($this, 'get_categories_plugin'));
         $this->design->smarty->registerPlugin("function", "get_banner", array($this, 'get_banner_plugin'));
     }
 }
Ejemplo n.º 7
0
 /**
  * В конструкторе подключаем базу
  */
 public function __construct()
 {
     parent::__construct();
     $this->connect();
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 9
0
 public function __construct()
 {
     parent::__construct();
     $_POST = $this->stripslashes_recursive($_POST);
     $_GET = $this->stripslashes_recursive($_GET);
 }