Page 5 of 6

Posted: Thu Jun 08, 2006 10:21 am
by Merlin Sythove
chris3471 wrote: So what happens if you ban someone and then they delete their cookies?


Asked and answered

try to make some free CPU cycles

Posted: Thu Jul 06, 2006 10:27 am
by deadjdona
If you want to make this mod little faster try to change

Code: Select all

 //Set the ban_cookie, time it for 1 year. The time restarts every time the user comes here 
    if ($banned_ip) setcookie($board_config['cookie_name'].'_banned_ip',$banned_ip, time()+365*24*3600); 
    if ($banned_id) setcookie($board_config['cookie_name'].'_banned_id',$banned_id, time()+365*24*3600); 
365 * 24 * 3 600 = 31 536 000

:lol:

Posted: Thu Jul 06, 2006 11:42 am
by Merlin Sythove
Yes theoretically you are right. However, we're dealing with a once-only calculation and the time it takes to send the finished html over the net is thousands times slower than this calculation. So I've opted to keep it very clear and the main reason: easy to change without having to figure out what the number means...

Posted: Sat Aug 05, 2006 11:33 am
by maxklm
Where still changes?

Posted: Wed Aug 23, 2006 6:15 am
by Sassy
Hi,

Do you think you can show me how to install your mod while I have Temp Banned mod install as well.

http://phpbbmodders.com/mods/tempban/tempban_1.1.1.txt

By the way, this is a cool mod as well.
:)

Posted: Wed Aug 23, 2006 6:57 am
by Merlin Sythove
Sassy wrote: Hi,

Do you think you can show me how to install your mod while I have Temp Banned mod install as well.

http://phpbbmodders.com/mods/tempban/tempban_1.1.1.txt

By the way, this is a cool mod as well.
:)


Thanks.

To install, just follow the instructions. If you run into conflicts, you may have a think whether you need both mods or one of them is enough.

Posted: Sun Sep 10, 2006 10:26 am
by EzerchE
i am not soo good as php but i change the codes for bantron mod available:

Code: Select all

  //START MOD Ban_cookie
  //Give banned users a cookie and check that too, in addition to the existing checks.
  //Once the cookie is in place: if it matches the database, the user is banned,
  //even if the user gets another IP or is not logged in so the user ID is unknown.

  //Get cookie ban settings.
  $ban_cookie = '';
  $banned_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'].'_banned_id']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'].'_banned_id'] : '';
  $banned_ip = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'].'_banned_ip']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'].'_banned_ip'] : '';
 
  //Yes, cookie ban settings were there. See if they match the database.
  //If not, delete cookie.
  if ($banned_ip || $banned_id)
  {
    $sql = "SELECT *
       FROM " . BANLIST_TABLE . "
        WHERE ";
      $sql .= ($banned_ip) ? " ban_ip = '" . $banned_ip . "'" : '';
      $sql .= ($banned_id) ? ($banned_ip ? ' OR ' : '') . ' ban_userid = ' . $banned_id : '';
     if ( !($result = $db->sql_query($sql)) )
     {
        message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
     }
     if ( $ban_info = $db->sql_fetchrow($result) )    
    {
      $ban_cookie =  ( $ban_info['ban_ip'] || $ban_info['ban_userid'] && ((isset ($ban_info['ban_expire_time']) && $ban_info['ban_expire_time'] >= time ()) || !isset ($ban_info['ban_expire_time'])) );
     }
    //There was a cookie but no match in the database, so the ban is lifted:
    //delete the cookie by setting the expiry time 1 hour ago   
    if (! $ban_cookie)
    {
      if ($banned_ip) setcookie($board_config['cookie_name'].'_banned_ip',$banned_ip, time()-3600);
      if ($banned_id) setcookie($board_config['cookie_name'].'_banned_id',$banned_id, time()-3600);
     }
  }   
  //Have $ban_cookie, if not empty, the user is banned via a cookie.
  //If empty, then there was no cookie, or there was no LONGER a database match so the cookie was deleted

  //Check if there is database ban info - this is roughly the original ban code
  $ban_database = '';
   $sql = "SELECT *
      FROM " . BANLIST_TABLE . "
      WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')
         OR ban_userid = $user_id";
   if ( $user_id != ANONYMOUS )
   {
      $sql .= " OR ban_email LIKE '" . str_replace("\'", "''", $userdata['user_email']) . "'
         OR ban_email LIKE '" . substr(str_replace("\'", "''", $userdata['user_email']), strpos(str_replace("\'", "''", $userdata['user_email']), "@")) . "'";
   }
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
   }
   if ( $ban_info = $db->sql_fetchrow($result) )    
  {
    $ban_database = ( $ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email'] && ((isset ($ban_info['ban_expire_time']) && $ban_info['ban_expire_time'] >= time ()) || !isset ($ban_info['ban_expire_time']))  );
    //Fill these variables from database if not filled from cookie yet
    if (! $banned_ip) $banned_ip = $ban_info['ban_ip'];
    if (! $banned_id) $banned_id = $ban_info['ban_userid'];    
  }
 
  //User is banned in some way?
  if ($ban_cookie || $ban_database)
  {
    //Set the ban_cookie, time it for 1 year. The time restarts every time the user comes here
    if ($banned_ip) setcookie($board_config['cookie_name'].'_banned_ip',$banned_ip, time()+365*24*3600);
    if ($banned_id) setcookie($board_config['cookie_name'].'_banned_id',$banned_id, time()+365*24*3600);
     //Close the forum to this person
			if ($ban_info['ban_pub_reason_mode'] == '0' || !isset ($ban_info['ban_pub_reason_mode'])) {
				$reason = 'You_been_banned';
			} else if ($ban_info['ban_pub_reason_mode'] == '1') {
				$reason = str_replace ("\n", '<br />', stripslashes ($ban_info['ban_priv_reason']));
			} else if ($ban_info['ban_pub_reason_mode'] == '2') {
				$reason = str_replace ("\n", '<br />', stripslashes ($ban_info['ban_pub_reason']));
			}
				
			message_die(CRITICAL_MESSAGE, $reason);
  }
  //END MOD Ban_cookie 


Posted: Sun Dec 31, 2006 8:50 am
by Ghost_dk1
would it be possible to combine this mod with some sort of "must allow cokie to register" mod?

Posted: Sun Dec 31, 2006 9:10 am
by Merlin Sythove
Of course you can always check if there is a standard cookie set, and if not, deny access to the forum. And add a line to your registration screen explaining this.

Posted: Sun Dec 31, 2006 10:44 am
by igorw
Merlin Sythove, are there any plans of submitting this to the moddb?

Posted: Sun Dec 31, 2006 10:59 am
by Merlin Sythove
No, I don't have the time to do that. If someone else wants to invest time and effort in this respect, please get in touch.

Posted: Mon Jan 01, 2007 2:02 am
by Ramon Fincken
evil<3 , will you prepare it for submittal or will I :) ?

Posted: Tue Mar 06, 2007 6:27 pm
by lele710
Hi,
nice mod but...
i want another function in that...

I want that a specific user cannot be banned...

How can i do this?


Thanks

Posted: Tue Mar 06, 2007 6:45 pm
by igorw
lele710 wrote: Hi,
nice mod but...
i want another function in that...

I want that a specific user cannot be banned...

How can i do this?


Thanks


Start a new topic in the MOD request forums...

Posted: Tue Mar 06, 2007 7:15 pm
by lele710
eviL<3 wrote:
lele710 wrote:Hi,
nice mod but...
i want another function in that...

I want that a specific user cannot be banned...

How can i do this?


Thanks


Start a new topic in the MOD request forums...


Ok.

New topic is here