Hey,
I was looking through some users release packs and helping people out and saw some terrible ways of checking bans, so I thought I'd have ago to see if I can do a better one, and I think I have. I only used what Rev has built in by default for us.
This check will be put in two places, one place for users that are NOT logged in that will check IP bans and tell them the reason if necessary, and the other checking both username and IP bans.
Step 1: IP Bans only.
Step 2: User and IP Bans.
Step 3: Show the ban!
And that should be it, a quick thing to note the checker will check by username and not user ID, as I cannot remember if Phoenix checked via username or ID, I prefer ID (personally) but yeah simple to change this to user ID checking just edit '$_SESSION['user']['username']' to '$_SESSION['user']['id']'.
- Thanks.
I was looking through some users release packs and helping people out and saw some terrible ways of checking bans, so I thought I'd have ago to see if I can do a better one, and I think I have. I only used what Rev has built in by default for us.
This check will be put in two places, one place for users that are NOT logged in that will check IP bans and tell them the reason if necessary, and the other checking both username and IP bans.
Step 1: IP Bans only.
1) Open up app/class.core.php
2) Find 'final public function handleCall($k)'.
3) Under 'if(!isset($_SESSION['user']['id'])) {' add the following:
Done!
2) Find 'final public function handleCall($k)'.
3) Under 'if(!isset($_SESSION['user']['id'])) {' add the following:
PHP:
if ($k != "index")
{
if($users->isBanned($_SERVER['REMOTE_ADDR']) == true)
{
$banReason = $users->getReason($_SERVER['REMOTE_ADDR']);
session_destroy();
header("Location: index.php?url=index&reason={$banReason}");
exit;
}
}
Done!
1) Open up app/class.core.php
2) This might be harder for some users as they may of removed the last IP check, so you will have to find the else to the if statement, or search for 'switch($k)' (not the first one, the second one).
3) If you searched for 'switch($k)' then add the following snippet ABOVE that.
Done!
2) This might be harder for some users as they may of removed the last IP check, so you will have to find the else to the if statement, or search for 'switch($k)' (not the first one, the second one).
3) If you searched for 'switch($k)' then add the following snippet ABOVE that.
PHP:
if ($k != "index")
{
if($users->isBanned($_SESSION['user']['username']) == true || $users->isBanned($_SERVER['REMOTE_ADDR']) == true)
{
$banReason = "";
if($users->isBanned($_SESSION['user']['username']) == true)
$banReason = $users->getReason($_SESSION['user']['username']);
else
$banReason = $users->getReason($_SERVER['REMOTE_ADDR']);
session_destroy();
header("Location: index.php?url=index&reason={$banReason}");
exit;
}
}
Done!
And now, the final part (I couldn't think of an easier way so I just made a new, if you would 'error checking' part, on the index now even if you have a different skin you should ALL have this on the index.
1) Open up app/tpl/skins/YOURSKIN/index.php
2) Find 'if(isset($template->form->error))' and just BELOW '<?php } ?>' add the following:
Done!
1) Open up app/tpl/skins/YOURSKIN/index.php
2) Find 'if(isset($template->form->error))' and just BELOW '<?php } ?>' add the following:
PHP:
<?php if(isset($_GET['reason']) && $_GET['reason'] != null) { ?>
<div id="loginerrorfieldwrapper">
<div id="loginerrorfield">
<div><?php echo 'You have been banned for: '.filter($_GET['reason']); ?></div>
</div>
</div>
<?php } ?>
Done!
And that should be it, a quick thing to note the checker will check by username and not user ID, as I cannot remember if Phoenix checked via username or ID, I prefer ID (personally) but yeah simple to change this to user ID checking just edit '$_SESSION['user']['username']' to '$_SESSION['user']['id']'.
- Thanks.