This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Disabling all extensions at once

Description: Explains how to disable all extensions at once. Useful when you have too many extensions to do this manually or when a rogue extension prevents you from accessing the Administration Control Panel.

In Categories:

Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.3/kb/article/disabling-all-extensions-at-once/]Knowledge Base - Disabling all extensions at once[/url]

Disabling All Extensions
There are several reasons why you might want, or need, to disable all of your extensions and there are several ways of achieving this depending on the circumstances.

Disabling extensions means that the extension(s) is not visible to phpBB so that it does not perform the action that it has been designed to do – it does not remove any files or configuration options that you have set and when you re-enable the extension the configuration options will still be there.

Reasons for disabling extensions
  • You do not want any extensions any more.
  • You need to update an extension.
  • You have a problem with an extension but you do not know which one therefore you need to disable all of your extensions and then re-enable them one at a time until you find the extension that is causing the problem.
  • You are upgrading to another version of phpBB and you want to ensure that all of your extensions are compatible. By disabling all of your extensions, before you upgrade, you can then re-enable them one at a time to ensure compatibility.
  • You have a “rogue” extension which is preventing access to your ACP and/or your board.
How not to disable extensions
  • You should not, when trying to disable any extension, run an sql command against the database as this will not, in some situations, correctly disable your extensions and may cause even more problems with your board not functions correctly, or possibly not functioning at all.
  • You should not delete the extension’s files from the ext folder – this will not disable your extensions and will result in further errors being created.
Correct methods to disable extensions, how/when to use each method and the advantages & disadvantages

Manually, via the ACP, where you disable your extensions one at a time.
  • When – any time you want to disable an extension.
  • Advantages – built into the core of phpBB and is the default method.
  • Disadvantages – can become laborious if you have many extensions. Will not be possible if you cannot access the ACP.
  • Usage – access Extension Management in the ACP
Manually, via Command Line Interface (CLI) where, again, you disable your extensions one at a time.
  • When – mainly if you are unable to access the ACP.
  • Advantages – built in phpBB core function. Can be useful if you cannot gain access to the ACP.
  • Disadvantages – requires shell, or SSH, access to your server and you need to know the vendor and extension name for each extension. This may be a very slow method if there are many extensions that you want to disable as you will need to type the details for each extension.
  • Usage –for details on how to use CLI see here
By using the Disable all Extensions extension, where all of your extensions can be disabled in one go.
  • When – any time that you want/need to disable all of your extensions.
  • Advantages – quick “one click” disable option.
  • Disadvantages – need to have the extension installed and enabled. Requires access to the ACP. Only available for phpBB 3.2 and above.
  • Usage –you can download the Disable all Extensions extension here
By using the Disable Extensions script.
  • When – when you need to disable your extensions and you cannot access your board in any other way.
  • Advantages – does not require direct access to the ACP or the board.
  • Disadvantages – requires founder status to run. Requires FTP access to your board.
  • Usage – Save the file added below and upload it to your root (same place where config.php is) as ext_disable.php. Then navigate to the file in your browser and run it.

    Code: Select all

    <?php
    /***
    *
    * Usage: Download and unzip the file, upload it to your Board's root (i.e.: www.mydomain.com/phpBB3/)
    * Point your browser to i.e.: www.mydomain.com/phpBB3/ext_disable.php) and follow instructions.
    *
    * Version 1.0.0 - david63 2017
    * Based on modisson.php - Oyabun1 2015
    *
    * This script is free software. It comes without any warranty.
    * license http://opensource.org/licenses/GPL-2.0 GNU General Public License v2.
    *
    * Ensure that you have a backup of your Database before to run this tool
    *
    */
    
    define('IN_PHPBB', true);
    
    $phpbb_root_path	= (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx 				= substr(strrchr(__FILE__, '.'), 1);
    
    // Change this to 'false' if you do not want to delete this file
    $remove_me = true;
    
    include($phpbb_root_path . 'common.' . $phpEx);
    include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
    include_once($phpbb_root_path . 'phpbb/extension/manager.' . $phpEx);
    
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    
    /* If ANONYMOUS = login box */
    if ((int) $user->data['user_id'] == ANONYMOUS)
    {
    	login_box(request_var('redirect', "ext_disable.$phpEx"));
    }
    
    // Limit this to founders or admins
    if ((int) $user->data['user_type'] !== USER_FOUNDER || !$auth->acl_get('a_'))
    {
    	trigger_error('You do not have permission to alter the database.
    	You need to be logged in as a founder or administrator.');
    }
    
    // Let's see how many extension we can disable
    $orig_ext_count = get_active_ext();
    
    // Create a HTML5 page to add some form elements and display stuff
    echo '<!DOCTYPE html>';
    echo '<html>';
    echo '<head>';
    echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
    echo '<title>' . basename(__FILE__) . '</title>';
    
    echo '<style type="text/css">
    	body {
    		font-size: 1em;
    		background-color: #C0C0C0 ;
    		width: 600px;
    		margin: 2em auto 0;
    	}
    
    	form {
    		text-align: center;
    		line-height: 230%;
    	}
    
    	fieldset {
    		-moz-border-radius:7px;
    		border-radius: 7px;
    		-webkit-border-radius: 7px;
    	}
    
    	h3 {
    		text-align: center;
    	}
    
    	label {
    		cursor: pointer;
    		background-color: #FFD700;
    		border-style: outset;
    		border-width; 1px;
    		border-radius: 7px;
    		border-color: #808080;
    		font-size: 1.1em;
    		padding: 2px;
    		margin: 2px;
    	}
    
    	input[type="checkbox"]:disabled {
        	opacity:0;
    	}
    
    	input[type="checkbox"] {
    		cursor: pointer;
    	}
    
    	img.mid {
    		display: block;
    		margin-top: 1em;
    		margin-left: auto;
    		margin-right: auto
    	}
    
    	/* Buttons based on Pressable CSS Buttons by Joshua Hibbert */
    	.button {
    		background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));
    		background-image:    -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));
    		background-image:     -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));
    		background-image:      -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));
    		background-image:         linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,0%,.1));
    		border: none;
    		border-radius: 1.25em;
    		box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),
    					inset 0 2px 0 hsla(0,0%,100%,.1),
    					inset 0 1.2em 0 hsla(0,0%,100%,.05),
    					inset 0 -.2em 0 hsla(0,0%,100%,.1),
    					inset 0 -.25em 0 hsla(0,0%,0%,.5),
    					0 .25em .25em hsla(0,0%,0%,.1);
    		color: #fff;
    		text-shadow: 0 -1px 1px hsla(0,0%,0%,.25);
    		cursor: pointer;
    		display: inline-block;
    		font-family: sans-serif;
    		font-size: 1.1em;
    		font-weight: bold;
    		line-height: 150%;
    		margin: 0 .5em;
    		padding: .25em .75em .5em;
    		position: relative;
    		text-decoration: none;
    		vertical-align: middle;
    	}
    
    	.button:hover {
    		outline: none;
    	}
    
    	.button:hover, .button:focus {
    		box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),
    					inset 0 2px 0 hsla(0,0%,100%,.1),
    					inset 0 1.2em 0 hsla(0,0%,100%,.05),
    					inset 0 -.2em 0 hsla(0,0%,100%,.1),
    					inset 0 -.25em 0 hsla(0,0%,0%,.5),
    					inset 0 0 0 3em hsla(0,0%,100%,.2),
    					0 .25em .25em hsla(0,0%,0%,.1);
    	}
    
    	.button:active {
    		box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.25),
    					inset 0 2px 0 hsla(0,0%,100%,.1),
    					inset 0 1.2em 0 hsla(0,0%,100%,.05),
    					inset 0 0 0 3em hsla(0,0%,100%,.2),
    					inset 0 .25em .5em hsla(0,0%,0%,.05),
    					0 -1px 1px hsla(0,0%,0%,.1),
    					0 1px 1px hsla(0,0%,100%,.25);
    		margin-top: .25em;
    		outline: none;
    		padding-bottom: .5em;
    	}
    
    	.green {
    		background-color: #228B22;
    	}
    
    	.remove_me {
    		color: #FFFFFF;
    		width: 560px;
    		margin: 2em auto 0;
    		padding: .5em;
    		font-size: 1.1em;
    		background-color: #8B0000;
    	}
    
    </style>';
    
    echo '</head>';
    echo '<body>';
    
    // Create a form with a checkbox
    echo '<h3>Disable all extensions</h3>';
    echo '<fieldset><legend><strong>Check the selection box and click the Run button.</strong></legend>';
    echo '<form action="' . basename(__FILE__) . '" method="post" onsubmit="return confirm(\'You are about to disable ' . $orig_ext_count . ' extensions. \n Make sure you first have a database backup. \n If you click OK there is no going back.\')">';
    echo '<label title="Disable '. $orig_ext_count . ' extensions"><input type="checkbox" name="chkExt"
    	value="Yes" />Disable '. $orig_ext_count . ' extensions&nbsp;</label>&nbsp;';
    echo '<p><button type="submit" class="button green";>Run</button></p>';
    echo '</form>';
    echo '</fieldset><br>';
    echo '<fieldset style="background-color:#F5FCFF; border-color:#00CC00; border-style: solid;"><legend>
    		<strong>Result</strong></legend>';
    
    // Use request_var() to get the returned value of the selection
    $chk_ext = (request_var('chkExt', ''));
    
    // Get the current version from 'includes/constants.php'
    $version = PHPBB_VERSION;
    
    // Let's make sure that we are running phpBB > 3.1
    if (phpbb_version_compare($version, '3.1.0', '>='))
    {
    	// Disable extensions
    	if($chk_ext == 'Yes')
    	{
    		// Get the enabled extensions
    		$sql = 'SELECT ext_name
    			FROM ' . EXT_TABLE . '
    			WHERE ext_active = 1';
    
    		$result = $db->sql_query($sql);
    
    		// Now we can try to disable the extensions
    		if (!empty($result))
    		{
    			while ($ext_name = $db->sql_fetchrow($result))
    			{
    				while ($phpbb_extension_manager->disable_step($ext_name['ext_name']));
    			}
    
    			$db->sql_freeresult($result);
    		}
    		else
    		{
    			echo 'No extensions found to disable';
    
    			remove_me();
    		}
    
    		// Get count of extensions disabled
    		$disabled_ext = $orig_ext_count - get_active_ext();
    
    		// Add disable action to the admin log
    		add_log('admin', $disabled_ext . ' extensions disabled');
    
    		echo $disabled_ext . ' extensions have been disabled.';
    
    		remove_me();
    	}
    }
    else
    {
    	// User has an invalid version of phpBB
    	echo 'This script can only be run on versions of phpBB greater than 3.1.0<br />Your version of phpBB: /includes/constants.php ' . $version .'<br>Since the version is invalid no extensions are able to be disabled.<br>';
    
    	remove_me();
    }
    
    echo '</form>';
    echo '</fieldset>';
    echo '</body>';
    echo '</html>';
    
    
    // Get count of active extensions
    function get_active_ext()
    {
    	global $db;
    
    	$sql = 'SELECT COUNT(ext_active) AS active_ext
    		FROM ' . EXT_TABLE . '
    		WHERE ext_active = 1';
    
    	$result		= $db->sql_query($sql);
    	$ext_count	= (int)$db->sql_fetchfield('active_ext');
    
    	$db->sql_freeresult($result);
    
    	return $ext_count;
    }
    
    // Try to delete this file
    function remove_me()
    {
    	if ($remove_me)
    	{
    		@unlink(__FILE__);
    
    		// Windows IIS servers may have a problem with unlinking recently created files.
    		// So check if file exists and give a message
    		if (file_exists(__FILE__))
    		{
    			echo '<p class="remove_me">File could not be deleted. You will need to manually delete the ' . basename(__FILE__) . ' file from the server.</p>';
    		}
    	}
    }