-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_pw.php
60 lines (57 loc) · 1.84 KB
/
check_pw.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
//password_hash("rasmuslerdorf", PASSWORD_DEFAULT)
include('funktionen.php');
session_start();
/******************
variablen einholen
******************/
$mysqli=connect();
$user=$_POST["user"];
$password=$_POST["password"];
/******************
validate userdata
******************/
$user= addslashes(strip_tags($user));
$password= addslashes(strip_tags($password));
echo'loading';
/******************
CHECK ip flood
******************/
$ip = get_client_ip();
sql("insert into msg.login_attempts values('$ip',sysdate())",$mysqli);
$result=sql("select * from msg.login_attempts where ip_adress='$ip' and c_date>sysdate()-INTERVAL 1 MINUTE",$mysqli);
$rows_returned = $result->num_rows;
if($rows_returned>10){
sql("insert into msg.blocklist values('$ip','ip_flood detected')",$mysqli);
}
$result=sql("select * from msg.blocklist where ip='$ip'",$mysqli);
$rows_returned = $result->num_rows;
if($rows_returned==0){
$result=sql("select * from msg.login where name='$user'",$mysqli);//binary= case sensitive password
$rows_returned = $result->num_rows;
if($rows_returned>0){
$row = $result->fetch_object();
$DBPW= $row ->password;
$user_id=$row ->user_id;
/******************
verify password
******************/
if ($user !== false && password_verify($password, $DBPW)) {
$_SESSION['userid'] = $user_id;
$_SESSION['ip']=$ip;
sql("insert into msg.logbuch (`user`,`ip_address`, `time`, `type`) values($user_id, '$ip', sysdate(),'log in')",$mysqli);
if(isset($_GET['fwd'])){
weiterleiten('/'.addslashes(strip_tags($_GET['fwd'])));
}else{
weiterleiten('main.php');
}
} else {
echo "User oder Passwort war ungültig<br>";
weiterleiten('index.php?failed=j');
}
}else{
echo "User oder Passwort war ungültig<br>";
weiterleiten('index.php?failed=j');
}
}
?>