/** * 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'] = ''; }
/** * 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'"); } }
/** * Function mostly used in installer/upgrader * Inserts new hooks * * @param string Application to install hooks for */ public function installAppHooks($app) { static $hooks = array(); $msgs = array('inserted' => 0, 'updated' => 0, 'skipped' => 0); $xmlData = array(); $path = IPSLib::getAppDir($app) . '/xml'; if (is_file($path . '/hooks.xml') and is_dir($path . '/hooks')) { if (!count($hooks)) { /* Fetch current hooks */ $this->DB->build(array('select' => '*', 'from' => 'core_hooks')); $this->DB->execute(); while ($row = $this->DB->fetch()) { if ($row['hook_key']) { $hooks[$row['hook_key']] = $row; } } } /* Alright. We're in. Read the XML file */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); /* Grab wrapper file */ $xml->load($path . '/hooks.xml'); foreach ($xml->fetchElements('hook') as $data) { $xmlData[] = $xml->fetchElementsFromRecord($data); } /* Examine XML */ if (is_array($xmlData) and count($xmlData)) { foreach ($xmlData as $x) { if (is_file($path . '/hooks/' . $x['file'])) { $xml->load($path . '/hooks/' . $x['file']); foreach ($xml->fetchElements('config') as $data) { $config = $xml->fetchElementsFromRecord($data); } if (!isset($hooks[$config['hook_key']])) { /* Add it */ $msgs['inserted']++; $this->installHook(file_get_contents($path . '/hooks/' . $x['file']), FALSE, FALSE, $x['enabled']); } else { $this->installHook(file_get_contents($path . '/hooks/' . $x['file']), FALSE, FALSE, $x['enabled']); $msgs['updated']++; } } } } } return $msgs; }
/** * 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(); }
/** * 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'); } }
/** * 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 Other stuff * * @return void */ public function install_other() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; //----------------------------------------- // HOOKS: Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, 'hooks.xml'); /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Insert tasks //----------------------------------------- if ($next['key']) { $output[] = $next['title'] . ": Inserting hooks..."; $_PATH = IPSLib::getAppDir($next['key']) . '/xml/'; if (file_exists($_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'; $hooks = new admin_core_applications_hooks(); $hooks->makeRegistryShortcuts($this->registry); $result = $hooks->installAppHooks($next['key']); $output[] = "Hooks " . $next['title'] . ": " . $result['inserted'] . " 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: Hook", 'install&do=other&previous=' . $next['key']); } else { require_once IPS_KERNEL_PATH . 'classXML.php'; //----------------------------------------- // ****** LOG IN MODULES //----------------------------------------- $output[] = "Inserting log in modules information..."; $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']); $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[] = "Inserting default user agents..."; $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'; $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'); } //----------------------------------------- // ****** GROUPS //----------------------------------------- $output[] = "Inserting groups information..."; $xml = new classXML(IPSSetUp::charSet); if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('groups'); } $xml->load(IPS_ROOT_PATH . 'setup/xml/groups.xml'); foreach ($xml->fetchElements('row') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $this->DB->insert('groups', $data); } if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('groups'); } //----------------------------------------- // ****** ATTACHMENTS //----------------------------------------- $output[] = "Inserting attachment type information..."; 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'; $cal = new admin_calendar_calendar_calendars(); $cal->makeRegistryShortcuts($this->registry); $output[] = "Building calendar 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' => 'en-US'), 'lang_id=1'); } else { $this->DB->update('core_sys_lang', array('lang_short' => 'en_US'), 'lang_id=1'); } } //----------------------------------------- // Next... //----------------------------------------- $this->_finishStep($output, "Install: Other Data", 'install&do=caches'); }
/** * 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; } }
/** * 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'); }
/** * Remove an application * * @return @e void [Outputs to screen] */ public function applicationRemove() { //-------------------------------------------- // INIT //-------------------------------------------- $app_id = intval($this->request['app_id']); //----------------------------------------- // Got an application? //----------------------------------------- $application = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_applications', 'where' => 'app_id=' . $app_id)); if (!$application['app_id']) { $this->registry->output->global_message = $this->lang->words['a_noid']; $this->applicationsOverview(); return; } //----------------------------------------- // Protected? //----------------------------------------- if (!IN_DEV and $application['app_protected']) { $this->registry->output->global_message = $this->lang->words['a_protectapp']; $this->applicationsOverview(); return; } //----------------------------------------- // Remove Settings //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_app='{$application['app_directory']}'")); $this->DB->execute(); $conf_title_id = array(); while ($r = $this->DB->fetch()) { $conf_title_id[] = $r['conf_title_id']; } if (count($conf_title_id)) { $this->DB->delete('core_sys_conf_settings', 'conf_group IN(' . implode(',', $conf_title_id) . ')'); } $this->DB->delete('core_sys_settings_titles', "conf_title_app='{$application['app_directory']}'"); $settingsFile = IPSLib::getAppDir($application['app_directory']) . '/xml/' . $application['app_directory'] . '_settings.xml'; if (is_file($settingsFile)) { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->load($settingsFile); $keys = array(); foreach ($xml->fetchElements('setting') as $setting) { $entry = $xml->fetchElementsFromRecord($setting); if ($entry['conf_is_title']) { continue; } $keys[] = "'{$entry['conf_key']}'"; } if (!empty($keys)) { $this->DB->delete('core_sys_conf_settings', 'conf_key IN(' . implode(',', $keys) . ')'); } } //----------------------------------------- // Remove Application Caches //----------------------------------------- $_file = IPSLib::getAppDir($application['app_directory']) . '/extensions/coreVariables.php'; if (is_file($_file)) { $CACHE = array(); require $_file; /*noLibHook*/ if (is_array($CACHE) and count($CACHE)) { foreach ($CACHE as $key => $data) { $this->DB->delete('cache_store', "cs_key='{$key}'"); } } } //----------------------------------------- // Remove tables //----------------------------------------- $_file = IPSLib::getAppDir($application['app_directory']) . '/setup/versions/install/sql/' . $application['app_directory'] . '_' . ipsRegistry::dbFunctions()->getDriverType() . '_tables.php'; if (is_file($_file)) { $TABLE = array(); require $_file; /*noLibHook*/ foreach ($TABLE as $q) { //----------------------------------------- // Capture create tables first //----------------------------------------- preg_match("/CREATE TABLE (\\S+)(\\s)?\\(/", $q, $match); if ($match[1]) { $_table = preg_replace('#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\\S+)#", "\\1", $match[1]); $this->DB->dropTable($_table); } else { //----------------------------------------- // Then capture alter tables //----------------------------------------- preg_match("/ALTER TABLE (\\S+)\\sADD\\s(\\S+)\\s/i", $q, $match); if ($match[1] and $match[2]) { $_table = preg_replace('#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\\S+)#", "\\1", $match[1]); $_field = $match[2]; /* check for field */ if ($this->DB->checkForField($_field, $_table)) { $this->DB->dropField($_table, $_field); } } } } } //----------------------------------------- // Check for uninstall sql //----------------------------------------- /* Any "extra" configs required for this driver? */ if (is_file(IPS_ROOT_PATH . 'setup/sql/' . $this->settings['sql_driver'] . '_install.php')) { require_once IPS_ROOT_PATH . 'setup/sql/' . $this->settings['sql_driver'] . '_install.php'; /*noLibHook*/ $extra_install = new install_extra($this->registry); } $_file = IPSLib::getAppDir($application['app_directory']) . '/setup/versions/install/sql/' . $application['app_directory'] . '_' . ipsRegistry::dbFunctions()->getDriverType() . '_uninstall.php'; if (is_file($_file)) { $QUERY = array(); require $_file; /*noLibHook*/ if (is_array($QUERY) and count($QUERY)) { foreach ($QUERY as $q) { if ($extra_install and method_exists($extra_install, 'process_query_create')) { $q = $extra_install->process_query_create($q); } $this->DB->query($q); } } } //----------------------------------------- // Remove Misc Stuff //----------------------------------------- $this->DB->delete('core_sys_lang_words', "word_app='{$application['app_directory']}'"); $this->DB->delete('task_manager', "task_application='{$application['app_directory']}'"); $this->DB->delete('permission_index', "app='{$application['app_directory']}'"); $this->DB->delete('reputation_index', "app='{$application['app_directory']}'"); $this->DB->delete('reputation_cache', "app='{$application['app_directory']}'"); $this->DB->delete('core_tags', "tag_meta_app='{$application['app_directory']}'"); $this->DB->delete('faq', "app='{$application['app_directory']}'"); $this->DB->delete('custom_bbcode', "bbcode_app='{$application['app_directory']}'"); $this->DB->delete('upgrade_history', "upgrade_app='{$application['app_directory']}'"); $this->DB->delete('core_like_cache', "like_cache_app='{$application['app_directory']}'"); $this->DB->delete('core_like', "like_app='{$application['app_directory']}'"); $this->DB->delete('core_item_markers', "item_app='{$application['app_directory']}'"); //----------------------------------------- // Report center.. //----------------------------------------- $plugin = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_classes', 'where' => "app='{$application['app_directory']}'")); if ($plugin['com_id']) { $this->DB->build(array('select' => '*', 'from' => 'rc_reports_index', 'where' => 'rc_class=' . $plugin['com_id'])); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $this->DB->delete('rc_reports', "rid=" . $r['id']); $this->DB->delete('rc_comments', "rid=" . $r['id']); } $this->DB->delete('rc_reports_index', 'rc_class=' . $plugin['com_id']); $this->DB->delete('rc_classes', 'com_id=' . $plugin['com_id']); } //----------------------------------------- // Attachments //----------------------------------------- $_plugins = array(); try { foreach (new DirectoryIterator(IPSLib::getAppDir($application['app_directory']) . '/extensions/attachments/') as $file) { if (!$file->isDot() && $file->isFile()) { if (preg_match("/^plugin_(.+?)\\.php\$/", $file->getFileName(), $matches)) { $_plugins[] = $matches[1]; } } } if (count($_plugins)) { foreach ($_plugins as $_plugin) { $this->DB->build(array('select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module='{$_plugin}'")); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { if (is_file($this->settings['upload_dir'] . "/" . $r['attach_location'])) { @unlink($this->settings['upload_dir'] . "/" . $r['attach_location']); } } $this->DB->delete('attachments', "attach_rel_module='{$_plugin}'"); } } } catch (Exception $e) { } //----------------------------------------- // Get all hook files //----------------------------------------- if (is_dir(IPSLib::getAppDir($application['app_directory']) . '/xml/hooks')) { $files = scandir(IPSLib::getAppDir($application['app_directory']) . '/xml/hooks'); $hooks = array(); require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); if (count($files) and is_array($files)) { foreach ($files as $_hookFile) { if ($_hookFile != '.' and $_hookFile != '..' and preg_match("/(\\.xml)\$/", $_hookFile)) { $xml->loadXML(file_get_contents(IPSLib::getAppDir($application['app_directory']) . '/xml/hooks/' . $_hookFile)); foreach ($xml->fetchElements('config') as $data) { $config = $xml->fetchElementsFromRecord($data); if (!count($config)) { continue; } else { $hooks[] = $config['hook_key']; } } } } } if (count($hooks)) { foreach ($hooks as $hook) { $hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => "hook_key='" . $hook . "'")); if (!$hook['hook_id']) { continue; } $this->DB->delete('core_hooks', "hook_id={$hook['hook_id']}"); /* Get associated files */ $this->DB->build(array('select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook['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['hook_id']}"); } $this->cache->rebuildCache('hooks', 'global'); } } //----------------------------------------- // Remove Files //----------------------------------------- /* Languages */ try { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'cache/lang_cache/') as $dir) { if (!$dir->isDot() && intval($dir->getFileName())) { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'cache/lang_cache/' . $dir->getFileName() . '/') as $file) { if (!$file->isDot()) { if (preg_match("/^({$application['app_directory']}_)/", $file->getFileName())) { unlink($file->getPathName()); } } } } } } catch (Exception $e) { } /* Remove Skins */ if (is_file(IPSLib::getAppDir($application['app_directory']) . '/xml/information.xml')) { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML($this->settings['gb_char_set']); $xml->load(IPSLib::getAppDir($application['app_directory']) . '/xml/information.xml'); if (is_object($xml->fetchElements('template'))) { foreach ($xml->fetchElements('template') as $template) { $name = $xml->fetchItem($template); $match = $xml->fetchAttribute($template, 'match'); if ($name) { $templateGroups[$name] = $match; } } } if (is_array($templateGroups) and count($templateGroups)) { /* Loop through skin directories */ try { foreach (new DirectoryIterator(IPS_CACHE_PATH . 'cache/skin_cache/') as $dir) { if (preg_match("/^(cacheid_)/", $dir->getFileName())) { foreach (new DirectoryIterator(IPS_CACHE_PATH . 'cache/skin_cache/' . $dir->getFileName() . '/') as $file) { if (!$file->isDot()) { foreach ($templateGroups as $name => $match) { if ($match == 'contains') { if (stristr($file->getFileName(), $name)) { unlink($file->getPathName()); } } else { if ($file->getFileName() == $name . '.php') { unlink($file->getPathName()); } } } } } } } } catch (Exception $e) { } /* Delete from database */ foreach ($templateGroups as $name => $match) { if ($match == 'contains') { $this->DB->delete('skin_templates', "template_group LIKE '%{$name}%'"); $this->DB->delete('skin_templates_previous', "p_template_group LIKE '%{$name}%'"); $this->DB->delete('skin_cache', "cache_type='phptemplate' AND cache_value_1 LIKE '%{$name}%'"); } else { $this->DB->delete('skin_templates', "template_group='{$name}'"); $this->DB->delete('skin_templates_previous', "p_template_group='{$name}'"); $this->DB->delete('skin_cache', "cache_type='phptemplate' AND cache_value_1='{$name}'"); } } } } /* CSS files */ $css_files = array(); $this->DB->build(array('select' => '*', 'from' => 'skin_css', 'where' => "css_app='" . $application['app_directory'] . "'")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $css_files[$r['css_group']] = $r['css_group']; } if (count($css_files)) { $this->DB->delete('skin_css', "css_app='" . $application['app_directory'] . "'"); $this->DB->delete('skin_cache', "cache_type='css' AND cache_value_1 IN('" . implode("','", $css_files) . "')"); try { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/') as $dir) { if (preg_match("/^(css_)/", $dir->getFileName())) { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $dir->getFileName() . '/') as $file) { if (!$file->isDot()) { foreach ($css_files as $css_file) { if ($file->getFileName() == $css_file . '.css') { unlink($file->getPathName()); } } } } } } } catch (Exception $e) { } } //----------------------------------------- // Remove Modules //----------------------------------------- $this->DB->delete('core_sys_module', "sys_module_application='{$application['app_directory']}'"); //----------------------------------------- // Remove Application //----------------------------------------- $this->DB->delete('core_applications', 'app_id=' . $app_id); //----------------------------------------- // Recache //----------------------------------------- $this->moduleRecacheAll(1); $this->cache->rebuildCache('settings', 'global'); $this->cache->rebuildCache('notifications', 'global'); /* Delete from upgrade */ $this->DB->delete('upgrade_history', "upgrade_app='{$application['app_directory']}'"); //----------------------------------------- // FURL templates //----------------------------------------- try { IPSLib::cacheFurlTemplates(); IPSLib::cacheGlobalCaches(); } catch (Exception $e) { } //----------------------------------------- // Sphinx involved? //----------------------------------------- if ($this->settings['search_method'] == 'sphinx') { $this->registry->output->global_message .= sprintf($this->lang->words['rebuild_sphinx'], $this->settings['_base_url']); } //----------------------------------------- // Done... //----------------------------------------- $this->registry->output->global_message = $this->lang->words['a_appremoved']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=applications_overview'); }
/** * 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; }
/** * 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>Вы должны переименовать файл 'conf_global.<b style='color:red'>dist.php</b>' в 'conf_global.<b style='color:red'>php</b>' перед продолжением.</strong>\n\t\t\t\t\t\t\t \t\t\t\t\t\t Этот файл можно найти в корневой директории IP.Board."); } } /* 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('Директория "' . $data['path'] . '" не существует, создайте ее'); } } else { $this->registry->output->addError('Файл "' . $data['path'] . '" не существует, создайте его'); } } if (!is_writeable($_path)) { if (!@chmod($_path, is_dir($_path) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION)) { if (is_dir($_path)) { $this->registry->output->addError('Запись в директорию: "' . $data['path'] . '" невозможна , измените права доступа'); } else { $this->registry->output->addError('Запись в файл "' . $data['path'] . '" невозможна, измените права доступа'); } } } } } if (!count($this->registry->output->fetchErrors())) { $filesOK = TRUE; } } catch (Exception $error) { $filesOK = FALSE; $this->registry->output->addError("Файл " . 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("Требования"); $this->registry->output->addContent($this->registry->output->template()->page_requirements($filesOK, $extensionsOK, $extensionData)); $this->registry->output->sendOutput(); }
/** * Execute selected method * * @access public * @param object Registry object * @return void */ public function doExecute(ipsRegistry $registry) { /* INIT */ $filesOK = NULL; $extensions = get_loaded_extensions(); $extensionsOK = TRUE; $extensionData = array(); /* Test Extensions */ include IPS_ROOT_PATH . 'setup/xml/requiredextensions.php'; if (is_array($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'; $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, 0777, 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, 0777)) { 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(); }
/** * Fetch Apps XML Modules File * * @access public * @param string Application Directory * @return array ..of data */ public static function fetchXmlAppModules($app) { //----------------------------------------- // No modules? //----------------------------------------- if (!file_exists(IPSLib::getAppDir($app) . '/xml/' . $app . '_modules.xml')) { return array(); } /* INIT */ $modules = array(); /* Fetch core writeable files */ require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(IPSSetUp::charSet); try { require_once IPS_KERNEL_PATH . 'classXML.php'; $xml = new classXML(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']); } $modules[$data['sys_module_key'] . intval($data['sys_module_admin'])] = $data; } return $modules; } catch (Exception $error) { return FALSE; } }
/** * Import all tasks from XML * * @return @e void */ public function tasksImportAllApps() { /* INIT */ $tasks = array(); $_gmsg = array(); /* Grab current tasks */ $this->DB->build(array('select' => '*', 'from' => 'task_manager')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $tasks[$row['task_key']] = $row; } /* Grab XML class */ require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ /* Loop through all the applications */ foreach ($this->registry->getApplications() as $app => $__data) { $stats = array('inserted' => 0, 'updated' => 0); $xml = new classXML(IPS_DOC_CHAR_SET); $file = IPSLib::getAppDir($app) . '/xml/' . $app . '_tasks.xml'; if (is_file($file)) { $xml->load($file); foreach ($xml->fetchElements('row') as $task) { $entry = $xml->fetchElementsFromRecord($task); /* Remove unneeded */ unset($entry['task_id']); unset($entry['task_next_run']); /* Update */ $entry['task_cronkey'] = $entry['task_cronkey'] ? $entry['task_cronkey'] : md5(uniqid(microtime())); $entry['task_next_run'] = $entry['task_next_run'] ? $entry['task_next_run'] : time(); $entry['task_description'] = $entry['task_description'] ? $entry['task_description'] : ''; $entry['task_locked'] = intval($entry['task_locked']); if ($tasks[$entry['task_key']]['task_key']) { unset($entry['task_cronkey']); unset($entry['task_enabled']); $stats['updated']++; $this->DB->update('task_manager', $entry, "task_key='" . $entry['task_key'] . "'"); } else { $stats['inserted']++; $this->DB->insert('task_manager', $entry); $tasks[$entry['task_key']] = $entry; } } } $_gmsg[] = $app . ': ' . sprintf($this->lang->words['t_inserted'], $stats['inserted'], $stats['updated']); /* In dev time stamp? */ if (IN_DEV) { $cache = $this->caches['indev']; $cache['import']['tasks'][$app] = time(); $this->cache->setCache('indev', $cache, array('donow' => 1, 'array' => 1)); } } /* Got a global message? */ if (count($_gmsg)) { $this->registry->output->setMessage(implode('<br />', $_gmsg), 1); } /* Return */ $this->taskManagerOverview(); }
/** * 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; } }
/** * 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(); }
/** * Import help files XML helper. Abstracted so * it can be used outside of this file. * * @param string App Directory * @param bool Allow overwrite. If FALSE, it will not update. * @return array Number of items added / updated */ public function helpFilesXMLImport_app($app, $overwrite = TRUE) { /* INIT */ $file = IPSLib::getAppDir($app) . '/xml/' . $app . '_help.xml'; $processed = array('added' => 0, 'updated' => 0); /* Got anything to import? */ if (is_file($file)) { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $xml->load($file); foreach ($xml->fetchElements('row') as $row) { $entry = $xml->fetchElementsFromRecord($row); $db = array('title' => $entry['title'], 'text' => $entry['text'], 'description' => $entry['description'], 'position' => $entry['position'], 'app' => $app); if ($entry['title']) { $curFaq = $this->DB->buildAndFetch(array('select' => 'id', 'from' => 'faq', 'where' => "app='" . $app . "' AND title = '" . $this->DB->addSlashes($entry['title']) . "'")); if ($curFaq['id']) { if ($overwrite === TRUE) { $processed['updated']++; $this->DB->update('faq', $db, "id = " . $curFaq['id']); } } else { $processed['added']++; $this->DB->insert('faq', $db); } } } } return $processed; }
/** * 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'] = ''; }
/** * Install templates * * @return void */ public function install_templates() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; if (file_exists(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'; $extra_install = new install_extra($this->registry); } //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous); /* Got any skin sets? */ $count = $this->DB->buildAndFetch(array('select' => 'count(*) as count', 'from' => 'skin_collections')); if (!$count['count']) { //----------------------------------------- // Next... //----------------------------------------- $output[] = "Inserting template set data..."; require_once IPS_KERNEL_PATH . 'classXML.php'; $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_PUBLIC_PATH . 'resources/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'; require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; require_once IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php'; $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'] . ": Upgrading {$skinData['set_name']} templates..."; if (file_exists($_PATH . $next['key'] . '_' . $skinKey . '_templates.xml')) { //----------------------------------------- // Install //----------------------------------------- $return = $skinFunctions->importTemplateAppXML($next['key'], $skinKey, $skinData['set_id'], TRUE); $output[] = $next['title'] . ": " . intval($return['insertCount']) . " templates inserted"; } if (file_exists($_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 files inserted"; } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $this->_finishStep($output, "Upgrade: Templates", 'upgrade&do=templates&previous=' . $next['key']); } else { //----------------------------------------- // Recache templates //----------------------------------------- $output[] = "Recaching templates..."; foreach ($skinSets as $skinKey => $skinData) { /* Replacements */ if (file_exists(IPS_PUBLIC_PATH . 'resources/skins/replacements_' . $skinKey . '.xml')) { $skinFunctions->importReplacementsXMLArchive(file_get_contents(IPS_PUBLIC_PATH . 'resources/skins/replacements_' . $skinKey . '.xml')); } } $skinFunctions->rebuildSkinSetsCache(); $output[] = "All templates upgraded"; $this->_finishStep($output, "Upgrade: Templates", 'upgrade&do=tasks'); } }