Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=113)
-   -   [FTS 1.0] Send message to user on login failure (http://www.bvlist.com/showthread.php?t=4179)

elvira 9th January 2010 00:00

[FTS 1.0] Send message to user on login failure
 
First open include/functions.php and look for this line:
Code:

function failedlogins ($type = 'login', $recover = false, $head = true) {
Above this function add the following code:
Code:

function idfromusername ($logusar) {
        $res = sql_query("SELECT id FROM users WHERE username = " . sqlesc($logusar) . " AND status = 'confirmed'");
        $row = mysql_fetch_array($res);             
return $row["id"];
}

Now below that Replace the ENTIRE failedlogins function with this:

EDIT: Updated the function, fixed a minor bug. Be sure to grab the function again.

Code:

function failedlogins ($type = 'login', $recover = false, $head = true) {       
        $p_user = $_POST['username'];
        $p_pass = $_POST['password'];
        if (!$p_pass) {
                $p_pass = "";
        }
        $s_subject = "Failed Login Warning!";
        $ip = sqlesc(getip());
        $added = sqlesc(get_date_time());
        $a = (@mysql_fetch_row(@mysql_query("select count(*) from loginattempts where ip=$ip"))) or sqlerr(__FILE__, __LINE__);
        $msg = "At: " . get_date_time() . ", IP: ". getip() ." tried to log in on your account using the password: " . $p_pass . "";
       
        mysql_query("INSERT INTO messages (poster, sender, receiver, added, msg, subject) VALUES(0, 0, '" . idfromusername($p_user) . "', '" . get_date_time() . "', " . sqlesc($msg) . ", " . sqlesc($s_subject) . ")") or sqlerr(__FILE__, __LINE__);

        if ($a[0] == 0)
                mysql_query("INSERT INTO loginattempts (ip, added, attempts) VALUES ($ip, $added, 1)") or sqlerr(__FILE__, __LINE__);
        else
                mysql_query("UPDATE loginattempts SET attempts = attempts + 1 where ip=$ip") or sqlerr(__FILE__, __LINE__);               
       
        if ($recover)
                mysql_query("UPDATE loginattempts SET type = 'recover' WHERE ip = $ip") or sqlerr(__FILE__, __LINE__);
        if ($type == 'silent')
                return;                               
        elseif ($type == 'login')       
                stderr("Login failed!","Error: Username or password incorrect!Don't remember your password? Click here to recover your password!",false);       
        else
                stderr("Recover Failed",$type,false, $head);
       
}



All times are GMT +2. The time now is 13:42.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.