コード例 #1
0
 /**
  * Constructor
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry)
 {
     /* Make diff class object */
     require_once IPS_KERNEL_PATH . 'classDifference.php';
     /*noLibHook*/
     $this->classDifference = new classDifference();
     $this->classDifference->method = 'PHP';
     /* Make object */
     parent::__construct($registry);
 }
コード例 #2
0
ファイル: setup.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Rebuild PHP Templates Cache
  *
  * @return	@e void
  */
 public function recacheTemplates()
 {
     /* Flag skins for recache */
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     $skinCaching = new skinCaching($this->registry);
     /* Flag all for recache */
     $skinCaching->flagSetForRecache();
     $data = $this->getVars();
     $this->showRedirectScreen($data['app_directory'], array($this->lang->words['install_skins_flag_recache']), '', $this->getNextURL('finish', $data));
 }
コード例 #3
0
 /**
  * Restore IPB default skin as default
  * 
  * @return	@e void
  */
 public function setDefaultSkin()
 {
     /* Get skin functions library */
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     $skinFunctions = new skinCaching($this->registry);
     /* Update members to use default skin */
     $this->DB->update('members', array('skin' => 0));
     /* Update forums to use default skin */
     $this->DB->update('forums', array('skin_id' => 0));
     /* Reset any default skin(s) */
     $this->DB->update('skin_collections', array('set_is_default' => 0));
     /* Set IPB default skin as default */
     $this->DB->update('skin_collections', array('set_is_default' => 1), "set_key='default'");
     /* Verify we have a skin set as default */
     $_check = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_collections', 'where' => 'set_is_default=1'));
     if ($_check['total'] < 1) {
         $this->DB->build(array('update' => 'skin_collections', 'set' => 'set_is_default=1', 'where' => "set_output_format='html'", 'limit' => array(0, 1)));
         $this->DB->execute();
     }
     /* Check for any modifications in IPB default skin */
     $_master = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => "set_key='default'"));
     $_master['set_id'] = intval($_master['set_id']);
     $_modifiedTemplates = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_templates', 'where' => "template_set_id={$_master['set_id']} AND template_removable=1 OR template_user_edited=1"));
     $_modifiedCSS = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_css', 'where' => "css_set_id={$_master['set_id']} AND css_master_key=''"));
     if ($_modifiedTemplates['total'] or $_modifiedCSS['total']) {
         /* Create a new skin with IPB default as parent */
         $curPos = $skinFunctions->fetchHighestSetPosition();
         $_master['set_key'] = 'default_modified';
         $_master['set_parent_id'] = $_master['set_id'];
         $_master['set_is_default'] = 0;
         $_master['set_name'] = $_master['set_name'] . ' (Pre 3.2)';
         $_master['set_order'] = (int) $curPos++;
         unset($_master['set_id']);
         $this->DB->insert('skin_collections', $_master);
         $set_id = $this->DB->getInsertId();
         $this->DB->update('skin_templates', array('template_set_id' => $set_id), "template_set_id={$_master['set_parent_id']} AND template_removable=1 OR template_user_edited=1");
         $this->DB->update('skin_css', array('css_set_id' => $set_id), "css_set_id={$_master['set_parent_id']} AND css_master_key=''");
         $skinFunctions->rebuildSkinSetsCache();
         $skinFunctions->rebuildTreeInformation($set_id);
         //$skinFunctions->flushSkinData();
         $skinFunctions->rebuildCSS($set_id);
         $skinFunctions->rebuildPHPTemplates($set_id);
         $skinFunctions->rebuildReplacementsCache($set_id);
     }
     /* Message */
     $this->registry->output->addMessage("Восстановлен новый базовый стиль....");
     /* Next Page */
     $this->request['workact'] = 'hooks';
 }
コード例 #4
0
 /**
  * Construct
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @param	bool		Whether to init or not
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry, $initialize = FALSE)
 {
     /* Make object */
     $this->registry = $registry;
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->lang = $this->registry->getClass('class_localization');
     $this->member = $this->registry->member();
     $this->memberData =& $this->registry->member()->fetchMemberData();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     /* Safe mode skins... */
     $this->_usingSafeModeSkins = ($this->settings['safe_mode_skins'] == 0 and $this->settings['safe_mode'] == 0 or IN_DEV) ? FALSE : TRUE;
     if ($initialize === TRUE) {
         //-----------------------------------------
         // INIT
         //-----------------------------------------
         $_outputFormat = 'html';
         $_outputClassName = 'htmlOutput';
         $this->allSkins = $this->_fetchAllSkins();
         $skinSetID = $this->_fetchUserSkin();
         $this->skin = $this->allSkins[$skinSetID];
         /* Does it need a recache? */
         if ($this->skin['set_updated'] == -2) {
             /* Flag skins for recache */
             require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
             /*noLibHook*/
             require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
             /*noLibHook*/
             $skinCaching = new skinCaching($this->registry);
             /* Set it as caching */
             $skinCaching->flagSetAsRecaching($skinSetID);
             /* Just recache this one skin set */
             $skinCaching->setIgnoreChildrenWhenRecaching(true);
             $skinCaching->rebuildPHPTemplates($skinSetID);
             $skinCaching->rebuildCSS($skinSetID);
             $skinCaching->rebuildReplacementsCache($skinSetID);
             IPSDebug::addMessage("Recached skin set: " . $skinSetID);
         }
         //-----------------------------------------
         // Get the skin caches
         //-----------------------------------------
         $skinCaches = $this->cache->getWithCacheLib('Skin_Store_' . $skinSetID);
         if (!is_array($skinCaches) or !count($skinCaches)) {
             $_grab = "'css', 'replacements'";
             $this->DB->build(array('select' => '*', 'from' => 'skin_cache', 'where' => "cache_set_id=" . intval($skinSetID) . " AND cache_type IN (" . $_grab . ")"));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 $skinCaches[$row['cache_value_2'] . '.' . $row['cache_id']] = $row;
             }
             /* Put skin cache back if needed */
             $this->cache->putWithCacheLib('Skin_Store_' . $skinSetID, $skinCaches, 86400);
         }
         /* Avoid SQL filesort */
         ksort($skinCaches);
         /* Loop and build */
         foreach ($skinCaches as $row) {
             switch ($row['cache_type']) {
                 default:
                     break;
                 case 'css':
                     $appDir = '';
                     $appHide = 0;
                     if (strstr($row['cache_value_4'], '-')) {
                         list($appDir, $appHide) = explode('-', $row['cache_value_4']);
                         if ($appDir and $appDir != IPS_APP_COMPONENT and $appHide) {
                             continue;
                         } else {
                             if ($appDir and !IPSLib::appIsInstalled($appDir)) {
                                 continue;
                             }
                         }
                     }
                     /* Tied to specific modules within the app? */
                     if ($row['cache_value_6'] and $this->request['module']) {
                         if (!in_array($this->request['module'], explode(',', str_replace(' ', '', $row['cache_value_6'])))) {
                             continue;
                         }
                     }
                     $skinCaches['css'][$row['cache_value_1']] = array('content' => $row['cache_content'], 'attributes' => $row['cache_value_5']);
                     break;
                 case 'replacements':
                     $skinCaches['replacements'] = $row['cache_content'];
                     break;
             }
         }
         $this->skin['_css'] = is_array($skinCaches['css']) ? $skinCaches['css'] : array();
         $this->skin['_replacements'] = unserialize($skinCaches['replacements']);
         $this->skin['_skincacheid'] = $this->skin['set_id'];
         $this->skin['_csscacheid'] = 'css_' . $this->skin['set_id'];
         // Set a hash we can use to prevent client caching of CSS/JS
         $this->antiCacheHash = md5(IPB_VERSION . $this->settings['board_url'] . md5($this->settings['sql_tbl_prefix'] . $this->settings['sql_pass']) . $this->skin['set_updated']);
         /* IN_DEV Stuff */
         if (IN_DEV) {
             $this->skin['_css'] = array();
             if (is_file(IPS_CACHE_PATH . 'cache/skin_cache/masterMap.php')) {
                 $REMAP = $this->buildRemapData();
                 $_setId = intval($REMAP['inDevDefault']);
                 $_dir = $REMAP['templates'][$REMAP['inDevDefault']];
                 $_cdir = $REMAP['css'][$REMAP['inDevDefault']];
                 /* Reset master dir */
                 $this->skin['set_image_dir'] = $REMAP['images'][$REMAP['inDevDefault']];
                 $this->skin['set_key'] = $REMAP['inDevDefault'];
             } else {
                 $_setId = 0;
                 $_dir = 'master_skin';
                 $_cdir = 'master_css';
             }
             /* Using a custom master skin */
             if ($_setId) {
                 $this->skin = $this->allSkins[$_setId];
                 $this->skin['_replacements'] = unserialize($skinCaches['replacements']);
             }
             /* Sort out CSS */
             if (!isset($this->_skinFunctions) || !is_object($this->_skinFunctions)) {
                 require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
                 /*noLibHook*/
                 require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
                 /*noLibHook*/
                 $this->_skinFunctions = new skinCaching($this->registry);
             }
             $css = $this->_skinFunctions->fetchDirectoryCSS($_cdir);
             $tmp = array();
             $ord = array();
             foreach ($css as $name => $data) {
                 /* Tied to app? */
                 if ($data['css_app'] and $data['css_app'] != IPS_APP_COMPONENT and $data['css_app_hide']) {
                     continue;
                 }
                 /* Tied to specific modules within the app? */
                 if ($data['css_modules'] and !in_array($this->request['module'], explode(',', str_replace(' ', '', $data['css_modules'])))) {
                     continue;
                 }
                 $tmp[$data['css_position'] . '.' . $data['css_group']][$name] = array('content' => $data['css_content'], 'attributes' => $data['css_attributes']);
             }
             ksort($tmp);
             foreach ($tmp as $blah => $data) {
                 foreach ($data as $name => $data) {
                     $ord[$blah] = array('css_group' => $name, 'css_position' => 1);
                     $this->skin['_css'][$name] = $data;
                 }
             }
             /* Other data */
             $this->skin['_cssGroupsArray'] = $ord;
             $this->skin['_skincacheid'] = is_dir(IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir) ? $_setId : $this->skin['set_id'];
             $this->skin['_csscacheid'] = $_cdir;
             $this->skin['set_css_inline'] = is_dir(IPS_PUBLIC_PATH . 'style_css/' . $_cdir) ? 1 : 0;
             if (is_file(IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir . '/_replacements.inc')) {
                 $replacements = array();
                 include_once IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir . '/_replacements.inc';
                 /*noLibHook*/
                 $this->skin['_replacements'] = $replacements;
             }
         }
         /* Is this a mobile skin? */
         if ($this->skin['set_key'] == 'mobile') {
             $this->setAsMobileSkin(true);
         }
         //-----------------------------------------
         // Which output engine?
         //-----------------------------------------
         if ($this->skin['set_output_format']) {
             if (file_exists(IPS_ROOT_PATH . 'sources/classes/output/formats/' . $this->skin['set_output_format'])) {
                 $_outputFormat = $this->skin['set_output_format'];
                 $_outputClassName = $this->skin['set_output_format'] . 'Output';
             }
         }
         require_once IPS_ROOT_PATH . 'sources/classes/output/formats/coreOutput.php';
         /*noLibHook*/
         $outputClassToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/output/formats/' . $_outputFormat . '/' . $_outputClassName . '.php', $_outputClassName);
         $this->outputFormatClass = new $outputClassToLoad($this);
         /* Build URLs */
         $this->_buildUrls();
         /* Special set up for mobile skin */
         if ($this->getAsMobileSkin() === true) {
             $this->_mobileSkinSetUp();
         }
     }
 }
コード例 #5
0
 /**
  * Constructor
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry)
 {
     /* Make object */
     parent::__construct($registry);
 }
コード例 #6
0
ファイル: hooks.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Hook add/edit save
  * Save the new (or updated) hook record
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 protected function _hookSave($type = 'add')
 {
     /* Init vars */
     $hookData = array();
     $newFiles = array();
     $requireApp = array();
     $_hookFiles = array();
     $extraKey = '';
     /* Get data if we are editing */
     if ($type == 'edit') {
         $id = intval($this->request['hook_id']);
         if (!$id) {
             $this->registry->output->showError($this->lang->words['h_noedit'], 1118);
         }
         $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id));
         if (!$hookData['hook_id']) {
             $this->registry->output->showError($this->lang->words['h_noedit'], 1119);
         }
         $extraKey = ' AND hook_id != ' . $hookData['hook_id'];
     }
     /* Error Checking */
     if (!$this->request['hook_name']) {
         $errors[] = $this->lang->words['hook_form_no_title'];
     }
     if (empty($this->request['hook_key'])) {
         $errors[] = $this->lang->words['hook_form_no_key'];
     } else {
         $keyCheck = $this->DB->buildAndFetch(array('select' => 'count(*) as found', 'from' => 'core_hooks', 'where' => "hook_key='" . $this->DB->addSlashes($this->request['hook_key']) . "'" . $extraKey));
         if ($keyCheck['found'] > 0) {
             $errors[] = $this->lang->words['hook_form_dupe_key'];
         }
     }
     /* Got any errors? */
     if (is_array($errors) && count($errors)) {
         $this->registry->output->global_error = implode('<br />', $errors);
         $this->_hookForm();
         return;
     }
     /* Not IN_DEV? */
     if (!IN_DEV) {
         $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . intval($this->request['hook_id'])));
         $this->DB->execute();
         while ($_r = $this->DB->fetch()) {
             $_hookFiles[$_r['hook_classname']] = $_r['hook_file_stored'];
         }
     }
     /* Check for requirements */
     if (is_array($this->request['requireApp']) and count($this->request['requireApp'])) {
         foreach ($this->request['requireApp'] as $_index => $app_key) {
             if ($app_key) {
                 $minVersion = intval($this->request['minVersion'][$_index]);
                 $maxVersion = intval($this->request['maxVersion'][$_index]);
                 $requireApp[$app_key] = array('app_name' => ipsRegistry::$applications[$app_key]['app_title'], 'min_version' => $minVersion, 'max_version' => $maxVersion);
             }
         }
     }
     /* Check for files */
     if (is_array($this->request['file']) and count($this->request['file'])) {
         foreach ($this->request['file'] as $index => $file) {
             if ($file) {
                 $newFiles[$index] = array('hook_file_real' => $file, 'hook_type' => $this->request['hook_type'][$index], 'hook_classname' => $this->request['hook_classname'][$index], 'hook_data' => serialize(array('dataLocation' => trim($this->request['dataLocation'][$index]), 'libApplication' => trim($this->request['libApplication'][$index]), 'classToOverload' => trim($this->request['classToOverload'][$index]), 'skinGroup' => $this->request['skinGroup'][$index], 'skinFunction' => $this->request['skinFunction'][$index], 'type' => $this->request['type'][$index], 'id' => $this->request['id'][$index], 'position' => $this->request['position'][$index])));
                 /**
                  * @link	http://community.invisionpower.com/tracker/issue-22084-hook-edit-does-not-preserve-correct-name/
                  * We don't want to reset the stored name if you are not in developer mode
                  */
                 if (IN_DEV) {
                     $newFiles[$index]['hook_file_stored'] = $file;
                     // During import this is a random name, but for devs it's actual file
                 } else {
                     $newFiles[$index]['hook_file_stored'] = $_hookFiles[$this->request['hook_classname'][$index]] ? $_hookFiles[$this->request['hook_classname'][$index]] : $file;
                 }
             }
         }
     }
     /* Get position */
     if ($type == 'add') {
         $position = $this->DB->buildAndFetch(array('select' => 'MAX(hook_position) as newPos', 'from' => 'core_hooks'));
         $position['newPos'] = intval($position['newPos']) + 1;
     } else {
         $position['newPos'] = $hookData['hook_position'];
     }
     $mainHookRecord = array('hook_name' => trim($this->request['hook_name']), 'hook_key' => substr(trim($this->request['hook_key']), 0, 32), 'hook_global_caches' => is_array($this->request['hook_global_caches']) && count($this->request['hook_global_caches']) ? implode(',', $this->request['hook_global_caches']) : '', 'hook_desc' => trim($this->request['hook_desc']), 'hook_version_human' => trim($this->request['hook_version_human']), 'hook_version_long' => trim($this->request['hook_version_long']), 'hook_author' => trim($this->request['hook_author']), 'hook_email' => trim($this->request['hook_email']), 'hook_website' => trim($this->request['hook_website']), 'hook_update_check' => trim($this->request['hook_update_check']), 'hook_enabled' => $type == 'add' ? 1 : $hookData['hook_enabled'], 'hook_installed' => $type == 'add' ? IPS_UNIX_TIME_NOW : $hookData['hook_installed'], 'hook_updated' => $type == 'add' ? 0 : IPS_UNIX_TIME_NOW, 'hook_position' => $position['newPos'], 'hook_requirements' => serialize(array('required_applications' => $requireApp, 'hook_php_version_min' => trim($this->request['hook_php_version_min']), 'hook_php_version_max' => trim($this->request['hook_php_version_max']))));
     if ($type == 'edit') {
         $this->DB->update('core_hooks', $mainHookRecord, 'hook_id=' . $hookData['hook_id']);
         $this->DB->delete('core_hooks_files', 'hook_hook_id=' . $hookData['hook_id']);
     } else {
         $this->DB->insert('core_hooks', $mainHookRecord);
         $hookData['hook_id'] = $this->DB->getInsertId();
     }
     foreach ($newFiles as $index => $toInsert) {
         $toInsert['hook_hook_id'] = $hookData['hook_id'];
         $this->DB->insert('core_hooks_files', $toInsert);
     }
     /* Rebuild cache */
     $this->rebuildHooksCache();
     /* Rebuild global caches */
     try {
         IPSLib::cacheGlobalCaches();
     } catch (Exception $e) {
     }
     /* Flag skins for recache */
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     $skinCaching = new skinCaching($this->registry);
     $skinCaching->flagSetForRecache();
     /* Redirect */
     $this->registry->output->setMessage($this->lang->words['h_saved']);
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&amp;do=hooks_overview');
 }
コード例 #7
0
 /**
  * Uninstall a hook
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _uninstallHook()
 {
     /* INI */
     $hook_id = intval($this->request['id']);
     $hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id));
     $extra_data = unserialize($hook['hook_extra_data']);
     /* Delete main hook entry */
     $this->DB->delete('core_hooks', "hook_id={$hook_id}");
     /* Get associated files */
     $this->DB->build(array('select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook_id));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         @unlink(IPS_HOOKS_PATH . $r['hook_file_stored']);
     }
     /* Delete hook file entries */
     $this->DB->delete('core_hooks_files', "hook_hook_id={$hook_id}");
     //-----------------------------------------
     // Settings or setting groups?
     //-----------------------------------------
     if (count($extra_data['settingGroups'])) {
         $this->DB->delete('core_sys_settings_titles', 'conf_title_id IN(' . implode(',', $extra_data['settingGroups']) . ')');
     }
     if (count($extra_data['settings'])) {
         $this->DB->delete('core_sys_conf_settings', 'conf_id IN(' . implode(',', $extra_data['settings']) . ')');
     }
     $this->cache->rebuildCache('settings', 'global');
     //-----------------------------------------
     // Language strings/files
     //-----------------------------------------
     if (count($extra_data['language'])) {
         foreach ($extra_data['language'] as $file => $bit) {
             $this->DB->delete('core_sys_lang_words', "word_pack='{$file}' AND word_key IN('" . implode("','", $bit) . "')");
         }
         $langPacks = array();
         $this->DB->build(array('select' => 'lang_id', 'from' => 'core_sys_lang'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $langPacks[] = $r['lang_id'];
         }
         require_once IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php';
         $langLib = new admin_core_languages_manage_languages($this->registry);
         $langLib->makeRegistryShortcuts($this->registry);
         foreach ($langPacks as $langId) {
             $langLib->cacheToDisk($langId);
         }
     }
     //-----------------------------------------
     // Modules
     //-----------------------------------------
     if (count($extra_data['modules'])) {
         $this->DB->delete('core_sys_module', 'sys_module_id IN(' . implode(',', $extra_data['modules']) . ')');
         $this->cache->rebuildCache('module_cache', 'global');
         $this->cache->rebuildCache('app_menu_cache', 'global');
     }
     //-----------------------------------------
     // Help files
     //-----------------------------------------
     if (count($extra_data['help'])) {
         $this->DB->delete('faq', 'id IN(' . implode(',', $extra_data['help']) . ')');
     }
     //-----------------------------------------
     // Skin templates
     //-----------------------------------------
     if (count($extra_data['templates'])) {
         foreach ($extra_data['templates'] as $file => $bit) {
             $this->DB->delete('skin_templates', "template_group='{$file}' AND template_name IN('" . implode("','", $bit) . "')");
         }
         require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
         require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
         $skinCaching = new skinCaching($this->registry);
         $skinCaching->rebuildPHPTemplates(0);
     }
     //-----------------------------------------
     // Tasks
     //-----------------------------------------
     if (count($extra_data['tasks'])) {
         $this->DB->delete('task_manager', 'task_id IN(' . implode(',', $extra_data['tasks']) . ')');
     }
     //-----------------------------------------
     // Database changes
     //-----------------------------------------
     if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) {
         foreach ($extra_data['database']['create'] as $create_query) {
             $this->DB->return_die = true;
             $this->DB->dropTable($create_query['name']);
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) {
         foreach ($extra_data['database']['alter'] as $alter_query) {
             $this->DB->return_die = true;
             if ($alter_query['altertype'] == 'add') {
                 if ($this->DB->checkForField($alter_query['field'], $alter_query['table'])) {
                     $this->DB->dropField($alter_query['table'], $alter_query['field']);
                 }
             } else {
                 if ($alter_query['altertype'] == 'change') {
                     if ($this->DB->checkForField($alter_query['newfield'], $alter_query['table'])) {
                         $this->DB->changeField($alter_query['table'], $alter_query['newfield'], $alter_query['field'], $alter_query['fieldtype'], $alter_query['default']);
                     }
                 }
             }
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) {
         foreach ($extra_data['database']['update'] as $update_query) {
             $this->DB->return_die = true;
             $this->DB->update($update_query['table'], array($update_query['field'] => $update_query['oldvalue']), $update_query['where']);
             $this->DB->return_die = false;
         }
     }
     if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) {
         foreach ($extra_data['database']['insert'] as $insert_query) {
             if ($insert_query['fordelete']) {
                 $this->DB->return_die = true;
                 $this->DB->delete($insert_query['table'], $insert_query['fordelete']);
                 $this->DB->return_die = false;
             }
         }
     }
     //-----------------------------------------
     // Custom install/uninstall script?
     //-----------------------------------------
     if ($extra_data['custom']) {
         if (file_exists(IPS_HOOKS_PATH . $extra_data['custom'])) {
             require_once IPS_HOOKS_PATH . $extra_data['custom'];
             $classname = str_replace('.php', '', $extra_data['custom']);
             if (class_exists($classname)) {
                 $uninstall = new $classname($this->registry);
                 if (method_exists($uninstall, 'uninstall')) {
                     $uninstall->uninstall();
                 }
             }
             @unlink(IPS_HOOKS_PATH . $extra_data['custom']);
         }
     }
     $this->rebuildHooksCache();
     /* Done */
     $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&amp;do=hooks_overview');
 }
コード例 #8
0
ファイル: ipscdn.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Edit Settings
  */
 public function editSettings()
 {
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     $skinFunctions = new skinCaching(ipsRegistry::instance());
     if (ipsRegistry::$request['recache']) {
         $skinFunctions->flushipscdn();
         ipsRegistry::getClass('output')->redirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements&amp;do=edit&amp;service=enhancements_core_ipscdn", ipsRegistry::getClass('class_localization')->words['cdn_recached']);
     }
     if (ipsRegistry::$request['disable']) {
         IPSLib::updateSettings(array('ips_cdn' => FALSE, 'ipb_img_url' => '', 'ipb_css_url' => '', 'ipb_js_url' => '', 'upload_url' => ''));
         if (IPSLib::appIsInstalled('gallery')) {
             $this_script = str_replace('\\', '/', getenv('SCRIPT_FILENAME'));
             $url = ipsRegistry::$settings['_original_base_url'];
             if ($this_script) {
                 $this_script = str_replace('/' . CP_DIRECTORY . '/index.php', '', $this_script);
                 if (substr(ipsRegistry::$settings['gallery_images_path'], 0, strlen($this_script)) === $this_script) {
                     $url = str_replace('\\', '/', str_replace($this_script, $url, ipsRegistry::$settings['gallery_images_path']));
                 }
             } else {
                 $url .= '/uploads';
             }
             IPSLib::updateSettings(array('gallery_images_path' => $url));
         }
         IPSContentCache::truncate('post');
         IPSContentCache::truncate('sig');
         /* Set skin sets to recache */
         $skinFunctions->flagSetForRecache();
         ipsRegistry::getClass('output')->redirect(ipsRegistry::$settings['_base_url'] . "app=core&amp;module=applications&amp;section=enhancements", ipsRegistry::getClass('class_localization')->words['cdn_disabled']);
         return;
     }
     if (!ipsRegistry::$settings['ipb_reg_number']) {
         ipsRegistry::getClass('output')->showError(sprintf(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_nokey'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools&section=licensekey', 'admin')));
     }
     $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement');
     $file = new $classToLoad();
     $return = NULL;
     if ($json = @json_decode($ping, TRUE)) {
         if ($json['ENABLED'] and $json['BYTES'] > 0) {
             if (!ipsRegistry::$settings['ips_cdn'] and !ipsRegistry::$request['enable']) {
                 return $this->html->cdnInactive($json);
             } else {
                 $settings = array('ips_cdn' => TRUE, 'ipb_img_url' => $json['URL'], 'ipb_css_url' => rtrim($json['URL'], '/') . '/', 'ipb_js_url' => rtrim($json['URL'], '/') . '/', 'upload_url' => $json['URL'] . '/uploads');
                 if (IPSLib::appIsInstalled('downloads')) {
                     if (substr(ipsRegistry::$settings['idm_localsspath'], 0, 11) === '{root_path}') {
                         $settings['idm_screenshot_url'] = str_replace('{root_path}', $json['URL'], ipsRegistry::$settings['idm_localsspath']);
                     }
                 }
                 if (IPSLib::appIsInstalled('gallery')) {
                     $this_script = str_replace('\\', '/', getenv('SCRIPT_FILENAME'));
                     if ($this_script) {
                         $this_script = str_replace('/' . CP_DIRECTORY . '/index.php', '', $this_script);
                         if (substr(ipsRegistry::$settings['gallery_images_path'], 0, strlen($this_script)) === $this_script) {
                             $settings['gallery_images_url'] = str_replace('\\', '/', str_replace($this_script, $json['URL'], ipsRegistry::$settings['gallery_images_path']));
                         }
                     }
                 }
                 $_settings = array();
                 foreach ($settings as $k => $v) {
                     if (ipsRegistry::$settings[$k] != $v) {
                         $_settings[$k] = $v;
                     }
                 }
                 if (!empty($_settings)) {
                     IPSLib::updateSettings($settings);
                 }
                 /* Set skin sets to recache */
                 $skinFunctions->flagSetForRecache();
             }
         } else {
             $licenseData = ipsRegistry::cache()->getCache('licenseData');
             if ($licenseData['key']['url'] != ipsRegistry::$settings['board_url']) {
                 ipsRegistry::getClass('output')->showError(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_url']);
             }
             /* Set skin sets to recache */
             $skinFunctions->flagSetForRecache();
             return $this->html->cdnNotEnabled($json);
         }
     } else {
         ipsRegistry::getClass('output')->showError(sprintf(ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_key'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools&section=licensekey', 'admin')));
     }
     return $this->html->cdnOverview($json);
 }