MyBB Community Forums

Full Version: ModCP Ban bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
in modcp.php?action=banuser I find a bug.
if We only one banned group MyBB use <input type="hidden" for banned group but value of it is last gid! 

for fix:
in modcp.php
find:

	$bangroup_option = $bangroups = '';
	$numgroups = 0;
	$groupscache = $cache->read("usergroups");

	foreach($groupscache as $key => $group)
	{
		if($group['isbannedgroup'])
		{
			$selected = "";
			if(isset($banned['gid']) && $banned['gid'] == $group['gid'])
			{
				$selected = " selected=\"selected\"";
			}

			$group['title'] = htmlspecialchars_uni($group['title']);
			eval("\$bangroup_option .= \"".$templates->get("modcp_banuser_bangroups_group")."\";");
			++$numgroups;
		}
	}

	if($numgroups > 1)
	{
		eval("\$bangroups = \"".$templates->get("modcp_banuser_bangroups")."\";");
	}
	else
	{
		eval("\$bangroups = \"".$templates->get("modcp_banuser_bangroups_hidden")."\";");
	}
replace to:

	$bangroup_option = $bangroups = '';
	$numgroups = 0;
	$groupscache = $cache->read("usergroups");
	$banned_group = 0;

	foreach($groupscache as $key => $group)
	{
		if($group['isbannedgroup'])
		{
			$selected = "";
			if(isset($banned['gid']) && $banned['gid'] == $group['gid'])
			{
				$selected = " selected=\"selected\"";
			}

			$group['title'] = htmlspecialchars_uni($group['title']);
			eval("\$bangroup_option .= \"".$templates->get("modcp_banuser_bangroups_group")."\";");
			$banned_group = $group['gid'];
			++$numgroups;
		}
	}

	if($numgroups > 1)
	{
		eval("\$bangroups = \"".$templates->get("modcp_banuser_bangroups")."\";");
	}
	else
	{
		eval("\$bangroups = \"".$templates->get("modcp_banuser_bangroups_hidden")."\";");
	}

and in install/resources/mybb_theme.xml
find:
<template name="modcp_banuser_bangroups_hidden" version="1800"><![CDATA[<input type="hidden" name="usergroup" value="{$group['gid']}" />]]></template>
Replace to:
<template name="modcp_banuser_bangroups_hidden" version="1801"><![CDATA[<input type="hidden" name="usergroup" value="{$banned_group}" />]]></template>
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/1406

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Do you want to submit those changes as a Pull Request please? Smile
(2014-09-09, 06:13 PM)JordanMussi Wrote: [ -> ]Do you want to submit those changes as a Pull Request please? Smile
https://github.com/mybb/mybb/issues/1408
but the error existing even after the changes.