-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirm.php
47 lines (37 loc) · 1.13 KB
/
confirm.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
<?php
require_once("connection.php");
$ip = $_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']);
$loginTest = "";
$redirect = false;
if(!empty($_POST['password'])){
$loginTest = crypt($_POST['password'],'P9');
$redirect = true;
} elseif(!empty($_COOKIE['login'])){
$loginTest = $_COOKIE['login'];
}
$loginResult = $db_server->query("SELECT * FROM login");
$loginRow = $loginResult->fetch_assoc();
$ipResult = $db_server->query("SELECT * FROM ip WHERE adress = '".$ip."' ");
if ($ipResult->num_rows != 1){
echo "You are not whitelisted to use this server!";
echo "<br>";
echo $ip;
echo "<br>";
echo "This incident will be recorded!";
$stmt = $db_server->prepare("INSERT INTO logs (adress) VALUES (?)");
$stmt->bind_param('s', $ip);
$stmt->execute();
$stmt->close();
header('Location: login.php?e=1');
}
if($loginTest == $loginRow['password']){
setcookie("login",$loginRow['password']);
// echo "correct";
if ($redirect){
header('Location: index.php');
}
} else {
// echo "incorrect";
header('Location: login.php?e=1');
}
?>