/** * And let's see what happens when removing them */ function testRemoveHooks() { foreach ($this->_tests as $test) { remove_integration_function($this->_hook_name, $test['call'], $test['file']); $this->assertFalse($this->_hook_exists($test, $test['perm'])); } }
public function removeIntegration($forumDirectoryPath) { try { $smfSSI = DRUPAL_ROOT . '/' . $forumDirectoryPath . '/SSI.php'; if (file_exists($smfSSI)) { require_once $smfSSI; remove_integration_function('integrate_pre_include', DRUPAL_ROOT . '/' . drupal_get_path('module', 'smfbridge') . '/src/Smf/Hooks.php'); remove_integration_function('integrate_actions', 'Drupal\\smfbridge\\Smf\\Hooks::actions'); remove_integration_function('integrate_menu_buttons', 'Drupal\\smfbridge\\Smf\\Hooks::smfMenuButtons'); //Using SMF native functions global $smcFunc; $smcFunc['db_query']('', 'DELETE FROM {db_prefix}settings WHERE variable = {string:variable}', ['variable' => 'drupalHomeLinkButton']); } else { throw new \Exception(t('Can\'t find forum/SSI.php. Please, place SMF sources into DRUPAL_ROOT/forum folder.')); } } catch (\Exception $e) { $errorMsg = t('Error while disabling smfbridge. @message', ['@message' => $e->getMessage()]); \Drupal::logger('smfbridge')->error($errorMsg); drupal_set_message($errorMsg, 'error'); } }
// Other $hooks[] = array('hook' => 'integrate_convert_msgbody', 'function' => 'shd_convert_msgbody'); $hooks[] = array('hook' => 'integrate_modifylanguages', 'function' => 'shd_modifylanguages'); // Display $hooks[] = array('hook' => 'integrate_display_buttons', 'function' => 'shd_display_btn_mvtopic'); $hooks[] = array('hook' => 'integrate_download_request', 'function' => 'shd_download_request', 'file' => '$sourcedir/sd_source/Subs-SimpleDeskDisplay.php'); // BoardIndex $hooks[] = array('hook' => 'integrate_getboardtree', 'function' => 'shd_add_to_boardindex', 'file' => '$sourcedir/sd_source/Subs-SimpleDeskBoardIndex.php'); // Profile $hooks[] = array('hook' => 'integrate_pre_profile_areas', 'function' => 'shd_profile_areas', 'file' => '$sourcedir/sd_source/Subs-SimpleDeskProfile.php'); $hooks[] = array('hook' => 'integrate_profile_profileSaveGroups', 'function' => 'shd_clear_active_tickets'); $hooks[] = array('hook' => 'integrate_profile_trackip', 'function' => 'shd_profile_trackip'); // Other $hooks[] = array('hook' => 'integrate_SSI', 'function' => false, 'file' => '$sourcedir/sd_source/SimpleDesk-SSI.php'); foreach ($hooks as $hook) { remove_integration_function($hook['hook'], $hook['function']); } // 3. Removing the scheduled task. $smcFunc['db_query']('', ' DELETE FROM {db_prefix}scheduled_tasks WHERE task = {string:simpledesk}', array('simpledesk' => 'simpledesk')); // 4. Forcing all SD plugin hooks to be disabled. $shd_hooks = array('shd_enabled_plugins'); foreach ($modSettings as $k => $v) { if (strpos($k, 'shd_hook') === 0 || strpos($k, 'shd_include') === 0) { $shd_hooks[] = $k; } } $new_hooks = array(); foreach ($shd_hooks as $hook) { $new_hooks[$hook] = '';
/** * Apply another type of (avatar, language, etc.) package. */ public function action_install2() { global $txt, $context, $boardurl, $scripturl, $modSettings; // Make sure we don't install this mod twice. checkSubmitOnce('check'); checkSession(); // If there's no file, what are we installing? if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { redirectexit('action=admin;area=packages'); } $context['filename'] = $_REQUEST['package']; // If this is an uninstall, we'll have an id. $context['install_id'] = isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : 0; require_once SUBSDIR . '/Package.subs.php'; require_once SUBSDIR . '/Themes.subs.php'; // @todo Perhaps do it in steps, if necessary? $context['uninstalling'] = $_REQUEST['sa'] == 'uninstall2'; // Set up the linktree for other. $context['linktree'][count($context['linktree']) - 1] = array('url' => $scripturl . '?action=admin;area=packages;sa=browse', 'name' => $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['page_title'] .= ' - ' . ($context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['sub_template'] = 'extract_package'; if (!file_exists(BOARDDIR . '/packages/' . $context['filename'])) { fatal_lang_error('package_no_file', false); } // Load up the package FTP information? create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); // Make sure temp directory exists and is empty! if (file_exists(BOARDDIR . '/packages/temp')) { deltree(BOARDDIR . '/packages/temp', false); } else { mktree(BOARDDIR . '/packages/temp', 0777); } // Let the unpacker do the work. if (is_file(BOARDDIR . '/packages/' . $context['filename'])) { $context['extracted_files'] = read_tgz_file(BOARDDIR . '/packages/' . $context['filename'], BOARDDIR . '/packages/temp'); if (!file_exists(BOARDDIR . '/packages/temp/package-info.xml')) { foreach ($context['extracted_files'] as $file) { if (basename($file['filename']) == 'package-info.xml') { $context['base_path'] = dirname($file['filename']) . '/'; break; } } } if (!isset($context['base_path'])) { $context['base_path'] = ''; } } elseif (is_dir(BOARDDIR . '/packages/' . $context['filename'])) { copytree(BOARDDIR . '/packages/' . $context['filename'], BOARDDIR . '/packages/temp'); $context['extracted_files'] = listtree(BOARDDIR . '/packages/temp'); $context['base_path'] = ''; } else { fatal_lang_error('no_access', false); } // Are we installing this into any custom themes? $custom_themes = array(1); $known_themes = explode(',', $modSettings['knownThemes']); if (!empty($_POST['custom_theme'])) { foreach ($_POST['custom_theme'] as $tid) { if (in_array($tid, $known_themes)) { $custom_themes[] = (int) $tid; } } } // Now load up the paths of the themes that we need to know about. $theme_paths = getThemesPathbyID($custom_themes); $themes_installed = array(1); // Are there any theme copying that we want to take place? $context['theme_copies'] = array('require-file' => array(), 'require-dir' => array()); if (!empty($_POST['theme_changes'])) { foreach ($_POST['theme_changes'] as $change) { if (empty($change)) { continue; } $theme_data = unserialize(base64_decode($change)); if (empty($theme_data['type'])) { continue; } $themes_installed[] = $theme_data['id']; $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; } } // Get the package info... $packageInfo = getPackageInfo($context['filename']); if (!is_array($packageInfo)) { fatal_lang_error($packageInfo); } $packageInfo['filename'] = $context['filename']; // Set the type of extraction... $context['extract_type'] = isset($packageInfo['type']) ? $packageInfo['type'] : 'modification'; // Create a backup file to roll back to! (but if they do this more than once, don't run it a zillion times.) if (!empty($modSettings['package_make_full_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['filename'] . ($context['uninstalling'] ? '$$' : '$'))) { $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); // @todo Internationalize this? package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); } // The mod isn't installed.... unless proven otherwise. $context['is_installed'] = false; // Is it actually installed? $package_installed = isPackageInstalled($packageInfo['id']); // Wait, it's not installed yet! // @todo Replace with a better error message! if (!isset($package_installed['old_version']) && $context['uninstalling']) { deltree(BOARDDIR . '/packages/temp'); fatal_error('Hacker?', false); } elseif ($context['uninstalling']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); // Gadzooks! There's no uninstaller at all!? if (empty($install_log)) { fatal_lang_error('package_uninstall_cannot', false); } // They can only uninstall from what it was originally installed into. foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $package_installed['old_themes'])) { unset($theme_paths[$id]); } } } elseif (isset($package_installed['old_version']) && $package_installed['old_version'] != $packageInfo['version']) { // Look for an upgrade... $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $package_installed['old_version']); // There was no upgrade.... if (empty($install_log)) { $context['is_installed'] = true; } else { // Upgrade previous themes only! foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $package_installed['old_themes'])) { unset($theme_paths[$id]); } } } } elseif (isset($package_installed['old_version']) && $package_installed['old_version'] == $packageInfo['version']) { $context['is_installed'] = true; } if (!isset($package_installed['old_version']) || $context['is_installed']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); } $context['install_finished'] = false; // We're gonna be needing the table db functions! ...Sometimes. $table_installer = db_table(); // @todo Make a log of any errors that occurred and output them? if (!empty($install_log)) { $failed_steps = array(); $failed_count = 0; foreach ($install_log as $action) { $failed_count++; if ($action['type'] == 'modification' && !empty($action['filename'])) { if ($action['boardmod']) { $mod_actions = parseBoardMod(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } else { $mod_actions = parseModification(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } // Any errors worth noting? foreach ($mod_actions as $key => $action) { if ($action['type'] == 'failure') { $failed_steps[] = array('file' => $action['filename'], 'large_step' => $failed_count, 'sub_step' => $key, 'theme' => 1); } // Gather the themes we installed into. if (!empty($action['is_custom'])) { $themes_installed[] = $action['is_custom']; } } } elseif ($action['type'] == 'code' && !empty($action['filename'])) { // This is just here as reference for what is available. global $txt, $modSettings, $context; // Now include the file and be done with it ;). if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) { require BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'credits') { // Time to build the billboard $credits_tag = array('url' => $action['url'], 'license' => $action['license'], 'copyright' => $action['copyright'], 'title' => $action['title']); } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) { if ($action['reverse']) { remove_integration_function($action['hook'], $action['function'], $action['include_file']); } else { add_integration_function($action['hook'], $action['function'], $action['include_file']); } } elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) { // These can also be there for database changes. global $txt, $modSettings, $context; // Let the file work its magic ;) if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) { require BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) { $context['redirect_url'] = $action['redirect_url']; $context['redirect_text'] = !empty($action['filename']) && file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']) ? file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']); $context['redirect_timeout'] = $action['redirect_timeout']; // Parse out a couple of common urls. $urls = array('$boardurl' => $boardurl, '$scripturl' => $scripturl, '$session_var' => $context['session_var'], '$session_id' => $context['session_id']); $context['redirect_url'] = strtr($context['redirect_url'], $urls); } } package_flush_cache(); // First, ensure this change doesn't get removed by putting a stake in the ground (So to speak). package_put_contents(BOARDDIR . '/packages/installed.list', time()); // See if this is already installed $is_upgrade = false; $old_db_changes = array(); $package_check = isPackageInstalled($packageInfo['id']); // Change the installed state as required. if (!empty($package_check['install_state'])) { if ($context['uninstalling']) { setPackageState($package_check['package_id']); } else { // not uninstalling so must be an upgrade $is_upgrade = true; $old_db_changes = empty($package_check['db_changes']) ? array() : $package_check['db_changes']; } } // Assuming we're not uninstalling, add the entry. if (!$context['uninstalling']) { // Any db changes from older version? $table_log = $table_installer->package_log(); if (!empty($old_db_changes)) { $db_package_log = empty($table_log) ? $old_db_changes : array_merge($old_db_changes, $table_log); } else { $db_package_log = $table_log; } // If there are some database changes we might want to remove then filter them out. if (!empty($db_package_log)) { // We're really just checking for entries which are create table AND add columns (etc). $tables = array(); usort($db_package_log, array($this, '_sort_table_first')); foreach ($db_package_log as $k => $log) { if ($log[0] == 'remove_table') { $tables[] = $log[1]; } elseif (in_array($log[1], $tables)) { unset($db_package_log[$k]); } } $package_installed['db_changes'] = serialize($db_package_log); } else { $package_installed['db_changes'] = ''; } // What themes did we actually install? $themes_installed = array_unique($themes_installed); $themes_installed = implode(',', $themes_installed); // What failed steps? $failed_step_insert = serialize($failed_steps); // Credits tag? $credits_tag = empty($credits_tag) ? '' : serialize($credits_tag); // Add to the log packages addPackageLog($packageInfo, $failed_step_insert, $themes_installed, $package_installed['db_changes'], $is_upgrade, $credits_tag); } $context['install_finished'] = true; } // If there's database changes - and they want them removed - let's do it last! if (!empty($package_installed['db_changes']) && !empty($_POST['do_db_changes'])) { foreach ($package_installed['db_changes'] as $change) { if ($change[0] == 'remove_table' && isset($change[1])) { $table_installer->db_drop_table($change[1]); } elseif ($change[0] == 'remove_column' && isset($change[2])) { $table_installer->db_remove_column($change[1], $change[2]); } elseif ($change[0] == 'remove_index' && isset($change[2])) { $table_installer->db_remove_index($change[1], $change[2]); } } } // Clean house... get rid of the evidence ;). if (file_exists(BOARDDIR . '/packages/temp')) { deltree(BOARDDIR . '/packages/temp'); } // Log what we just did. logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => Util::htmlspecialchars($packageInfo['name']), 'version' => Util::htmlspecialchars($packageInfo['version'])), 'admin'); // Just in case, let's clear the whole cache to avoid anything going up the swanny. clean_cache(); // Restore file permissions? create_chmod_control(array(), array(), true); }
function list_integration_hooks() { global $sourcedir, $scripturl, $context, $txt, $modSettings, $settings; $context['filter'] = ''; $currentHooks = get_integration_hooks(); if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($currentHooks))) { $context['filter'] = ';filter=' . $_GET['filter']; } if (!empty($modSettings['handlinghooks_enabled'])) { if (!empty($_REQUEST['do']) && isset($_REQUEST['hook']) && isset($_REQUEST['function'])) { checkSession('request'); validateToken('admin-hook', 'request'); if ($_REQUEST['do'] == 'remove') { remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); } else { if ($_REQUEST['do'] == 'disable') { // It's a hack I know...but I'm way too lazy!!! $function_remove = $_REQUEST['function']; $function_add = $_REQUEST['function'] . ']'; } else { $function_remove = $_REQUEST['function'] . ']'; $function_add = $_REQUEST['function']; } $file = !empty($_REQUEST['includedfile']) ? urldecode($_REQUEST['includedfile']) : ''; remove_integration_function($_REQUEST['hook'], $function_remove, $file); add_integration_function($_REQUEST['hook'], $function_add, $file); redirectexit('action=admin;area=modsettings;sa=hooks' . $context['filter']); } } } $list_options = array('id' => 'list_integration_hooks', 'title' => $txt['hooks_title_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'hook_name', 'get_items' => array('function' => 'get_integration_hooks_data'), 'get_count' => array('function' => 'get_integration_hooks_count'), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('hook_name' => array('header' => array('value' => $txt['hooks_field_hook_name']), 'data' => array('db' => 'hook_name'), 'sort' => array('default' => 'hook_name', 'reverse' => 'hook_name DESC')), 'function_name' => array('header' => array('value' => $txt['hooks_field_function_name']), 'data' => array('function' => create_function('$data', ' global $txt; if (!empty($data[\'included_file\'])) return $txt[\'hooks_field_function\'] . \': \' . $data[\'real_function\'] . \'<br />\' . $txt[\'hooks_field_included_file\'] . \': \' . $data[\'included_file\']; else return $data[\'real_function\']; ')), 'sort' => array('default' => 'function_name', 'reverse' => 'function_name DESC')), 'file_name' => array('header' => array('value' => $txt['hooks_field_file_name']), 'data' => array('db' => 'file_name'), 'sort' => array('default' => 'file_name', 'reverse' => 'file_name DESC')), 'status' => array('header' => array('value' => $txt['hooks_field_hook_exists'], 'style' => 'width:3%'), 'data' => array('function' => create_function('$data', ' global $txt, $settings, $scripturl, $context; $change_status = array(\'before\' => \'\', \'after\' => \'\'); if ($data[\'can_be_disabled\'] && $data[\'status\'] != \'deny\') { $change_status[\'before\'] = \'<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=\' . ($data[\'enabled\'] ? \'disable\' : \'enable\') . \';hook=\' . $data[\'hook_name\'] . \';function=\' . $data[\'real_function\'] . (!empty($data[\'included_file\']) ? \';includedfile=\' . urlencode($data[\'included_file\']) : \'\') . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">\'; $change_status[\'after\'] = \'</a>\'; } return $change_status[\'before\'] . \'<img src="\' . $settings[\'images_url\'] . \'/admin/post_moderation_\' . $data[\'status\'] . \'.png" alt="\' . $data[\'img_text\'] . \'" title="\' . $data[\'img_text\'] . \'" />\' . $change_status[\'after\']; '), 'class' => 'centertext'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC'))), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['hooks_disable_instructions'] . '<br /> ' . $txt['hooks_disable_legend'] . ': <ul style="list-style: none;"> <li><img src="' . $settings['images_url'] . '/admin/post_moderation_allow.png" alt="' . $txt['hooks_active'] . '" title="' . $txt['hooks_active'] . '" /> ' . $txt['hooks_disable_legend_exists'] . '</li> <li><img src="' . $settings['images_url'] . '/admin/post_moderation_moderate.png" alt="' . $txt['hooks_disabled'] . '" title="' . $txt['hooks_disabled'] . '" /> ' . $txt['hooks_disable_legend_disabled'] . '</li> <li><img src="' . $settings['images_url'] . '/admin/post_moderation_deny.png" alt="' . $txt['hooks_missing'] . '" title="' . $txt['hooks_missing'] . '" /> ' . $txt['hooks_disable_legend_missing'] . '</li> </ul>'))); if (!empty($modSettings['handlinghooks_enabled'])) { createToken('admin-hook', 'request'); $list_options['columns']['remove'] = array('header' => array('value' => $txt['hooks_button_remove'], 'style' => 'width:3%'), 'data' => array('function' => create_function('$data', ' global $txt, $settings, $scripturl, $context; if (!$data[\'hook_exists\']) return \' <a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=remove;hook=\' . $data[\'hook_name\'] . \';function=\' . urlencode($data[\'function_name\']) . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');"> <img src="\' . $settings[\'images_url\'] . \'/icons/quick_remove.png" alt="\' . $txt[\'hooks_button_remove\'] . \'" title="\' . $txt[\'hooks_button_remove\'] . \'" /> </a>\'; '), 'class' => 'centertext')); $list_options['form'] = array('href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => 'list_integration_hooks'); } require_once $sourcedir . '/Subs-List.php'; createList($list_options); $context['page_title'] = $txt['hooks_title_list']; $context['sub_template'] = 'show_list'; $context['default_list'] = 'list_integration_hooks'; }
<?php remove_integration_function('integrate_pre_include', '$sourcedir/PostHistory.php'); remove_integration_function('integrate_actions', 'PH_actions'); remove_integration_function('integrate_core_features', 'PH_core_features'); remove_integration_function('integrate_load_permissions', 'PH_load_permissions'); ?>
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is http://www.sa-mods.info * * The Initial Developer of the Original Code is * wayne Mankertz. * Portions created by the Initial Developer are Copyright (C) 2011 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ if (!defined('SMF')) { require '../SSI.php'; } $twitterHooks = array('integrate_pre_include' => '$boarddir/Sources/Twitter/TwitterHooks.php', 'integrate_load_theme' => 'twitter_loadTheme', 'integrate_admin_areas' => 'twitter_admin_areas', 'integrate_buffer' => 'ob_twitter', 'integrate_profile_areas' => 'twitter_profile_areas', 'integrate_actions' => 'twitter_actions', 'integrate_login' => 'twit_integrate_login', 'integrate_create_topic' => 'twit_post_topic', 'integrate_register' => 'twit_Post_members'); foreach ($twitterHooks as $hook => $function) { remove_integration_function($hook, $function); }
<?php if (!defined('SMF') && file_exists(dirname(__FILE__) . '/SSI.php')) { require_once dirname(__FILE__) . '/SSI.php'; } elseif (!defined('SMF')) { die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.'); } remove_integration_function('integrate_pre_include', '$sourcedir/Subs-iflychat.php'); remove_integration_function('integrate_actions', 'iflychat_add_hook'); remove_integration_function('integrate_buffer', 'iflychat_template_init'); remove_integration_function('inetgrate_load_permissions', 'iflychat_load_permissions');
<?php //Last modified: 2012/04/16 if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { $ssi = true; require_once dirname(__FILE__) . '/SSI.php'; } elseif (!defined('SMF')) { exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.'); } remove_integration_function('integrate_pre_include', '$sourcedir/cls.php'); remove_integration_function('integrate_modify_modifications', 'cls_int_modify_modifications'); remove_integration_function('integrate_admin_areas', 'cls_int_admin_area'); if (!empty($ssi)) { echo 'Database installation complete!'; }
/** * Apply another type of (avatar, language, etc.) package. */ function PackageInstall() { global $boarddir, $txt, $context, $boardurl, $scripturl, $sourcedir, $modSettings; global $user_info, $smcFunc; // Make sure we don't install this mod twice. checkSubmitOnce('check'); checkSession(); // If there's no file, what are we installing? if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { redirectexit('action=admin;area=packages'); } $context['filename'] = $_REQUEST['package']; // If this is an uninstall, we'll have an id. $context['install_id'] = isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : 0; require_once $sourcedir . '/Subs-Package.php'; // @todo Perhaps do it in steps, if necessary? $context['uninstalling'] = $_REQUEST['sa'] == 'uninstall2'; // Set up the linktree for other. $context['linktree'][count($context['linktree']) - 1] = array('url' => $scripturl . '?action=admin;area=packages;sa=browse', 'name' => $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['page_title'] .= ' - ' . ($context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['sub_template'] = 'extract_package'; if (!file_exists($boarddir . '/Packages/' . $context['filename'])) { fatal_lang_error('package_no_file', false); } // Load up the package FTP information? create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); // Make sure temp directory exists and is empty! if (file_exists($boarddir . '/Packages/temp')) { deltree($boarddir . '/Packages/temp', false); } else { mktree($boarddir . '/Packages/temp', 0777); } // Let the unpacker do the work. if (is_file($boarddir . '/Packages/' . $context['filename'])) { $context['extracted_files'] = read_tgz_file($boarddir . '/Packages/' . $context['filename'], $boarddir . '/Packages/temp'); if (!file_exists($boarddir . '/Packages/temp/package-info.xml')) { foreach ($context['extracted_files'] as $file) { if (basename($file['filename']) == 'package-info.xml') { $context['base_path'] = dirname($file['filename']) . '/'; break; } } } if (!isset($context['base_path'])) { $context['base_path'] = ''; } } elseif (is_dir($boarddir . '/Packages/' . $context['filename'])) { copytree($boarddir . '/Packages/' . $context['filename'], $boarddir . '/Packages/temp'); $context['extracted_files'] = listtree($boarddir . '/Packages/temp'); $context['base_path'] = ''; } else { fatal_lang_error('no_access', false); } // Are we installing this into any custom themes? $custom_themes = array(1); $known_themes = explode(',', $modSettings['knownThemes']); if (!empty($_POST['custom_theme'])) { foreach ($_POST['custom_theme'] as $tid) { if (in_array($tid, $known_themes)) { $custom_themes[] = (int) $tid; } } } // Now load up the paths of the themes that we need to know about. $request = $smcFunc['db_query']('', ' SELECT id_theme, variable, value FROM {db_prefix}themes WHERE id_theme IN ({array_int:custom_themes}) AND variable IN ({string:name}, {string:theme_dir})', array('custom_themes' => $custom_themes, 'name' => 'name', 'theme_dir' => 'theme_dir')); $theme_paths = array(); $themes_installed = array(1); while ($row = $smcFunc['db_fetch_assoc']($request)) { $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; } $smcFunc['db_free_result']($request); // Are there any theme copying that we want to take place? $context['theme_copies'] = array('require-file' => array(), 'require-dir' => array()); if (!empty($_POST['theme_changes'])) { foreach ($_POST['theme_changes'] as $change) { if (empty($change)) { continue; } $theme_data = unserialize(base64_decode($change)); if (empty($theme_data['type'])) { continue; } $themes_installed[] = $theme_data['id']; $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; } } // Get the package info... $packageInfo = getPackageInfo($context['filename']); if (!is_array($packageInfo)) { fatal_lang_error($packageInfo); } $packageInfo['filename'] = $context['filename']; // Set the type of extraction... $context['extract_type'] = isset($packageInfo['type']) ? $packageInfo['type'] : 'modification'; // Create a backup file to roll back to! (but if they do this more than once, don't run it a zillion times.) if (!empty($modSettings['package_make_full_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['filename'] . ($context['uninstalling'] ? '$$' : '$'))) { $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); // @todo Internationalize this? package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); } // The mod isn't installed.... unless proven otherwise. $context['is_installed'] = false; // Is it actually installed? $request = $smcFunc['db_query']('', ' SELECT version, themes_installed, db_changes FROM {db_prefix}log_packages WHERE package_id = {string:current_package} AND install_state != {int:not_installed} ORDER BY time_installed DESC LIMIT 1', array('not_installed' => 0, 'current_package' => $packageInfo['id'])); while ($row = $smcFunc['db_fetch_assoc']($request)) { $old_themes = explode(',', $row['themes_installed']); $old_version = $row['version']; $db_changes = empty($row['db_changes']) ? array() : unserialize($row['db_changes']); } $smcFunc['db_free_result']($request); // Wait, it's not installed yet! // @todo Replace with a better error message! if (!isset($old_version) && $context['uninstalling']) { deltree($boarddir . '/Packages/temp'); fatal_error('Hacker?', false); } elseif ($context['uninstalling']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); // Gadzooks! There's no uninstaller at all!? if (empty($install_log)) { fatal_lang_error('package_uninstall_cannot', false); } // They can only uninstall from what it was originally installed into. foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $old_themes)) { unset($theme_paths[$id]); } } } elseif (isset($old_version) && $old_version != $packageInfo['version']) { // Look for an upgrade... $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $old_version); // There was no upgrade.... if (empty($install_log)) { $context['is_installed'] = true; } else { // Upgrade previous themes only! foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $old_themes)) { unset($theme_paths[$id]); } } } } elseif (isset($old_version) && $old_version == $packageInfo['version']) { $context['is_installed'] = true; } if (!isset($old_version) || $context['is_installed']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); } $context['install_finished'] = false; // @todo Make a log of any errors that occurred and output them? if (!empty($install_log)) { $failed_steps = array(); $failed_count = 0; foreach ($install_log as $action) { $failed_count++; if ($action['type'] == 'modification' && !empty($action['filename'])) { if ($action['boardmod']) { $mod_actions = parseBoardMod(file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } else { $mod_actions = parseModification(file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } // Any errors worth noting? foreach ($mod_actions as $key => $action) { if ($action['type'] == 'failure') { $failed_steps[] = array('file' => $action['filename'], 'large_step' => $failed_count, 'sub_step' => $key, 'theme' => 1); } // Gather the themes we installed into. if (!empty($action['is_custom'])) { $themes_installed[] = $action['is_custom']; } } } elseif ($action['type'] == 'code' && !empty($action['filename'])) { // This is just here as reference for what is available. global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $forum_version, $smcFunc; // Now include the file and be done with it ;). if (file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'])) { require $boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'credits') { // Time to build the billboard $credits_tag = array('url' => $action['url'], 'license' => $action['license'], 'copyright' => $action['copyright'], 'title' => $action['title']); } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) { if ($action['reverse']) { remove_integration_function($action['hook'], $action['function'], $action['include_file']); } else { add_integration_function($action['hook'], $action['function'], $action['include_file']); } } elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) { // These can also be there for database changes. global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $forum_version, $smcFunc; global $db_package_log; // We'll likely want the package specific database functionality! db_extend('packages'); // Let the file work its magic ;) if (file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'])) { require $boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) { $context['redirect_url'] = $action['redirect_url']; $context['redirect_text'] = !empty($action['filename']) && file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) ? file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']); $context['redirect_timeout'] = $action['redirect_timeout']; // Parse out a couple of common urls. $urls = array('$boardurl' => $boardurl, '$scripturl' => $scripturl, '$session_var' => $context['session_var'], '$session_id' => $context['session_id']); $context['redirect_url'] = strtr($context['redirect_url'], $urls); } } package_flush_cache(); // First, ensure this change doesn't get removed by putting a stake in the ground (So to speak). package_put_contents($boarddir . '/Packages/installed.list', time()); // See if this is already installed, and change it's state as required. $request = $smcFunc['db_query']('', ' SELECT package_id, install_state, db_changes FROM {db_prefix}log_packages WHERE install_state != {int:not_installed} AND package_id = {string:current_package} ' . ($context['install_id'] ? ' AND id_install = {int:install_id} ' : '') . ' ORDER BY time_installed DESC LIMIT 1', array('not_installed' => 0, 'install_id' => $context['install_id'], 'current_package' => $packageInfo['id'])); $is_upgrade = false; while ($row = $smcFunc['db_fetch_assoc']($request)) { // Uninstalling? if ($context['uninstalling']) { $smcFunc['db_query']('', ' UPDATE {db_prefix}log_packages SET install_state = {int:not_installed}, member_removed = {string:member_name}, id_member_removed = {int:current_member}, time_removed = {int:current_time} WHERE package_id = {string:package_id} AND id_install = {int:install_id}', array('current_member' => $user_info['id'], 'not_installed' => 0, 'current_time' => time(), 'package_id' => $row['package_id'], 'member_name' => $user_info['name'], 'install_id' => $context['install_id'])); } else { $is_upgrade = true; $old_db_changes = empty($row['db_changes']) ? array() : unserialize($row['db_changes']); } } // Assuming we're not uninstalling, add the entry. if (!$context['uninstalling']) { // Any db changes from older version? if (!empty($old_db_changes)) { $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); } // If there are some database changes we might want to remove then filter them out. if (!empty($db_package_log)) { // We're really just checking for entries which are create table AND add columns (etc). $tables = array(); function sort_table_first($a, $b) { if ($a[0] == $b[0]) { return 0; } return $a[0] == 'remove_table' ? -1 : 1; } usort($db_package_log, 'sort_table_first'); foreach ($db_package_log as $k => $log) { if ($log[0] == 'remove_table') { $tables[] = $log[1]; } elseif (in_array($log[1], $tables)) { unset($db_package_log[$k]); } } $db_changes = serialize($db_package_log); } else { $db_changes = ''; } // What themes did we actually install? $themes_installed = array_unique($themes_installed); $themes_installed = implode(',', $themes_installed); // What failed steps? $failed_step_insert = serialize($failed_steps); // Credits tag? $credits_tag = empty($credits_tag) ? '' : serialize($credits_tag); $smcFunc['db_insert']('', '{db_prefix}log_packages', array('filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string'), array($packageInfo['filename'], $packageInfo['name'], $packageInfo['id'], $packageInfo['version'], $user_info['id'], $user_info['name'], time(), $is_upgrade ? 2 : 1, $failed_step_insert, $themes_installed, 0, $db_changes, $credits_tag), array('id_install')); } $smcFunc['db_free_result']($request); $context['install_finished'] = true; } // If there's database changes - and they want them removed - let's do it last! if (!empty($db_changes) && !empty($_POST['do_db_changes'])) { // We're gonna be needing the package db functions! db_extend('packages'); foreach ($db_changes as $change) { if ($change[0] == 'remove_table' && isset($change[1])) { $smcFunc['db_drop_table']($change[1]); } elseif ($change[0] == 'remove_column' && isset($change[2])) { $smcFunc['db_remove_column']($change[1], $change[2]); } elseif ($change[0] == 'remove_index' && isset($change[2])) { $smcFunc['db_remove_index']($change[1], $change[2]); } } } // Clean house... get rid of the evidence ;). if (file_exists($boarddir . '/Packages/temp')) { deltree($boarddir . '/Packages/temp'); } // Log what we just did. logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin'); // Just in case, let's clear the whole cache to avoid anything going up the swanny. clean_cache(); // Restore file permissions? create_chmod_control(array(), array(), true); }
<?php /** * Adk Portal * Version: 3.1 * Official support: http://www.smfpersonal.net * Author: Adk Team * Copyright: 2009 - 2016 © SMFPersonal * Developers: * Juarez, Lucas Javier * Clavijo, Pablo * */ $direct_install = false; if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { require_once dirname(__FILE__) . '/SSI.php'; $direct_install = true; } elseif (!defined('SMF')) { die('Adk portal wasn\'t able to conect to smf'); } db_extend('packages'); //Hooks Integration $hooks = array('integrate_actions' => 'Adk_portal_add_index_actions', 'integrate_admin_areas' => 'Adk_portal_add_admin_areas', 'integrate_menu_buttons' => 'Adk_portal_add_menu_buttons', 'integrate_display_buttons' => 'Adk_portal_display_buttons', 'integrate_load_permissions' => 'Adk_portal_Permissions', 'integrate_whos_online' => 'Adk_portal_who', 'integrate_buffer' => 'Adk_portal_change_buffer', 'integrate_load_theme' => 'Adk_portal_load_from_theme', 'integrate_pre_include' => '$sourcedir/AdkPortal/Subs-adkfunction.php', 'integrate_pre_load' => 'Adk_portal_pre_load'); foreach ($hooks as $hook => $call) { remove_integration_function($hook, $call); } if ($direct_install) { echo 'Done... Adk portal was uninstalled correctly. Enjoy it!'; }
<?php if (!defined('SMF')) { require_once 'SSI.php'; } remove_integration_function('integrate_pre_include', '$sourcedir/og.php'); remove_integration_function('integrate_bbc_codes', 'og_bbc'); remove_integration_function('integrate_modify_modifications', 'og_admin'); remove_integration_function('integrate_admin_areas', 'og_admin_areas'); $smcFunc['db_query']('', 'DELETE FROM {db_prefix}scheduled_tasks WHERE task = "og_prune"');
/** * Remove integration functions from to SMF */ public function smfRemoveHooks() { global $modSettings; if (!function_exists('add_integration_function')) { $smfPath = $this->config['smfPath']; /** @noinspection PhpIncludeInspection */ require $smfPath . 'Sources/Subs.php'; /** @noinspection PhpIncludeInspection */ require $smfPath . 'Sources/Load.php'; } $hooks = $this->_smfHooks; $hooks['integrate_pre_include'] = ''; foreach ($hooks as $hook => $value) { if (!empty($modSettings[$hook])) { $tmp = explode(',', $modSettings[$hook]); foreach ($tmp as $v) { remove_integration_function($hook, $v); } } } }
UPDATE {db_prefix}log_packages SET install_state = {int:val} WHERE id_install = {int:id}', array('id' => $id, 'val' => $val)); } _dbinst_write('Table log_packages updated.' . $newline); } // remove all hooks $hooklist = array('integrate_pre_include' => '$sourcedir/PortaMx/PortaMxLoader.php', 'integrate_buffer' => 'ob_portamx', 'integrate_actions' => 'PortaMx_Actions', 'integrate_admin_areas' => 'PortaMx_AdminMenu', 'integrate_dynamic_buttons' => 'PortaMx_MenuContext', 'integrate_whos_online' => 'PortaMx_whos_online', 'integrate_load_theme' => 'pmx_eclnonemodal', 'integrate_default_action' => 'PortaMx_wireless', 'integrate_pre_css_output' => 'PortaMx_loadCSS'); $sefhooklist = array('integrate_pre_load' => 'pmxsef_convertSEF', 'integrate_buffer' => 'ob_pmxsef', 'integrate_redirect' => 'pmxsef_Redirect', 'integrate_outgoing_email' => 'pmxsef_EmailOutput', 'integrate_exit' => 'pmxsef_XMLOutput', 'integrate_fix_url' => 'pmxsef_fixurl'); _dbinst_write('Removing all PortaMx integration hooks.' . $newline); foreach ($hooklist as $hook => $function) { remove_integration_function($hook, $function, true, '', false); } _dbinst_write('Removing all PortaMx SEF integration hooks.' . $newline); foreach ($sefhooklist as $hook => $function) { remove_integration_function($hook, $function, true, '', false); } // remove all PortaMx settings _dbinst_write('Removing all PortaMx settings.' . $newline); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}settings WHERE variable LIKE {string:variable}', array('variable' => 'pmx%')); // update smiley sets $request = $smcFunc['db_query']('', ' SELECT value FROM {db_prefix}settings WHERE variable = {string:variable}', array('variable' => 'smiley_sets_known')); $row = $smcFunc['db_fetch_assoc']($request); $smcFunc['db_free_result']($request); $row['value'] = str_replace(',PortaMx', '', $row['value']); $smcFunc['db_insert']('replace', '
<?php /** * This script removes all the extraneous data if the user requests it be removed on uninstall. * * NOTE: This script is meant to run using the <samp><code></code></samp> elements of our package-info.xml file. This is because * certain items in the database and within SMF will need to be removed regardless of whether the user wants to keep data or not, * for example hooks need to be deactivated. */ /** * Before attempting to execute, this file attempts to load SSI.php to enable access to the database functions. */ // If we have found SSI.php and we are outside of SMF, then we are running standalone. if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { require_once dirname(__FILE__) . '/SSI.php'; db_extend('packages'); } elseif (!defined('SMF')) { die('<b>Error:</b> Cannot uninstall - please verify you put this file in the same place as SMF\'s SSI.php.'); } global $smcFunc; // 1. Removing all the SMF hooks. $hooks = array(); $hooks[] = array('hook' => 'integrate_user_info', 'function' => 'integrate_chars', 'file' => '$sourcedir/Characters.php'); foreach ($hooks as $hook) { remove_integration_function($hook['hook'], $hook['function'], true, !empty($hook['file']) ? $hook['file'] : ''); }