Find Duplicate Permissions

Tools by the phpBBModders team and Community contributed tools.
Forum rules
Only post tools related to modding in here, simple.
Post Reply
JRSweets
New member
New member
Posts: 22
Joined: 02 May 2008, 13:52
Real name: Jeff

Find Duplicate Permissions

Post by JRSweets »

While creating mods I have had users complain that the acp modules are not accessable even though they are set to founder status. They can also see the modules in module management but not in the ACP. I have tracked the problem down. It is caused by having duplicate entries in the phpbb_acl_options tabled, in other words options with the same names.

I created this script to display the duplicate values and thought it may be useful.

Code: Select all

<?php
/**
*
* @package arcade
* @version $Id: perm_check.php 217 2008-05-01 20:14:38Z jrsweets $
* @copyright (c) 2008 http://www.JeffRusso.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB'1);
$phpEx substr(strrchr(__FILE__'.'), 1);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH './';
include(
$phpbb_root_path 'common.'.$phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if (
$user->data['user_type'] != USER_FOUNDER)
{
    die(
'You are not authorized to use this script.');
}

$sql 'SELECT auth_option_id, auth_option
    FROM ' 
ACL_OPTIONS_TABLE '
    ORDER BY auth_option_id'
;
$result $db->sql_query($sql);
$auth_option_id = array();
while (
$row $db->sql_fetchrow($result))
{
    
$auth_option_id[$row['auth_option_id']] = $row['auth_option'];
}
$db->sql_freeresult($result);

$duplicate_auth array_count_values($auth_option_id);
unset(
$auth_option_id);

$auth_option_id = array();
foreach (
$duplicate_auth as $key => $value)
{
    if (
$value 1)
    {
        
$auth_option_id[] = $key ' was found ' $value ' times';
    }
}

if (!empty(
$auth_option_id))
{
    
display_error('Duplicate auth values can cause problems with permissions. The following duplicate auth values were found inside the ' ACL_OPTIONS_TABLE ':'$auth_option_id);
}
else
{
    echo 
'No duplicates found';
}

function 
display_error($title$error)
{
    echo 
'<p style="color: red; font-size: 1.05em; font-family: \'Trebuchet MS\', Helvetica, sans-serif;"><strong>'$title .'</strong><br />' implode('<br />'$error) . '</p>';
}
    
?>
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: Find Duplicate Permissions

Post by igorw »

Welcome jeff, and thanks for posting :)
Post Reply