/** * Uninstall an addon. * * @param string Name of the addon */ function uninstall_addon($name) { $addon_row = read_addon_info($name); require_code('zones2'); require_code('zones3'); require_code('abstract_file_manager'); // Clear some cacheing require_code('view_modes'); require_code('zones2'); require_code('zones3'); erase_comcode_page_cache(); erase_tempcode_cache(); persistant_cache_empty(); erase_cached_templates(); erase_cached_language(); global $HOOKS_CACHE; $HOOKS_CACHE = array(); // Remove addon info from database, modules, blocks, and files $last = array(); foreach ($addon_row['addon_files'] as $filename) { if (@file_exists(get_file_base() . '/' . $filename)) { $test = $GLOBALS['SITE_DB']->query_value('addons_files', 'COUNT(*)', array('filename' => $filename)); if ($test <= 1) { if (substr($filename, 0, 37) == 'sources/hooks/systems/addon_registry/') { $last[] = $filename; continue; } $matches = array(); if (preg_match('#([^/]*)/?pages/modules(_custom)?/(.*)\\.php#', $filename, $matches) != 0) { uninstall_module($matches[1], $matches[3]); } if (preg_match('#sources(_custom)?/blocks/(.*)\\.php#', $filename, $matches) != 0) { uninstall_block($matches[2]); } if (preg_match('#^([^/]*)/index.php#', $filename, $matches) != 0) { actual_delete_zone_lite($matches[1]); } if ($filename != 'mod.inf' && $filename != 'mod.php' && $filename != '' && substr($filename, -1) != '/') { $last[] = $filename; } } } } foreach ($last as $filename) { afm_delete_file($filename); } $GLOBALS['SITE_DB']->query_delete('addons_files', array('addon_name' => $addon_row['addon_name'])); $GLOBALS['SITE_DB']->query_delete('addons_dependencies', array('addon_name' => $addon_row['addon_name'])); $GLOBALS['SITE_DB']->query_delete('addons', array('addon_name' => $addon_row['addon_name']), '', 1); global $ADDON_INSTALLED_CACHE; unset($ADDON_INSTALLED_CACHE[$addon_row['addon_name']]); if (function_exists('persistent_cache_set')) { persistent_cache_set('ADDONS_INSTALLED', $ADDON_INSTALLED_CACHE, true); } log_it('UNINSTALL_ADDON', $addon_row['addon_name']); }
/** * Version specific upgrading. These are things that are relatively major structural changes and therefore will get done outside the module upgrade system. * * @return boolean Whether anything was done */ function version_specific() { // Version specific (rather than component specific) upgrading $version_files = ocp_version_number(); $_version_database = get_value('version'); $version_database = floatval($_version_database); if (is_null($_version_database)) { $version_database = 2.1; } // Either 2.0 or 2.1, and they are equivalent in terms of what we need to do if ($version_database < $version_files) { if ($version_database < 2.5) { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'chat_messages'); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'galleries'), array('module_the_name' => 'images')); $GLOBALS['SITE_DB']->query_update('group_page_access', array('page_name' => 'galleries'), array('page_name' => 'images')); $GLOBALS['SITE_DB']->alter_table_field('zones', 'zone_wide', '?BINARY'); $GLOBALS['SITE_DB']->alter_table_field('theme_images', 'id', 'SHORT_TEXT'); $GLOBALS['SITE_DB']->refresh_field_definition('URLPATH'); $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'translate TYPE=MYISAM'); // Just in case it's not $GLOBALS['SITE_DB']->create_index('translate', '#search', array('text_original')); $trans4 = insert_lang(do_lang('A_SITE_ABOUT', '???'), 1); $trans8 = insert_lang(do_lang('GUIDES'), 1); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'membersonly', 'zone_default_page' => 'start', 'zone_header_text' => $trans4, 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 0)); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_default_page' => 'userguide', 'zone_header_text' => $trans8, 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 0)); } if ($version_database < 3.0) { fu_rename_zone('membersonly', 'site'); fu_rename_zone('admincentre', 'adminzone'); if (file_exists(get_file_base() . '/collaboration')) { fu_rename_zone('supermembercentre', 'collaboration'); } fu_rename_zone('membercentre', 'site', true); // Merged into 'site' (formerly membersonly) actual_delete_zone_lite('seedy'); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'cms', 'zone_title' => insert_lang(do_lang('CMS'), 1), 'zone_default_page' => 'cms', 'zone_header_text' => insert_lang(do_lang('CMS'), 1), 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 1)); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'admin_cleanup'), array('module_the_name' => 'admin_caches')); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'seedy_page'), array('module_the_name' => 'cedi')); $GLOBALS['SITE_DB']->query_update('attachment_refs', array('r_referer_type' => 'cedi_page'), array('r_referer_type' => 'seedy_page')); $GLOBALS['SITE_DB']->query_update('attachment_refs', array('r_referer_type' => 'cedi_post'), array('r_referer_type' => 'seedy_post')); $modules_gone = array('seedy_move', 'seedy_changes', 'seedy_edit_page', 'seedy_manage_tree', 'seedy_move', 'seedy_post', 'seedy_show_tree', 'seedy_merge', 'admin_seedy', 'admin_pages', 'admin_ftp_downloads', 'admin_timezone', 'admin_modules', 'admin_ocf_moderator_logs', 'admin_submitban'); foreach ($modules_gone as $module) { $GLOBALS['SITE_DB']->query_delete('modules', array('module_the_name' => $module), '', 1); } $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'galleries'), array('module_the_name' => 'images'), '', 1); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'admin_sitetree'), array('module_the_name' => 'admin_comcode_pages'), '', 1); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'admin_addons'), array('module_the_name' => 'admin_mods'), '', 1); $GLOBALS['SITE_DB']->query_update('modules', array('module_the_name' => 'admin_awards'), array('module_the_name' => 'admin_dotws'), '', 1); } if ($version_database < 4.0) { $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'translate CHANGE id id INT(10) UNSIGNED AUTO_INCREMENT'); } if ($version_database < 5.1) { // Installaton code got moved over $sitetree_version = $GLOBALS['SITE_DB']->query_value('modules', 'module_version', array('module_the_name' => 'admin_sitetree')); $GLOBALS['SITE_DB']->query_update('modules', array('module_version' => $sitetree_version), array('module_the_name' => 'cms_comcode_pages'), '', 1); } if ($version_database < 8.0) { actual_delete_zone_lite('personalzone'); } set_value('version', float_to_raw_string($version_files)); return true; } return false; }
/** * Delete a zone. * * @param ID_TEXT The name of the zone */ function actual_delete_zone($zone) { if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } require_code('abstract_file_manager'); force_have_afm_details(); if (function_exists('set_time_limit')) { @set_time_limit(0); } disable_php_memory_limit(); $pages = find_all_pages_wrap($zone, false, false, FIND_ALL_PAGES__ALL); $bad = array(); foreach (array_keys($pages) as $page) { if (substr($page, 0, 6) != 'panel_' && $page != 'start') { $bad[] = $page; } } if ($bad != array()) { require_lang('zones'); warn_exit(do_lang_tempcode('DELETE_ZONE_ERROR', '<kbd>' . implode('</kbd>, <kbd>', $bad) . '</kbd>')); } actual_delete_zone_lite($zone); if (file_exists(get_custom_file_base() . '/' . filter_naughty($zone))) { afm_delete_directory(filter_naughty($zone), true); } }