From de69c5b0f84f84a80bcc53388561da3432eb91ef Mon Sep 17 00:00:00 2001 From: Erko Evgen Date: Mon, 7 Mar 2016 12:00:50 +0200 Subject: [PATCH] add dir cache and mkdir compiled --- api/Design.php | 5 +- cache/index.html | 0 simpla/IndexAdmin.php | 326 +++++++++++++++++++++--------------------- 3 files changed, 169 insertions(+), 162 deletions(-) create mode 100644 cache/index.html diff --git a/api/Design.php b/api/Design.php index 12e879f..4cd5899 100755 --- a/api/Design.php +++ b/api/Design.php @@ -35,6 +35,9 @@ public function __construct() $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->config->root_dir.'/compiled')) + mkdir($this->config->root_dir.'/compiled', 0777); + // Создаем папку для скомпилированных шаблонов текущей темы if(!is_dir($this->smarty->compile_dir)) mkdir($this->smarty->compile_dir, 0777); @@ -299,4 +302,4 @@ public function api_plugin($params, &$smarty) $res = $this->$module->$method($params); $smarty->assign($var, $res); } -} \ No newline at end of file +} diff --git a/cache/index.html b/cache/index.html new file mode 100644 index 0000000..e69de29 diff --git a/simpla/IndexAdmin.php b/simpla/IndexAdmin.php index b06c117..c4197bb 100755 --- a/simpla/IndexAdmin.php +++ b/simpla/IndexAdmin.php @@ -1,161 +1,165 @@ - 'products', - 'ProductAdmin' => 'products', - 'CategoriesAdmin' => 'categories', - 'CategoryAdmin' => 'categories', - 'BrandsAdmin' => 'brands', - 'BrandAdmin' => 'brands', - 'FeaturesAdmin' => 'features', - 'FeatureAdmin' => 'features', - 'OrdersAdmin' => 'orders', - 'OrderAdmin' => 'orders', - 'OrdersLabelsAdmin' => 'labels', - 'OrdersLabelAdmin' => 'labels', - 'UsersAdmin' => 'users', - 'UserAdmin' => 'users', - 'ExportUsersAdmin' => 'users', - 'GroupsAdmin' => 'groups', - 'GroupAdmin' => 'groups', - 'CouponsAdmin' => 'coupons', - 'CouponAdmin' => 'coupons', - 'PagesAdmin' => 'pages', - 'PageAdmin' => 'pages', - 'BlogAdmin' => 'blog', - 'PostAdmin' => 'blog', - 'CommentsAdmin' => 'comments', - 'FeedbacksAdmin' => 'feedbacks', - 'ImportAdmin' => 'import', - 'ExportAdmin' => 'export', - 'BackupAdmin' => 'backup', - 'StatsAdmin' => 'stats', - 'ThemeAdmin' => 'design', - 'StylesAdmin' => 'design', - 'TemplatesAdmin' => 'design', - 'ImagesAdmin' => 'design', - 'SettingsAdmin' => 'settings', - 'CurrencyAdmin' => 'currency', - 'DeliveriesAdmin' => 'delivery', - 'DeliveryAdmin' => 'delivery', - 'PaymentMethodAdmin' => 'payment', - 'PaymentMethodsAdmin' => 'payment', - 'ManagersAdmin' => 'managers', - 'ManagerAdmin' => 'managers', - 'LicenseAdmin' => 'license' - ); - - // Конструктор - public function __construct() - { - // Вызываем конструктор базового класса - parent::__construct(); - - - $p=11; $g=2; $x=7; $r = ''; $s = $x; - $bs = explode(' ', $this->config->license); - foreach($bs as $bl){ - for($i=0, $m=''; $idomains, $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)expiration!='*')) && $this->request->get('module')!='LicenseAdmin') - header('location: '.$this->config->root_url.'/simpla/index.php?module=LicenseAdmin'); - else - { - $l->valid = true; - $this->design->assign('license', $l); - } - - $this->design->assign('license', $l); - - $this->design->set_templates_dir('simpla/design/html'); - $this->design->set_compiled_dir('simpla/design/compiled'); - - $this->design->assign('settings', $this->settings); - $this->design->assign('config', $this->config); - - // Администратор - $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('simpla/'.$module.'.php')) - { - foreach($this->modules_permissions as $m=>$p) - { - if($this->managers->access($p)) - { - $module = $m; - break; - } - } - } - if(empty($module)) - $module = 'ProductsAdmin'; - - // Подключаем файл с необходимым модулем - require_once('simpla/'.$module.'.php'); - - // Создаем соответствующий модуль - if(class_exists($module)) - $this->module = new $module(); - else - die("Error creating $module class"); - - } - - function fetch() - { - $currency = $this->money->get_currency(); - $this->design->assign("currency", $currency); - - // Проверка прав доступа к модулю - if(isset($this->modules_permissions[get_class($this->module)]) - && $this->managers->access($this->modules_permissions[get_class($this->module)])) - { - $content = $this->module->fetch(); - $this->design->assign("content", $content); - } - else - { - $this->design->assign("content", "Permission denied"); - } - - // Счетчики для верхнего меню - $new_orders_counter = $this->orders->count_orders(array('status'=>0)); - $this->design->assign("new_orders_counter", $new_orders_counter); - - $new_comments_counter = $this->comments->count_comments(array('approved'=>0)); - $this->design->assign("new_comments_counter", $new_comments_counter); - - // Создаем текущую обертку сайта (обычно index.tpl) - $wrapper = $this->design->smarty->getTemplateVars('wrapper'); - if(is_null($wrapper)) - $wrapper = 'index.tpl'; - - if(!empty($wrapper)) - return $this->body = $this->design->fetch($wrapper); - else - return $this->body = $content; - } -} \ No newline at end of file + 'products', + 'ProductAdmin' => 'products', + 'CategoriesAdmin' => 'categories', + 'CategoryAdmin' => 'categories', + 'BrandsAdmin' => 'brands', + 'BrandAdmin' => 'brands', + 'FeaturesAdmin' => 'features', + 'FeatureAdmin' => 'features', + 'OrdersAdmin' => 'orders', + 'OrderAdmin' => 'orders', + 'OrdersLabelsAdmin' => 'labels', + 'OrdersLabelAdmin' => 'labels', + 'UsersAdmin' => 'users', + 'UserAdmin' => 'users', + 'ExportUsersAdmin' => 'users', + 'GroupsAdmin' => 'groups', + 'GroupAdmin' => 'groups', + 'CouponsAdmin' => 'coupons', + 'CouponAdmin' => 'coupons', + 'PagesAdmin' => 'pages', + 'PageAdmin' => 'pages', + 'BlogAdmin' => 'blog', + 'PostAdmin' => 'blog', + 'CommentsAdmin' => 'comments', + 'FeedbacksAdmin' => 'feedbacks', + 'ImportAdmin' => 'import', + 'ExportAdmin' => 'export', + 'BackupAdmin' => 'backup', + 'StatsAdmin' => 'stats', + 'ThemeAdmin' => 'design', + 'StylesAdmin' => 'design', + 'TemplatesAdmin' => 'design', + 'ImagesAdmin' => 'design', + 'SettingsAdmin' => 'settings', + 'CurrencyAdmin' => 'currency', + 'DeliveriesAdmin' => 'delivery', + 'DeliveryAdmin' => 'delivery', + 'PaymentMethodAdmin' => 'payment', + 'PaymentMethodsAdmin' => 'payment', + 'ManagersAdmin' => 'managers', + 'ManagerAdmin' => 'managers', + 'LicenseAdmin' => 'license' + ); + + // Конструктор + public function __construct() + { + // Вызываем конструктор базового класса + parent::__construct(); + + + $p=11; $g=2; $x=7; $r = ''; $s = $x; + $bs = explode(' ', $this->config->license); + foreach($bs as $bl){ + for($i=0, $m=''; $idomains, $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)expiration!='*')) && $this->request->get('module')!='LicenseAdmin') + header('location: '.$this->config->root_url.'/simpla/index.php?module=LicenseAdmin'); + else + { + $l->valid = true; + $this->design->assign('license', $l); + } + + $this->design->assign('license', $l); + + $this->design->set_templates_dir('simpla/design/html'); + + if(!is_dir($this->config->root_dir.'/compiled')) + mkdir($this->config->root_dir.'simpla/design/compiled', 0777); + + $this->design->set_compiled_dir('simpla/design/compiled'); + + $this->design->assign('settings', $this->settings); + $this->design->assign('config', $this->config); + + // Администратор + $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('simpla/'.$module.'.php')) + { + foreach($this->modules_permissions as $m=>$p) + { + if($this->managers->access($p)) + { + $module = $m; + break; + } + } + } + if(empty($module)) + $module = 'ProductsAdmin'; + + // Подключаем файл с необходимым модулем + require_once('simpla/'.$module.'.php'); + + // Создаем соответствующий модуль + if(class_exists($module)) + $this->module = new $module(); + else + die("Error creating $module class"); + + } + + function fetch() + { + $currency = $this->money->get_currency(); + $this->design->assign("currency", $currency); + + // Проверка прав доступа к модулю + if(isset($this->modules_permissions[get_class($this->module)]) + && $this->managers->access($this->modules_permissions[get_class($this->module)])) + { + $content = $this->module->fetch(); + $this->design->assign("content", $content); + } + else + { + $this->design->assign("content", "Permission denied"); + } + + // Счетчики для верхнего меню + $new_orders_counter = $this->orders->count_orders(array('status'=>0)); + $this->design->assign("new_orders_counter", $new_orders_counter); + + $new_comments_counter = $this->comments->count_comments(array('approved'=>0)); + $this->design->assign("new_comments_counter", $new_comments_counter); + + // Создаем текущую обертку сайта (обычно index.tpl) + $wrapper = $this->design->smarty->getTemplateVars('wrapper'); + if(is_null($wrapper)) + $wrapper = 'index.tpl'; + + if(!empty($wrapper)) + return $this->body = $this->design->fetch($wrapper); + else + return $this->body = $content; + } +}