Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2014-08-29 10:58:22

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Admin Restrictions

This modification will allow the original board administrator to impose restrictions upon the other administrators.

Currently, their use of admin_options, admin_permissions, admin_categories, admin_forums, admin_groups, admin_censoring and admin_maintenace can be stopped - as well as allowing them to delete/demote other users and using plugins.

If like me, you have an admin who you maybe don't have quite as much trust in as the others, it's a perfect solution without demoting them. It also makes sure that only people you authorise can access the administrative features, and also technically could make them global moderators and work as a replacement for that mod. However, it is compatible with that, my own site is a perfect example.

It uses caches to speed up page loading and avoids un-needed queries per page.

Link: https://fluxbb.org/resources/mods/admin-restrictions/

Last edited by chris98 (2014-08-29 11:07:49)

Offline

#2 2014-09-04 08:58:25

joel
Member
Registered: 2014-07-04
Posts: 440

Re: Admin Restrictions

umm. Will try out.


Warning! be informed and be forewarned. <p>
<?php
I'm not a native English Man. So my comments might contain some grammatical explosive (ELD), missapropreation of words (dinamyt), The use of wrong words (missiles), & mis spelling of words (war drones). Any of the occurrence can cause havoc. So be warned
?>

Offline

#3 2014-09-09 10:22:57

joel
Member
Registered: 2014-07-04
Posts: 440

Re: Admin Restrictions

fatal error: call to undefined function generate_admin_restrictins_cashes() In yourforum.com/include/common_admin.php on line 24.

Call stack
Require include/common_admin.php')

Last edited by joel (2014-09-09 10:28:10)


Warning! be informed and be forewarned. <p>
<?php
I'm not a native English Man. So my comments might contain some grammatical explosive (ELD), missapropreation of words (dinamyt), The use of wrong words (missiles), & mis spelling of words (war drones). Any of the occurrence can cause havoc. So be warned
?>

Offline

#4 2014-09-09 10:32:22

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Can you post your code?

That function is not in the mod, only generate_admin_restrictions_cache()

Offline

#5 2014-09-09 11:40:04

joel
Member
Registered: 2014-07-04
Posts: 440

Re: Admin Restrictions

the section that has

generate_admin_restrictions_cache()

The first find and put after in the readme instruction that has it. i had never modify the admin area so its the original fluxbb administrator.


Warning! be informed and be forewarned. <p>
<?php
I'm not a native English Man. So my comments might contain some grammatical explosive (ELD), missapropreation of words (dinamyt), The use of wrong words (missiles), & mis spelling of words (war drones). Any of the occurrence can cause havoc. So be warned
?>

Offline

#6 2014-09-09 14:16:43

Sxderp
Member
Registered: 2012-11-02
Posts: 101

Re: Admin Restrictions

Looks like a typo? I'm just going by what was posted in this thread. I haven't looked at the mod.

Last edited by Sxderp (2014-09-09 14:17:25)

Offline

#7 2014-09-09 17:37:47

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

I downloaded the mod again (as I have half modified files that are upside down) and when I searched for the function above, Notepad++ was unable to find it. I have also installed the mod and have been unable to reproduce the error.

However, if you find the appropriate line and change:

generate_admin_restrictins_cashes

To:

generate_admin_restrictions_cache

It will work.

Offline

#8 2014-09-10 21:57:29

joel
Member
Registered: 2014-07-04
Posts: 440

Re: Admin Restrictions

well I tried several time still the same problem. Anyway thanks I really don't need it for now.  it was on a test server.


Warning! be informed and be forewarned. <p>
<?php
I'm not a native English Man. So my comments might contain some grammatical explosive (ELD), missapropreation of words (dinamyt), The use of wrong words (missiles), & mis spelling of words (war drones). Any of the occurrence can cause havoc. So be warned
?>

Offline

#9 2014-09-11 06:37:42

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Well I'm not sure for the life of me what you've done then. But it certainly isn't in the mod.

Offline

#10 2014-09-18 17:20:05

quy
Administrator
From: California
Registered: 2008-05-09
Posts: 921

Re: Admin Restrictions

In readme.txt,
step 20: remove $pun_user['id'] = '24';

In admin_restrictions.php,
line 46, 63, 79, 96 and 182: remove 'Alter User Ranks' option and remove admin_ranks from query
line 31: remove $db->escape
line 123: missing $lang_admin_common['Restrictions']
line 434 and 438: add $db->prefix to the admin_restrictions table
line 436 and 439: apply pun_htmlspecialchars to $admin['username']

Offline

#11 2014-09-18 17:22:11

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Whoops, I thought I removed those - especially the $pun_user['id'] = '24'.

Thanks, I'll get some code out to fix those.

Offline

#12 2014-09-20 14:11:14

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Version 1.1 released:

- removed $pun_user['id'] = '24'; from readmen.txt (left over from debugging)

- removed admin_ranks options - no admin_ranks exist i 1.4.x/1.5.x

- Added missing language index for $lang_admin_common['Restrictions']

- added $db->prefix to the admin_restrictions table in two missing spots

- applied pun_htmlspecialchars to $admin['username']

A thanks to quy for bringing these to my attention.

https://fluxbb.org/resources/mods/admin … eases/1.1/

@joel: You should be able to install no problem now.

Offline

#13 2014-09-20 15:25:35

quy
Administrator
From: California
Registered: 2008-05-09
Posts: 921

Re: Admin Restrictions

readme.txt:
step 6 - change to:

if (file_exists(FORUM_CACHE_DIR.'cache_admin.php'))
	require FORUM_CACHE_DIR.'cache_admin.php';
else
{
	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require PUN_ROOT.'include/cache.php';

	generate_admin_restrictions_cache();
	require FORUM_CACHE_DIR.'cache_admin.php';
}

$admin should be $admins.

In cache_admin.php, it is $admins:

$admins['3'] = array (

but it is referenced as $admin:

if ($pun_user['id'] != '2')
{
	if(!is_null($admin[$pun_user['id']]['admin_permissions']))
	{
		if ($admin[$pun_user['id']]['admin_permissions'] == '0')
			message($lang_common['No permission'], false, '403 Forbidden');
	}
}

admin_restrictions.php:
- Apply pun_htmlspecialchars to $valid['username'] in 3 places

Offline

#14 2014-12-04 20:37:32

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

The error: Fatal error: Call to undefined function generate_admin_restrictions_cache() in /home/a5061422/public_html/include/common_admin.php on line 23 
The Error appear   in : admin_index.php

The admin panel not function.

Offline

#15 2014-12-04 20:41:25

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

By code, I did mean the code in the file of the error you're getting smile Sorry for the misunderstanding. Can you copy the full code from /include/common_admin.php below into code tags?

Offline

#16 2014-12-04 20:48:01

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

Common_admin.php

<?php

/**
 * Copyright (C) 2008-2012 FluxBB
 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 */

// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
	exit;

// Make sure we have a usable language pack for admin.
if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/admin_common.php'))
	$admin_language = $pun_user['language'];
else if (file_exists(PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/admin_common.php'))
	$admin_language = $pun_config['o_default_lang'];
else
	$admin_language = 'English';
if (file_exists(FORUM_CACHE_DIR.'cache_admin.php'))
	require FORUM_CACHE_DIR.'cache_admin.php';
else
	generate_admin_restrictions_cache();

// Attempt to load the admin_common language file
require PUN_ROOT.'lang/'.$admin_language.'/admin_common.php';

//
// Display the admin navigation menu
//
function generate_admin_menu($page = '')
{
	global $pun_config, $pun_user, $lang_admin_common, $admins;

$output = array();
	$is_admin = $pun_user['g_id'] == PUN_ADMIN ? true : false;
	if (!isset($admins[$pun_user['id']]) || $pun_user['id'] == '2')
		$admins[$pun_user['id']] = array('admin_options' => '1', 'admin_permissions' => '1', 'admin_categories' => '1', 'admin_forums' => '1', 'admin_groups' => '1', 'admin_users' => '1', 'admin_censoring' => '1', 'admin_maintenance' => '1', 'admin_plugins' => '1', 'admin_restrictions' => '1');

 	
	if ($admins[$pun_user['id']]['admin_options'] == '1')
		$output[] = ($page == 'options') ? '<li class="isactive"><a href="admin_options.php">'.$lang_admin_common['Options'].'</a></li>' : '<li><a href="admin_options.php">'.$lang_admin_common['Options'].'</a></li>';

	if ($admins[$pun_user['id']]['admin_permissions'] == '1')
		$output[] = ($page == 'permissions') ? '<li class="isactive"><a href="admin_permissions.php">'.$lang_admin_common['Permissions'].'</a></li>' : '<li><a href="admin_permissions.php">'.$lang_admin_common['Permissions'].'</a></li>';

	if ($admins[$pun_user['id']]['admin_categories'] == '1')
		$output[] = ($page == 'categories') ? '<li class="isactive"><a href="admin_categories.php">'.$lang_admin_common['Categories'].'</a></li>' : '<li><a href="admin_categories.php">'.$lang_admin_common['Categories'].'</a></li>';
		
	if ($admins[$pun_user['id']]['admin_forums'] == '1')
		$output[] = ($page == 'forums') ? '<li class="isactive"><a href="admin_forums.php">'.$lang_admin_common['Forums'].'</a></li>' : '<li><a href="admin_forums.php">'.$lang_admin_common['Forums'].'</a></li>';
		
	if ($admins[$pun_user['id']]['admin_groups'] == '1')
		$output[] = ($page == 'groups') ? '<li class="isactive"><a href="admin_groups.php">'.$lang_admin_common['User groups'].'</a></li>' : '<li><a href="admin_groups.php">'.$lang_admin_common['User groups'].'</a></li>';
		
	if ($admins[$pun_user['id']]['admin_censoring'] == '1')
		$output[] = ($page == 'censoring') ? '<li class="isactive"><a href="admin_censoring.php">'.$lang_admin_common['Censoring'].'</a></li>' : '<li><a href="admin_censoring.php">'.$lang_admin_common['Censoring'].'</a></li>';
		
	if ($admins[$pun_user['id']]['admin_maintenance'] == '1')
		$output[] = ($page == 'maintenance') ? '<li class="isactive"><a href="admin_maintenance.php">'.$lang_admin_common['Maintenance'].'</a></li>' : '<li><a href="admin_maintenance.php">'.$lang_admin_common['Maintenance'].'</a></li>';

if ($admins[$pun_user['id']]['admin_restrictions'] == '1')
		$output[] = ($page == 'restrictions') ? '<li class="isactive"><a href="admin_restrictions.php">'.$lang_admin_common['Restrictions'].'</a></li>' : '<li><a href="admin_restrictions.php">'.$lang_admin_common['Restrictions'].'</a></li>';

	$is_admin = $pun_user['g_id'] == PUN_ADMIN ? true : false;

?>
<div id="adminconsole" class="block2col">
	<div id="adminmenu" class="blockmenu">
		<h2><span><?php echo $lang_admin_common['Moderator menu'] ?></span></h2>
		<div class="box">
			<div class="inbox">
				<ul>
					<li<?php if ($page == 'index') echo ' class="isactive"'; ?>><a href="admin_index.php"><?php echo $lang_admin_common['Index'] ?></a></li>
					<li<?php if ($page == 'users') echo ' class="isactive"'; ?>><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li>
<?php if ($is_admin || $pun_user['g_mod_ban_users'] == '1'): ?>					<li<?php if ($page == 'bans') echo ' class="isactive"'; ?>><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li>
<?php endif; if ($is_admin || $pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2'): ?>					<li<?php if ($page == 'reports') echo ' class="isactive"'; ?>><a href="admin_reports.php"><?php echo $lang_admin_common['Reports'] ?></a></li>
<?php endif; ?>				</ul>
			</div>
		</div>
<?php

	if ($is_admin)
	{

?>
		<h2 class="block2"><span><?php echo $lang_admin_common['Admin menu'] ?></span></h2>
		<div class="box">
			<div class="inbox">
				<ul>
					<?php echo implode("\t\t\t\t\t", $output); ?>
				</ul>
			</div>
		</div>
<?php

	}

	// See if there are any plugins
	$plugins = forum_list_plugins($is_admin);

	// Did we find any plugins?
	if (!empty($plugins) && ($admins[$pun_user['id']]['admin_plugins'] == '1'))
	{

?>
		<h2 class="block2"><span><?php echo $lang_admin_common['Plugins menu'] ?></span></h2>
		<div class="box">
			<div class="inbox">
				<ul>
<?php

		foreach ($plugins as $plugin_name => $plugin)
			echo "\t\t\t\t\t".'<li'.(($page == $plugin_name) ? ' class="isactive"' : '').'><a href="admin_loader.php?plugin='.$plugin_name.'">'.str_replace('_', ' ', $plugin).'</a></li>'."\n";

?>
				</ul>
			</div>
		</div>
<?php

	}

?>
	</div>

<?php

}


//
// Delete topics from $forum_id that are "older than" $prune_date (if $prune_sticky is 1, sticky topics will also be deleted)
//
function prune($forum_id, $prune_sticky, $prune_date)
{
	global $db;

	$extra_sql = ($prune_date != -1) ? ' AND last_post<'.$prune_date : '';

	if (!$prune_sticky)
		$extra_sql .= ' AND sticky=\'0\'';

	// Fetch topics to prune
	$result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.$extra_sql, true) or error('Unable to fetch topics', __FILE__, __LINE__, $db->error());

	$topic_ids = '';
	while ($row = $db->fetch_row($result))
		$topic_ids .= (($topic_ids != '') ? ',' : '').$row[0];

	if ($topic_ids != '')
	{
		// Fetch posts to prune
		$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topic_ids.')', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());

		$post_ids = '';
		while ($row = $db->fetch_row($result))
			$post_ids .= (($post_ids != '') ? ',' : '').$row[0];

		if ($post_ids != '')
		{
			// Delete topics
			$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topic_ids.')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error());
			// Delete subscriptions
			$db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE topic_id IN('.$topic_ids.')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error());
			// Delete posts
			$db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$post_ids.')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error());

			// We removed a bunch of posts, so now we have to update the search index
			require_once PUN_ROOT.'include/search_idx.php';
			strip_search_index($post_ids);
		}
	}
}

Last edited by slv00 (2014-12-04 20:48:46)

Offline

#17 2014-12-04 21:15:45

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Hmm. Okay, this is indeed a mod bug. Change

if (file_exists(FORUM_CACHE_DIR.'cache_admin.php'))
	require FORUM_CACHE_DIR.'cache_admin.php';
else
	generate_admin_restrictions_cache();

to

if (file_exists(FORUM_CACHE_DIR.'cache_admin.php'))
	require FORUM_CACHE_DIR.'cache_admin.php';
else
{
	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require PUN_ROOT.'include/cache.php';

	generate_admin_restrictions_cache();
	require FORUM_CACHE_DIR.'cache_admin.php';
}

and it will work. Thanks for your patience, and sorry for the inconvenience smile

Offline

#18 2014-12-04 21:32:16

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

It's works.

A question:
What restrictions can be set for other admin's?
  I not found in the administration panel the settings for this mod.
Thanks for help.

Last edited by slv00 (2014-12-05 09:17:19)

Offline

#19 2014-12-05 08:08:39

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

You can navigate to admin_restrictions.php and this will allow you to see what you can set for other admins. Note that you must have at least another admin as the original board admin can't have any restrictions.

Offline

#20 2014-12-05 09:17:35

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

Thanks for help.

Offline

#21 2014-12-05 14:59:48

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

Question:

I set  : Allow this user to alter the admin restrictions. WARNING! Setting this option to yes will automatically give them power to over-ride their own restrictions to NO  but other administrator may change the restrictions.

How can I block the acces of other admin to modify the restictions.

And to my profile the other admin may make changes.

Thanks for help.

Offline

#22 2014-12-05 15:03:28

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

How can I block the acces of other admin to modify the restictions.

You add restrictions for other admins which will stop them from going to the admin_restrictions.php page (that exact option you posted above). Note that you only need to set that option to no which will stop them from viewing/editing them.

And to my profile the other admin may make changes.

Since they're still admins, they will be able to rename your account, change your email, as well as the rest of your account details. However, they will not be allowed to delete you, or change your user group if you stop them.

Offline

#23 2014-12-05 15:07:15

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

I test with another admin account and I could acces of the admin_restriction.php page . I set the that optoin to NO.

And Profile tho other admin i could change password.

Last edited by slv00 (2014-12-05 15:09:00)

Offline

#24 2014-12-05 15:08:26

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 1,292
Website

Re: Admin Restrictions

Did it appear in the sidebar or did you just URL hack? Can I see the cache/cache_admin.php file?

Last edited by chris98 (2014-12-05 15:08:47)

Offline

#25 2014-12-05 15:13:45

slv00
Member
Registered: 2013-12-22
Posts: 24

Re: Admin Restrictions

cache_admin.php


<?php

if (!defined('PUN')) exit;


$admins = array();

$admins['3'] = array (
  'admin_options' => '0',
  'admin_permissions' => '0',
  'admin_categories' => '1',
  'admin_forums' => '1',
  'admin_groups' => '0',
  'admin_users' => '0',
  'admin_censoring' => '0',
  'admin_maintenance' => '0',
  'admin_plugins' => '0',
  'admin_restrictions' => '0',
);

it appear in the sidebar  not hack.

Last edited by slv00 (2014-12-05 15:16:02)

Offline

Board footer

Powered by FluxBB