コード例 #1
0
ファイル: x.php プロジェクト: matexo/Security
    $encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
    $language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    $data = '';
    #$data .= $client_ip;
    #$data .= '</br>';
    $data .= $useragent;
    $data .= '</br>';
    $data .= $accept;
    $data .= '</br>';
    #$data .= $charset;
    #$data .= '</br>';
    $data .= $encoding;
    $data .= '</br>';
    $data .= $language;
    #$data .= '</br>';
    return $data;
}
function getClientIp()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
        if (array_key_exists($key, $_SERVER) === true) {
            foreach (explode(',', $_SERVER[$key]) as $ip) {
                if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
                    return $ip;
                }
            }
        }
    }
}
echo getBrowserFingerprint();
コード例 #2
0
ファイル: login.php プロジェクト: matexo/Security
if ($connection->connect_errno != 0) {
    $_SESSION['loginMessage'] = "Error" . $connection->connect_errno . $connection->connect_error;
} else {
    $login = htmlentities($_POST['login'], ENT_QUOTES, "UTF-8");
    $password = htmlentities($_POST['password'], ENT_QUOTES, "UTF-8");
    if ($result = @$connection->query(sprintf(" SELECT * FROM users WHERE login='******' ", mysqli_real_escape_string($connection, $login)))) {
        if ($result->num_rows > 0) {
            $row = $result->fetch_assoc();
            $login = $row['login'];
            $db_password = $row['password'];
            $counter = $row['counter'];
            $timer = $row['timer'];
            $lasttime = $row['time'];
            $time = date(DATE_RFC822);
            $lastbrowser = $row['browser'];
            $browser = getBrowserFingerprint();
            $result->free_result();
            if (time() - $timer >= 30) {
                $counter = 0;
            }
            if ($counter >= 3) {
                $_SESSION['loginMessage'] = "Blokada logowania poczekaj chwilę";
                header('Location: ../signin.php');
                exit;
            }
            if (testPassword($password, $db_password) == true) {
                $result = @$connection->query(sprintf("UPDATE users SET counter='%d' , timer='%s'  , time='%s'  ,  lasttime='%s'  , browser='%s' , lbrowser='%s' WHERE login='******'", 0, time(), $time, $lasttime, $browser, $lastbrowser, $row['login']));
                $_SESSION['lasttime'] = $lasttime;
                $_SESSION['lastbrowser'] = $lastbrowser;
                $_SESSION['time'] = $time;
                $_SESSION['browser'] = $browser;