/**
  * Language Import
  *
  * @access	public
  * @return	void
  **/
 public function languages()
 {
     /* INIT */
     $vars = $this->getVars();
     $output = array();
     $errors = array();
     /* Load the language file */
     $this->registry->class_localization->loadLanguageFile(array('admin_system'));
     /* Get the language stuff */
     require_once IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php';
     $lang = new admin_core_languages_manage_languages($this->registry);
     $lang->makeRegistryShortcuts($this->registry);
     /* Loop through the xml directory and look for lang packs */
     $_PATH = $this->app_full_path . '/xml/';
     try {
         foreach (new DirectoryIterator($_PATH) as $f) {
             if (preg_match("#(.+?)_language_pack.xml#", $f->getFileName())) {
                 $this->request['file_location'] = $_PATH . $f->getFileName();
                 $lang->imprtFromXML(true, true, true, $vars['app_directory']);
             }
         }
     } catch (Exception $e) {
     }
     $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['redir__nolanguages'];
     /* Clear main msg */
     $this->registry->output->global_message = '';
     /* Show redirect... */
     $this->showRedirectScreen($vars['app_directory'], $output, $errors, $this->getNextURL('tasks', $vars));
 }
 /**
  * Uninstall a hook
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _uninstallHook()
 {
     /* INI */
     $hook_id = intval($this->request['id']);
     $hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id));
     $extra_data = unserialize($hook['hook_extra_data']);
     /* Delete main hook entry */
     $this->DB->delete('core_hooks', "hook_id={$hook_id}");
     /* Get associated files */
     $this->DB->build(array('select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook_id));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         @unlink(IPS_HOOKS_PATH . $r['hook_file_stored']);
     }
     /* Delete hook file entries */
     $this->DB->delete('core_hooks_files', "hook_hook_id={$hook_id}");
     //-----------------------------------------
     // Settings or setting groups?
     //-----------------------------------------
     if (count($extra_data['settingGroups'])) {
         $this->DB->delete('core_sys_settings_titles', 'conf_title_id IN(' . implode(',', $extra_data['settingGroups']) . ')');
     }
     if (count($extra_data['settings'])) {
         $this->DB->delete('core_sys_conf_settings', 'conf_id IN(' . implode(',', $extra_data['settings']) . ')');
     }
     $this->cache->rebuildCache('settings', 'global');
     //-----------------------------------------
     // Language strings/files
     //-----------------------------------------
     if (count($extra_data['language'])) {
         foreach ($extra_data['language'] as $file => $bit) {
             $this->DB->delete('core_sys_lang_words', "word_pack='{$file}' AND word_key IN('" . implode("','", $bit) . "')");
         }
         $langPacks = array();
         $this->DB->build(array('select' => 'lang_id', 'from' => 'core_sys_lang'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $langPacks[] = $r['lang_id'];
         }
         require_once IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php';
         $langLib = new admin_core_languages_manage_languages($this->registry);
         $langLib->makeRegistryShortcuts($this->registry);
         foreach ($langPacks as $langId) {
             $langLib->cacheToDisk($langId);
         }
     }
     //-----------------------------------------
     // Modules
     //-----------------------------------------
     if (count($extra_data['modules'])) {
         $this->DB->delete('core_sys_module', 'sys_module_id IN(' . implode(',', $extra_data['modules']) . ')');
         $this->cache->rebuildCache('module_cache', 'global');
         $this->cache->rebuildCache('app_menu_cache', 'global');
     }
     //-----------------------------------------
     // Help files
     //-----------------------------------------
     if (count($extra_data['help'])) {
         $this->DB->delete('faq', 'id IN(' . implode(',', $extra_data['help']) . ')');
     }
     //-----------------------------------------
     // Skin templates
     //-----------------------------------------
     if (count($extra_data['templates'])) {
         foreach ($extra_data['templates'] as $file => $bit) {
             $this->DB->delete('skin_templates', "template_group='{$file}' AND template_name IN('" . implode("','", $bit) . "')");
         }
         require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
         require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
         $skinCaching = new skinCaching($this->registry);
         $skinCaching->rebuildPHPTemplates(0);
     }
     //-----------------------------------------
     // Tasks
     //-----------------------------------------
     if (count($extra_data['tasks'])) {
         $this->DB->delete('task_manager', 'task_id IN(' . implode(',', $extra_data['tasks']) . ')');
     }
     //-----------------------------------------
     // Database changes
     //-----------------------------------------
     if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) {
         foreach ($extra_data['database']['create'] as $create_query) {
             $this->DB->return_die = true;
             $this->DB->dropTable($create_query['name']);
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) {
         foreach ($extra_data['database']['alter'] as $alter_query) {
             $this->DB->return_die = true;
             if ($alter_query['altertype'] == 'add') {
                 if ($this->DB->checkForField($alter_query['field'], $alter_query['table'])) {
                     $this->DB->dropField($alter_query['table'], $alter_query['field']);
                 }
             } else {
                 if ($alter_query['altertype'] == 'change') {
                     if ($this->DB->checkForField($alter_query['newfield'], $alter_query['table'])) {
                         $this->DB->changeField($alter_query['table'], $alter_query['newfield'], $alter_query['field'], $alter_query['fieldtype'], $alter_query['default']);
                     }
                 }
             }
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) {
         foreach ($extra_data['database']['update'] as $update_query) {
             $this->DB->return_die = true;
             $this->DB->update($update_query['table'], array($update_query['field'] => $update_query['oldvalue']), $update_query['where']);
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) {
         foreach ($extra_data['database']['insert'] as $insert_query) {
             if ($insert_query['fordelete']) {
                 $this->DB->return_die = true;
                 $this->DB->delete($insert_query['table'], $insert_query['fordelete']);
                 $this->DB->return_die = false;
             }
         }
     }
     //-----------------------------------------
     // Custom install/uninstall script?
     //-----------------------------------------
     if ($extra_data['custom']) {
         if (file_exists(IPS_HOOKS_PATH . $extra_data['custom'])) {
             require_once IPS_HOOKS_PATH . $extra_data['custom'];
             $classname = str_replace('.php', '', $extra_data['custom']);
             if (class_exists($classname)) {
                 $uninstall = new $classname($this->registry);
                 if (method_exists($uninstall, 'uninstall')) {
                     $uninstall->uninstall();
                 }
             }
             @unlink(IPS_HOOKS_PATH . $extra_data['custom']);
         }
     }
     $this->rebuildHooksCache();
     /* Done */
     $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=hooks_overview');
 }
Пример #3
0
 /**
  * Install Public Languages
  *
  * @return void
  */
 public function install_client_languages()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']);
     /* Set up DB driver */
     $extra_install = $this->_setUpDBDriver(FALSE);
     //-----------------------------------------
     // Install Languages
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Добавление языков";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         //-----------------------------------------
         // Get the language stuff
         //-----------------------------------------
         require_once IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php';
         /*noLibHook*/
         $lang = new admin_core_languages_manage_languages();
         $lang->makeRegistryShortcuts($this->registry);
         /* Loop through the xml directory and look for lang packs */
         try {
             foreach (new DirectoryIterator($_PATH) as $f) {
                 if (preg_match("#public_(.+?)_language_pack.xml#", $f->getFileName())) {
                     //-----------------------------------------
                     // Adjust the table?
                     //-----------------------------------------
                     if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
                         $q = $extra_install->before_inserts_run('languages');
                     }
                     //-----------------------------------------
                     // Import and cache
                     //-----------------------------------------
                     $this->request['file_location'] = $_PATH . $f->getFileName();
                     $lang->imprtFromXML(true, true, true, $next['key'], false, 1);
                     //-----------------------------------------
                     // Adjust the table?
                     //-----------------------------------------
                     if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
                         $q = $extra_install->after_inserts_run('languages');
                     }
                 }
             }
         } catch (Exception $e) {
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Установка: Языки", 'install&do=clientlanguages&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "Добавление языков завершено";
         $this->_finishStep($output, "Установка: Языки", 'install&do=bbcode');
     }
 }
Пример #4
0
 /**
  * Install Public Languages
  *
  * @return void
  */
 public function install_client_languages()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']);
     //-----------------------------------------
     // Install Languages
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Обновление языков";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         //-----------------------------------------
         // Get the language stuff
         //-----------------------------------------
         require_once IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php';
         /*noLibHook*/
         $lang = new admin_core_languages_manage_languages();
         $lang->makeRegistryShortcuts($this->registry);
         /* Loop through the xml directory and look for lang packs */
         try {
             foreach (new DirectoryIterator($_PATH) as $f) {
                 // Check it's a valid file
                 if (substr($f->getFileName(), 0, 1) === '.') {
                     continue;
                 }
                 if (preg_match("#public_(.+?)_language_pack.xml#", $f->getFileName())) {
                     //-----------------------------------------
                     // Import and cache
                     //-----------------------------------------
                     $this->request['file_location'] = $_PATH . $f->getFileName();
                     $lang->imprtFromXML(true, true, true, $next['key'], true, 1);
                 }
             }
         } catch (Exception $e) {
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Обновление: Языки", 'upgrade&do=clientlanguages&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "Языки обновлены";
         $this->_finishStep($output, "Обновление: Языки", 'upgrade&do=bbcode');
     }
 }
 /**
  * Install Public Languages
  *
  * @return void
  */
 public function install_client_languages()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous);
     //-----------------------------------------
     // Install Languages
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Upgrading Public languages...";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         //-----------------------------------------
         // Get the language stuff
         //-----------------------------------------
         require_once IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php';
         $lang = new admin_core_languages_manage_languages();
         $lang->makeRegistryShortcuts($this->registry);
         /* Loop through the xml directory and look for lang packs */
         try {
             foreach (new DirectoryIterator($_PATH) as $f) {
                 if (preg_match("#public_(.+?)_language_pack.xml#", $f->getFileName())) {
                     //-----------------------------------------
                     // Import and cache
                     //-----------------------------------------
                     $this->request['file_location'] = $_PATH . $f->getFileName();
                     $lang->imprtFromXML(true, true, true, $next['key']);
                 }
             }
         } catch (Exception $e) {
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Upgrade: Public Languages", 'upgrade&do=clientlanguages&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "All Public languages upgraded";
         $this->_finishStep($output, "Upgrade: Public Languages", 'upgrade&do=bbcode');
     }
 }