Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

RevCMS Ban for Arcturus

Custom Title Activated
Member
Joined
Jun 27, 2009
Messages
1,571
Reaction score
170
Hey Y'all...

I'm back working on CMS feature for RevCMS and trying to improve it... So like I'm trying to get the ban function to work on the CMS so when I ban the user it will direct them to banned page.

Now I understand about editing the class.users.php which I have done, but idk if it proper coding for the function.
PHP:
final public function isBanned($value)
	{
		global $engine;
		if($engine->num_rows("SELECT * FROM bans WHERE type = '" . $value . "' LIMIT 1") > 0)
		if($engine->num_rows("SELECT * FROM bans WHERE ip = '" . $value . "' LIMIT 1") > 0)
		{
			return true;
		}
			
		return false;
	}

I bet I'm going to have to place "}" or "{" somewhere guarantee, I have placed around with me but getting syntax error. Unexpected } but everything seem to match.

Now here is the checktheban.php

PHP:
<?php

if($_SESSION['user']['id']){

$getuserinfo = mysql_query("SELECT * FROM users WHERE id='".$_SESSION['user']['id']."'");
while($row = mysql_fetch_array($getuserinfo)){
$usernameban = $row['user_id'];
$ipban = $row['ip'];

}

$getuserinfo= mysql_query("SELECT * FROM bans WHERE user_id='{$usernameban}' AND ban_expire > UNIX_TIMESTAMP() ORDER BY expire DESC LIMIT 1");
$getuserinfoip= mysql_query("SELECT * FROM bans WHERE ip='{$ipban}' AND ban_expire > UNIX_TIMESTAMP() ORDER BY expire DESC LIMIT 1");

while($row = mysql_fetch_array($getuserinfo)){

$expire = $row['ban_expire'];

 if($expire <= time()){ 
 
 } 
 else
 {
header('Location: /banned');
exit;
 }
 }

 while($row = mysql_fetch_array($getuserinfoip)){

$expire = $row['ban_expire'];

 if($expire <= time()){ 
 
 } 
 else
 {
header('Location: /ipbanned');
exit;
 }
 }
 }
 
?>

Can someone please tell me what is going on??
 
Joined
Aug 10, 2011
Messages
7,401
Reaction score
3,299
Code:
        if($engine->num_rows("SELECT * FROM bans WHERE type = '" . $value . "' LIMIT 1") > 0) 
        if($engine->num_rows("SELECT * FROM bans WHERE ip = '" . $value . "' LIMIT 1") > 0)

Is read as:

Code:
        if($engine->num_rows("SELECT * FROM bans WHERE type = '" . $value . "' LIMIT 1") > 0)
        { 
                if($engine->num_rows("SELECT * FROM bans WHERE ip = '" . $value . "' LIMIT 1") > 0) 
                {
                      return true;
                }
         }

What you need is to check a couple things:
Is the user_id banned where the expiretime is greater than now (account ban & superban) => BANNED
Is the current IP banned where the expiretime is greater than now (ipban & superban) => BANNED

These are OR conditions. If either of them is true, then the player is banned.
 
Upvote 0
Custom Title Activated
Member
Joined
Jun 27, 2009
Messages
1,571
Reaction score
170
What you need is to check a couple things:
Is the user_id banned where the expiretime is greater than now (account ban & superban) => BANNED
Is the current IP banned where the expiretime is greater than now (ipban & superban) => BANNED

These are OR conditions. If either of them is true, then the player is banned.

would that be in the checktheban.php? Because as far I can see everything is correct in that page?
 
Upvote 0
Junior Spellweaver
Joined
Sep 12, 2013
Messages
146
Reaction score
66
would that be in the checktheban.php? Because as far I can see everything is correct in that page?

If your using the good old Build 3.2 as an base, then yeah. Checktheban.php checks whether the user has an ban or not and it needs to be included in every single page.
 
Upvote 0
Custom Title Activated
Member
Joined
Jun 27, 2009
Messages
1,571
Reaction score
170
So I need to bump this thread as this is the last part of RevCMS for Arcturus to properly work!

I have inserted the code to work as expected but it's not checking the ban.
 
Upvote 0
Junior Spellweaver
Joined
Jan 28, 2013
Messages
157
Reaction score
104
It's been a very long time since i've played with PHP, but give this a shot. This code should be replacing your checktheban.php page

Code:
[COLOR=#000000][COLOR=#800000]<?php[/COLOR]
[COLOR=#001080]$userID[/COLOR] = ([COLOR=#795e26]isset[/COLOR]([COLOR=#001080]$_SESSION[/COLOR][[COLOR=#a31515]'user'[/COLOR]][[COLOR=#a31515]'id'[/COLOR]])) ? [COLOR=#001080]$_SESSION[/COLOR][[COLOR=#a31515]'user'[/COLOR]][[COLOR=#a31515]'id'[/COLOR]] : [COLOR=#09885a]0[/COLOR];
[COLOR=#001080]$ip[/COLOR] = ([COLOR=#795e26]isset[/COLOR]([COLOR=#001080]$_SERVER[/COLOR][[COLOR=#a31515]"HTTP_CF_CONNECTING_IP"[/COLOR]]) && ![COLOR=#795e26]empty[/COLOR]([COLOR=#001080]$_SERVER[/COLOR][[COLOR=#a31515]"HTTP_CF_CONNECTING_IP"[/COLOR]])) ? [COLOR=#001080]$_SERVER[/COLOR][[COLOR=#a31515]"HTTP_CF_CONNECTING_IP"[/COLOR]] : [COLOR=#001080]$_SERVER[/COLOR][[COLOR=#a31515]"REMOTE_ADDR"[/COLOR]];
[COLOR=#001080]$getBan[/COLOR] = [COLOR=#795e26]mysql_query[/COLOR]([COLOR=#a31515]"[/COLOR][COLOR=#0000ff]SELECT [/COLOR]* [COLOR=#0000ff]FROM[/COLOR][COLOR=#a31515] bans [/COLOR][COLOR=#0000ff]WHERE[/COLOR][COLOR=#a31515] user_id [/COLOR]=[COLOR=#a31515] '{[/COLOR][COLOR=#001080]$userID[/COLOR][COLOR=#a31515]}' [/COLOR][COLOR=#0000ff]OR[/COLOR][COLOR=#a31515] ip [/COLOR]=[COLOR=#a31515] '{[/COLOR][COLOR=#001080]$ip[/COLOR][COLOR=#a31515]}' [/COLOR][COLOR=#0000ff]ORDER BY[/COLOR][COLOR=#a31515] ban_expire [/COLOR][COLOR=#0000ff]DESC [/COLOR][COLOR=#0000ff]LIMIT [/COLOR][COLOR=#09885a]1[/COLOR][COLOR=#a31515]"[/COLOR]);

[COLOR=#af00db]while[/COLOR]([COLOR=#001080]$ban[/COLOR] = [COLOR=#795e26]mysql_fetch_array[/COLOR]([COLOR=#001080]$getBan[/COLOR]))
{
    [COLOR=#af00db]if[/COLOR]([COLOR=#001080]$ban[/COLOR][[COLOR=#a31515]'ban_expire'[/COLOR]] >= [COLOR=#795e26]time[/COLOR]())
    {
        [COLOR=#af00db]if[/COLOR]([COLOR=#001080]$ban[/COLOR][[COLOR=#a31515]'type'[/COLOR]] == [COLOR=#a31515]'account'[/COLOR]) [COLOR=#af00db]die[/COLOR]([COLOR=#795e26]header[/COLOR]([COLOR=#a31515]'Location: /banned'[/COLOR]));

        [COLOR=#af00db]die[/COLOR]([COLOR=#795e26]header[/COLOR]([COLOR=#a31515]'Location: /ipbanned'[/COLOR]));
    }
}
[COLOR=#800000]?[/COLOR][COLOR=#800000]>[/COLOR]
[/COLOR]
 
Upvote 0
Custom Title Activated
Member
Joined
Jun 27, 2009
Messages
1,571
Reaction score
170
it's been a very long time since i've played with php, but give this a shot. This code should be replacing your checktheban.php page

Code:
[color=#000000][color=#800000]<?php[/color]
[color=#001080]$userid[/color] = ([color=#795e26]isset[/color]([color=#001080]$_session[/color][[color=#a31515]'user'[/color]][[color=#a31515]'id'[/color]])) ? [color=#001080]$_session[/color][[color=#a31515]'user'[/color]][[color=#a31515]'id'[/color]] : [color=#09885a]0[/color];
[color=#001080]$ip[/color] = ([color=#795e26]isset[/color]([color=#001080]$_server[/color][[color=#a31515]"http_cf_connecting_ip"[/color]]) && ![color=#795e26]empty[/color]([color=#001080]$_server[/color][[color=#a31515]"http_cf_connecting_ip"[/color]])) ? [color=#001080]$_server[/color][[color=#a31515]"http_cf_connecting_ip"[/color]] : [color=#001080]$_server[/color][[color=#a31515]"remote_addr"[/color]];
[color=#001080]$getban[/color] = [color=#795e26]mysql_query[/color]([color=#a31515]"[/color][color=#0000ff]select [/color]* [color=#0000ff]from[/color][color=#a31515] bans [/color][color=#0000ff]where[/color][color=#a31515] user_id [/color]=[color=#a31515] '{[/color][color=#001080]$userid[/color][color=#a31515]}' [/color][color=#0000ff]or[/color][color=#a31515] ip [/color]=[color=#a31515] '{[/color][color=#001080]$ip[/color][color=#a31515]}' [/color][color=#0000ff]order by[/color][color=#a31515] ban_expire [/color][color=#0000ff]desc [/color][color=#0000ff]limit [/color][color=#09885a]1[/color][color=#a31515]"[/color]);

[color=#af00db]while[/color]([color=#001080]$ban[/color] = [color=#795e26]mysql_fetch_array[/color]([color=#001080]$getban[/color]))
{
    [color=#af00db]if[/color]([color=#001080]$ban[/color][[color=#a31515]'ban_expire'[/color]] >= [color=#795e26]time[/color]())
    {
        [color=#af00db]if[/color]([color=#001080]$ban[/color][[color=#a31515]'type'[/color]] == [color=#a31515]'account'[/color]) [color=#af00db]die[/color]([color=#795e26]header[/color]([color=#a31515]'location: /banned'[/color]));

        [color=#af00db]die[/color]([color=#795e26]header[/color]([color=#a31515]'location: /ipbanned'[/color]));
    }
}
[color=#800000]?[/color][color=#800000]>[/color]
[/color]

omg i love you!
 
Upvote 0
Back
Top