Getting IP address displayed in the registration admin notification message Getting IP address displayed in the registration admin notification message
 

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

Getting IP address displayed in the registration admin notification message

Started by mr5, August 22, 2012, 11:09:43 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

mr5

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

Jeff Bailey

There are a couple of files that need to be edited to accoplish this.

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

Next edit register.php.
Find:
function check_user_info(&$error)
In the global variables add $raw_ip
global $lang_register_user_login, $lang_errors, $raw_ip;

In the same function
Find this twice:

$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );

and replace with:

$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
            '{RAW_IP}'    => $raw_ip,
        );
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford


mr5

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.

Jeff Bailey

Try this.

In lang/english.php
Find:
$lang_register_php['notify_admin_email_body'] = 'A new user with the username "%s" has registered in your gallery';
Change to:
$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
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
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.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

mr5


Jeff Bailey

Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

Happykeppi

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?

Jeff Bailey

Reread the thread, looks like you missed this part.
Quote from: Jeff Bailey on August 24, 2012, 10:48:27 PM
Edit register.php.
Find:
function check_user_info(&$error)
In the global variables add $raw_ip
global $lang_register_user_login, $lang_errors, $raw_ip;

In the same function
Find this twice:

$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );

and replace with:

$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
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford