Beispiel #1
0
 /**
  * Try and deconstruct the link if it's a FURRY FURL
  *
  * @access	protected
  * @param	string		Incoming URL
  * @return	array		Array of request data or false
  */
 protected function _checkForFurl($url)
 {
     $_urlBits = array();
     $_toTest = $url;
     $templates = array();
     if (is_file(FURL_CACHE_PATH)) {
         $templates = array();
         require FURL_CACHE_PATH;
         /*noLibHook*/
         $_seoTemplates = $templates;
     } else {
         /* Attempt to write it */
         $_seoTemplates = IPSLib::buildFurlTemplates();
         try {
             IPSLib::cacheFurlTemplates();
         } catch (Exception $e) {
         }
     }
     if (is_array($_seoTemplates) and count($_seoTemplates)) {
         foreach ($_seoTemplates as $key => $data) {
             if (empty($data['in']['regex'])) {
                 continue;
             }
             if (preg_match($data['in']['regex'], $_toTest, $matches)) {
                 if (is_array($data['in']['matches'])) {
                     foreach ($data['in']['matches'] as $_replace) {
                         $k = IPSText::parseCleanKey($_replace[0]);
                         if (strpos($_replace[1], '$') !== false) {
                             $v = IPSText::parseCleanValue($matches[intval(str_replace('$', '', $_replace[1]))]);
                         } else {
                             $v = IPSText::parseCleanValue($_replace[1]);
                         }
                         $_urlBits[$k] = $v;
                     }
                 }
                 if (strpos($_toTest, $_seoTemplates['__data__']['varBlock']) !== false) {
                     $_parse = substr($_toTest, strpos($_toTest, $_seoTemplates['__data__']['varBlock']) + strlen($_seoTemplates['__data__']['varBlock']));
                     $_data = explode($_seoTemplates['__data__']['varSep'], $_parse);
                     $_c = 0;
                     foreach ($_data as $_v) {
                         if (!$_c) {
                             $k = IPSText::parseCleanKey($_v);
                             $v = '';
                             $_c++;
                         } else {
                             $v = IPSText::parseCleanValue($_v);
                             $_c = 0;
                             $_urlBits[$k] = $v;
                         }
                     }
                 }
                 break;
             }
         }
         //-----------------------------------------
         // If using query string furl, extract any
         // secondary query string.
         // Ex: http://localhost/index.php?/path/file.html?key=value
         // Will pull the key=value properly
         //-----------------------------------------
         $_qmCount = substr_count($_toTest, '?');
         if ($_qmCount > 1) {
             $_secondQueryString = substr($_toTest, strrpos($_toTest, '?') + 1);
             $_secondParams = explode('&', $_secondQueryString);
             if (count($_secondParams)) {
                 foreach ($_secondParams as $_param) {
                     list($k, $v) = explode('=', $_param);
                     $k = IPSText::parseCleanKey($k);
                     $v = IPSText::parseCleanValue($v);
                     $_urlBits[$k] = $v;
                 }
             }
         }
         /* Process URL bits for extra ? in them */
         if (is_array($_urlBits) and count($_urlBits)) {
             foreach ($_urlBits as $k => $v) {
                 if (strstr($v, '?')) {
                     list($rvalue, $more) = explode('?', $v);
                     if ($rvalue and $more) {
                         /* Reset key with correct value */
                         $_v = $rvalue;
                         $_urlBits[$k] = $_v;
                         /* Now add in the other value */
                         if (strstr($more, '=')) {
                             list($_k, $_v) = explode('=', $more);
                             if ($_k and $_v) {
                                 $_urlBits[$_k] = $_v;
                             }
                         }
                     }
                 }
             }
         }
     }
     return count($_urlBits) ? $_urlBits : false;
 }
Beispiel #2
0
 /**
  * Finalizes installation and rebuilds caches
  *
  * @return	@e void
  */
 public function finish()
 {
     /* INIT */
     $vars = $this->getVars();
     $output = array();
     $errors = array();
     /* Init Data */
     $data = IPSSetUp::fetchXmlAppInformation($vars['app_directory'], $this->settings['gb_char_set']);
     $_numbers = IPSSetUp::fetchAppVersionNumbers($vars['app_directory']);
     /* Grab Data */
     $data['app_directory'] = $vars['app_directory'];
     $data['current_version'] = $_numbers['current'][0] ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
     $data['latest_version'] = $_numbers['latest'][1];
     $data['next_version'] = $_numbers['next'][0];
     /* Rebuild applications and modules cache */
     $this->cache->rebuildCache('app_cache', 'global');
     $this->cache->rebuildCache('module_cache', 'global');
     $this->cache->rebuildCache('app_menu_cache', 'global');
     $this->cache->rebuildCache('group_cache', 'global');
     $this->cache->rebuildCache('notifications', 'global');
     $this->cache->rebuildCache('report_plugins', 'global');
     /* Rebuild application specific caches */
     $_file = $this->app_full_path . 'extensions/coreVariables.php';
     if (is_file($_file)) {
         $CACHE = array();
         require $_file;
         /*noLibHook*/
         if (is_array($CACHE) and count($CACHE)) {
             foreach ($CACHE as $key => $cdata) {
                 $this->cache->rebuildCache($key, $vars['app_directory']);
             }
         }
     }
     /* Rebuild GLOBAL CACHES! */
     try {
         IPSLib::cacheGlobalCaches();
     } catch (Exception $e) {
         // Show an error?
     }
     /* Rebuild FURLs */
     $furltemplatesfile = $this->app_full_path;
     if (IPB_USE_ONLY_ID_FURL && is_file($furltemplatesfile . '/extensions/furlTemplatesID.php')) {
         $furltemplatesfile .= '/extensions/furlTemplatesID.php';
     } else {
         $furltemplatesfile .= '/extensions/furlTemplates.php';
     }
     if (is_file($furltemplatesfile)) {
         try {
             IPSLib::cacheFurlTemplates();
         } catch (Exception $e) {
             // Show an error?
         }
     }
     /* Show completed screen... */
     $this->registry->output->html .= $this->html->setup_completed_screen($data, $vars['type']);
 }
Beispiel #3
0
 /**
  * Install Tenplate Caches
  *
  * @return void
  */
 public function install_template_caches()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->settings['base_url'] = IPSSetUp::getSavedData('install_url');
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $skinId = intval($this->request['skinId']);
     $skinData = array();
     $output = array();
     //-----------------------------------------
     // Recache skins: Moved here so they are
     // build after hooks are added
     //-----------------------------------------
     /* 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 */
     $skinData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => 'set_id > ' . $skinId . ' AND set_parent_id=0', 'order' => 'set_id ASC', 'limit' => array(0, 1)));
     if ($skinData['set_id']) {
         $skinFunctions->rebuildPHPTemplates($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $skinFunctions->rebuildCSS($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $skinFunctions->rebuildReplacementsCache($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $output[] = "Обновлен кеш стиля " . $skinData['set_name'] . "...";
         /* Go for the next */
         $this->_finishStep($output, "Обновление: Кеш стилей", 'upgrade&do=templatecache&skinId=' . $skinData['set_id']);
     } else {
         /* All diddly done */
         $output[] = "Кеш стилей обновлен";
         $skinFunctions->rebuildSkinSetsCache();
         /* Rebuild FURL & GLOBAL caches */
         try {
             IPSLib::cacheFurlTemplates();
             IPSLib::cacheGlobalCaches();
         } catch (Exception $error) {
         }
         /* Clear out minify files */
         try {
             if (is_dir(DOC_IPS_ROOT_PATH . 'cache/tmp')) {
                 foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'cache/tmp') as $cache) {
                     if ($cache->getMTime() < time() - 60 * 60 * 24 * 7 and $cache->getFilename() != 'index.html') {
                         @unlink($cache->getPathname());
                     }
                 }
             }
         } catch (Exception $e) {
         }
         /* Show message and go */
         $this->_finishStep($output, "Upgrade: Skin Caches", 'done');
     }
 }
 /**
  * INIT furls
  * Performs set up and figures out any incoming links
  *
  * @return	@e void
  */
 protected static function _fUrlInit()
 {
     /**
      * Fix request uri
      */
     self::_fixRequestUri();
     if (ipsRegistry::$settings['use_friendly_urls']) {
         /* Grab and store accessing URL */
         self::$_uri = preg_replace("/s=(&|\$)/", '', str_replace('/?', '/' . IPS_PUBLIC_SCRIPT . '?', $_SERVER['REQUEST_URI']));
         $_urlBits = array();
         /* Grab FURL data... */
         if (!IN_DEV and is_file(FURL_CACHE_PATH)) {
             $templates = array();
             include FURL_CACHE_PATH;
             /*noLibHook*/
             self::$_seoTemplates = $templates;
         } else {
             /* Attempt to write it */
             self::$_seoTemplates = IPSLib::buildFurlTemplates();
             try {
                 IPSLib::cacheFurlTemplates();
             } catch (Exception $e) {
             }
         }
         if (is_array(self::$_seoTemplates) and count(self::$_seoTemplates)) {
             $uri = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI');
             /* Bug 21295 - remove known URL from test URI */
             $_t = !empty(ipsRegistry::$settings['board_url']) ? @parse_url(ipsRegistry::$settings['board_url']) : @parse_url(ipsRegistry::$settings['base_url']);
             $_toTest = ($_t['path'] and $_t['path'] != '/') ? preg_replace("#^{$_t['path']}#", '', $uri) : str_replace($_t['scheme'] . '://' . $_t['host'], '', $uri);
             $_404Check = $_toTest;
             //We want to retain any /index.php for this test later in this block of code
             $_toTest = str_ireplace(array('//' . IPS_PUBLIC_SCRIPT . '?', '/' . IPS_PUBLIC_SCRIPT . '?', '/' . IPS_PUBLIC_SCRIPT), '', $_toTest);
             $_gotMatch = false;
             foreach (self::$_seoTemplates as $key => $data) {
                 if (empty($data['in']['regex'])) {
                     continue;
                 }
                 /* Clean up regex */
                 $data['in']['regex'] = str_replace('#{__varBlock__}', preg_quote(self::$_seoTemplates['__data__']['varBlock'], '#'), $data['in']['regex']);
                 if (preg_match($data['in']['regex'], $_toTest, $matches)) {
                     $_gotMatch = true;
                     /* Handling pages as a special thing? */
                     if ($data['isPagesMode']) {
                         if (strstr($_toTest, self::$_seoTemplates['__data__']['varPage'])) {
                             preg_match('#(' . preg_quote(self::$_seoTemplates['__data__']['varPage'], '#') . '(\\d+?))(?:$|' . preg_quote(self::$_seoTemplates['__data__']['varBlock'], '#') . ')#', $_toTest, $pageMatches);
                             if ($pageMatches[1]) {
                                 $k = 'page';
                                 $_GET[$k] = intval($pageMatches[2]);
                                 $_POST[$k] = intval($pageMatches[2]);
                                 $_REQUEST[$k] = intval($pageMatches[2]);
                                 $_urlBits[$k] = intval($pageMatches[2]);
                                 ipsRegistry::$request[$k] = intval($pageMatches[2]);
                                 $_toTest = str_replace($pageMatches[1], '', $_toTest);
                             }
                         } else {
                             /* Redirect all < 3.4 links to the new sexy awesome format if need be */
                             if (self::$_seoTemplates['__data__']['varBlock'] != '/page__' && $uri && strstr($uri, '/page__')) {
                                 preg_match('#(.*)(page__.*)$#', $uri, $matches);
                                 $url = $matches[1];
                                 $query = $matches[2];
                                 $newQuery = '?';
                                 $data = explode('__', substr($query, 6));
                                 for ($i = 0, $j = count($data); $i < $j; $i++) {
                                     $newQuery .= ($i % 2 == 0 ? '&' : '=') . $data[$i];
                                 }
                                 /* Class output not created here */
                                 header("HTTP/1.1 301 Moved Permanently");
                                 header("Location: " . $_t['scheme'] . '://' . $_t['host'] . $url . $newQuery);
                                 exit;
                             }
                         }
                     }
                     if (is_array($data['in']['matches'])) {
                         foreach ($data['in']['matches'] as $_replace) {
                             $k = IPSText::parseCleanKey($_replace[0]);
                             if (strpos($_replace[1], '$') !== false) {
                                 $v = IPSText::parseCleanValue($matches[intval(str_replace('$', '', $_replace[1]))]);
                             } else {
                                 $v = IPSText::parseCleanValue($_replace[1]);
                             }
                             $_GET[$k] = $v;
                             $_POST[$k] = $v;
                             $_REQUEST[$k] = $v;
                             $_urlBits[$k] = $v;
                             ipsRegistry::$request[$k] = $v;
                         }
                     }
                     if (strpos($_toTest, self::$_seoTemplates['__data__']['varBlock']) !== false) {
                         /* Changed how the input variables are parsed based on feedback in bug report 24907
                            @link http://community.invisionpower.com/tracker/issue-24907-member-list-pagination-not-work-with-checkbox
                            Input variables now preserve array depth properly as a result */
                         $_parse = substr($_toTest, strpos($_toTest, self::$_seoTemplates['__data__']['varBlock']) + strlen(self::$_seoTemplates['__data__']['varBlock']));
                         $_data = explode(self::$_seoTemplates['__data__']['varSep'], $_parse);
                         $_query = '';
                         foreach ($_data as $line) {
                             list($k, $v) = explode(self::$_seoTemplates['__data__']['varJoin'], $line);
                             $_query .= $k . '=' . $v . '&';
                         }
                         $_data = array();
                         parse_str($_query, $_data);
                         $_data = IPSLib::parseIncomingRecursively($_data);
                         foreach ($_data as $k => $v) {
                             $_GET[$k] = $v;
                             $_POST[$k] = $v;
                             $_REQUEST[$k] = $v;
                             $_urlBits[$k] = $v;
                             ipsRegistry::$request[$k] = $v;
                         }
                     }
                     break;
                 }
             }
             /* Check against the original request for 404 error */
             $_404checkPass = false;
             if (!strstr($_404Check, '&') and !strstr($_404Check, '=') and (strstr($_404Check, IPS_PUBLIC_SCRIPT . '?/') or !strstr($_404Check, '.php'))) {
                 $_404checkPass = true;
             }
             if (strstr($_404Check, '/' . IPS_PUBLIC_SCRIPT)) {
                 if (preg_match("#(.+?)/" . preg_quote(IPS_PUBLIC_SCRIPT) . "#", $_404Check, $matches) and !is_file(DOC_IPS_ROOT_PATH . preg_replace('/(.+?)\\?.+/', '$1', $_404Check))) {
                     $_404checkPass = true;
                 }
             }
             /* Got a match? */
             if (!defined('CCS_GATEWAY_CALLED') and !defined('IPS_ENFORCE_ACCESS') and !defined('LOFIVERSION_CALLED') and IPS_IS_MOBILE_APP === false and IPS_DEFAULT_PUBLIC_APP == 'forums' and $_gotMatch === false and $_toTest and $_toTest != '/' and $_toTest != '/?' and $_404checkPass) {
                 self::$_noFurlMatch = true;
             }
             //-----------------------------------------
             // If using query string furl, extract any
             // secondary query string.
             // Ex: http://localhost/index.php?/path/file.html?key=value
             // Will pull the key=value properly
             //-----------------------------------------
             $_qmCount = substr_count($_toTest, '?');
             /* We don't want to check for secondary query strings in the ACP */
             if (!IN_ACP && $_qmCount > 1) {
                 $_secondQueryString = substr($_toTest, strrpos($_toTest, '?') + 1);
                 $_secondParams = explode('&', $_secondQueryString);
                 if (count($_secondParams)) {
                     foreach ($_secondParams as $_param) {
                         list($k, $v) = explode('=', $_param);
                         $k = IPSText::parseCleanKey($k);
                         $v = IPSText::parseCleanValue($v);
                         $_GET[$k] = $v;
                         $_REQUEST[$k] = $v;
                         $_urlBits[$k] = $v;
                         ipsRegistry::$request[$k] = $v;
                     }
                 }
             }
             /* Process URL bits for extra ? in them */
             /* We don't want to check for secondary query strings in the ACP */
             if (!IN_ACP && is_array($_GET) and count($_GET)) {
                 foreach ($_GET as $k => $v) {
                     /* Nexus sends &url=.... as a parameter, which can have a ? in it, but we don't want to strip that out of the parameter or consider those values part of the input */
                     if ($k == 'url') {
                         continue;
                     }
                     if (!is_array($v) and strstr($v, '?')) {
                         list($rvalue, $more) = explode('?', $v);
                         if ($rvalue and $more) {
                             //$k	= IPSText::parseCleanKey( $_k );
                             //$v	= IPSText::parseCleanValue( $_v );
                             /* Reset key with correct value */
                             $_v = IPSText::parseCleanValue($rvalue);
                             $_GET[$k] = $_v;
                             $_REQUEST[$k] = $_v;
                             $_urlBits[$k] = $_v;
                             ipsRegistry::$request[$k] = $_v;
                             /* Now add in the other value */
                             if (strstr($more, '=')) {
                                 list($_k, $_v) = explode('=', $more);
                                 if ($_k and $_v) {
                                     $_GET[$_k] = $_v;
                                     $_REQUEST[$_k] = $_v;
                                     $_urlBits[$_k] = $_v;
                                     ipsRegistry::$request[$_k] = $_v;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /* Reformat basic URL */
         if (is_array($_urlBits)) {
             ipsRegistry::$settings['query_string_real'] = trim(http_build_query($_urlBits), '&');
         }
     }
 }
Beispiel #5
0
 /**
  * Install Caches
  *
  * @return void
  */
 public function install_caches()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->settings['base_url'] = IPSSetUp::getSavedData('install_url');
     $this->settings['ipb_reg_number'] = IPSSetUp::getSavedData('lkey');
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']);
     /* Set up DB driver */
     $extra_install = $this->_setUpDBDriver(FALSE);
     //-----------------------------------------
     // Install SYSTEM Templates on first cycle
     //-----------------------------------------
     if (!$previous) {
         //-----------------------------------------
         // Global caches...
         //-----------------------------------------
         # Grab cache master file
         require_once IPS_ROOT_PATH . 'extensions/coreVariables.php';
         /*noLibHook*/
         /* Add handle */
         $_tmp = new coreVariables();
         $_cache = $_tmp->fetchCaches();
         $CACHE = $_cache['caches'];
         //-----------------------------------------
         // Adjust the table?
         //-----------------------------------------
         if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
             $q = $extra_install->before_inserts_run('caches');
         }
         //-----------------------------------------
         // Continue
         //-----------------------------------------
         if (is_array($CACHE)) {
             foreach ($CACHE as $cs_key => $cs_data) {
                 $output[] = "Обновление {$cs_key}...";
                 ipsRegistry::cache()->rebuildCache($cs_key, 'global');
             }
         }
         //-------------------------------------------------------------
         // Systemvars
         //-------------------------------------------------------------
         $output[] = "Обновление кеша системных переменных";
         $cache = array('mail_queue' => 0, 'task_next_run' => time() + 3600);
         ipsRegistry::cache()->setCache('systemvars', $cache, array('array' => 1));
         //-------------------------------------------------------------
         // Stats
         //-------------------------------------------------------------
         $output[] = "Обновление кеша статистики";
         $cache = array('total_replies' => 0, 'total_topics' => 1, 'mem_count' => 1, 'last_mem_name' => IPSSetUp::getSavedData('admin_user'), 'last_mem_id' => 1);
         ipsRegistry::cache()->setCache('stats', $cache, array('array' => 1));
         //-----------------------------------------
         // Adjust the table?
         //-----------------------------------------
         if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
             $q = $extra_install->after_inserts_run('caches');
         }
         $output[] = "Все кеши обновлены";
         //-----------------------------------------
         // Recache skins: Moved here so they are
         // build after hooks are added
         //-----------------------------------------
         /* 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;
         }
         foreach ($skinSets as $skinKey => $skinData) {
             /* Bit of jiggery pokery... */
             if ($skinData['set_key'] == 'root') {
                 $skinData['set_key'] = 'default';
                 $skinData['set_id'] = 1;
                 $skinKey = 'default';
             }
             $skinFunctions->rebuildPHPTemplates($skinData['set_id']);
             if ($skinFunctions->fetchErrorMessages() !== FALSE) {
                 $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
             }
             $skinFunctions->rebuildCSS($skinData['set_id']);
             if ($skinFunctions->fetchErrorMessages() !== FALSE) {
                 $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
             }
             $skinFunctions->rebuildReplacementsCache($skinData['set_id']);
             if ($skinFunctions->fetchErrorMessages() !== FALSE) {
                 $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
             }
         }
         $skinFunctions->rebuildSkinSetsCache();
         $output[] = "Кеш стиля обновлен";
         /* Rebuild FURL & GLOBAL caches */
         try {
             IPSLib::cacheFurlTemplates();
             IPSLib::cacheGlobalCaches();
         } catch (Exception $error) {
         }
     }
     //-----------------------------------------
     // Now install other caches
     //-----------------------------------------
     if ($next['key']) {
         $_PATH = IPSLib::getAppDir($next['key']) . '/extensions/';
         if (is_file($_PATH . 'coreVariables.php')) {
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
                 $q = $extra_install->before_inserts_run('caches');
             }
             # Grab cache master file
             require_once $_PATH . 'coreVariables.php';
             /*noLibHook*/
             if (is_array($CACHE)) {
                 foreach ($CACHE as $cs_key => $cs_data) {
                     $output[] = $next['title'] . ": Обновление {$cs_key}...";
                     ipsRegistry::cache()->rebuildCache($cs_key, $next['key']);
                 }
             } else {
                 $output[] = $next['title'] . ": Нет кешей для обновления...";
             }
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
                 $q = $extra_install->after_inserts_run('caches');
             }
         } else {
             $output[] = $next['title'] . ": Нет кешей для обновления...";
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Установка: кеш", 'install&do=caches&previous=' . $next['key']);
     } else {
         $this->_finishStep($output, "Установка: кеш", 'done');
     }
 }
 /**
  * Save an application
  *
  * @param	string		Type [add|edit]
  * @return	@e void		[Outputs to screen]
  */
 public function applicationSave($type = 'add')
 {
     /* Init vars */
     $app_title = trim($this->request['app_title']);
     $app_public = trim($this->request['app_public_title']);
     $app_directory = trim($this->request['app_directory']);
     $app_enabled = intval($this->request['app_enabled']);
     $application = array();
     $sphinxRebuild = false;
     /* Editing? */
     if ($type == 'edit') {
         $application = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_applications', 'where' => 'app_id=' . intval($this->request['app_id'])));
         if (!$application['app_id']) {
             $this->registry->output->global_message = $this->lang->words['a_noid'];
             $this->applicationsOverview();
             return;
         }
     } else {
         $_check = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_applications', 'where' => "app_directory='{$app_directory}'"));
         if ($_check['app_id']) {
             $this->registry->output->showError($this->lang->words['app_already_added'], 111161.3);
         }
     }
     /* Error check */
     if (!$app_title or !$app_directory) {
         $this->registry->output->global_message = $this->lang->words['a_titledirectory'];
         $this->applicationForm($type);
         return;
     }
     if ((empty($app_enabled) || empty($app_public)) && in_array($app_directory, array('core', 'forums', 'members'))) {
         $this->registry->output->showError($this->lang->words['cannot_toggle_defaults'], 111161.2);
     }
     /* $etup update array */
     $array = array('app_title' => $app_title, 'app_public_title' => $app_public, 'app_enabled' => $app_enabled, 'app_hide_tab' => intval($this->request['app_hide_tab']), 'app_description' => trim($this->request['app_description']), 'app_author' => trim($this->request['app_author']), 'app_version' => trim($this->request['app_version']), 'app_directory' => $app_directory, 'app_website' => trim($this->request['app_website']), 'app_update_check' => trim($this->request['app_update_check']), 'app_global_caches' => is_array($this->request['app_global_caches']) && count($this->request['app_global_caches']) ? implode(',', $this->request['app_global_caches']) : '', 'app_tab_groups' => is_array($this->request['app_tab_groups']) && count($this->request['app_tab_groups']) ? implode(',', $this->request['app_tab_groups']) : '');
     //-----------------------------------------
     // IN DEV?
     //-----------------------------------------
     if (IN_DEV) {
         $array['app_protected'] = intval($this->request['app_protected']);
     }
     //-----------------------------------------
     // Save...
     //-----------------------------------------
     if ($type == 'add') {
         $array['app_added'] = IPS_UNIX_TIME_NOW;
         $array['app_location'] = 'other';
         $max = $this->DB->buildAndFetch(array('select' => 'MAX(app_position) as position', 'from' => 'core_applications'));
         $array['app_position'] = intval($max['position']) + 1;
         $this->DB->insert('core_applications', $array);
         $this->registry->output->global_message = $this->lang->words['a_newapp'];
     } else {
         /* We're disabling the app? */
         if (empty($app_enabled)) {
             $array['app_position'] = 0;
         } else {
             if (empty($application['app_enabled'])) {
                 $appsCount = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as total', 'from' => 'core_applications', 'where' => 'app_enabled=1'));
                 $array['app_position'] = $appsCount['total'] + 1;
             }
         }
         /* Update the application record */
         $this->DB->update('core_applications', $array, 'app_id=' . $application['app_id']);
         /* Update modules and tasks, if the application directory changed */
         if ($application['app_directory'] != $app_directory) {
             $sphinxRebuild = true;
             $this->DB->update('task_manager', array('task_application' => $app_directory), "task_application='{$application['app_directory']}'");
             $this->DB->update('core_sys_module', array('sys_module_application' => $app_directory), "sys_module_application='{$application['app_directory']}'");
             $this->DB->update('admin_logs', array('appcomponent' => $app_directory), "appcomponent='{$application['app_directory']}'");
             $this->DB->update('core_editor_autosave', array('eas_app' => $app_directory), "eas_app='{$application['app_directory']}'");
             $this->DB->update('core_incoming_emails', array('rule_app' => $app_directory), "rule_app='{$application['app_directory']}'");
             $this->DB->update('core_item_markers', array('item_app' => $app_directory), "item_app='{$application['app_directory']}'");
             $this->DB->update('core_like', array('like_app' => $app_directory), "like_app='{$application['app_directory']}'");
             $this->DB->update('core_like_cache', array('like_cache_app' => $app_directory), "like_cache_app='{$application['app_directory']}'");
             $this->DB->update('core_share_links_log', array('log_data_app' => $app_directory), "log_data_app='{$application['app_directory']}'");
             $this->DB->update('core_sys_lang_words', array('word_app' => $app_directory), "word_app='{$application['app_directory']}'");
             $this->DB->update('core_sys_settings_titles', array('conf_title_app' => $app_directory), "conf_title_app='{$application['app_directory']}'");
             $this->DB->update('core_tags', array('tag_meta_app' => $app_directory), "tag_meta_app='{$application['app_directory']}'");
             $this->DB->update('custom_bbcode', array('bbcode_app' => $app_directory), "bbcode_app='{$application['app_directory']}'");
             $this->DB->update('faq', array('app' => $app_directory), "app='{$application['app_directory']}'");
             $this->DB->update('inline_notifications', array('notify_meta_app' => $app_directory), "notify_meta_app='{$application['app_directory']}'");
             $this->DB->update('permission_index', array('app' => $app_directory), "app='{$application['app_directory']}'");
             $this->DB->update('reputation_cache', array('app' => $app_directory), "app='{$application['app_directory']}'");
             $this->DB->update('reputation_index', array('app' => $app_directory), "app='{$application['app_directory']}'");
             $this->DB->update('skin_css', array('css_app' => $app_directory), "css_app='{$application['app_directory']}'");
             $this->DB->update('skin_css_previous', array('p_css_app' => $app_directory), "p_css_app='{$application['app_directory']}'");
             $this->DB->update('upgrade_history', array('upgrade_app' => $app_directory), "upgrade_app='{$application['app_directory']}'");
         }
         /* Set the message */
         $this->registry->output->global_message = $this->lang->words['a_editappdone'];
     }
     /* Have we toggled this? */
     if ($app_enabled != $application['app_enabled']) {
         $sphinxRebuild = true;
     }
     //-----------------------------------------
     // Recache
     //-----------------------------------------
     $this->applicationsRecache();
     $this->applicationsMenuDataRecache();
     try {
         IPSLib::cacheFurlTemplates();
         IPSLib::cacheGlobalCaches();
     } catch (Exception $e) {
     }
     /**
      * Re-enable the tasks if app is active
      * (more effective than checking per-case)
      */
     if ($app_enabled) {
         $this->DB->update('task_manager', array('task_enabled' => 1), "task_application='{$app_directory}'");
     }
     /* Check for possible hook warnings */
     if ($type == 'edit' && $application['app_enabled'] && !$app_enabled) {
         // Switch the enabled value here or check will fail with the current cache!
         ipsRegistry::$applications[$application['app_directory']]['app_enabled'] = 0;
         $this->_checkHooksWarnings($application['app_directory']);
     }
     //-----------------------------------------
     // Sphinx involved?
     //-----------------------------------------
     if ($sphinxRebuild and $this->settings['search_method'] == 'sphinx' && is_file(IPSLib::getAppDir($app_directory) . '/extensions/sphinxTemplate.php')) {
         $this->registry->output->global_message .= sprintf($this->lang->words['rebuild_sphinx'], $this->settings['_base_url']);
     }
     /* All done */
     $this->applicationsOverview();
 }
Beispiel #7
0
 protected static function init()
 {
     if (is_file(FURL_CACHE_PATH)) {
         $templates = array();
         require FURL_CACHE_PATH;
         /*noLibHook*/
         self::$_seoTemplates = $templates;
     } else {
         /* Attempt to write it */
         self::$_seoTemplates = IPSLib::buildFurlTemplates();
         try {
             IPSLib::cacheFurlTemplates();
         } catch (Exception $e) {
         }
     }
 }
 /**
  * Install Tenplate Caches
  *
  * @return void
  */
 public function install_template_caches()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->settings['base_url'] = IPSSetUp::getSavedData('install_url');
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $skinId = intval($this->request['skinId']);
     $skinData = array();
     $output = array();
     //-----------------------------------------
     // Recache skins: Moved here so they are
     // build after hooks are added
     //-----------------------------------------
     /* 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 */
     $skinData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => 'set_id > ' . $skinId . ' AND set_parent_id=0', 'order' => 'set_id ASC', 'limit' => array(0, 1)));
     if ($skinData['set_id']) {
         $skinFunctions->rebuildPHPTemplates($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $skinFunctions->rebuildCSS($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $skinFunctions->rebuildReplacementsCache($skinData['set_id']);
         $output = array_merge($output, $skinFunctions->fetchMessages(TRUE));
         if ($skinFunctions->fetchErrorMessages() !== FALSE) {
             $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages()));
         }
         $output[] = "Recached skin " . $skinData['set_name'] . "...";
         /* Go for the next */
         $this->_finishStep($output, "Upgrade: Skin Caches", 'upgrade&do=templatecache&skinId=' . $skinData['set_id']);
     } else {
         /* All diddly done */
         $output[] = "All skins recached";
         $skinFunctions->rebuildSkinSetsCache();
         /* Rebuild FURL cache */
         try {
             IPSLib::cacheFurlTemplates();
         } catch (Exception $error) {
         }
         $this->_finishStep($output, "Upgrade: Skin Caches", 'done');
     }
 }
 /**
  * Build the FURL templates file into cache
  *
  * @access	public
  * @return	void
  */
 public function seoRebuild()
 {
     try {
         IPSLib::cacheFurlTemplates();
         $msg = $this->lang->words['furl_cache_rebuilt'];
     } catch (Exception $e) {
         $msg = $e->getMessage();
         switch ($msg) {
             case 'CANNOT_WRITE':
                 $msg = $this->lang->words['seo_cannot_write'];
                 break;
             case 'NO_DATA_TO_WRITE':
                 $msg = $this->lang->words['seo_no_data'];
                 break;
         }
     }
     $this->registry->output->global_message = $msg;
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&amp;do=applications_overview');
 }