Пример #1
0
 /**
  * Main function executed automatically by the controller
  *
  * @param	object		$registry		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Load skin
     //-----------------------------------------
     $this->html = $this->registry->output->loadTemplate('cp_skin_mycp');
     //-----------------------------------------
     // Load language
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('admin_mycp'));
     /* This is a little hacky, but we have to allow access to the whole module to get access to 
        'change my details'.  This check just makes sure that we don't also get access to the Dashboard
        if the permission system automatically added permission for 'change my details' */
     if ($this->registry->getClass('class_permissions')->editDetailsOnly) {
         /* If they just don't have access to the dashboard, let's show them something we do have access to */
         if (!$this->request['app']) {
             foreach (ipsRegistry::$applications as $k => $data) {
                 if ($this->registry->getClass('class_permissions')->checkForAppAccess($k) and ($k != 'core' or !$this->registry->getClass('class_permissions')->editDetailsOnly)) {
                     foreach (ipsRegistry::$modules[$k] as $module) {
                         if ($this->registry->getClass('class_permissions')->checkForModuleAccess($k, $module['sys_module_key'])) {
                             $filepath = IPSLib::getAppDir($k) . '/modules_admin/' . $module['sys_module_key'] . '/defaultSection.php';
                             if (is_file($filepath)) {
                                 $DEFAULT_SECTION = '';
                                 include $filepath;
                                 /*noLibHook*/
                                 if ($this->registry->getClass('class_permissions')->checkForSectionAccess($k, $module['sys_module_key'], $DEFAULT_SECTION)) {
                                     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "app={$k}&module={$module['sys_module_key']}&section={$DEFAULT_SECTION}");
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /* If all else fails, take them to the change details page */
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "core&module=mycp&section=details");
     } else {
         if (!$this->registry->getClass('class_permissions')->checkPermission('dashboard', 'core', 'mycp')) {
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "core&module=mycp&section=details");
         }
     }
     //-----------------------------------------
     // Set up stuff
     //-----------------------------------------
     $this->form_code = $this->html->form_code = 'module=mycp&section=dashboard';
     $this->form_code_js = $this->html->form_code_js = 'module=mycp&section=dashboard';
     //-----------------------------------------
     // Hang on, do we need the upgrader?
     // The only reason this is still here, since we check on the login form, is because Rhett Buck AKA BHP wants to
     // login to the ACP, then upload files, then click the System tab and be automatically redirected to the upgrader.
     // Seriously though?  Who does that?  The login form redirects you, so if you happen to upload files and click on
     // the ACP link you're already covered.  Only Mr. RB, that's who.
     //-----------------------------------------
     if (!IN_DEV and (!defined('SKIP_UPGRADE_CHECK') or !SKIP_UPGRADE_CHECK)) {
         require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
         /*noLibHook*/
         foreach (ipsRegistry::$applications as $app_dir => $app) {
             $_a = ($app_dir == 'forums' or $app_dir == 'members') ? 'core' : $app_dir;
             $numbers = IPSSetUp::fetchAppVersionNumbers($_a);
             if ($numbers['latest'][0] and $numbers['latest'][0] > $numbers['current'][0]) {
                 $this->registry->output->silentRedirect($this->settings['base_acp_url'] . '/upgrade/index.php?_acpRedirect=1');
                 return;
             }
         }
     }
     //-----------------------------------------
     // Get external data
     //-----------------------------------------
     $content = array();
     $thiscontent = "";
     $latest_version = array();
     $reg_end = "";
     $unfinished_upgrade = 0;
     $ipsNewsData = $this->cache->getCache('ipsNewsData');
     if (!isset($ipsNewsData['time']) or $ipsNewsData['time'] < time() - 43200) {
         $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement');
         $classFileManagement = new $classToLoad();
         if (strpos($this->settings['base_url'], 'https://') !== false) {
             $ipsNewsData['news'] = $classFileManagement->getFileContents('https://external.ipslink.com/ipboard33/dashboard/index.php?v=' . ipsRegistry::$vn_full);
             $ipsNewsData['vcheck'] = $classFileManagement->getFileContents('https://external.ipslink.com/latestversioncheck/ipb30x.php?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']));
         } else {
             $ipsNewsData['news'] = $classFileManagement->getFileContents('http://external.ipslink.com/ipboard33/dashboard/index.php?v=' . ipsRegistry::$vn_full);
             $ipsNewsData['vcheck'] = $classFileManagement->getFileContents('http://external.ipslink.com/latestversioncheck/ipb30x.php?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']));
         }
         $ipsNewsData['time'] = time();
         $this->cache->setCache('ipsNewsData', $ipsNewsData, array('array' => 1));
     }
     //-----------------------------------------
     // Get MySQL & PHP Version
     //-----------------------------------------
     $this->DB->getSqlVersion();
     //-----------------------------------------
     // Upgrade history?
     //-----------------------------------------
     $latest_version = array('upgrade_version_id' => NULL);
     $this->DB->build(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $latest_version = $r;
     }
     //-----------------------------------------
     // Resetting security image?
     //-----------------------------------------
     if ($this->request['reset_security_flag'] and $this->request['reset_security_flag'] == 1 and $this->request['new_build']) {
         $_latest = IPSLib::fetchVersionNumber('core');
         $new_build = intval($this->request['new_build']);
         $new_reason = trim(substr($this->request['new_reason'], 0, 1));
         $new_version = $_latest['long'] . '.' . $new_build . '.' . $new_reason;
         $this->DB->update('upgrade_history', array('upgrade_notes' => $new_version), 'upgrade_version_id=' . $latest_version['upgrade_version_id']);
         $latest_version['upgrade_notes'] = $new_version;
     }
     //-----------------------------------------
     // Got real version number?
     //-----------------------------------------
     ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
     ipsRegistry::$vn_full = !empty($latest_version['upgrade_notes']) ? $latest_version['upgrade_notes'] : ipsRegistry::$vn_full;
     //-----------------------------------------
     // Notepad
     //-----------------------------------------
     if ($this->request['save'] and $this->request['save'] == 1) {
         $_POST['notes'] = $_POST['notes'] ? $_POST['notes'] : $this->lang->words['cp_acpnotes'];
         $this->cache->setCache('adminnotes', IPSText::stripslashes($_POST['notes']), array('donow' => 1, 'array' => 0));
     }
     $text = $this->lang->words['cp_acpnotes'];
     if (!$this->cache->getCache('adminnotes')) {
         $this->cache->setCache('adminnotes', $text, array('donow' => 1, 'array' => 0));
     }
     $this->cache->updateCacheWithoutSaving('adminnotes', htmlspecialchars($this->cache->getCache('adminnotes'), ENT_QUOTES));
     $this->cache->updateCacheWithoutSaving('adminnotes', str_replace("&amp;#", "&#", $this->cache->getCache('adminnotes')));
     $content['ad_notes'] = $this->html->acp_notes($this->cache->getCache('adminnotes'));
     //-----------------------------------------
     // ADMINS USING CP
     //-----------------------------------------
     $t_time = time() - 60 * 10;
     $time_now = time();
     $seen_name = array();
     $acponline = "";
     $this->DB->build(array('select' => 's.session_member_name, s.session_member_id, s.session_location, s.session_log_in_time, s.session_running_time, s.session_ip_address, s.session_url', 'from' => array('core_sys_cp_sessions' => 's'), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => "m.member_id=s.session_member_id", 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $q = $this->DB->execute();
     while ($r = $this->DB->fetch($q)) {
         if (isset($seen_name[$r['session_member_name']]) and $seen_name[$r['session_member_name']] == 1) {
             continue;
         } else {
             $seen_name[$r['session_member_name']] = 1;
         }
         $r['_log_in'] = $time_now - $r['session_log_in_time'];
         $r['_click'] = $time_now - $r['session_running_time'];
         if ($r['_log_in'] / 60 < 1) {
             $r['_log_in'] = sprintf("%0d", $r['_log_in']) . ' ' . $this->lang->words['cp_secondsago'];
         } else {
             $r['_log_in'] = sprintf("%0d", $r['_log_in'] / 60) . ' ' . $this->lang->words['cp_minutesago'];
         }
         if ($r['_click'] / 60 < 1) {
             $r['_click'] = sprintf("%0d", $r['_click']) . ' ' . $this->lang->words['cp_secondsago'];
         } else {
             $r['_click'] = sprintf("%0d", $r['_click'] / 60) . ' ' . $this->lang->words['cp_minutesago'];
         }
         $r['session_location'] = $r['session_location'] ? $r['session_location'] : $this->lang->words['cp_index'];
         $r['seo_link'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?showuser='******'session_member_id'], 'none', $r['members_seo_name'], 'showuser');
         $admins_online[] = $r;
     }
     $content['acp_online'] = $this->html->acp_onlineadmin_wrapper($admins_online);
     //-----------------------------------------
     // Members awaiting admin validation?
     //-----------------------------------------
     if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'admin') {
         $where_extra = $this->settings['reg_auth_type'] == 'admin_user' ? ' AND user_verified=1' : '';
         $admin_reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => 'validating', 'where' => 'new_reg=1' . $where_extra));
         if ($admin_reg['reg'] > 0) {
             // We have some member's awaiting admin validation
             $data = null;
             $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => 'new_reg=1' . $where_extra, 'limit' => array(3), 'add_join' => array(array('type' => 'left', 'select' => 'm.members_display_name, m.email, m.ip_address', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id'))));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if ($r['coppa_user'] == 1) {
                     $r['_coppa'] = ' ( COPPA )';
                 } else {
                     $r['_coppa'] = "";
                 }
                 $r['_entry'] = $this->registry->getClass('class_localization')->getDate($r['entry_date'], 'TINY');
                 $data .= $this->html->acp_validating_block($r);
             }
             $content['validating'] = $this->html->acp_validating_wrapper($data);
         }
     }
     //-----------------------------------------
     // Info for the stats bar
     //-----------------------------------------
     $stats = array('performance' => false, 'active_users' => 0, 'server_load' => 0);
     $record = $this->cache->getCache('performanceCache');
     if (is_array($record) and count($record)) {
         $stats['performance'] = true;
     }
     list($load, $time) = explode('-', $this->caches['systemvars']['loadlimit']);
     $time = time() - $this->settings['au_cutoff'] * 60;
     $online = $this->DB->buildAndFetch(array('select' => 'count(*) as rows', 'from' => 'sessions', 'where' => "running_time > {$time}"));
     $stats['active_users'] = $online['rows'];
     $stats['server_load'] = $load;
     //-----------------------------------------
     // Piece it together
     //-----------------------------------------
     $this->registry->output->html .= $this->html->mainTemplate($content, $ipsNewsData, $this->getNotificationPanelEntries(), $stats);
     //-----------------------------------------
     // Left log all on?
     //-----------------------------------------
     if (IPS_LOG_ALL === TRUE) {
         $_html = $this->html->warning_box($this->lang->words['ds_log_all_title'], $this->lang->words['ds_log_all_desc']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     //-----------------------------------------
     // IN DEV stuff...
     //-----------------------------------------
     if (IN_DEV) {
         $lastUpdate = $this->caches['indev'];
         $lastUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('settings' => array()));
         $lastModUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('modules' => array()));
         $lastTaskUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('tasks' => array()));
         $lastHelpUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('help' => array()));
         $lastbbUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('bbcode' => array()));
         $content = array();
         $modContent = array();
         $tasksContent = array();
         $helpContent = array();
         $bbContent = array();
         $_html = '';
         foreach (ipsRegistry::$applications as $app_dir => $data) {
             /* Settings */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml'));
             $lastDBtime = intval($lastUpdate['import']['settings'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $content[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_settingsupdated']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Modules */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_modules.xml'));
             $lastDBtime = intval($lastUpdate['import']['modules'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $modContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_modulessneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Tasks */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_tasks.xml'));
             $lastDBtime = intval($lastUpdate['import']['tasks'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $tasksContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_taskssneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Help Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_help.xml'));
             $lastDBtime = intval($lastUpdate['import']['help'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $helpContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_helpneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* BBCode Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_bbcode.xml'));
             $lastDBtime = intval($lastUpdate['import']['bbcode'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $bbContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_bbcodeneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
         }
         if (count($content)) {
             $_html = $this->html->warning_box($this->lang->words['cp_settingsneedup'], implode($content, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=settings&amp;section=settings&amp;do=settingsImportApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($modContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_modulessneedup'], implode($modContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=inDevRebuildAll'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($tasksContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($helpContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_helpneedup'], implode($helpContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=help&amp;do=importXml'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($bbContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_bbcodeneedup'], implode($bbContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=posts&amp;section=bbcode&amp;do=bbcode_import_all'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html, $this->registry->output->html);
         /* Got notes!? */
         if (is_file(DOC_IPS_ROOT_PATH . '_dev_notes.txt')) {
             /* file retains tabs, file_get_contents not! */
             $_notes = file(DOC_IPS_ROOT_PATH . '_dev_notes.txt');
             if ($_notes) {
                 /* sanitize data and convert tabs! */
                 //$_notes = array_map( 'htmlentities', $_notes );
                 $_notes = implode('', $_notes);
                 $_notes = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $_notes);
                 $_html = $this->registry->output->global_template->warning_box($this->lang->words['cp_devnotes'], nl2br($_notes)) . "<br />";
                 $this->registry->output->html = str_replace('<!--in_dev_notes-->', $_html, $this->registry->output->html);
             }
         }
     }
     //-----------------------------------------
     // Last 5 log in attempts
     //-----------------------------------------
     $this->registry->getClass('class_permissions')->return = true;
     if ($this->registry->getClass('class_permissions')->checkPermission('acplogin_log', 'core', 'logs')) {
         $this->DB->build(array('select' => '*', 'from' => 'admin_login_logs', 'where' => 'admin_success = 0 AND admin_time > 0', 'order' => 'admin_time DESC', 'limit' => array(0, 4)));
         $this->DB->execute();
         while ($rowb = $this->DB->fetch()) {
             $rowb['_admin_time'] = $this->registry->class_localization->getDate($rowb['admin_time'], 'long');
             $logins .= $this->html->acp_last_logins_row($rowb);
         }
         $this->registry->output->html = str_replace('<!--acplogins-->', $this->html->acp_last_logins_wrapper($logins), $this->registry->output->html);
     }
     //-----------------------------------------
     // Pass to CP output hander
     //-----------------------------------------
     $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
     $this->registry->getClass('output')->sendOutput();
 }
 /**
  * Main class entry point
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Load skin
     //-----------------------------------------
     $this->html = $this->registry->output->loadTemplate('cp_skin_mycp');
     //-----------------------------------------
     // Load language
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('admin_mycp'));
     //-----------------------------------------
     // Set up stuff
     //-----------------------------------------
     $this->form_code = $this->html->form_code = 'module=mycp&amp;section=dashboard';
     $this->form_code_js = $this->html->form_code_js = 'module=mycp&section=dashboard';
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     define('IPS_NEWS_URL', 'http://external./globalfeeds/news/');
     define('IPS_BULLETINS_URL', 'http://external./ipbfeeds/300/staffbulletin/');
     define('IPS_VERSION_CHECK_URL', 'http://www./latestversioncheck/ipb30x.php');
     $content = array();
     $thiscontent = "";
     $latest_version = array();
     $reg_end = "";
     $sm_install = 0;
     $lock_file = 0;
     $converter = 0;
     $fulltext_a = 0;
     $unfinished_upgrade = 0;
     $urls = array('news' => IPS_NEWS_URL, 'keiths_bits' => IPS_BULLETINS_URL, 'version_check' => IPS_VERSION_CHECK_URL, 'blogs' => 'http://external./globalfeeds/blog/');
     if (@file_exists(IPS_ROOT_PATH . 'install/index.php')) {
         $sm_install = 1;
     }
     if (@file_exists(DOC_IPS_ROOT_PATH . 'cache/installer_lock.php')) {
         $lock_file = 1;
     }
     if (@is_dir(IPS_ROOT_PATH . 'applications_addon/ips/convert/')) {
         $converter = 1;
         if (!@file_exists(DOC_IPS_ROOT_PATH . 'cache/converter_lock.php')) {
             $converter = 2;
         }
     }
     if ($this->DB->checkFulltextSupport()) {
         if (!$this->DB->getFulltextStatus('posts')) {
             $fulltext_a = 1;
         }
     }
     require_once IPS_ROOT_PATH . '/setup/sources/base/setup.php';
     $versions = IPSSetUp::fetchAppVersionNumbers('core');
     if ($versions['current'][0] != $versions['latest'][0]) {
         $unfinished_upgrade = 1;
     }
     //-----------------------------------------
     // Get MySQL & PHP Version
     //-----------------------------------------
     $this->DB->getSqlVersion();
     //-----------------------------------------
     // Upgrade history?
     //-----------------------------------------
     $latest_version = array('upgrade_version_id' => NULL);
     $this->DB->build(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $latest_version = $r;
     }
     //-----------------------------------------
     // Resetting security image?
     //-----------------------------------------
     if ($this->request['reset_security_flag'] and $this->request['reset_security_flag'] == 1 and $this->request['new_build']) {
         $_latest = IPSLib::fetchVersionNumber('core');
         $new_build = intval($this->request['new_build']);
         $new_reason = trim(substr($this->request['new_reason'], 0, 1));
         $new_version = $_latest['long'] . '.' . $new_build . '.' . $new_reason;
         $this->DB->update('upgrade_history', array('upgrade_notes' => $new_version), 'upgrade_version_id=' . $latest_version['upgrade_version_id']);
         $latest_version['upgrade_notes'] = $new_version;
     }
     //-----------------------------------------
     // Got real version number?
     //-----------------------------------------
     ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
     ipsRegistry::$vn_full = (isset($latest_version['upgrade_notes']) and $latest_version['upgrade_notes']) ? $latest_version['upgrade_notes'] : ipsRegistry::$vn_full;
     //-----------------------------------------
     // Licensed?
     //-----------------------------------------
     $urls['keiths_bits'] = IPS_BULLETINS_URL . '?v=' . ipsRegistry::$vn_full;
     //-----------------------------------------
     // Notepad
     //-----------------------------------------
     if ($this->request['save'] and $this->request['save'] == 1) {
         $_POST['notes'] = $_POST['notes'] ? $_POST['notes'] : $this->lang->words['cp_acpnotes'];
         $this->cache->setCache('adminnotes', IPSText::stripslashes($_POST['notes']), array('donow' => 1, 'deletefirst' => 0, 'array' => 0));
     }
     $text = $this->lang->words['cp_acpnotes'];
     if (!$this->cache->getCache('adminnotes') or !$this->cache->getCache('adminnotes')) {
         $this->cache->setCache('adminnotes', $text, array('donow' => 1, 'deletefirst' => 0, 'array' => 0));
     }
     $this->cache->updateCacheWithoutSaving('adminnotes', htmlspecialchars($this->cache->getCache('adminnotes'), ENT_QUOTES));
     $this->cache->updateCacheWithoutSaving('adminnotes', str_replace("&amp;#", "&#", $this->cache->getCache('adminnotes')));
     $content['ad_notes'] = $this->html->acp_notes($this->cache->getCache('adminnotes'));
     //-----------------------------------------
     // ADMINS USING CP
     //-----------------------------------------
     $t_time = time() - 60 * 10;
     $time_now = time();
     $seen_name = array();
     $acponline = "";
     $this->DB->build(array('select' => 's.session_member_name, s.session_member_id, s.session_location, s.session_log_in_time, s.session_running_time, s.session_ip_address, s.session_url', 'from' => array('core_sys_cp_sessions' => 's'), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => "m.member_id=s.session_member_id", 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $q = $this->DB->execute();
     while ($r = $this->DB->fetch($q)) {
         if (isset($seen_name[$r['session_member_name']]) and $seen_name[$r['session_member_name']] == 1) {
             continue;
         } else {
             $seen_name[$r['session_member_name']] = 1;
         }
         $r['_log_in'] = $time_now - $r['session_log_in_time'];
         $r['_click'] = $time_now - $r['session_running_time'];
         if ($r['_log_in'] / 60 < 1) {
             $r['_log_in'] = sprintf("%0d", $r['_log_in']) . $this->lang->words['cp_secondsago'];
         } else {
             $r['_log_in'] = sprintf("%0d", $r['_log_in'] / 60) . $this->lang->words['cp_minutesago'];
         }
         if ($r['_click'] / 60 < 1) {
             $r['_click'] = sprintf("%0d", $r['_click']) . $this->lang->words['cp_secondsago'];
         } else {
             $r['_click'] = sprintf("%0d", $r['_click'] / 60) . $this->lang->words['cp_minutesago'];
         }
         $r['session_location'] = $r['session_location'] ? "<a href='" . preg_replace('/&amp;app=([a-zA-Z0-9\\-_]+)/', '', $this->settings['base_url']) . $r['session_url'] . "'>{$r['session_location']}</a>" : $this->lang->words['cp_index'];
         $acponline .= $this->html->acp_onlineadmin_row(IPSMember::buildDisplayData($r));
     }
     $content['acp_online'] = $this->html->acp_onlineadmin_wrapper($acponline);
     //-----------------------------------------
     // Stats
     //-----------------------------------------
     $reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => array('validating' => 'v'), 'where' => 'v.lost_pass <> 1 AND m.member_group_id=' . $this->settings['auth_group'], 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left'))));
     if ($this->settings['ipb_bruteforce_attempts']) {
         $lock = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as mems', 'from' => 'members', 'where' => 'failed_login_count >= ' . $this->settings['ipb_bruteforce_attempts']));
     }
     $coppa = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as coppa', 'from' => 'validating', 'where' => 'coppa_user=1'));
     $my_timestamp = time() - $this->settings['au_cutoff'] * 60;
     $online = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as sessions', 'from' => 'sessions', 'where' => 'running_time>' . $my_timestamp));
     $pending = $this->DB->buildAndFetch(array('select' => 'SUM(queued_topics) as topics, SUM(queued_posts) as posts', 'from' => 'forums'));
     $spammers = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count, MAX(joined) as joined', 'from' => 'members', 'where' => "members_bitoptions = '1'"));
     $content['stats'] = $this->html->acp_stats_wrapper(array('topics' => intval($this->caches['stats']['total_topics']), 'replies' => intval($this->caches['stats']['total_replies']), 'topics_mod' => intval($pending['topics']), 'posts_mod' => intval($pending['posts']), 'members' => intval($this->caches['stats']['mem_count']), 'validate' => intval($reg['reg']), 'spammer' => array(intval($spammers['count']), intval($spammers['joined'])), 'locked' => intval($lock['mems']), 'coppa' => intval($coppa['coppa']), 'sql_driver' => strtoupper(SQL_DRIVER), 'sql_version' => $this->DB->true_version, 'php_version' => phpversion(), 'sessions' => intval($online['sessions']), 'php_sapi' => @php_sapi_name(), 'ipb_version' => ipsRegistry::$version, 'ipb_id' => ipsRegistry::$vn_full));
     //-----------------------------------------
     // Members awaiting admin validation?
     //-----------------------------------------
     if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'admin') {
         $where_extra = $this->settings['reg_auth_type'] == 'admin_user' ? ' AND user_verified=1' : '';
         $admin_reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => 'validating', 'where' => 'new_reg=1' . $where_extra));
         if ($admin_reg['reg'] > 0) {
             // We have some member's awaiting admin validation
             $data = null;
             $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => 'new_reg=1' . $where_extra, 'limit' => array(3), 'add_join' => array(array('type' => 'left', 'select' => 'm.members_display_name, m.email, m.ip_address', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id'))));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if ($r['coppa_user'] == 1) {
                     $r['_coppa'] = ' ( COPPA )';
                 } else {
                     $r['_coppa'] = "";
                 }
                 $r['_entry'] = $this->registry->getClass('class_localization')->getDate($r['entry_date'], 'TINY');
                 $data .= $this->html->acp_validating_block($r);
             }
             $content['validating'] = $this->html->acp_validating_wrapper($data);
         }
     }
     //-----------------------------------------
     // Forum and group dropdowns
     //-----------------------------------------
     require_once IPSLib::getAppDir('forums') . '/sources/classes/forums/class_forums.php';
     $this->registry->setClass('class_forums', new class_forums($this->registry));
     $this->registry->getClass('class_forums')->forumsInit();
     $forums = $this->registry->getClass('class_forums')->forumsForumJump(1);
     $groups = array();
     $groups_html = '';
     foreach ($this->cache->getCache('group_cache') as $k => $v) {
         $groups[$v['g_title']] = "<option value='{$k}'>{$v['g_title']}</option>";
     }
     ksort($groups);
     $groups_html = implode("\n", $groups);
     //-----------------------------------------
     // Piece it together
     //-----------------------------------------
     $urls['version_check'] = IPS_VERSION_CHECK_URL . '?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']);
     $this->registry->output->html .= $this->html->mainTemplate($content, $forums, $groups_html, $urls);
     //-----------------------------------------
     // FURL cache OOD?
     //-----------------------------------------
     if (file_exists(IPS_CACHE_PATH . 'cache/furlCache.php')) {
         $mtime = intval(@filemtime(IPS_CACHE_PATH . 'cache/furlCache.php'));
         /* Check mtimes on extensions.. */
         foreach (ipsRegistry::$applications as $app_dir => $application) {
             if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/furlTemplates.php')) {
                 $_mtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/extensions/furlTemplates.php'));
                 if ($_mtime > $mtime) {
                     $_html = $this->html->warning_box($this->lang->words['furlcache_outofdate'], "<a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=seoRebuild'>{$this->lang->words['rebuild_furl_cache']}</a>") . "<br />";
                     $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
                     break;
                 }
             }
         }
     }
     //-----------------------------------------
     // Minify on but /cache/tmp not writeable?
     //-----------------------------------------
     if (isset($this->settings['_use_minify']) and $this->settings['_use_minify']) {
         $_html = $this->html->warning_box($this->lang->words['minifywrite_head'], $this->lang->words['minifynot_writeable']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     //-----------------------------------------
     // Left log all on?
     //-----------------------------------------
     if (IPS_LOG_ALL === TRUE) {
         $_html = $this->html->warning_box($this->lang->words['ds_log_all_title'], $this->lang->words['ds_log_all_desc']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     if (count($tasksContent)) {
         $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
     }
     //-----------------------------------------
     // IN DEV stuff...
     //-----------------------------------------
     if (IN_DEV) {
         $lastUpdate = $this->caches['indev'];
         $lastUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('settings' => array()));
         $lastModUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('modules' => array()));
         $lastTaskUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('tasks' => array()));
         $lastHelpUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('help' => array()));
         $lastbbUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('bbcode' => array()));
         $content = array();
         $modContent = array();
         $tasksContent = array();
         $helpContent = array();
         $bbContent = array();
         $apps = new IPSApplicationsIterator();
         $_html = '';
         foreach ($apps as $app) {
             $app_dir = $apps->fetchAppDir();
             /* Settings */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml'));
             $lastDBtime = intval($lastUpdate['import']['settings'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $content[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_settingsupdated']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Modules */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_modules.xml'));
             $lastDBtime = intval($lastUpdate['import']['modules'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $modContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_modulessneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Tasks */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_tasks.xml'));
             $lastDBtime = intval($lastUpdate['import']['tasks'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $tasksContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_taskssneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Help Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_help.xml'));
             $lastDBtime = intval($lastUpdate['import']['help'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $helpContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_helpneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* BBCode Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_bbcode.xml'));
             $lastDBtime = intval($lastUpdate['import']['bbcode'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $bbContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_bbcodeneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
         }
         if (count($content)) {
             $_html = $this->html->warning_box($this->lang->words['cp_settingsneedup'], implode($content, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=settings&amp;do=settingsImportApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($modContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_modulessneedup'], implode($modContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=inDevRebuildAll'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($tasksContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($helpContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_helpneedup'], implode($helpContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=help&amp;do=importXml'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($bbContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_bbcodeneedup'], implode($bbContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=posts&amp;section=bbcode&amp;do=bbcode_import_all'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html, $this->registry->output->html);
         if (@file_exists(DOC_IPS_ROOT_PATH . '_dev_notes.txt')) {
             $_notes = @file_get_contents(DOC_IPS_ROOT_PATH . '_dev_notes.txt');
             if ($_notes) {
                 $_html = $this->registry->output->global_template->information_box($this->lang->words['cp_devnotes'], nl2br($_notes)) . "<br />";
                 $this->registry->output->html = str_replace('<!--in_dev_notes-->', $_html, $this->registry->output->html);
             }
         }
     }
     //-----------------------------------------
     // INSTALLER PRESENT?
     //-----------------------------------------
     if ($sm_install == 1) {
         if ($lock_file != 1) {
             $installer = $this->html->warning_box($this->lang->words['cp_unlockedinstaller'], $this->html->warning_unlocked_installer()) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         } else {
             $installer = $this->html->warning_box($this->lang->words['cp_installerpresent'], $this->html->warning_installer()) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         }
     } else {
         if ($converter) {
             $text = $converter == 2 ? $this->lang->words['cp_unlocked_converter'] : $this->lang->words['cp_converterpresent'];
             $installer = $this->html->warning_box($text, $this->html->warning_converter($converter)) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         }
     }
     //-----------------------------------------
     // UNFINISHED UPGRADE?
     //-----------------------------------------
     if ($unfinished_upgrade == 1) {
         $this->lang->words['cp_upgrade_warning'] = sprintf($this->lang->words['cp_upgrade_warning'], $versions['current'][1], $versions['latest'][1], $this->settings['base_acp_url']);
         $upgrade = $this->html->warning_box($this->lang->words['cp_unfinishedupgrade'], $this->html->warning_upgrade()) . "<br />";
         $this->registry->output->html = str_replace('<!--warningupgrade-->', $upgrade, $this->registry->output->html);
     }
     //-----------------------------------------
     // INSUFFICIENT PHP VERSION?
     //-----------------------------------------
     if (PHP_VERSION < '5.1.0') {
         $version = $this->html->warning_box(sprintf($this->lang->words['cp_yourphpversion'], PHP_VERSION), $this->html->acp_php_version_warning()) . "<br />";
         $this->registry->output->html = str_replace('<!--phpversioncheck-->', $version, $this->registry->output->html);
     }
     //-----------------------------------------
     // BOARD OFFLINE?
     //-----------------------------------------
     if ($this->settings['board_offline']) {
         $offline = $this->html->warning_box($this->lang->words['cp_boardoffline'], "{$this->lang->words['cp_boardoffline1']}<br /><br />&raquo; <a href='" . $this->settings['base_url'] . "&amp;module=tools&amp;section=settings&amp;do=findsetting&amp;key=boardoffline'>{$this->lang->words['cp_boardoffline2']}</a>") . "<br />";
         $this->registry->output->html = str_replace('<!--boardoffline-->', $offline, $this->registry->output->html);
     }
     //-----------------------------------------
     // No fulltext
     //-----------------------------------------
     if ($this->settings['search_method'] == 'traditional' and !$this->settings['use_fulltext'] and !$this->settings['hide_ftext_note']) {
         $ftext = $this->html->warning_box($this->lang->words['fulltext_off'], "{$this->lang->words['fulltext_turnon']}<br /><br />&raquo; <a href='" . $this->settings['base_url'] . "&amp;module=tools&amp;section=settings&amp;do=findsetting&amp;key=searchsetup'>{$this->lang->words['fulltext_find']}</a>") . "<br />";
         $this->registry->output->html = str_replace('<!--fulltext-->', $ftext, $this->registry->output->html);
     }
     //-----------------------------------------
     // Last 5 log in attempts
     //-----------------------------------------
     $this->registry->getClass('class_permissions')->return = true;
     if ($this->registry->getClass('class_permissions')->checkPermission('acplogin_log')) {
         $this->DB->build(array('select' => '*', 'from' => 'admin_login_logs', 'order' => 'admin_time DESC', 'limit' => array(0, 5)));
         $this->DB->execute();
         while ($rowb = $this->DB->fetch()) {
             $rowb['_admin_time'] = $this->registry->class_localization->getDate($rowb['admin_time'], 'long');
             $rowb['_admin_img'] = $rowb['admin_success'] ? 'aff_tick.png' : 'aff_cross.png';
             $logins .= $this->html->acp_last_logins_row($rowb);
         }
         $this->registry->output->html = str_replace('<!--acplogins-->', $this->html->acp_last_logins_wrapper($logins), $this->registry->output->html);
     }
     //-----------------------------------------
     // Pass to CP output hander
     //-----------------------------------------
     $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
     $this->registry->getClass('output')->sendOutput();
 }
 /**
  * Builds the language db entries from cache
  *
  * @param	boolean			return as normal
  * @return	@e void
  * @author	Josh
  */
 public function importFromCacheFiles($returnAsNormal = TRUE)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $msg = array();
     $lang_id = 1;
     $LATESTVERSION = IPSLib::fetchVersionNumber();
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!is_array($_POST['apps'])) {
         $this->registry->output->global_message = $this->lang->words['l_noapp'];
         $this->languagesList();
         return;
     }
     //-----------------------------------------
     // Loop through apps...
     //-----------------------------------------
     foreach (ipsRegistry::$applications as $app => $app_data) {
         if (in_array($app, $_POST['apps'])) {
             //-----------------------------------------
             // Get directory
             //-----------------------------------------
             $_dir = IPS_CACHE_PATH . 'cache/lang_cache/master_lang/';
             //-----------------------------------------
             // Go through directories
             //-----------------------------------------
             if (is_dir($_dir)) {
                 $dh = opendir($_dir);
                 while ($f = readdir($dh)) {
                     if ($f[0] == '.' || $f == 'index.html') {
                         continue;
                     }
                     if (preg_match("#^" . $app . '_\\S+?\\.php$#', $f)) {
                         //-----------------------------------------
                         // INIT
                         //-----------------------------------------
                         $updated = 0;
                         $inserted = 0;
                         $word_pack = preg_replace("#^" . $app . '_(\\S+?)\\.php$#', "\\1", $f);
                         $lang = array();
                         $db_lang = array();
                         //-----------------------------------------
                         // Delete current language bits
                         //-----------------------------------------
                         $this->DB->delete('core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $word_pack . "'");
                         if (IPS_IS_SHELL) {
                             $stdout = fopen('php://stdout', 'w');
                             fwrite($stdout, 'Processing: ' . $f . "\n");
                             fclose($stdout);
                         }
                         require $_dir . $f;
                         /*noLibHook*/
                         //-----------------------------------------
                         // Loop
                         //-----------------------------------------
                         foreach ($lang as $k => $v) {
                             $inserted++;
                             $insert = array('lang_id' => $lang_id, 'word_app' => $app, 'word_pack' => $word_pack, 'word_key' => $k, 'word_default' => IPSText::encodeForXml($v), 'word_default_version' => $LATESTVERSION['long'], 'word_js' => 0);
                             $this->DB->insert('core_sys_lang_words', $insert);
                         }
                         $msg[] = sprintf($this->lang->words['indev_lang_import'], $f, $inserted, $updated);
                     } else {
                         if (preg_match('/(\\.js)$/', $f) and $app == 'core') {
                             $_js_word_pack = '';
                             if ($f == 'ipb.lang.js') {
                                 $_js_word_pack = 'public_js';
                             } else {
                                 if ($f == 'acp.lang.js') {
                                     $_js_word_pack = 'admin_js';
                                 }
                             }
                             //-----------------------------------------
                             // Delete current words for this app and word pack
                             //-----------------------------------------
                             $this->DB->delete('core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $_js_word_pack . "'");
                             if (IPS_IS_SHELL) {
                                 $stdout = fopen('php://stdout', 'w');
                                 fwrite($stdout, 'Processing: ' . $f . "\n");
                                 fclose($stdout);
                             }
                             //-----------------------------------------
                             // Get each line
                             //-----------------------------------------
                             $js_file = file($_dir . $f);
                             //-----------------------------------------
                             // Loop through lines and import
                             //-----------------------------------------
                             foreach ($js_file as $r) {
                                 //-----------------------------------------
                                 // preg_match what we want
                                 //-----------------------------------------
                                 preg_match('#ipb\\.lang\\[\'(.+?)\'\\](.+?)= ["\'](.+?)["\'];#', $r, $matches);
                                 //-----------------------------------------
                                 // Valid?
                                 //-----------------------------------------
                                 if ($matches[1] && $matches[3]) {
                                     $inserted++;
                                     $insert = array('lang_id' => $lang_id, 'word_app' => 'core', 'word_pack' => $_js_word_pack, 'word_key' => $matches[1], 'word_default' => IPSText::encodeForXml($matches[3]), 'word_js' => 1);
                                     $this->DB->insert('core_sys_lang_words', $insert);
                                 }
                             }
                         }
                     }
                 }
                 closedir($dh);
             }
         }
     }
     //-----------------------------------------
     // Done...
     //-----------------------------------------
     if ($returnAsNormal === TRUE) {
         $this->registry->output->setMessage(implode("<br />", $msg), true);
         if (!$this->__daily) {
             $this->languagesList();
         }
     } else {
         return $msg;
     }
 }
Пример #4
0
 /**
  * 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;
 }
 /**
  * Recache main version number
  *
  * @return	@e void
  */
 public function versionNumbersRecache()
 {
     $numbers = IPSLib::fetchVersionNumber();
     $this->cache->setCache('vnums', $numbers, array('array' => 1, 'donow' => 1));
 }
Пример #6
0
 /**
  * Create new session
  *
  * @access	public
  * @param	int			Template set ID to run merge on
  * @return	int			New session ID
  *
  * Exception Codes
  * NO_SET				No such skin set
  * NO_PREVIOUS			No previous data found
  */
 public function createSession($setId)
 {
     /* INIT */
     $templates = array();
     $css = array();
     $skinData = $this->fetchSkinData($setId);
     /* Quick test */
     if (!$skinData['set_id']) {
         throw new Exception('NO_SET');
     }
     /* Got a master key? */
     $skinData['set_master_key'] = $skinData['set_master_key'] ? $skinData['set_master_key'] : 'root';
     /* Fetch version ID of previous elements */
     $previous = $this->DB->buildAndFetch(array('select' => 'p_template_long_version', 'from' => 'skin_templates_previous', 'order' => 'p_template_long_version DESC', 'limit' => array(0, 1)));
     /* Got any previous data? */
     if (!$previous['p_template_long_version']) {
         throw new Exception('NO_PREVIOUS');
     }
     /* Delete all previous with this set ID */
     $this->DB->build(array('select' => 'merge_id', 'from' => 'skin_merge_session', 'where' => 'merge_set_id=' . $setId));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         $this->removeSession($row['merge_id']);
     }
     /* Now grab master elements based on root key data */
     $tCount = 0;
     $templates = $this->fetchTemplates($skinData['set_master_key'], 'allNoContent');
     $css = $this->fetchCSS($skinData['set_master_key'], false);
     /* Get correct count of templates */
     foreach ($templates as $group => $data) {
         $tCount += count($templates[$group]);
     }
     /* Grab current version numbers */
     $cVersion = IPSLib::fetchVersionNumber();
     /* Create session */
     $this->DB->insert('skin_merge_session', array('merge_date' => time(), 'merge_set_id' => $setId, 'merge_master_key' => $skinData['set_master_key'], 'merge_old_version' => $previous['p_template_long_version'], 'merge_new_version' => $cVersion['long'], 'merge_templates_togo' => $tCount, 'merge_css_togo' => intval(count($css)), 'merge_templates_done' => 0, 'merge_css_done' => 0));
     $diffSesssionID = $this->DB->getInsertId();
     return $diffSesssionID;
 }
 /**
  * Import an XMLarchive skin set
  *
  * @return	string		HTML to show
  */
 protected function _importSet()
 {
     $importName = trim($this->request['importName']);
     $importUpgrade = intval($this->request['importUpgrade']) ? TRUE : FALSE;
     $importLocation = trim($this->request['importLocation']);
     $imageDir = trim($this->request['importImgDirs']);
     $checkVersion = trim($this->request['noVersionCheck']) ? FALSE : TRUE;
     //-----------------------------------------
     // Attempt to get contents
     //-----------------------------------------
     if ($checkVersion) {
         try {
             $content = $this->registry->adminFunctions->importXml($importLocation);
         } catch (Exception $e) {
             $this->registry->output->showError($e->getMessage());
         }
     } else {
         $_c = $this->DB->buildAndFetch(array('select' => 'cs_value', 'from' => 'cache_store', 'where' => 'cs_key=\'_importSkinContent_\''));
         $content = $_c['cs_value'];
     }
     if ($content) {
         /* Checking versions? */
         if ($checkVersion) {
             $this->DB->delete('cache_store', 'cs_key=\'_importSkinContent_\'');
             preg_match('#ipbLongVersion=\\"(\\d+?)\\"\\s+?ipbHumanVersion=\\"([\\d\\.\\-\\_]+?)\\"#i', $content, $matches);
             if ($matches[1] and $matches[2]) {
                 $_version = IPSLib::fetchVersionNumber();
                 /* Long version is in format of 31001 (Major Minor X X X) we'll just check majorminor */
                 $_importMajor = substr($matches[1], 0, 2);
                 $_currentMajor = substr($_version['long'], 0, 2);
                 if ($_importMajor < $_currentMajor) {
                     /* Store it */
                     $this->DB->insert('cache_store', array('cs_key' => '_importSkinContent_', 'cs_value' => $content));
                     /* Generate continue link */
                     $link = $this->settings['base_url'] . '&amp;noVersionCheck=1&amp;' . http_build_query($this->request);
                     /* Show form */
                     $this->registry->output->global_error = sprintf($this->lang->words['ie_importfail_old_version'], $matches[2], $_version['human'], $link);
                     return $this->_showForm();
                 }
             }
         }
         $added = $this->skinFunctions->importSetXMLArchive($content, 0, $imageDir, $importName, $importUpgrade);
         $message = $added['upgrade'] ? $this->lang->words['ie_set_upgraded'] : $this->lang->words['ie_set_imported'];
         $this->registry->output->global_message = sprintf($message, $added['templates'], $added['replacements'], $added['css']);
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=templates&section=importexport&do=overview');
     } else {
         $this->registry->output->global_error = $this->lang->words['ie_importfail_no'];
         return $this->_showForm();
     }
 }
 /**
  * Generate XML Information data file
  *
  * @access	public
  * @param	int			Set ID
  * @return	string		XML
  */
 public function generateInfoXML($setID = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $data = array();
     $setData = $this->fetchSkinData($setID);
     $version = IPSLib::fetchVersionNumber();
     //-----------------------------------------
     // Grab the XML parser
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     //-----------------------------------------
     // Loop through...
     //-----------------------------------------
     $xml->newXMLDocument();
     $xml->addElement('info');
     $xml->addElementAsRecord('info', 'data', array('set_name' => $setData['set_name'], 'set_key' => $setData['set_key'], 'set_author_name' => $setData['set_author_name'], 'set_author_url' => $setData['set_author_url'], 'set_output_format' => $setData['set_output_format'], 'set_master_key' => $setData['set_master_key'], 'ipb_human_version' => $version['human'], 'ipb_long_version' => $version['long'], 'ipb_major_version' => '3'));
     return $xml->fetchDocument();
 }