2013-02-14, 03:58 PM
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
2013-02-14, 05:22 PM
(2013-02-14, 03:58 PM)JordanMussi Wrote: [ -> ]I was under the impression that they wanted to customise what groups can access it.
This is correct, I only want specific usergroups to be able to access the page but I want it to check additional groups and if they are in that group to allow access.
2013-02-14, 05:51 PM
Sorry I misunderstood. Try this:
<?php
global $mybb;
$users_groups = array();
// not a guest . . .
if($mybb->user['uid'] > 0)
{
// add the main group
if($mybb->user['usergroup'])
{
$users_groups[] = (int) $mybb->user['usergroup'];
}
// add any additional groups
if($mybb->user['additionalgroups'])
{
$additional = array();
$additional = explode(",", $mybb->user['additionalgroups']);
if(is_array($additional))
{
// merge the arrays
$users_groups = array_merge($users_groups, $additional);
}
}
}
$access = false;
foreach($users_groups as $this_group)
{
if(in_array($this_group, array(3, 4, 6)) && $this_group != 0 && !empty($users_groups)); // change the group id numbers accordingly
{
$access = true;
}
}
if(!$access)
{
// permission denied
error_no_permission();
}
// continue
?>
2013-02-14, 05:53 PM
(2013-02-14, 05:51 PM)Wildcard Wrote: [ -> ]Sorry I misunderstood. Try this:
<?php global $mybb; $users_groups = array(); // not a guest . . . if($mybb->user['uid'] > 0) { // add the main group if($mybb->user['usergroup']) { $users_groups[] = (int) $mybb->user['usergroup']; } // add any additional groups if($mybb->user['additionalgroups']) { $additional = array(); $additional = explode(",", $mybb->user['additionalgroups']); if(is_array($additional)) { // merge the arrays $users_groups = array_merge($users_groups, $additional); } } } $access = false; foreach($users_groups as $this_group) { if(in_array($this_group, array(3, 4, 6)) && $this_group != 0 && !empty($users_groups)); // change the group id numbers accordingly { $access = true; } } if(!$access) { // permission denied error_no_permission(); } // continue ?>
But where do I add that to the previous code I posted and where to define what groups are allowed to access the page.
2013-02-14, 05:59 PM
Use the following code altogether
<?php
global $headerinclude, $header, $theme, $footer, $lang, $mybb;
$users_groups = array();
// not a guest . . .
if($mybb->user['uid'] > 0)
{
// add the main group
if($mybb->user['usergroup'])
{
$users_groups[] = (int) $mybb->user['usergroup'];
}
// add any additional groups
if($mybb->user['additionalgroups'])
{
$additional = array();
$additional = explode(",", $mybb->user['additionalgroups']);
if(is_array($additional))
{
// merge the arrays
$users_groups = array_merge($users_groups, $additional);
}
}
}
$access = false;
foreach($users_groups as $this_group)
{
if(in_array($this_group, array(3, 4, 6)) && $this_group != 0 && !empty($users_groups)); // change the group id numbers accordingly
{
$access = true;
}
}
if(!$access)
{
// permission denied
error_no_permission();
}
$lang->load('modcp');
$bannedquery = $db->simple_select("banned", "uid, admin, reason, dateline, lifted", "", array("order_by" => 'dateline', "order_dir" => 'DESC'));
if ($db->num_rows($bannedquery) > 0)
{
$bannedtablerows = "";
while ($ban = $db->fetch_array($bannedquery))
{
$banneduser = get_user($ban['uid']);
$banby = get_user($ban['admin']);
if ($ban['lifted'] > 0)
$unbandate = my_date($mybb->settings['dateformat'], $ban['lifted']);
else
$unbandate = $lang->never;
$bannedtablerows .= '<tr>
<td class="trow1">'. build_profile_link($banneduser['username'], $banneduser['uid']). '</td>
<td class="trow1">'. $ban['reason']. '</td>
<td class="trow1">'. build_profile_link($banby['username'], $banby['uid']). '</td>
<td class="trow1">'. my_date($mybb->settings['dateformat'], $ban['dateline']) .'</td>
<td class="trow1">'. $unbandate .'</td>
</tr>';
}
}
else
{
$bannedtablerows = '<tr><td class="trow1" colspan="5" align="center">'. $lang->no_banned .'</td></tr>';
}
$template='<html>
<head>
<title>'.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr><td class="thead" colspan="5"><strong>{$lang->ban_banned}</strong></td></tr>
<tr>
<td class="tcat"><span class="smalltext"><strong>{$lang->username}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->reason}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->ban_bannedby}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->start_date}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->end_date}</strong></span></td>
</tr>
{$bannedtablerows}
</table>
{$footer}
</body>
</html>';
$template=str_replace("\'", "'", addslashes($template));
add_breadcrumb($pages['name']);
eval("\$page=\"".$template."\";");
output_page($page);
2013-02-15, 12:05 AM
Sorry to be a pain but that code lets all groups access the page :/
2013-02-15, 12:26 AM
@Wildcard you do not help me to solve problems that are here community.mybb.com/thread-63357-post-962032.html#pid962032
2013-02-15, 12:39 AM
(2013-01-16, 10:48 AM)SunDi3yansyah Wrote: [ -> ]how to make these URLs
Quote:www.site.com/misc.php?page=contact
could be like this
Quote:www.site.com/contact
Add this rule to .htaccess:
RewriteRule ^contact.*$ misc.php?page=contact [L,QSA,NC]
2013-02-15, 07:58 PM
ouch, sorry @ Wildcard mean I want to call @ querschlaeger to help me solve how to change the URL of the page manager,,, wrong tag
but I am very grateful to you for helping me
but I am very grateful to you for helping me
2013-03-29, 06:49 PM
work contact us