Ejemplo n.º 1
0
 public function run()
 {
     $path = $this->cms_config->upload_path . $this->installer_upload_path;
     $path_relative = $this->cms_config->upload_root . $this->installer_upload_path;
     clearstatcache();
     $installer_path = $path . '/' . 'install.php';
     $sql_dump_path = $path . '/' . 'install.sql';
     $is_imported = $this->importPackageDump($sql_dump_path);
     if ($is_imported) {
         $is_installed = $this->runPackageInstaller($installer_path);
     } else {
         $is_installed = false;
     }
     // считаем, что пришла ошибка
     if (is_string($is_installed)) {
         cmsUser::addSessionMessage($is_installed, 'error');
         $this->redirectToAction('install');
     }
     // или ошибка уже сформирована в функции установки через addSessionMessage
     if ($is_installed === false) {
         cmsUser::addSessionMessage(LANG_CP_INSTALL_ERROR, 'error');
         $this->redirectToAction('install');
     }
     $redirect_action = '';
     if ($is_imported && $is_installed === true) {
         $redirect_action = $this->doPackage();
         // если в файле install.php есть функция after_install_package, вызываем ее
         // этот файл, если он есть, уже должен был загружен ранее
         if (function_exists('after_install_package')) {
             call_user_func('after_install_package');
         }
     }
     $is_cleared = files_clear_directory($path);
     return $this->cms_template->render('install_finish', array('is_cleared' => $is_cleared, 'redirect_action' => $redirect_action, 'path_relative' => $path_relative));
 }
Ejemplo n.º 2
0
 public function run()
 {
     $config = cmsConfig::getInstance();
     $path = $config->upload_path . $this->installer_upload_path;
     $path_relative = $config->upload_root . $this->installer_upload_path;
     $installer_path = $path . '/' . 'install.php';
     $sql_dump_path = $path . '/' . 'install.sql';
     $is_imported = $this->importPackageDump($sql_dump_path);
     $is_installed = $this->runPackageInstaller($installer_path);
     // считаем, что пришла ошибка
     if (is_string($is_installed)) {
         cmsUser::addSessionMessage($is_installed, 'error');
         $this->redirectToAction('install');
     }
     $redirect_action = '';
     if ($is_imported && $is_installed === true) {
         $redirect_action = $this->doPackage();
         // если в файле install.php есть функция after_install_package, вызываем ее
         // этот файл, если он есть, уже должен был загружен ранее
         if (function_exists('after_install_package')) {
             call_user_func('after_install_package');
         }
     }
     $is_cleared = files_clear_directory($path);
     return cmsTemplate::getInstance()->render('install_finish', array('is_cleared' => $is_cleared, 'redirect_action' => $redirect_action, 'path_relative' => $path_relative));
 }
Ejemplo n.º 3
0
 public function clean($key = false)
 {
     if ($key) {
         $path = cmsConfig::get('cache_path') . str_replace('.', '/', $key);
         return files_remove_directory($path);
     } else {
         return files_clear_directory(cmsConfig::get('cache_path'));
     }
 }
Ejemplo n.º 4
0
 public function clean($key = false)
 {
     if ($key) {
         $path = $this->cache_path . str_replace('.', '/', $key);
         if (is_file($path . '.dat')) {
             @unlink($path . '.dat');
         }
         return files_remove_directory($path);
     } else {
         return files_clear_directory($this->cache_path);
     }
 }
Ejemplo n.º 5
0
 public function run()
 {
     $config = cmsConfig::getInstance();
     $path = $config->upload_path . $this->installer_upload_path;
     $path_relative = $config->upload_root . $this->installer_upload_path;
     $installer_path = $path . '/' . 'install.php';
     $sql_dump_path = $path . '/' . 'install.sql';
     $this->importPackageDump($sql_dump_path);
     $this->runPackageInstaller($installer_path);
     $is_cleared = files_clear_directory($path);
     return cmsTemplate::getInstance()->render('install_finish', array('is_cleared' => $is_cleared, 'path_relative' => $path_relative));
 }
Ejemplo n.º 6
0
 public function run($do = false)
 {
     // если нужно, передаем управление другому экшену
     if ($do) {
         $this->runAction('settings_' . $do, array_slice($this->params, 1));
         return;
     }
     $values = $this->cms_config->getAll();
     $values['time_zone'] = $values['cfg_time_zone'];
     $form = $this->getForm('settings');
     if ($this->request->has('submit')) {
         $values = array_merge($values, $form->parse($this->request, true));
         $errors = $form->validate($this, $values);
         if (!$errors) {
             if ($values['cache_method'] == 'memory') {
                 if (!class_exists('Memcache')) {
                     cmsUser::addSessionMessage(LANG_CP_MEMCACHE_NOT_AVAILABLE, 'error');
                     $values['cache_method'] = 'files';
                 }
             }
             if ($values['cache_method'] == 'memory') {
                 $memcache_tester = new Memcache();
                 $memcache_result = @$memcache_tester->connect($values['cache_host'], $values['cache_port']);
                 if (!$memcache_result) {
                     cmsUser::addSessionMessage(LANG_CP_MEMCACHE_CONNECT_ERROR, 'error');
                     $values['cache_method'] = 'files';
                 }
             }
             if (!$values['cache_enabled'] && $values['cache_method'] == 'files') {
                 files_clear_directory($this->cms_config->cache_path . 'data/');
             }
             $result = $this->cms_config->save($values);
             if (!$result) {
                 $errors = array();
                 cmsUser::addSessionMessage(LANG_CP_SETTINGS_NOT_WRITABLE, 'error');
             } else {
                 cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
                 $this->redirectToAction('settings');
             }
         } else {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     $tpls = cmsCore::getTemplates();
     foreach ($tpls as $tpl) {
         if (file_exists($this->cms_config->root_path . 'templates/' . $tpl . '/options.form.php')) {
             $templates_has_options[] = $tpl;
         }
     }
     return $this->cms_template->render('settings', array('templates_has_options' => $templates_has_options, 'do' => 'edit', 'values' => $values, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
Ejemplo n.º 7
0
 public function run($type)
 {
     if (!in_array($type, array('css', 'js'))) {
         cmsCore::error404();
     }
     $cache_folder = "cache/static/{$type}";
     $cache_folder_path = cmsConfig::get('root_path') . $cache_folder;
     if (files_clear_directory($cache_folder_path)) {
         cmsUser::addSessionMessage(sprintf(LANG_CP_SETTINGS_MERGED_CLEANED, '/' . $cache_folder), 'success');
     } else {
         cmsUser::addSessionMessage(sprintf(LANG_CP_SETTINGS_MERGED_CLEAN_FAIL, '/' . $cache_folder), 'error');
     }
     $this->redirectBack();
 }
Ejemplo n.º 8
0
 private function uploadPackage()
 {
     $uploader = new cmsUploader();
     if (!$uploader->isUploaded($this->upload_name)) {
         return false;
     }
     files_clear_directory(cmsConfig::get('upload_path') . $this->installer_upload_path);
     $result = $uploader->uploadForm($this->upload_name, $this->upload_exts, 0, $this->installer_upload_path);
     if (!$result['success']) {
         cmsUser::addSessionMessage($result['error'], 'error');
         return false;
     }
     return $result['name'];
 }