Log in

View Full Version : Need a small modification in this code


00pavan00
10-24-2013, 05:15 AM
The below code sends email to admin when failed login attempt but i am using cloudfare so ia m always getting cloudfare ip . can some one please change the code to get the real ip address of the hacker who tried to login into my account thanku.I am already did these changes
https://support.cloudflare.com/hc/en-us/articles/200170856-How-do-I-restore-original-visitor-IP-with-vBulletin-
But its not working of the plugins i think we need a permanent solution.

/*
By : Ali Madkour
WebSite : http://www.masrawycafe.com/vb/
Contact me @ : http://www.masrawycafe.com/vb/sendmessage.php?langid=1
*/
if($vbulletin->options['madkour_admin_login_fail_onoff'])
{
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$user_ip = $_SERVER['REMOTE_ADDR'];
$madkour_admins = split(',', $vbulletin->options['madkour_admins']);
if (in_array($_POST["vb_login_username"], $madkour_admins))
{
$Madkour_TO = $vbulletin->options['madkour_admin_login_fail_adminmail'];
$message = "
Hello <br>
Someone try to login at " . $vbulletin->options['bbtitle'] ."<br>
username : " . $_POST["vb_login_username"] . "
<br> from IP : " . $user_ip . "<br> Referer : " . $referer ."<br>". $_SERVER['HTTP_USER_AGENT'];
$subject = "Login failure at - " . $vbulletin->options['bbtitle'];
$from_mail = $vbulletin->options['webmasteremail'];
$name = "Login failure Notification";
$mail_headers .= "Content-Type: text/html; charset=\"" . $vbulletin->options['madkour_admin_login_fail_encode'] . "\"\r\n";
$mail_headers .= "From: ". $name ."<" . $from_mail . ">" . "\r\n";
mail($Madkour_TO, $subject, $message, $mail_headers);
if($vbulletin->options['madkour_admin_login_fail_errormsg'] != '')
{
standard_error($vbulletin->options['madkour_admin_login_fail_errormsg']);
}
}
}

squidsk
10-24-2013, 03:18 PM
You can't change the code to accomplish what you want, you need to change your cloudfare setting to pass through the originating IP instead of cloudfare's IPs.