forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: mr5 on August 22, 2012, 11:09:43 am

Title: Getting IP address displayed in the registration admin notification message
Post by: mr5 on August 22, 2012, 11:09:43 am
Hi, couldn't find the answer to that.
Lately some (probably unwanted) users have registered into my gallery. I would like to compare their IP addresses. For that it would be very useful to add IP address to the notification msg, like: "A new user with the username "nn" (IP=xxxxx) has registered in your gallery". 
Thanks
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: Jeff Bailey on August 24, 2012, 10:48:27 pm
There are a couple of files that need to be edited to accoplish this.

First edit your lang file. ie: lang/english.php
Find:
Code: [Select]
$lang_register_approve_email = <<< EOTadd
Code: [Select]
IP: {RAW_IP}wherever you want inside of the heredoc, the EOT tags.

Next edit register.php.
Find:
Code: [Select]
function check_user_info(&$error)In the global variables add $raw_ip
Code: [Select]
global $lang_register_user_login, $lang_errors, $raw_ip;
In the same function
Find this twice:
Code: [Select]
$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );
and replace with:
Code: [Select]
$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
            '{RAW_IP}'    => $raw_ip,
        );
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: mr5 on August 28, 2012, 08:23:08 am
Thanks a lot Jeff !!!  http://forum.coppermine-gallery.net/Smileys/default/smiley.gif
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: mr5 on August 28, 2012, 07:36:41 pm
Sorry to come back to this. The fix probably works when registration needs admin approval. But in my case the admin does not have to approve and it looks that we don't reach $lang_register_approve_email = <<< EOT line.
Thanks.
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: Jeff Bailey on August 28, 2012, 09:23:19 pm
Try this.

In lang/english.php
Find:
Code: [Select]
$lang_register_php['notify_admin_email_body'] = 'A new user with the username "%s" has registered in your gallery';Change to:
Code: [Select]
$lang_register_php['notify_admin_email_body'] = 'A new user with the username "%s" with an IP of %s has registered in your gallery';
In register.php (the same function as the last post function check_user_info(&$error))
Find
Code: [Select]
cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_register_php_def['notify_admin_email_body'], $user_name));replace with
Code: [Select]
cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_register_php_def['notify_admin_email_body'], $user_name, $raw_ip));
make sure you leave $raw_ip in the functions global varabiles.
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: mr5 on August 29, 2012, 08:30:12 am
 :) Thanks Jeff, bot cases work!
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: Jeff Bailey on August 29, 2012, 09:11:01 pm
Glad it worked for you. Please resolve your thread.
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270631.html#msg270631
Title: Re: Getting IP address displayed in the registration admin notification message
Post by: Happykeppi on September 28, 2012, 01:06:44 pm
Sorry to bump this thread, but I'm interested in the same feature and made the above mentioned edits to the corresponding files (language files / register.php). Unfortunately, it's not working as it should since the variable for the ip address isn't resolved and I only see "IP: {RAW_IP}" (in plain text) in the confirmation message. Has anyone an idea what goes wrong here?
Title: Re: Re: Getting IP address displayed in the registration admin notification message
Post by: Jeff Bailey on September 28, 2012, 09:06:20 pm
Reread the thread, looks like you missed this part.
Edit register.php.
Find:
Code: [Select]
function check_user_info(&$error)In the global variables add $raw_ip
Code: [Select]
global $lang_register_user_login, $lang_errors, $raw_ip;
In the same function
Find this twice:
Code: [Select]
$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );
and replace with:
Code: [Select]
$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
            '{RAW_IP}'    => $raw_ip,
        );

Please start your own threads and post a link in the future.
http://forum.coppermine-gallery.net/index.php?index.php/topic,55415.0.html