/** * Add Applications * * @return @e void */ public function addApplications() { /* Add applications.. */ $apps = array('core' => array(), 'ips' => array(), 'other' => array()); $components = array(); foreach (array('applications', 'applications_addon/ips', 'applications_addon/other') as $_pBit) { $path = IPS_ROOT_PATH . $_pBit; $handle = opendir($path); while (($file = readdir($handle)) !== FALSE) { if (!preg_match("#^\\.#", $file)) { if (is_dir($path . '/' . $file)) { //----------------------------------------- // Get it! //----------------------------------------- if (!is_file(IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml')) { continue; } $data = IPSSetUp::fetchXmlAppInformation($file); switch ($_pBit) { case 'applications': $apps['core'][$file] = $data; break; case 'applications_addon/ips': $apps['ips'][$file] = $data; break; case 'applications_addon/other': $apps['other'][$file] = $data; break; } } } } closedir($handle); } /* Reorder the array so that core is first */ $new_array = array(); $new_array['core'] = $apps['core']['core']; foreach ($apps['core'] as $app => $data) { if ($app == 'core') { continue; } $new_array[$app] = $data; } $apps['core'] = $new_array; /* Fetch data for current 'components' */ $this->DB->build(array('select' => '*', 'from' => 'components')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $components[$row['com_section']] = $row; } /* Got Gallery? */ if ($components['gallery']['com_enabled'] and $this->DB->checkForTable('gallery_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'gallery_upgrade_history', 'order' => 'gallery_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['gallery']['_currentLong'] = $version['gallery_version_id']; $apps['ips']['gallery']['_currentHuman'] = $version['gallery_version_human']; } /* Got Blog? */ if ($components['blog']['com_enabled'] and $this->DB->checkForTable('blog_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'blog_upgrade_history', 'order' => 'blog_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['blog']['_currentLong'] = $version['blog_version_id']; $apps['ips']['blog']['_currentHuman'] = $version['blog_version_human']; } /* Got Downloads? */ if ($components['downloads']['com_enabled'] and $this->DB->checkForTable('downloads_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'downloads_upgrade_history', 'order' => 'idm_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['downloads']['_currentLong'] = $version['idm_version_id']; $apps['ips']['downloads']['_currentHuman'] = $version['idm_version_human']; } /* Others.. */ $apps['core']['forums']['_currentLong'] = '30001'; $apps['core']['forums']['_currentHuman'] = '3.0.0'; $apps['core']['core']['_currentLong'] = '30001'; $apps['core']['core']['_currentHuman'] = '3.0.0'; $apps['core']['members']['_currentLong'] = '30001'; $apps['core']['members']['_currentHuman'] = '3.0.0'; $apps['ips']['portal']['_currentLong'] = '30003'; $apps['ips']['portal']['_currentHuman'] = '3.0.0'; //$apps['ips']['chat']['_currentLong'] = '30003'; //$apps['ips']['chat']['_currentHuman'] = '3.0.0'; /* If we are upgrading from 2.3 and did not upload the calendar files, we still need to insert the applications table entry, otherwise you won't be able to upgrade down the road. We will insert it as disabled, however, as calendar won't function since files are not available @link http://community.invisionpower.com/tracker/issue-33543-ipb2-upgrades */ if (!isset($apps['ips']['calendar']['name'])) { $apps['ips']['calendar'] = array('name' => 'Calendar', 'public_name' => 'Calendar', 'description' => "", 'author' => "Invision Power Services, Inc.", 'hide_tab' => 0, 'key' => 'calendar', 'disabledatinstall' => 1, 'ipskey' => "fa038db69fa627d8e8e034d65f554d1f", '_locationkey' => 'ips'); } $apps['ips']['calendar']['_currentLong'] = '30003'; $apps['ips']['calendar']['_currentHuman'] = '3.0.0'; /* Now install them.. */ $num = 0; foreach ($apps as $where => $data) { foreach ($apps[$where] as $dir => $appData) { //----------------------------------------- // Had Gallery (e.g.) but didn't upload updated files //----------------------------------------- if (!$appData['name']) { continue; } $num++; $_protected = in_array($appData['key'], array('core', 'forums', 'members')) ? 1 : 0; $_enabled = $appData['disabledatinstall'] ? 0 : 1; if (!$appData['_currentLong']) { continue; } $this->registry->output->addMessage("Добавление приложения: {$appData['name']}...."); $this->DB->insert('core_applications', array('app_title' => $appData['name'], 'app_public_title' => $appData['public_name'] ? $appData['public_name'] : '', 'app_description' => $appData['description'], 'app_author' => $appData['author'], 'app_hide_tab' => intval($appData['hide_tab']), 'app_version' => $appData['_currentHuman'], 'app_long_version' => $appData['_currentLong'], 'app_directory' => $appData['key'], 'app_added' => time(), 'app_position' => $num, 'app_protected' => $_protected, 'app_location' => $appData['_locationkey'] ? $appData['_locationkey'] : IPSLib::extractAppLocationKey($appData['key']), 'app_enabled' => $_enabled, 'app_website' => $appData['website'], 'app_update_check' => $appData['update_check'], 'app_global_caches' => $appData['global_caches'])); } } /* Next Page */ $this->request['workact'] = 'settings'; }
/** * Fetch the redirect mapping for short-hand urls * * @access public * @return array Redirect mappings */ public function fetchRedirects() { $_RESET = array(); /* Make old skin selectors work */ if (isset($_REQUEST['k']) && $_REQUEST['k'] && isset($_REQUEST['settingNewSkin']) && $_REQUEST['settingNewSkin']) { $_RESET['app'] = 'core'; $_RESET['module'] = 'global'; $_RESET['section'] = 'skin'; $_RESET['skinId'] = intval($_REQUEST['settingNewSkin']); /* Return here to stop other rules parsing */ return $_RESET; } else { if (isset($_REQUEST['setAsMobile']) && $_REQUEST['setAsMobile']) { $_RESET['app'] = 'core'; $_RESET['module'] = 'global'; $_RESET['section'] = 'skin'; $_RESET['skinId'] = 'setAsMobile'; /* Return here to stop other rules parsing */ return $_RESET; } } ###### New IPB 3.0.0 Redirects ###### /* Share links */ if (isset($_REQUEST['sharelink']) and is_string($_REQUEST['sharelink']) and !isset($_REQUEST['app'])) { /* Some set ups parse ; automagically (bah) */ if (!strstr($_REQUEST['sharelink'], ';')) { $_REQUEST['sharelink'] = preg_replace("#sharelink=(.*)\$#", "\\1", $_SERVER['QUERY_STRING']); } list($key, $url, $title) = explode(';', $_REQUEST['sharelink']); $_RESET['url'] = $url; $_RESET['title'] = $title; $_RESET['key'] = $key; $_RESET['app'] = 'core'; $_RESET['module'] = 'global'; $_RESET['section'] = 'share'; } if (!empty($_REQUEST['showannouncement'])) { $_RESET['app'] = 'forums'; $_RESET['module'] = 'forums'; $_RESET['section'] = 'announcements'; $_RESET['announce_id'] = intval($_REQUEST['showannouncement']); } ###### Redirect IPB 2.x to IPB 3.0 URLS ###### # IDX if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'idx') { $_RESET['app'] = 'forums'; $_RESET['section'] = 'boards'; $_RESET['module'] = 'forums'; } # FORUM if (!empty($_REQUEST['showforum'])) { $_RESET['app'] = 'forums'; $_RESET['module'] = 'forums'; $_RESET['section'] = 'forums'; $_RESET['showforum'] = intval($_REQUEST['showforum']); $_RESET['f'] = intval($_REQUEST['showforum']); } # TOPIC if (!empty($_REQUEST['showtopic']) or isset($_REQUEST['act']) and $_REQUEST['act'] == 'ST') { $_RESET['app'] = 'forums'; $_RESET['module'] = 'forums'; $_RESET['section'] = 'topics'; if (!$_REQUEST['t']) { $_RESET['t'] = intval($_REQUEST['showtopic']); } else { if ($_REQUEST['t'] and !$_REQUEST['showtopic']) { $_RESET['showtopic'] = intval($_REQUEST['t']); } } } if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'findpost' || !empty($_REQUEST['findpost'])) { $_RESET['pid'] = intval($_REQUEST['pid'] ? $_REQUEST['pid'] : $_REQUEST['findpost']); $_RESET['app'] = 'forums'; $_RESET['module'] = 'forums'; $_RESET['section'] = 'findpost'; } # PROFILE if (isset($_REQUEST['showuser'])) { $_RESET['app'] = 'members'; $_RESET['module'] = 'profile'; $_RESET['section'] = 'view'; $_RESET['id'] = intval($_REQUEST['showuser']); } if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'members') { $_RESET['app'] = 'members'; $_RESET['module'] = 'list'; } # RSS if (isset($_GET['act']) && $_GET['act'] == 'rss' && !empty($_GET['id'])) { $_RESET['app'] = 'core'; $_RESET['module'] = 'global'; $_RESET['section'] = 'rss'; $_RESET['type'] = 'forums'; } # Redirect IPN URLs to IP.Nexus / IP.Subscriptions if (isset($_REQUEST['act']) and $_REQUEST['act'] == 'paysubs' or isset($_REQUEST['app']) and $_REQUEST['app'] == 'subscriptions') { /* Brute force allow access */ if (!defined('IPS_ENFORCE_ACCESS')) { define('IPS_ENFORCE_ACCESS', TRUE); } $_RESET['old'] = '1'; // If Nexus is installed, go to Nexus $subs_version = IPSLib::fetchVersionNumber('subscriptions'); if (IPSLib::extractAppLocationKey('nexus') == 'ips' && $subs_version['long'] < 10008) { $_RESET['app'] = 'nexus'; $_RESET['module'] = 'payments'; $_RESET['section'] = 'receive'; $_RESET['validate'] = 'paypal'; } else { $_RESET['app'] = 'subscriptions'; if (isset($_REQUEST['CODE'])) { if ($_REQUEST['CODE'] == 'incoming') { $_RESET['module'] = 'incoming'; $_RESET['section'] = 'receive'; $_RESET['do'] = 'validate'; } else { if ($_REQUEST['CODE'] == 'paydone') { $_RESET['module'] = 'incoming'; $_RESET['section'] = 'receive'; $_RESET['do'] = 'done'; } else { $_RESET['do'] = $_REQUEST['CODE']; } } } } } #Fix IP.Board 2.1 style module links if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'module' && isset($_REQUEST['module'])) { $_REQUEST['autocom'] = $_REQUEST['module']; } if (isset($_REQUEST['cmd'])) { $_RESET['req'] = $_REQUEST['cmd']; } # ALL if (!isset($_REQUEST['do']) and (isset($_REQUEST['CODE']) or isset($_REQUEST['code']))) { $_RESET['do'] = $_REQUEST['CODE'] ? $_REQUEST['CODE'] : $_REQUEST['code']; } if (isset($_REQUEST['autocom']) or isset($_REQUEST['automodule'])) { $_RESET['app'] = $_REQUEST['autocom'] ? $_REQUEST['autocom'] : $_REQUEST['automodule']; } else { if (isset($_GET['autocom']) or isset($_GET['automodule'])) { $_RESET['app'] = $_GET['autocom'] ? $_GET['autocom'] : $_GET['automodule']; } } # Calendar if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'calendar') { $_RESET['app'] = 'calendar'; } return $_RESET; }
/** * Install Applications * * @return void */ public function install_applications() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; $num = intval($_REQUEST['num']) + 1; //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']); /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Install APP Data //----------------------------------------- if ($next['key']) { $output[] = $next['title'] . ": Добавление данных приложений"; $_PATH = IPSLib::getAppDir($next['key']) . '/xml/'; $_protected = in_array($next['key'], array('core', 'forums', 'members')) ? 1 : 0; $version = '1.0.0'; $long_version = '10000'; $_versions = array(); if (is_file($_PATH . 'versions.xml')) { require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPSSetUp::charSet); $xml->load($_PATH . 'versions.xml'); foreach ($xml->fetchElements('version') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $_versions[$data['long']] = $data; } krsort($_versions); $_this_version = current($_versions); $version = $_this_version['human']; $long_version = $_this_version['long']; } if (is_file($_PATH . 'information.xml')) { //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('applications'); } //----------------------------------------- // Continue //----------------------------------------- $appData = IPSSetUp::fetchXmlAppInformation($next['key'], $this->settings['gb_char_set']); //----------------------------------------- // Insert... //----------------------------------------- $this->DB->insert('core_applications', array('app_title' => $appData['name'], 'app_public_title' => $appData['public_name'] ? $appData['public_name'] : '', 'app_description' => $appData['description'], 'app_author' => $appData['author'], 'app_hide_tab' => intval($appData['hide_tab']), 'app_version' => $version, 'app_long_version' => $long_version, 'app_directory' => $next['key'], 'app_added' => time(), 'app_position' => isset($this->forcePositions[$next['key']]) ? $this->forcePositions[$next['key']] : $num, 'app_protected' => $_protected, 'app_location' => IPSLib::extractAppLocationKey($next['key']), 'app_enabled' => $appData['disabledatinstall'] ? 0 : 1, 'app_website' => $appData['website'], 'app_update_check' => $appData['update_check'], 'app_global_caches' => $appData['global_caches'])); $this->DB->insert('upgrade_history', array('upgrade_version_id' => $long_version, 'upgrade_version_human' => $version, 'upgrade_date' => 0, 'upgrade_mid' => 0, 'upgrade_notes' => '', 'upgrade_app' => $next['key'])); //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('applications'); } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $this->_finishStep($output, "Установка: Приложения", 'install&do=applications&previous=' . $next['key'] . '&num=' . $num); } else { //----------------------------------------- // Next... //----------------------------------------- $output[] = "Приложения установлены"; $this->_finishStep($output, "Установка: Приложения", 'install&do=modules'); } }
/** * Add Applications * * @access public * @param int */ public function addApplications() { /* Add applications.. */ $apps = array('core' => array(), 'ips' => array(), 'other' => array()); $components = array(); foreach (array('applications', 'applications_addon/ips', 'applications_addon/other') as $_pBit) { $path = IPS_ROOT_PATH . $_pBit; $handle = opendir($path); while (($file = readdir($handle)) !== FALSE) { if (!preg_match("#^\\.#", $file)) { if (is_dir($path . '/' . $file)) { //----------------------------------------- // Get it! //----------------------------------------- if (!file_exists(IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml')) { continue; } $data = IPSSetUp::fetchXmlAppInformation($file); switch ($_pBit) { case 'applications': $apps['core'][$file] = $data; break; case 'applications_addon/ips': $apps['ips'][$file] = $data; break; case 'applications_addon/other': $apps['other'][$file] = $data; break; } } } } closedir($handle); } /* Reorder the array so that core is first */ $new_array = array(); $new_array['core'] = $apps['core']['core']; foreach ($apps['core'] as $app => $data) { if ($app == 'core') { continue; } $new_array[$app] = $data; } $apps['core'] = $new_array; /* Fetch data for current 'components' */ $this->DB->build(array('select' => '*', 'from' => 'components')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $components[$row['com_section']] = $row; } /* Got Gallery? */ if ($components['gallery']['com_enabled'] and $this->DB->checkForTable('gallery_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'gallery_upgrade_history', 'order' => 'gallery_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['gallery']['_currentLong'] = $version['gallery_version_id']; $apps['ips']['gallery']['_currentHuman'] = $version['gallery_version_human']; } /* Got Blog? */ if ($components['blog']['com_enabled'] and $this->DB->checkForTable('blog_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'blog_upgrade_history', 'order' => 'blog_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['blog']['_currentLong'] = $version['blog_version_id']; $apps['ips']['blog']['_currentHuman'] = $version['blog_version_human']; } /* Got Downloads? */ if ($components['downloads']['com_enabled'] and $this->DB->checkForTable('downloads_upgrade_history')) { /* Fetch current version number */ $version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'downloads_upgrade_history', 'order' => 'idm_version_id DESC', 'limit' => array(0, 1))); $apps['ips']['downloads']['_currentLong'] = $version['idm_version_id']; $apps['ips']['downloads']['_currentHuman'] = $version['idm_version_human']; } /* Others.. */ $apps['core']['forums']['_currentLong'] = '30001'; $apps['core']['forums']['_currentHuman'] = '3.0.0'; $apps['core']['core']['_currentLong'] = '30001'; $apps['core']['core']['_currentHuman'] = '3.0.0'; $apps['core']['members']['_currentLong'] = '30001'; $apps['core']['members']['_currentHuman'] = '3.0.0'; $apps['ips']['portal']['_currentLong'] = '30003'; $apps['ips']['portal']['_currentHuman'] = '3.0.0'; $apps['ips']['chat']['_currentLong'] = '30003'; $apps['ips']['chat']['_currentHuman'] = '3.0.0'; $apps['ips']['calendar']['_currentLong'] = '30003'; $apps['ips']['calendar']['_currentHuman'] = '3.0.0'; /* Now install them.. */ $num = 0; foreach ($apps as $where => $data) { foreach ($apps[$where] as $dir => $appData) { //----------------------------------------- // Had Gallery (e.g.) but didn't upload updated files //----------------------------------------- if (!$appData['name']) { continue; } $num++; $_protected = in_array($appData['key'], array('core', 'forums', 'members')) ? 1 : 0; $_enabled = $appData['disabledatinstall'] ? 0 : 1; if (!$appData['_currentLong']) { continue; } $this->registry->output->addMessage("Adding application: {$appData['name']}...."); $this->DB->insert('core_applications', array('app_title' => $appData['name'], 'app_public_title' => $appData['public_name'] ? $appData['public_name'] : '', 'app_description' => $appData['description'], 'app_author' => $appData['author'], 'app_hide_tab' => intval($appData['hide_tab']), 'app_version' => $appData['_currentHuman'], 'app_long_version' => $appData['_currentLong'], 'app_directory' => $appData['key'], 'app_added' => time(), 'app_position' => $num, 'app_protected' => $_protected, 'app_location' => IPSLib::extractAppLocationKey($appData['key']), 'app_enabled' => $_enabled)); } } /* Next Page */ $this->request['workact'] = 'settings'; }