[Solved]: How can I ban user by username not IP [Solved]: How can I ban user by username not IP
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: How can I ban user by username not IP

Started by gaoyan528, September 02, 2008, 08:34:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gaoyan528

Hi all, I am using CPG 1.4.x, just thinking how to ban users only by ban the login name not ban the IP address.
Thanks

Nibbler

Go to the banning page, enter the username and click 'add'. What's the problem?

gaoyan528

Sorry, I mean, when a user has been banned. next time, when the banned user log in, system shows a banned mesaage, systems get stuck, and the user can not log off.
So, I would like to know, how can I log off when a banned user loged in.

Thanks

Nibbler

You could skip the ban check for the logout page I suppose. Edit include/init.inc.php, find


// Check if the user is banned
$user_id = USER_ID;
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_BANNED']} WHERE (ip_addr='$raw_ip' OR ip_addr='$hdr_ip' OR user_id=$user_id) AND brute_force=0");
if (mysql_num_rows($result)) {
        pageheader($lang_error);
        msg_box($lang_info, $lang_errors['banned']);
        pagefooter();
        exit;
}
mysql_free_result($result);


And add a check around it like:


if (!defined('LOGOUT_PHP')) {

// Check if the user is banned
$user_id = USER_ID;
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_BANNED']} WHERE (ip_addr='$raw_ip' OR ip_addr='$hdr_ip' OR user_id=$user_id) AND brute_force=0");
if (mysql_num_rows($result)) {
        pageheader($lang_error);
        msg_box($lang_info, $lang_errors['banned']);
        pagefooter();
        exit;
}
mysql_free_result($result);
}

gaoyan528

It works, Thank you so much.

Also, any idea, if I set password to my album, how can I let register user to see my album, and user password to open my album?

Nibbler

Enable config option 'Show private album Icon to unlogged user'.

One question per thread please.

Joachim Müller