-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip_security.php
More file actions
47 lines (41 loc) · 1.43 KB
/
ip_security.php
File metadata and controls
47 lines (41 loc) · 1.43 KB
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
include('database/db_config.php');
function get_ip() {
$mainIp = '';
if (getenv('HTTP_CLIENT_IP'))
$mainIp = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$mainIp = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$mainIp = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$mainIp = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$mainIp = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$mainIp = getenv('REMOTE_ADDR');
else
$mainIp = 'UNKNOWN';
return $mainIp;
}
$user_ip = get_ip();
$sql = "SELECT * FROM banned_ip WHERE ip_address = '$user_ip'";
$run = mysqli_query($conn, $sql);
$user = $run->fetch_array(MYSQLI_ASSOC);
if (isset($user['ip_address']) && $user['ip_address'] == null) {
// echo 'Success';
$sql_ = "SELECT * FROM user WHERE ip_address = '$user_ip'";
$run_ = mysqli_query($conn, $sql_);
$user_ = $run_->fetch_array(MYSQLI_ASSOC);
if ($user_['ip_address'] == null) {
$sql_ = "INSERT INTO unknown_ip (ip_address) VALUES ('$user_ip')";
$run_ = mysqli_query($conn, $sql_);
} else {
// header('location: https://www.pornhub.com/');
// echo 'error';
}
} else {
header('location: https://www.404.com/');
// echo 'error';
}
?>