IP Checker plugin problem

xryskom

Member
I have plugin DuplicateServerChecker ,
We set it up for new registrations and for usercp_edit_process_form

array_push($form_validate, validate_db_duplicate('title', mb_strtolower($TMPL['title']), array('LOWER(title)')));
array_push($form_validate, validate_db_duplicate('url', mb_strtolower($TMPL['url']), array('LOWER(url)')));
array_push($form_validate, validate_db_duplicate('acf_gameserver_ip', mb_strtolower($TMPL['acf_gameserver_ip']), array('LOWER(acf_gameserver_ip)')));
array_push($form_validate, validate_db_duplicate('acf_loginserver_ip', mb_strtolower($TMPL['acf_loginserver_ip']), array('LOWER(acf_loginserver_ip)')));

the problem is that even if users DO NOT edit these rows while trying to edit free-to-edit rows , they get an error for acf_gameserver_ip' and acf_loginserver_ip .

anything we can do about it ?
 

cajkan

Active Member
This plugin checks if user (server ) already registered ?

If thats so, what if im owner of google, and some fake user already submited google ?
 

xryskom

Member
this plugin check if the IP adress is already registered...i took it from here and just i changed abit like i posted
 

Basti

Administrator
Staff member
The issue is, that that method you have there is for join page. You cant take it as it is for the edit, as the function simply checks the db for duplicates, regardless of the member.

So, what you basicly need to do is surround those array push with a check to see if they edited the value or not.

Something like this might work ( untested )
1) that url check you shouldnt need. That is in the core already

2) If you run VL 1.3 you dont need those "LOWER" and "mb_strtolower", that has been added to the function itself since 1.3
Code:
$myusername_check = $DB->escape($FORM['myusername'], 1);

list($title_check, $gameserver_check, $loginserver_check) = $DB->fetch("SELECT title, acf_gameserver_ip, acf_loginserver_ip FROM {$CONF['sql_prefix']}_sites WHERE username = '{$myusername_check}'", __FILE__, __LINE__);

if ($title_check != $TMPL['title']) {
    array_push($form_validate, validate_db_duplicate('title', $TMPL['title'], array('title')));
}
if ($gameserver_check != $TMPL['acf_gameserver_ip']) {
    array_push($form_validate, validate_db_duplicate('acf_gameserver_ip', $TMPL['acf_gameserver_ip'], array('acf_gameserver_ip')));
}
if ($loginserver_check != $TMPL['acf_loginserver_ip']) {
    array_push($form_validate, validate_db_duplicate('acf_loginserver_ip', $TMPL['acf_loginserver_ip'], array('acf_loginserver_ip')));
}
It is a tad complicated, but this should do it. Vl 2.0 will handle this differently where you specify user id's to ignore the check on, but that wont work with the coding and db setup of the current visiolist
 
Top