/** * Run SQL files * * @access public * @param int */ public function _importTemplates() { $templates = array(); $this->DB->build(array('select' => '*', 'from' => 'ccs_template_blocks')); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { if (!preg_match("/_(\\d+)\$/", $r['tpb_name'])) { $templates[$r['tpb_name']] = $r; } } $content = file_get_contents(IPSLib::getAppDir('ccs') . '/xml/block_templates.xml'); require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->loadXML($content); foreach ($xml->fetchElements('template') as $template) { $_template = $xml->fetchElementsFromRecord($template); if ($_template['tpb_name']) { unset($_template['tpb_id']); if (array_key_exists($_template['tpb_name'], $templates)) { $this->DB->update("ccs_template_blocks", $_template, "tpb_id={$templates[$_template['tpb_name']]['tpb_id']}"); } else { $this->DB->insert("ccs_template_blocks", $_template); } } } }
/** * Execute selected method * * @param object Registry object * @return @e void */ public function _restoreXmlSkin() { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); /* Skin Set Data */ $xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml'); foreach ($xml->fetchElements('set') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); if ($data['set_key'] == 'xmlskin') { $data['set_order'] = intval($data['set_order']); unset($data['set_id']); $this->DB->delete('skin_collections', "set_key='xmlskin'"); $this->DB->insert('skin_collections', $data); } } $this->registry->output->addMessage("XML стиль восстановлен"); $this->request['workact'] = ''; }
/** * Finish up conversion stuff * * @return @e void */ public function finish() { $options = IPSSetUp::getSavedData('custom_options'); $skipPms = $options['core'][30001]['skipPms']; $output = array(); /* Emoticons */ if (file_exists(DOC_IPS_ROOT_PATH . 'style_emoticons/default')) { try { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'style_emoticons/default') as $file) { if (!$file->isDot()) { $_name = $file->getFileName(); /* Annoyingly, isDot doesn't match .svn, etc */ if (substr($_name, 0, 1) == '.') { continue; } if (@copy(DOC_IPS_ROOT_PATH . 'style_emoticons/default/' . $_name, IPS_PUBLIC_PATH . 'style_emoticons/default/' . $_name)) { $output[] = "Смайлики: скопирован {$_name}..."; } else { $output[] = "Не удалось скопировать {$_name} - после обновления перенесите его самостоятельно"; } } } } catch (Exception $e) { } } /* LOG IN METHODS */ $this->DB->build(array('select' => '*', 'from' => 'login_methods')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $loginMethods[$row['login_folder_name']] = $row; } $count = 6; $recount = array('internal' => 1, 'ipconverge' => 2, 'ldap' => 3, 'external' => 4); /* Fetch XML */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); $xml->load(IPS_ROOT_PATH . 'setup/xml/loginauth.xml'); foreach ($xml->fetchElements('login_methods') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $data['login_order'] = isset($recount[$data['login_folder_name']]) ? $recount[$data['login_folder_name']] : ++$count; unset($data['login_id']); if (!$loginMethods[$data['login_folder_name']]) { $this->DB->insert('login_methods', $data); } else { $this->DB->update('login_methods', array('login_order' => $data['login_order']), 'login_folder_name=\'' . $data['login_folder_name'] . '\''); } } /* Reset member languages and skins */ $this->DB->update('members', array('language' => IPSLib::getDefaultLanguage(), 'skin' => 0)); /* Empty caches */ $this->DB->delete('cache_store', "cs_key='forum_cache'"); $this->DB->delete('cache_store', "cs_key='skin_id_cache'"); /* Empty other tables */ $this->DB->delete('skin_cache'); $this->DB->delete('skin_templates_cache'); /* Reset admin permissions */ $this->DB->update('admin_permission_rows', array('row_perm_cache' => '')); /* Drop Tables */ $this->DB->dropTable('contacts'); $this->DB->dropTable('skin_macro'); $this->DB->dropTable('skin_template_links'); $this->DB->dropTable('skin_templates_old'); $this->DB->dropTable('skin_sets'); $this->DB->dropTable('languages'); $this->DB->dropTable('topics_read'); $this->DB->dropTable('topic_markers'); $this->DB->dropTable('acp_help'); $this->DB->dropTable('members_converge'); $this->DB->dropTable('member_extra'); $this->DB->dropTable('custom_bbcode_old'); $this->DB->dropTable('admin_sessions'); $this->DB->dropTable('components'); $this->DB->dropTable('admin_permission_keys'); $this->DB->dropTable('conf_settings'); $this->DB->dropTable('conf_settings_titles'); $this->DB->dropTable('reg_antispam'); if (!$skipPms) { $this->DB->dropTable('message_text'); $this->DB->dropTable('message_topics_old'); } $message = (is_array($output) and count($output)) ? implode("<br />", $output) . '<br />' : ''; $this->registry->output->addMessage($message . "очистка SQL завершена..."); /* Last function, so unset workact */ $this->request['workact'] = ''; }
/** * Export a mediaTag XML file * * @access private * @return void [Outputs to screen] */ private function _mediaTagExport() { //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('mediatagexport'); $xml->addElement('mediataggroup', 'mediatagexport'); $select = array('select' => '*', 'from' => 'bbcode_mediatag'); if ($this->request['id']) { $select['where'] = 'mediatag_id=' . intval($this->request['id']); } $this->DB->build($select); $this->DB->execute(); while ($r = $this->DB->fetch()) { $xml->addElementAsRecord('mediataggroup', 'mediatag', $r); } $xmlData = $xml->fetchDocument(); //----------------------------------------- // Send to browser. //----------------------------------------- $this->registry->output->showDownload($xmlData, 'mediatag.xml', '', 0); }
/** * Fetch Apps XML Modules File * * @access public * @param string Application Directory * @param string Charset (post install) * @return array ..of data */ public static function fetchXmlAppModules($app, $charset = '') { //----------------------------------------- // No modules? //----------------------------------------- if (!is_file(IPSLib::getAppDir($app) . '/xml/' . $app . '_modules.xml')) { return array(); } /* INIT */ $modules = array(); try { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML($charset ? $charset : IPSSetUp::charSet); $xml->load(IPSLib::getAppDir($app) . '/xml/' . $app . '_modules.xml'); /* Fetch info */ foreach ($xml->fetchElements('module') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); if ($data['sys_module_id']) { unset($data['sys_module_id']); } /* Remove fields removed from 3.1.3+ to avoid driver errors */ unset($data['sys_module_parent']); unset($data['sys_module_tables']); unset($data['sys_module_hooks']); $modules[$data['sys_module_key'] . intval($data['sys_module_admin'])] = $data; } return $modules; } catch (Exception $error) { return FALSE; } }
/** * Convert a string between charsets. XML will always be UTF-8 * * @param string Input String * @param string Current char set * @param string Destination char set * @return @e string * @todo [Future] If an error is set in classConvertCharset, show it or log it somehow */ protected function _convertCharsets($text, $original_cset, $destination_cset = "UTF-8") { $original_cset = strtolower($original_cset); $destination_cset = strtolower($destination_cset); $t = $text; //----------------------------------------- // Not the same? //----------------------------------------- if ($destination_cset == $original_cset) { return $t; } if (!is_object(self::$classConvertCharset)) { require_once dirname(__FILE__) . '/classConvertCharset.php'; /*noLibHook*/ self::$classConvertCharset = new classConvertCharset(); //----------------------------------------- // Ok, mb functions only support limited number // of charsets, so if mb functions are enabled // but using e.g. windows-1250, no conversion // ends up happening. Let's force internal. //----------------------------------------- //if ( function_exists( 'mb_convert_encoding' ) ) //{ // self::$classConvertCharset->method = 'mb'; //} //else if ( function_exists( 'iconv' ) ) //{ // self::$classConvertCharset->method = 'iconv'; //} //else if ( function_exists( 'recode_string' ) ) //{ // self::$classConvertCharset->method = 'recode'; //} //else //{ self::$classConvertCharset->method = 'internal'; //} } $text = self::$classConvertCharset->convertEncoding($text, $original_cset, $destination_cset); return $text ? $text : $t; }
/** * Export tasks to XML * * @return @e void */ public function tasksExportToXML() { /* INIT */ $entry = array(); require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ /* Loop through all the applications */ foreach ($this->registry->getApplications() as $app => $__data) { $_c = 0; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('export'); $xml->addElement('group', 'export'); /* Query tasks */ $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_application='{$app}'")); $this->DB->execute(); /* Loop through and add tasks to XML */ while ($r = $this->DB->fetch()) { $_c++; $xml->addElementAsRecord('group', 'row', $r); } /* Finish XML */ $doc = $xml->fetchDocument(); /* Write */ if ($doc and $_c) { file_put_contents(IPSLib::getAppDir($app) . '/xml/' . $app . '_tasks.xml', $doc); } } $this->registry->output->setMessage($this->lang->words['t_exported'], 1); $this->taskManagerOverview(); }
/** * Write Default Values */ public function writeDefaults() { $defaultTemplates = file_get_contents(IPS_ROOT_PATH . 'setup/xml/system_templates.xml'); if (!class_exists('classXML')) { require_once IPS_KERNEL_PATH . 'classXML.php'; } $xml = new classXML('utf-8'); $xml->loadXML($defaultTemplates); $array = $xml->fetchXMLAsArray(); foreach ($array['system_templates']['template'] as $template) { $params = array(); foreach ($template['params']['param'] as $p) { $params[] = $p['#alltext']; } $this->write($template['key']['#alltext'], $params, $template['content']['#alltext']); } }
/** * Read conf_global * * @access public * @return bool */ public static function readGlobalConfig() { /* Fetch core writeable files */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); try { $xml->load(IPS_ROOT_PATH . 'setup/xml/config.xml'); foreach ($xml->fetchElements('package') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); self::$_config = $data; } return TRUE; } catch (Exception $error) { return FALSE; } }
/** * Export the specified emoticon directory * * @return @e void */ public function emoticonsPackExport() { /* Setup XML */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); require_once IPS_KERNEL_PATH . 'classXMLArchive.php'; /*noLibHook*/ $xmlarchive = new classXMLArchive(); /* Check the emoticon set */ if (!$this->request['emo_set']) { $this->registry->output->global_message = $this->lang->words['emo_specify_exS']; $this->emoticonsOverview(); return; } /* Get emoticons from the database */ $emo_db = array(); $this->DB->build(array('select' => '*', 'from' => 'emoticons', 'where' => "emo_set='{$this->request['emo_set']}'")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $emo_db[$r['image']] = $r; } /* Get Emoticon Folders */ $emodirs = array(); $emodd = array(); $files_to_add = array(); try { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set']) as $file) { if (!$file->isDot()) { if ($emo_db[$file->getFilename()] != "") { $files_to_add[] = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] . '/' . $file->getFilename(); } } } } catch (Exception $e) { } /* Add each file to the xml archive */ foreach ($files_to_add as $f) { $xmlarchive->add($f); } $xml->newXMLDocument(); $xml->addElement('emoticonexport'); $xml->addElement('emogroup', 'emoticonexport'); foreach ($emo_db as $r) { $content = array(); $content['typed'] = $r['typed']; $content['image'] = $r['image']; $content['clickable'] = $r['clickable']; $xml->addElementAsRecord('emogroup', 'emoticon', $content); } /* Create the XML Document */ $xmlData = $xml->fetchDocument(); /* Add the xml document to the archive */ $xmlarchive->add($xmlData, 'emoticon_data.xml'); /* Send the archive to the browser */ $imagearchive = $xmlarchive->getArchiveContents(); $this->registry->output->showDownload($imagearchive, 'ipb_emoticons.xml'); }
/** * Export all settings to XML (IN_DEV mode) * * @access private * @param string Application directory * @return boolean */ private function _exportXML($app_dir = 'core') { //----------------------------------------- // Get setting groups //----------------------------------------- $this->_settingsGetGroups(true); //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('settingexport'); $xml->addElement('settinggroup', 'settingexport'); foreach ($this->setting_groups as $i => $roar) { //----------------------------------------- // App check? //----------------------------------------- if ($app_dir != $roar['conf_title_app']) { continue; } //----------------------------------------- // First, add in setting group title //----------------------------------------- $thisconf = array('conf_is_title' => 1, 'conf_title_keyword' => $roar['conf_title_keyword'], 'conf_title_title' => $roar['conf_title_title'], 'conf_title_desc' => $roar['conf_title_desc'], 'conf_title_tab' => $roar['conf_title_tab'], 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : $app_dir, 'conf_title_noshow' => $roar['conf_title_noshow']); $xml->addElementAsRecord('settinggroup', 'setting', $thisconf); //----------------------------------------- // Get settings... //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_group='{$roar['conf_title_id']}'", 'order' => 'conf_position, conf_title')); $this->DB->execute(); while ($r = $this->DB->fetch()) { //----------------------------------------- // Clean up... //----------------------------------------- unset($r['conf_value'], $r['conf_id']); $r['conf_title_keyword'] = $roar['conf_title_keyword']; $r['conf_is_title'] = 0; $xml->addElementAsRecord('settinggroup', 'setting', $r); } } //----------------------------------------- // Grab the XML document //----------------------------------------- $xmlData = $xml->fetchDocument(); //----------------------------------------- // Attempt to write... //----------------------------------------- $file = IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml'; @unlink($file); @file_put_contents($file, $xmlData); }
/** * Install Other stuff * * @return void */ public function install_other() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; //----------------------------------------- // HOOKS: Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, 'hooks.xml', $this->settings['gb_char_set']); /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Insert tasks //----------------------------------------- if ($next['key']) { $output[] = $next['title'] . ": Добавление модификаций"; $_PATH = IPSLib::getAppDir($next['key']) . '/xml/'; if (is_file($_PATH . 'hooks.xml')) { //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('hooks'); } //----------------------------------------- // Continue //----------------------------------------- require_once IPS_ROOT_PATH . 'applications/core/modules_admin/applications/hooks.php'; /*noLibHook*/ $hooks = new admin_core_applications_hooks(); $hooks->makeRegistryShortcuts($this->registry); $result = $hooks->installAppHooks($next['key']); $output[] = "Модификации " . $next['title'] . ": " . $result['inserted'] . " добавлено"; //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('hooks'); } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $this->_finishStep($output, "Установка: Модификации", 'install&do=other&previous=' . $next['key']); } else { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ //----------------------------------------- // ****** LOG IN MODULES //----------------------------------------- $output[] = "Добавление модулей авторизации"; $xml = new classXML(IPSSetUp::charSet); //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('login'); } //----------------------------------------- // Continue //----------------------------------------- $xml->load(IPS_ROOT_PATH . 'setup/xml/loginauth.xml'); foreach ($xml->fetchElements('login_methods') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); unset($data['login_id']); unset($data['login_date']); $this->DB->insert('login_methods', $data); } //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('login'); } //----------------------------------------- // ****** USER AGENTS //----------------------------------------- $output[] = "Добавление user-agent`ов по-умолчанию"; $xml = new classXML(IPSSetUp::charSet); if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('useragents'); } require_once IPS_ROOT_PATH . 'sources/classes/useragents/userAgentFunctions.php'; /*noLibHook*/ $userAgentFunctions = new userAgentFunctions($this->registry); $userAgentFunctions->rebuildMasterUserAgents(); if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('useragents'); } //----------------------------------------- // ****** ATTACHMENTS //----------------------------------------- $output[] = "Добавление типов прикрепляемых файлов"; if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('attachments'); } $xml = new classXML(IPSSetUp::charSet); $xml->load(IPS_ROOT_PATH . 'setup/xml/attachments.xml'); foreach ($xml->fetchElements('attachtype') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); unset($data['atype_id']); $this->DB->insert('attachments_type', $data); } if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('attachments'); } //----------------------------------------- // Build Calendar RSS //----------------------------------------- if (IPSLib::appIsInstalled('calendar')) { require_once IPSLib::getAppDir('calendar') . '/modules_admin/calendar/calendars.php'; /*noLibHook*/ $cal = new admin_calendar_calendar_calendars(); $cal->makeRegistryShortcuts($this->registry); $output[] = "Обновление RSS календаря"; $cal->calendarRSSCache(); } /* If this is windows, change the locale for the language pack */ if (strpos(strtolower(PHP_OS), 'win') === 0) { $this->DB->update('core_sys_lang', array('lang_short' => 'Russian_Russia.65001'), 'lang_id=1'); } else { $this->DB->update('core_sys_lang', array('lang_short' => 'ru_RU.UTF-8'), 'lang_id=1'); } } //----------------------------------------- // Next... //----------------------------------------- $this->_finishStep($output, "Установка: Другие данные", 'install&do=caches'); }
/** * Recache menu data * * @return @e void */ public function applicationsMenuDataRecache() { $app_menu_cache = array(); $modules_cache = array(); //----------------------------------------- // Get module data first in one query //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => 'sys_module_visible=1 AND sys_module_admin=1', 'order' => 'sys_module_position ASC')); $this->DB->execute(); while ($module = $this->DB->fetch()) { $modules_cache[$module['sys_module_application']][] = $module['sys_module_key']; } //----------------------------------------- // Now get applications and loop //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_applications', 'order' => 'app_position ASC')); $outer = $this->DB->execute(); while ($row = $this->DB->fetch($outer)) { $app_dir = $row['app_directory']; $main_items = $modules_cache[$app_dir]; //----------------------------------------- // Continue... //----------------------------------------- if (count($main_items)) { foreach ($main_items as $_current_module) { $_file = IPSLib::getAppDir($app_dir) . "/modules_admin/" . $_current_module . '/xml/menu.xml'; if (is_file($_file)) { //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $content = @file_get_contents($_file); if ($content) { $xml->loadXML($content); $menu = $xml->fetchXMLAsArray(); $item = array(); $subItemIndex = 0; $itemIndex = 0; /** * Easiest way I could find to get the data in a proper multi-dimensional array */ foreach ($menu as $id => $data) { foreach ($data as $dataKey => $dataValue) { if ($dataKey == 'tabitems') { foreach ($dataValue as $tabitemsKey => $tabItemsValue) { if ($tabitemsKey == 'item') { foreach ($tabItemsValue as $itemKey => $itemValue) { if (is_int($itemKey)) { foreach ($itemValue as $_itemKey => $_itemValue) { $subItemIndex = 0; if ($_itemKey == 'title' or $_itemKey == 'condition') { $item[$itemIndex][$_itemKey] = $_itemValue['#alltext']; } else { if ($_itemKey == 'subitems') { foreach ($_itemValue as $subitemKey => $subitemValue) { if ($subitemKey != '#alltext') { foreach ($subitemValue as $subitemRealKey => $subitemRealValue) { if (is_int($subitemRealKey)) { foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) { if ($_subitemRealKey != '#alltext') { $item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext']; } } } else { if ($subitemRealKey != '#alltext') { $item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$subitemRealKey] = $subitemRealValue['#alltext']; } } if (is_int($subitemRealKey)) { $subItemIndex++; } } $subItemIndex++; } } } } } $itemIndex++; } else { if ($itemKey == 'title') { $item[$itemIndex][$itemKey] = $itemValue['#alltext']; } else { if ($itemKey == 'subitems') { foreach ($itemValue as $subitemKey => $subitemValue) { if ($subitemKey != '#alltext') { foreach ($subitemValue as $subitemRealKey => $subitemRealValue) { if (is_int($subitemRealKey)) { foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) { if ($_subitemRealKey != '#alltext') { $item[$itemIndex][$itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext']; } } } else { if ($subitemRealKey != '#alltext') { $item[$itemIndex][$itemKey][$subitemKey][$subItemIndex][$subitemRealKey] = $subitemRealValue['#alltext']; } } if (is_int($subitemRealKey)) { $subItemIndex++; } } $subItemIndex++; } } } } } } $itemIndex++; } } } } } foreach ($item as $id => $data) { //----------------------------------------- // INIT //----------------------------------------- if ($data['condition']) { $func = create_function('', $data['condition']); if (!$func()) { continue; } } $_cat_title = $data['title']; $_cat_title = str_replace('&', '&', $_cat_title); // Validation thing $_nav_main_done = 0; if (is_array($data['subitems'])) { //----------------------------------------- // Loop.... //----------------------------------------- foreach ($data['subitems'] as $__data) { foreach ($__data as $_id => $_data) { $_sub_item_title = $_data['subitemtitle']; $_sub_item_url = $_data['subitemurl']; $_sub_is_redirect = $_data['subisredirect']; $_sub_section = $_data['subsection']; $_sub_keywords = $_data['subitemkeywords']; $_sub_item_role_key = isset($_data['subitemrolekey']) ? $_data['subitemrolekey'] : ''; $_sub_language = $_data['subitemlang']; //----------------------------------------- // Continue... //----------------------------------------- if ($_sub_item_title and $_sub_section) { $app_menu_cache[$app_dir][$id . '_' . $_current_module]['title'] = $_cat_title; $app_menu_cache[$app_dir][$id . '_' . $_current_module]['items'][$_id] = array('title' => $_sub_item_title, 'module' => $_current_module, 'langkey' => $_sub_language, 'keywords' => $_sub_keywords, 'section' => $_sub_section, 'url' => $_sub_item_url, 'rolekey' => $_sub_item_role_key, 'redirect' => $_sub_is_redirect); } } } } } } } } } } $this->cache->setCache('app_menu_cache', $app_menu_cache, array('array' => 1)); }
/** * Import a single app * * @access public * @param string App * @param string Skin key to import * @param int Set ID * @param boolean Set the edited / added flags to 0 (from install, upgrade) * @return mixed bool, or array of info */ public function importTemplateAppXML($app, $skinKey, $setID = 0, $ignoreAddedEditedFlag = false) { //----------------------------------------- // INIT //----------------------------------------- $templateGroups = array(); $templates = array(); $fileXML = IPSLib::getAppDir($app) . '/xml/' . $app . '_' . $skinKey . '_templates.xml'; $infoXML = IPSLib::getAppDir($app) . '/xml/information.xml'; $return = array('updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array()); if (!file_exists($fileXML)) { return $return; } if (!$setID and $skinKey != 'root') { /* Figure out correct set ID based on key */ $skinSetData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => "set_key='" . $skinKey . "'")); $setID = $skinSetData['set_id']; } /* Set ignore flag correctly */ if (!empty($skinKey) and in_array($skinKey, array('root', 'lofi', 'xmlskin'))) { $ignoreAddedEditedFlag = true; } //----------------------------------------- // XML //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPS_DOC_CHAR_SET); //----------------------------------------- // Get information file //----------------------------------------- $xml->load($infoXML); foreach ($xml->fetchElements('template') as $template) { $name = $xml->fetchItem($template); $match = $xml->fetchAttribute($template, 'match'); if ($name) { $templateGroups[$name] = $match; } } if (!is_array($templateGroups) or !count($templateGroups)) { $this->_addMessage("Nothing to export for " . $app); return FALSE; } //----------------------------------------- // Fetch templates //----------------------------------------- $_templates = $this->fetchTemplates($setID, 'allNoContent'); $_MASTER = $this->fetchTemplates(0, 'allNoContent'); //----------------------------------------- // Loop through... //----------------------------------------- foreach ($_templates as $group => $data) { $_okToGo = FALSE; foreach ($templateGroups as $name => $match) { if ($match == 'contains') { if (stristr($group, $name)) { $_okToGo = TRUE; break; } } else { if ($group == $name) { $_okToGo = TRUE; } } } if ($_okToGo === TRUE) { foreach ($data as $name => $templateData) { $templates[$group][$name] = $templateData; } } } //----------------------------------------- // Wipe the master skins //----------------------------------------- if ($setID == 0) { $this->DB->delete('skin_templates', "template_set_id=0 AND template_group IN ('" . implode("','", array_keys($templates)) . "') AND template_user_added=0 AND template_added_to=0"); /* Now wipe the array so we enforce creation */ unset($templates); } //----------------------------------------- // Now grab the actual XML files //----------------------------------------- $xml->load($fileXML); foreach ($xml->fetchElements('template') as $templatexml) { $data = $xml->fetchElementsFromRecord($templatexml); /* Figure out if this is added by a user or not */ if ($ignoreAddedEditedFlag === TRUE) { $isAdded = 0; $isEdited = 0; } else { $isAdded = (is_array($_MASTER[$data['template_group']][strtolower($data['template_name'])]) and !$_MASTER[$data['template_group']][strtolower($data['template_name'])]['template_user_added']) ? 0 : 1; $isEdited = 1; } if (is_array($templates[$data['template_group']][strtolower($data['template_name'])]) and $templates[$data['template_group']][strtolower($data['template_name'])]['template_set_id'] == $setID) { /* Update.. */ $return['updateCount']++; $return['updateBits'][] = $data['template_name']; $this->DB->update('skin_templates', array('template_content' => $data['template_content'], 'template_data' => $data['template_data'], 'template_user_edited' => $isEdited, 'template_user_added' => $isAdded, 'template_updated' => time()), 'template_set_id=' . $setID . " AND template_group='" . $data['template_group'] . "' AND template_name='" . $data['template_name'] . "'"); } else { /* Add... */ $return['insertCount']++; $return['insertBits'][] = $data['template_name']; $this->DB->insert('skin_templates', array('template_set_id' => $setID, 'template_group' => $data['template_group'], 'template_content' => $data['template_content'], 'template_name' => $data['template_name'], 'template_data' => $data['template_data'], 'template_removable' => $setID ? $data['template_removable'] : 0, 'template_added_to' => $setID, 'template_user_edited' => $isEdited, 'template_user_added' => $isAdded, 'template_updated' => time())); } } return $return; }
/** * Convert Polls * * @access private * @return void **/ private function convert_polls() { print 'Need data to finish this section'; exit; //--------------------------- // Set up //--------------------------- $main = array('select' => 'PostID, ThreadID, PostAuthor, UserID, CAST(Subject AS varchar) as Subject, PostDate, IsApproved, CAST(Body AS TEXT) as Body, IPAddress, SectionID', 'from' => 'cs_Posts', 'where' => "PostType = '2'", 'order' => 't.pollid ASC'); $loop = $this->lib->load('polls', $main, array('voters')); //--------------------------- // Loop //--------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) { $xml = new classXML(IPSSetUp::charSet); $xml->loadXML($row['Body']); foreach ($xml->fetchElements('VoteOptions') as $option) { $data = $this->_xml->fetchElementsFromRecord($_el); if ($data['appears'] and intval($data['frequency']) > $this->_minF) { return TRUE; } } //----------------------------------------- // Convert votes //----------------------------------------- $votes = array(); ipsRegistry::DB('hb')->build(array('select' => '*', 'from' => 'pollvoted', 'where' => "pollid='{$row['pollid']}' AND registered='1'")); $voterRes = ipsRegistry::DB('hb')->execute(); while ($voter = ipsRegistry::DB('hb')->fetch($voterRes)) { $vsave = array('vote_date' => time(), 'tid' => $row['threadid'], 'member_id' => $voter['memberid'], 'forum_id' => $row['forumid'], 'member_choices' => serialize(array(1 => $row['optionid']))); $this->lib->convertPollVoter($voter['voteid'], $vsave); } //----------------------------------------- // Options are stored in one place... //----------------------------------------- $choices = array(); $votes = array(); $totalVotes = 0; ipsRegistry::DB('hb')->build(array('select' => '*', 'from' => 'polloptions', 'where' => "pollid='{$row['pollid']}'")); $choiceRes = ipsRegistry::DB('hb')->execute(); while ($choice = ipsRegistry::DB('hb')->fetch($choiceRes)) { $choices[$choice['optionid']] = $choice['description']; $votes[$choice['optionid']] = $choice['votes']; $totalVotes += $choice['votes']; } //----------------------------------------- // Then we can do the actual poll //----------------------------------------- $poll_array = array(1 => array('question' => $row['threadsubject'], 'choice' => $choices, 'votes' => $votes)); $save = array('tid' => $row['threadid'], 'start_date' => strtotime($row['datecreated']), 'choices' => addslashes(serialize($poll_array)), 'starter_id' => $row['memberid'] == '-1' ? 0 : $row['memberid'], 'votes' => $totalVotes, 'forum_id' => $row['forumid'], 'poll_question' => $row['threadsubject']); $this->lib->convertPoll($row['pollid'], $save); } $this->lib->next(); }
/** * Rebuilds the mobile user agents from the skin set data */ public function rebuildMobileSkinUserAgentsFromSetDataXml() { /* Init */ $mobileSkinSet = $this->fetchSkinData($this->fetchSetIdByKey('mobile', true), true); $xmlData = array(); /* Grab xml */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML('UTF-8'); /* Skin Set Data */ $xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml'); foreach ($xml->fetchElements('set') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); if ($data['set_key'] == 'mobile') { $xmlData = $data; break; } } /* Update */ if ($xmlData['set_key'] && IPSLib::isSerialized($xmlData['set_locked_uagent']) && IPSLib::isSerialized($mobileSkinSet['set_locked_uagent'])) { $new = unserialize($xmlData['set_locked_uagent']); $old = unserialize($mobileSkinSet['set_locked_uagent']); /* Merge them */ foreach ($new['groups'] as $group) { if (!in_array($group, $old['groups'])) { $old['groups'][] = $group; } } foreach ($new['uagents'] as $agent => $version) { if (!in_array($agent, $new['uagents'])) { $old['uagents'][$agent] = $version; } } } if (is_array($old) && count($old)) { $this->DB->update('skin_collections', array('set_locked_uagent' => serialize($old)), "set_key='mobile'"); } }
/** * Sends forum data in xml format * * @param array $dataArray * @return @e void */ protected function _returnXml($dataArray) { /* XML Parser */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML('utf-8'); $xml->newXMLDocument(); /* Build Document */ $xml->addElement('forum'); $xml->addElementAsRecord('forum', 'capabilites', array('gallery' => $dataArray['gallery'])); $xml->addElementAsRecord('forum', 'capabilites', array('facebook' => $dataArray['facebook'])); $xml->addElementAsRecord('forum', 'capabilites', array('twitter' => $dataArray['twitter'])); $xml->addElementAsRecord('forum', 'capabilites', array('status' => $dataArray['status'])); $xml->addElementAsRecord('forum', 'capabilites', array('notifications' => $dataArray['notifications'])); $xml->addElement('albums', 'forum'); $xml->addElementAsRecord('forum', 'security', array('form_hash' => $dataArray['form_hash'])); /* Loop through albums */ if (is_array($dataArray['albums']) && count($dataArray['albums'])) { foreach ($dataArray['albums'] as $r) { $xml->addElementAsRecord('albums', array('album'), array('id' => $r['id'], 'name' => $r['name'])); } } $xml->addElementAsRecord('forum', 'version', array('version_id' => $dataArray['version_id'])); $xml->addElementAsRecord('forum', 'version', array('version_text' => $dataArray['version_text'])); /* Output */ echo $xml->fetchDocument(); exit; }
/** * Export help files XML * * @return @e void */ public function helpFilesXMLExport() { /* INIT */ $entry = array(); require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ /* Loop through all the applications */ foreach ($this->registry->getApplications() as $app => $__data) { $c = 0; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('export'); $xml->addElement('help', 'export'); /* Query tasks */ $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "app='{$app}'")); $this->DB->execute(); /* Loop through and add tasks to XML */ while ($r = $this->DB->fetch()) { $c++; unset($r['id']); $r['text'] = str_replace('%7Bstyle_image_url%7D', '{style_image_url}', $r['text']); $xml->addElementAsRecord('help', 'row', $r); } /* Finish XML */ $doc = $xml->fetchDocument(); @unlink(IPSLib::getAppDir($app) . '/xml/' . $app . '_help.xml'); /* Write */ if ($doc and $c) { $fh = @fopen(IPSLib::getAppDir($app) . '/xml/' . $app . '_help.xml', 'w'); @fwrite($fh, $doc); @fclose($fh); } /* In dev time stamp? */ if (IN_DEV) { $cache = $this->caches['indev']; $cache['import']['help'][$app] = time(); $this->cache->setCache('indev', $cache, array('donow' => 1, 'array' => 1)); } } $this->registry->output->global_message = $this->lang->words['h_exported']; $this->helpFilesList(); }
/** * Exports the groups to a master XML file for distribution * * @return @e void [Outputs to screen] */ public function masterXMLExport() { //----------------------------------------- // INIT //----------------------------------------- $entry = array(); $skip = IPSLib::fetchNonDefaultGroupFields(); //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('export'); $xml->addElement('group', 'export'); //----------------------------------------- // Grab our default 6 groups //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'groups', 'order' => 'g_id ASC', 'limit' => array(0, 6))); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); $r['g_icon'] = ''; if (is_array($skip) and count($skip)) { foreach ($skip as $_kk) { unset($r[$_kk]); } } $xml->addElementAsRecord('group', 'row', $r); } //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($xml->fetchDocument(), 'groups.xml', '', 0); }
/** * Construct * * @access public * @param object ipsRegistry reference * @param bool Whether to init * @return @e void */ public function __construct(ipsRegistry $registry, $init = FALSE) { /* Make object */ $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); if ($init === TRUE) { /* Load 'template' */ require_once IPS_ROOT_PATH . 'setup/templates/skin_setup.php'; /*noLibHook*/ $this->template = new skin_setup($registry); /* Images URL */ $this->imageUrl = '../setup/' . PUBLIC_DIRECTORY . '/images'; /* Fetch sequence data */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); $file = IPS_IS_UPGRADER ? IPS_ROOT_PATH . 'setup/xml/upgrade_sequence.xml' : IPS_ROOT_PATH . 'setup/xml/sequence.xml'; try { $xml->load($file); foreach ($xml->fetchElements('action') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $_tmp[$data['position']] = $data; ksort($_tmp); foreach ($_tmp as $pos => $data) { $this->sequenceData[$data['file']] = $data['menu']; } } } catch (Exception $error) { $this->addError("Could not locate: " . $file); } /* Set up URLs */ $this->settings['base_url'] = $this->settings['base_url'] ? $this->settings['base_url'] : IPSSetUp::getSavedData('install_url'); $this->settings['public_dir'] = $this->settings['base_url'] . '/' . PUBLIC_DIRECTORY . '/'; $this->settings['img_url_no_dir'] = $this->settings['base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/'; /* Set Current Page */ $this->currentPage = $this->request['section'] ? $this->request['section'] : 'index'; if (!$this->sequenceData[$this->currentPage]) { $this->currentPage = 'index'; } /* Set default next action */ $_hit = 0; foreach ($this->sequenceData as $file => $text) { if ($_hit) { $this->nextAction = $file; break; } if ($file == $this->currentPage) { $_hit = 1; } } /* Build all skins array */ if (IPS_IS_UPGRADER) { /* For < 3.0.0 upgrades, they won't have this table, so check for it */ if ($this->DB->checkForTable('skin_collections')) { $this->DB->build(array('select' => '*', 'from' => 'skin_collections', 'order' => 'set_id ASC')); $this->DB->execute(); while ($_skinSets = $this->DB->fetch()) { $id = $_skinSets['set_id']; $this->allSkins[$id] = $_skinSets; $this->allSkins[$id]['_parentTree'] = unserialize($_skinSets['set_parent_array']); $this->allSkins[$id]['_childTree'] = unserialize($_skinSets['set_child_array']); $this->allSkins[$id]['_userAgents'] = unserialize($_skinSets['set_locked_uagent']); $this->allSkins[$id]['_cssGroupsArray'] = unserialize($_skinSets['set_css_groups']); $this->allSkins[$id]['_youCanUse'] = TRUE; $this->allSkins[$id]['_gatewayExclude'] = FALSE; /* Array groups */ if (is_array($this->allSkins[$id]['_cssGroupsArray'])) { ksort($this->allSkins[$id]['_cssGroupsArray'], SORT_NUMERIC); } else { $this->allSkins[$id]['_cssGroupsArray'] = array(); } } } } } }
/** * Install a login method * * @return @e void [Outputs to screen] */ protected function _loginInstall() { //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $login_id = basename(ipsRegistry::$request['login_folder']); //----------------------------------------- // Now get the XML data //----------------------------------------- $dh = opendir(IPS_PATH_CUSTOM_LOGIN); if ($dh !== false) { while (false !== ($file = readdir($dh))) { if (is_dir(IPS_PATH_CUSTOM_LOGIN . '/' . $file) and $file == $login_id) { if (is_file(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml')) { $file_content = file_get_contents(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml'); $xml->loadXML($file_content); foreach ($xml->fetchElements('row') as $record) { $data = $xml->fetchElementsFromRecord($record); } } else { closedir($dh); ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404']; $this->_loginList(); return; } $dir_methods[$file] = $data; break; } } closedir($dh); } if (!is_array($dir_methods) or !count($dir_methods)) { ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404']; $this->_loginList(); return; } //----------------------------------------- // Now verify it isn't installed //----------------------------------------- $login = $this->DB->buildAndFetch(array('select' => 'login_id', 'from' => 'login_methods', 'where' => "login_folder_name='" . $login_id . "'")); if ($login['login_id']) { ipsRegistry::getClass('output')->global_message = $this->lang->words['l_already']; $this->_loginList(); return; } //----------------------------------------- // Get the highest order and insert method //----------------------------------------- $max = $this->DB->buildAndFetch(array('select' => 'MAX(login_order) as highest_order', 'from' => 'login_methods')); $dir_methods[$login_id]['login_order'] = $max['highest_order'] + 1; $this->DB->insert('login_methods', $dir_methods[$login_id]); //----------------------------------------- // Recache //----------------------------------------- $this->loginsRecache(); ipsRegistry::getClass('output')->redirect($this->settings['base_url'] . $this->form_code . "", $this->lang->words['l_yesinstalled']); }
/** * Install templates * * @return void */ public function install_templates() { ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_templates'), 'core'); //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; if (is_file(IPS_ROOT_PATH . 'setup/sql/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_install.php')) { require_once IPS_ROOT_PATH . 'setup/sql/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_install.php'; /*noLibHook*/ $extra_install = new install_extra($this->registry); } //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']); /* Got any skin sets? */ $count = $this->DB->buildAndFetch(array('select' => 'count(*) as count', 'from' => 'skin_collections')); if (!$count['count']) { //----------------------------------------- // Next... //----------------------------------------- $output[] = "Добавление шаблонов"; require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('skinset'); } /* Skin Set Data */ $xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml'); foreach ($xml->fetchElements('set') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $this->DB->insert('skin_collections', $data); } //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('skinset'); } } /* Load skin classes */ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php'; /*noLibHook*/ $skinFunctions = new skinImportExport($this->registry); /* Grab skin data */ $this->DB->build(array('select' => '*', 'from' => 'skin_collections')); $this->DB->execute(); while ($row = $this->DB->fetch()) { /* Bit of jiggery pokery... */ if ($row['set_key'] == 'default') { $row['set_key'] = 'root'; $row['set_id'] = 0; } $skinSets[$row['set_key']] = $row; } //----------------------------------------- // InstallTemplates //----------------------------------------- if ($next['key']) { foreach ($skinSets as $skinKey => $skinData) { $_PATH = IPSLib::getAppDir($next['key']) . '/xml/'; $output[] = $next['title'] . ": Обновление шаблонов {$skinData['set_name']}"; if (is_file($_PATH . $next['key'] . '_' . $skinKey . '_templates.xml')) { //----------------------------------------- // Install //----------------------------------------- $return = $skinFunctions->importTemplateAppXML($next['key'], $skinKey, $skinData['set_id'], TRUE); $output[] = $next['title'] . ": " . intval($return['insertCount']) . " шаблонов добавлено"; } if (is_file($_PATH . $next['key'] . '_' . $skinKey . '_css.xml')) { //----------------------------------------- // Install //----------------------------------------- $return = $skinFunctions->importCSSAppXML($next['key'], $skinKey, $skinData['set_id']); $output[] = $next['title'] . ": " . intval($return['insertCount']) . " {$skinData['set_name']} CSS файлов добавлено"; } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $this->_finishStep($output, "Обновление: Шаблоны", 'upgrade&do=templates&previous=' . $next['key']); } else { //----------------------------------------- // Recache templates //----------------------------------------- $output[] = "Кеширование шаблонов"; foreach ($skinSets as $skinKey => $skinData) { /* Replacements */ if (is_file(IPS_ROOT_PATH . 'setup/xml/skins/replacements_' . $skinKey . '.xml')) { $skinFunctions->importReplacementsXMLArchive(file_get_contents(IPS_ROOT_PATH . 'setup/xml/skins/replacements_' . $skinKey . '.xml'), $skinKey); } } $skinFunctions->rebuildMobileSkinUserAgentsFromSetDataXml(); $skinFunctions->rebuildSkinSetsCache(); $output[] = "Все шаблоны обновлены"; $this->_finishStep($output, "Обновление: Шаблоны", 'upgrade&do=tasks'); } }
/** * Execute selected method * * @access public * @param object Registry object * @return @e void */ public function doExecute(ipsRegistry $registry) { /* INIT */ $filesOK = NULL; $extensions = get_loaded_extensions(); $extensionsOK = TRUE; $extensionData = array(); /* Test to make sure core.php is up-to-date. Large file may not always upload cleanly */ if (!method_exists('IPSLib', 'loadLibrary')) { $filesOK = false; $this->registry->output->addError('Please ensure that "' . CP_DIRECTORY . '/sources/base/core.php" is up-to-date. Re-upload via FTP if necessary'); } /* Test Extensions */ $INSTALLDATA = array(); include IPS_ROOT_PATH . 'setup/xml/requiredextensions.php'; /*noLibHook*/ if (is_array($INSTALLDATA) && count($INSTALLDATA)) { foreach ($INSTALLDATA as $data) { if (!in_array($data['testfor'], $extensions)) { //----------------------------------------- // Added 'nohault' key which will show a // warning but not prohibit installation //----------------------------------------- if ($data['nohault']) { $data['_ok'] = 1; // Anything but true or false $extensionsOK = 1; // Anything but true or false } else { $extensionsOK = FALSE; } } else { $data['_ok'] = TRUE; } $extensionData[] = $data; } } /* All extensions loaded OK? */ if ($extensionsOK == TRUE and $filesOK === NULL) { $filesOK = FALSE; /* Fetch core writeable files */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); try { $xml->load(IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml'); foreach ($xml->fetchElements('file') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); if ($data['path']) { /* If we overrode hooks path in constants.php, check that instead */ if ($data['path'] == 'hooks') { $_path = IPS_HOOKS_PATH; } else { $_path = DOC_IPS_ROOT_PATH . $data['path']; } if (!file_exists($_path)) { if ($data['dir']) { if (!@mkdir($_path, IPS_FOLDER_PERMISSION, TRUE)) { $this->registry->output->addError('Directory does not exist: "' . $data['path'] . '", please create it via FTP'); } } else { $this->registry->output->addError('File does not exist: "' . $data['path'] . '", please create it via FTP'); } } if (!is_writeable($_path)) { //----------------------------------------- // If we're upgrading, don't do this to conf_global // @link http://community.invisionpower.com/tracker/issue-20478-config-file-premission/ //----------------------------------------- if (strpos($_path, 'conf_global.php') !== false) { continue; } if (!@chmod($_path, is_dir($_path) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION)) { if (is_dir($_path)) { $this->registry->output->addError('Can not write to directory: "' . $data['path'] . '", please CHMOD to 777'); } else { $this->registry->output->addError('Can not write to file: "' . $data['path'] . '", please CHMOD to 777'); } } } } } if (!count($this->registry->output->fetchErrors())) { $filesOK = TRUE; } } catch (Exception $error) { $filesOK = FALSE; $this->registry->output->addError("Cannot locate: " . IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml'); } } /* Set next action */ $this->registry->output->setNextAction('apps'); /* Hide buttons? */ if ($filesOK !== TRUE or $extensionsOK != TRUE) { $this->registry->output->setNextAction(''); $this->registry->output->setHideButton(TRUE); } /* Simply return the requirements page */ $this->registry->output->setTitle("Requirements"); $this->registry->output->addContent($this->registry->output->template()->page_requirements($filesOK, $extensionsOK, $extensionData, 'upgrade')); $this->registry->output->sendOutput(); }
/** * Exports badwords to an xml file * * @return @e void */ public function badwordsExport() { //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('badwordexport'); $xml->addElement('badwordgroup', 'badwordexport'); /* Query the badwords */ $this->DB->build(array('select' => 'type, swop, m_exact', 'from' => 'badwords', 'order' => 'type')); $this->DB->execute(); /* Add the bad word entries to the xml file */ while ($r = $this->DB->fetch()) { $xml->addElementAsRecord('badwordgroup', 'badword', $r); } /* Create the xml document and send to the browser */ $xmlData = $xml->fetchDocument(); $this->registry->output->showDownload($xmlData, 'ipb_badwords.xml'); }
/** * Export language entries to xml file * * @param integer $lang_id Language pack to export * @param bool $disk Save to disk instead * @return void */ public function languageExportToXML($lang_id, $disk = false) { //----------------------------------------- // Init //----------------------------------------- $app_dir = trim($this->request['app_dir']); $type = trim($this->request['type']); $_where = ''; $_name = 'language.xml'; $LATESTVERSION = IPSLib::fetchVersionNumber(); $doPack = true; //----------------------------------------- // Filter //----------------------------------------- if ($app_dir) { $_where = " AND word_app='" . $app_dir . "'"; $_name = $app_dir . '_language_pack.xml'; $doPack = false; } if ($type) { if ($type == 'admin') { $_where .= " AND word_pack LIKE 'admin_%'"; $_name = 'admin_' . $_name; } else { $_where .= " AND word_pack LIKE 'public_%'"; $_name = 'public_' . $_name; } $doPack = false; } //----------------------------------------- // Create the XML library //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('languageexport'); $xml->addElement('languagegroup', 'languageexport'); //----------------------------------------- // Get language pack //----------------------------------------- $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$lang_id}")); //----------------------------------------- // Add pack if necessary //----------------------------------------- if ($doPack) { $xml->addElementAsRecord('languagegroup', 'langinfo', $data); } //----------------------------------------- // Get the words //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id}" . $_where)); $this->DB->execute(); //----------------------------------------- // Add words to export //----------------------------------------- $word_packs = array(); $_strings = 0; while ($r = $this->DB->fetch()) { $content = array(); $_strings++; if ($disk) { $content = array('word_app' => $r['word_app'], 'word_pack' => $r['word_pack'], 'word_key' => $r['word_key'], 'word_default' => $r['word_default']); if ($r['word_js']) { $content['word_js'] = $r['word_js']; } } else { $content = array('word_app' => $r['word_app'], 'word_pack' => $r['word_pack'], 'word_key' => $r['word_key'], 'word_default' => $r['word_default'], 'word_custom' => $r['word_custom'], 'word_default_version' => $r['word_default_version'] >= 30000 ? $r['word_default_version'] : $LATESTVERSION['long'], 'word_custom_version' => $r['word_custom_version'], 'word_js' => $r['word_js']); } $xml->addElementAsRecord('languagegroup', 'lang', $content); } //----------------------------------------- // Got any strings? //----------------------------------------- if (!$_strings) { if ($disk) { return false; } else { $this->registry->output->global_message = $this->lang->words['l_nolangbits']; $this->languagesList(); return; } } //----------------------------------------- // Write to disk or output to browser //----------------------------------------- if ($disk) { @unlink(IPSLib::getAppDir($app_dir) . '/xml/' . $_name); @file_put_contents(IPSLib::getAppDir($app_dir) . '/xml/' . $_name, $xml->fetchDocument()); return true; } else { //----------------------------------------- // Create xml archive //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXMLArchive.php'; /*noLibHook*/ $xmlArchive = new classXMLArchive(); //----------------------------------------- // Add XML document //----------------------------------------- $xmlArchive->add($xml->fetchDocument(), 'language_entries.xml'); //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($xmlArchive->getArchiveContents(), $_name); exit; } }
/** * Actually export the damn hook already * Sorry, it has been a long day... * * @access private * @return void */ private function _doExportHook() { //----------------------------------------- // Get hook //----------------------------------------- $id = intval($this->request['id']); if (!$id) { $this->registry->output->showError($this->lang->words['h_noexport'], 1114); } $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id)); if (!$hookData['hook_id']) { $this->registry->output->showError($this->lang->words['h_noexport'], 1115); } $extra_data = unserialize($hookData['hook_extra_data']); //----------------------------------------- // Get hook files //----------------------------------------- $files = array(); $index = 1; $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id)); $this->DB->execute(); while ($r = $this->DB->fetch()) { $files[$index] = $r; $index++; } //----------------------------------------- // Get XML class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('hookexport'); //----------------------------------------- // Put hook data in export //----------------------------------------- $xml->addElement('hookdata', 'hookexport'); $content = array(); foreach ($hookData as $k => $v) { if (in_array($k, array('hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position'))) { continue; } $content[$k] = $v; } $xml->addElementAsRecord('hookdata', 'config', $content); //----------------------------------------- // Put hook files in export //----------------------------------------- $xml->addElement('hookfiles', 'hookexport'); foreach ($files as $index => $r) { $content = array(); foreach ($r as $k => $v) { if (in_array($k, array('hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source'))) { continue; } $content[$k] = $v; } $source = file_exists(IPS_HOOKS_PATH . $r['hook_file_stored']) ? file_get_contents(IPS_HOOKS_PATH . $r['hook_file_stored']) : ''; if ($r['hook_type'] == 'commandHooks') { $source = $this->_cleanSource($source); } $content['hooks_source'] = $source; $xml->addElementAsRecord('hookfiles', 'file', $content); } //----------------------------------------- // Custom install/uninstall script? //----------------------------------------- if ($extra_data['custom']) { $content = array(); $xml->addElement('hookextras_custom', 'hookexport'); $content['filename'] = $extra_data['custom']; $content['source'] = file_exists(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) ? file_get_contents(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) : ''; $xml->addElementAsRecord('hookextras_custom', 'file', $content); } //----------------------------------------- // Settings or setting groups? //----------------------------------------- $entry = array(); $_groups = array(); $_settings = array(); $titles = array(); $content = array(); $xml->addElement('hookextras_settings', 'hookexport'); # Store group ids and setting ids for entire setting groups if (is_array($extra_data['settingGroups']) and count($extra_data['settingGroups'])) { $_groups = $extra_data['settingGroups']; $this->DB->build(array('select' => 'conf_id', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode(',', $_groups) . ')')); $this->DB->execute(); while ($setting = $this->DB->fetch()) { $_settings[] = $setting['conf_id']; } } # Store group ids and setting ids for indvidual settings if (is_array($extra_data['settings']) and count($extra_data['settings'])) { foreach ($extra_data['settings'] as $settingId) { $_settings[] = $settingId; } $this->DB->build(array('select' => 'conf_group', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id IN(' . implode(',', $extra_data['settings']) . ')')); $this->DB->execute(); while ($group = $this->DB->fetch()) { $_groups[] = $group['conf_group']; } } if (count($_groups)) { # Now get the group data for the XML file $this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => 'conf_title_id IN(' . implode(',', $_groups) . ')')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); $titles[$r['conf_title_id']] = $r['conf_title_keyword']; $content['conf_is_title'] = 1; foreach ($r as $k => $v) { if (in_array($k, array('conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow'))) { $content[$k] = $v; } } $xml->addElementAsRecord('hookextras_settings', 'setting', $content); } } if (count($_settings)) { # Now get the group data for the XML file $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id IN(' . implode(',', $_settings) . ')')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $r['conf_value'] = ''; $r['conf_title_keyword'] = $titles[$r['conf_group']]; $r['conf_is_title'] = 0; $xml->addElementAsRecord('hookextras_settings', 'setting', $r); } } //----------------------------------------- // Language strings/files //----------------------------------------- $entry = array(); $xml->addElement('hookextras_language', 'hookexport'); if (is_array($extra_data['language']) and count($extra_data['language'])) { foreach ($extra_data['language'] as $file => $strings) { $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_pack='{$file}' AND word_key IN('" . implode("','", $strings) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); foreach ($r as $k => $v) { if (in_array($k, array('word_id', 'lang_id', 'word_default_version', 'word_custom_version'))) { continue; } $content[$k] = $v; } $xml->addElementAsRecord('hookextras_language', 'language', $content); } } } //----------------------------------------- // Modules //----------------------------------------- $xml->addElement('hookextras_modules', 'hookexport'); if (is_array($extra_data['modules']) and count($extra_data['modules'])) { $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_key IN('" . implode("','", $extra_data['modules']) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['sys_module_id']); $xml->addElementAsRecord('hookextras_modules', 'module', $r); } } //----------------------------------------- // Help files //----------------------------------------- $xml->addElement('hookextras_help', 'hookexport'); if (is_array($extra_data['help']) and count($extra_data['help'])) { $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "id IN(" . implode(",", $extra_data['help']) . ")")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['id']); $xml->addElementAsRecord('hookextras_help', 'help', $r); } } //----------------------------------------- // Skin templates //----------------------------------------- $xml->addElement('hookextras_templates', 'hookexport'); if (is_array($extra_data['templates']) and count($extra_data['templates'])) { foreach ($extra_data['templates'] as $file => $templates) { $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id=0 AND template_group='{$file}' AND template_name IN('" . implode("','", $templates) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['template_id']); $xml->addElementAsRecord('hookextras_templates', 'templates', $r); } } } //----------------------------------------- // Tasks //----------------------------------------- $xml->addElement('hookextras_tasks', 'hookexport'); if (is_array($extra_data['tasks']) and count($extra_data['tasks'])) { $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_id IN(" . implode(",", $extra_data['tasks']) . ")")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['task_id']); unset($r['task_next_run']); $xml->addElementAsRecord('hookextras_tasks', 'tasks', $r); } } //----------------------------------------- // Database changes //----------------------------------------- $xml->addElement('hookextras_database_create', 'hookexport'); if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) { foreach ($extra_data['database']['create'] as $create_query) { $xml->addElementAsRecord('hookextras_database_create', 'create', $create_query); } } $xml->addElement('hookextras_database_alter', 'hookexport'); if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) { foreach ($extra_data['database']['alter'] as $alter_query) { $xml->addElementAsRecord('hookextras_database_alter', 'alter', $alter_query); } } $xml->addElement('hookextras_database_update', 'hookexport'); if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) { foreach ($extra_data['database']['update'] as $update_query) { $xml->addElementAsRecord('hookextras_database_update', 'update', $update_query); } } $xml->addElement('hookextras_database_insert', 'hookexport'); if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) { foreach ($extra_data['database']['insert'] as $insert_query) { $xml->addElementAsRecord('hookextras_database_update', 'insert', $insert_query); } } //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($xml->fetchDocument(), 'hook.xml', '', 0); }
/** * Export a bbcode XML file * * @return @e void [Outputs to screen] */ protected function _bbcodeExport() { //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('bbcodeexport'); $xml->addElement('bbcodegroup', 'bbcodeexport'); //----------------------------------------- // Get bbcodes //----------------------------------------- $select = array('select' => '*', 'from' => 'custom_bbcode'); if ($this->request['id']) { $select['where'] = 'bbcode_id=' . intval($this->request['id']); } $this->DB->build($select); $this->DB->execute(); while ($r = $this->DB->fetch()) { $xml->addElementAsRecord('bbcodegroup', 'bbcode', $r); } $xmlData = $xml->fetchDocument(); //----------------------------------------- // Send to browser. //----------------------------------------- $this->registry->output->showDownload($xmlData, 'bbcode.xml', '', 0); }
/** * Execute selected method * * @access public * @param object Registry object * @return @e void */ public function doExecute(ipsRegistry $registry) { /* INIT */ $filesOK = NULL; $extensions = get_loaded_extensions(); $extensionsOK = TRUE; $extensionData = array(); /* Test Extensions */ $INSTALLDATA = array(); include IPS_ROOT_PATH . 'setup/xml/requiredextensions.php'; /*noLibHook*/ if (is_array($INSTALLDATA) && count($INSTALLDATA)) { foreach ($INSTALLDATA as $data) { if (!in_array($data['testfor'], $extensions)) { //----------------------------------------- // Added 'nohault' key which will show a // warning but not prohibit installation //----------------------------------------- if ($data['nohault']) { $data['_ok'] = 1; // Anything but true or false $extensionsOK = 1; // Anything but true or false } else { $extensionsOK = FALSE; } } else { $data['_ok'] = TRUE; } $extensionData[] = $data; } } /* Check for conf_global.dist.php */ if (is_file(DOC_IPS_ROOT_PATH . 'conf_global.dist.php') and !is_file(DOC_IPS_ROOT_PATH . 'conf_global.php')) { if (!@rename(DOC_IPS_ROOT_PATH . 'conf_global.dist.php', DOC_IPS_ROOT_PATH . 'conf_global.php')) { $filesOK = FALSE; $this->registry->output->addError("<strong>You MUST rename the file 'conf_global.<b style='color:red'>dist.php</b>' TO 'conf_global.<b style='color:red'>php</b>' before continuing.</strong>\r\r\n\t\t\t\t\t\t\t \t\t\t\t\t\t This file can be found in the 'root' directory on your IP.Board install."); } } /* All extensions loaded OK? */ if ($extensionsOK == TRUE and $filesOK === NULL) { $filesOK = FALSE; /* Fetch core writeable files */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); try { $xml->load(IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml'); foreach ($xml->fetchElements('file') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); if ($data['path']) { $_path = DOC_IPS_ROOT_PATH . $data['path']; if (!file_exists($_path)) { if ($data['dir']) { if (!@mkdir($_path, IPS_FOLDER_PERMISSION, TRUE)) { $this->registry->output->addError('Directory does not exist: "' . $data['path'] . '", please create it via FTP'); } } else { $this->registry->output->addError('File does not exist: "' . $data['path'] . '", please create it via FTP'); } } if (!is_writeable($_path)) { if (!@chmod($_path, is_dir($_path) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION)) { if (is_dir($_path)) { $this->registry->output->addError('Can not write to directory: "' . $data['path'] . '", please CHMOD to 777'); } else { $this->registry->output->addError('Can not write to file: "' . $data['path'] . '", please CHMOD to 777'); } } } } } if (!count($this->registry->output->fetchErrors())) { $filesOK = TRUE; } } catch (Exception $error) { $filesOK = FALSE; $this->registry->output->addError("Cannot locate: " . IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml'); } } /* Hide buttons? */ if ($filesOK !== TRUE or $extensionsOK != TRUE) { $this->registry->output->setNextAction(''); $this->registry->output->setHideButton(TRUE); } /* Simply return the requirements page */ $this->registry->output->setTitle("Requirements"); $this->registry->output->addContent($this->registry->output->template()->page_requirements($filesOK, $extensionsOK, $extensionData)); $this->registry->output->sendOutput(); }
/** * Builds the attachment type xml export * * @return @e void */ public function attachmentTypeExport() { //----------------------------------------- // Get xml class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('attachtypesexport'); $xml->addElement('attachtypesgroup', 'attachtypesexport'); /* Query the attachment Types */ $this->DB->build(array('select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'order' => "atype_extension")); $this->DB->execute(); /* Loop through the types */ $entry = array(); while ($r = $this->DB->fetch()) { $xml->addElementAsRecord('attachtypesgroup', 'attachtype', $r); } /* Send for download */ $this->registry->output->showDownload($xml->fetchDocument(), 'attachments.xml', "unknown/unknown", false); }
/** * Actually export the damn hook already * Sorry, it has been a long day... * * @return @e void */ protected function _doExportHook() { //----------------------------------------- // Get hook //----------------------------------------- $id = intval($this->request['id']); if (!$id) { $this->registry->output->showError($this->lang->words['h_noexport'], 1114); } $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id)); if (!$hookData['hook_id']) { $this->registry->output->showError($this->lang->words['h_noexport'], 1115); } $extra_data = unserialize($hookData['hook_extra_data']); //----------------------------------------- // Get hook files //----------------------------------------- $files = array(); $index = 1; $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id, 'order' => 'hook_file_id ASC')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $files[$index] = $r; $index++; } //----------------------------------------- // Get XML class //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->newXMLDocument(); $xml->addElement('hookexport'); //----------------------------------------- // Put hook data in export //----------------------------------------- $xml->addElement('hookdata', 'hookexport'); $content = array(); foreach ($hookData as $k => $v) { if (in_array($k, array('hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position'))) { continue; } $content[$k] = $v; } $xml->addElementAsRecord('hookdata', 'config', $content); //----------------------------------------- // Put hook files in export //----------------------------------------- $xml->addElement('hookfiles', 'hookexport'); foreach ($files as $index => $r) { $content = array(); foreach ($r as $k => $v) { if (in_array($k, array('hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source'))) { continue; } $content[$k] = $v; } $source = is_file(IPS_HOOKS_PATH . $r['hook_file_stored']) ? file_get_contents(IPS_HOOKS_PATH . $r['hook_file_stored']) : ''; if (!empty($source) && in_array($r['hook_type'], array('skinHooks', 'commandHooks', 'libraryHooks'))) { $source = $this->_cleanSource($source); } $content['hooks_source'] = $source; $xml->addElementAsRecord('hookfiles', 'file', $content); } //----------------------------------------- // Custom install/uninstall script? //----------------------------------------- if ($extra_data['custom']) { $content = array(); $xml->addElement('hookextras_custom', 'hookexport'); $content['filename'] = $extra_data['custom']; $content['source'] = is_file(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) ? file_get_contents(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) : ''; $xml->addElementAsRecord('hookextras_custom', 'file', $content); } //----------------------------------------- // Settings or setting groups? //----------------------------------------- $entry = array(); $_groups = array(); $_settings = array(); $titles = array(); $content = array(); $xml->addElement('hookextras_settings', 'hookexport'); # Store group ids and setting ids for entire setting groups if (is_array($extra_data['settingGroups']) and count($extra_data['settingGroups'])) { $_groups = $extra_data['settingGroups']; $_groupIds = array(); $this->DB->build(array('select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode("','", $_groups) . "')")); $this->DB->execute(); while ($rr = $this->DB->fetch()) { $_groupIds[] = $rr['conf_title_id']; } if (count($_groupIds)) { $this->DB->build(array('select' => 'conf_key', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode(',', $_groupIds) . ')')); $this->DB->execute(); while ($setting = $this->DB->fetch()) { $_settings[] = $setting['conf_key']; } } } # Store group ids and setting ids for indvidual settings if (is_array($extra_data['settings']) and count($extra_data['settings'])) { foreach ($extra_data['settings'] as $_aSetting) { $_settings[] = $_aSetting; } $this->DB->build(array('select' => 't.conf_title_keyword', 'from' => array('core_sys_settings_titles' => 't'), 'where' => "c.conf_key IN('" . implode("','", $extra_data['settings']) . "')", 'add_join' => array(array('from' => array('core_sys_conf_settings' => 'c'), 'where' => 'c.conf_group=t.conf_title_id', 'type' => 'left')))); $this->DB->execute(); while ($group = $this->DB->fetch()) { $_groups[] = $group['conf_title_keyword']; } } if (count($_groups)) { # Now get the group data for the XML file $this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode("','", $_groups) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); $titles[$r['conf_title_id']] = $r['conf_title_keyword']; $content['conf_is_title'] = 1; foreach ($r as $k => $v) { if (in_array($k, array('conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow'))) { $content[$k] = $v; } } $xml->addElementAsRecord('hookextras_settings', 'setting', $content); } } if (count($_settings)) { # Now get the group data for the XML file $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN('" . implode("','", $_settings) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $r['conf_value'] = ''; $r['conf_title_keyword'] = $titles[$r['conf_group']]; $r['conf_is_title'] = 0; $xml->addElementAsRecord('hookextras_settings', 'setting', $r); } } //----------------------------------------- // Language strings/files //----------------------------------------- $entry = array(); $xml->addElement('hookextras_language', 'hookexport'); if (is_array($extra_data['language']) and count($extra_data['language'])) { foreach ($extra_data['language'] as $file => $strings) { $bits = explode('_', $file); $app = $bits[0]; $pack = str_replace($app . '_', '', $file); $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_app='{$app}' AND word_pack='{$pack}' AND word_key IN('" . implode("','", $strings) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); foreach ($r as $k => $v) { if (!in_array($k, array('word_app', 'word_pack', 'word_key', 'word_default'))) { continue; } $content[$k] = $v; } $xml->addElementAsRecord('hookextras_language', 'language', $content); } } } //----------------------------------------- // Modules //----------------------------------------- $xml->addElement('hookextras_modules', 'hookexport'); if (is_array($extra_data['modules']) and count($extra_data['modules'])) { foreach ($extra_data['modules'] as $module) { list($_side, $_app, $_module) = explode('-', $module); $_is_admin = $_side == 'admin' ? 1 : 0; $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['sys_module_id']); $xml->addElementAsRecord('hookextras_modules', 'module', $r); } } } //----------------------------------------- // Help files //----------------------------------------- $xml->addElement('hookextras_help', 'hookexport'); if (is_array($extra_data['help']) and count($extra_data['help'])) { $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "title IN('" . implode("','", $extra_data['help']) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['id']); $xml->addElementAsRecord('hookextras_help', 'help', $r); } } //----------------------------------------- // Skin templates //----------------------------------------- $remapData = $this->registry->output->buildRemapData(true); $xml->addElement('hookextras_templates', 'hookexport'); if (is_array($extra_data['templates']) and count($extra_data['templates'])) { foreach ($extra_data['templates'] as $file => $templates) { $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id IN ('" . implode("','", $remapData['export']) . "') AND template_master_key != '' AND template_group='{$file}' AND template_name IN('" . implode("','", $templates) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['template_id']); unset($r['template_set_id']); $xml->addElementAsRecord('hookextras_templates', 'templates', $r); } } } //----------------------------------------- // CSS //----------------------------------------- $xml->addElement('hookextras_css', 'hookexport'); if (is_array($extra_data['css']) and count($extra_data['css'])) { $this->DB->build(array('select' => '*', 'from' => 'skin_css', 'where' => "css_set_id IN ('" . implode("','", $remapData['export']) . "') AND css_master_key != '' AND css_group IN('" . implode("','", $extra_data['css']) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['css_id']); unset($r['css_set_id']); $xml->addElementAsRecord('hookextras_css', 'css', $r); } } //----------------------------------------- // Replacements //----------------------------------------- $xml->addElement('hookextras_replacements', 'hookexport'); if (is_array($extra_data['replacements']) and count($extra_data['replacements'])) { $this->DB->build(array('select' => '*', 'from' => 'skin_replacements', 'where' => "replacement_key IN('" . implode("','", $extra_data['replacements']) . "')", 'group' => 'replacement_key')); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['replacement_id']); unset($r['replacement_set_id']); $xml->addElementAsRecord('hookextras_replacements', 'replacements', $r); } } //----------------------------------------- // Tasks //----------------------------------------- $xml->addElement('hookextras_tasks', 'hookexport'); if (is_array($extra_data['tasks']) and count($extra_data['tasks'])) { $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_key IN('" . implode("','", $extra_data['tasks']) . "')")); $this->DB->execute(); while ($r = $this->DB->fetch()) { unset($r['task_id']); unset($r['task_next_run']); $xml->addElementAsRecord('hookextras_tasks', 'tasks', $r); } } //----------------------------------------- // Database changes //----------------------------------------- $xml->addElement('hookextras_database_create', 'hookexport'); if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) { foreach ($extra_data['database']['create'] as $create_query) { $xml->addElementAsRecord('hookextras_database_create', 'create', $create_query); } } $xml->addElement('hookextras_database_alter', 'hookexport'); if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) { foreach ($extra_data['database']['alter'] as $alter_query) { $xml->addElementAsRecord('hookextras_database_alter', 'alter', $alter_query); } } $xml->addElement('hookextras_database_update', 'hookexport'); if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) { foreach ($extra_data['database']['update'] as $update_query) { $xml->addElementAsRecord('hookextras_database_update', 'update', $update_query); } } $xml->addElement('hookextras_database_insert', 'hookexport'); if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) { foreach ($extra_data['database']['insert'] as $insert_query) { $xml->addElementAsRecord('hookextras_database_insert', 'insert', $insert_query); } } //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($xml->fetchDocument(), $hookData['hook_key'] . '.xml', '', 0); }