-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.php
More file actions
83 lines (74 loc) · 1.88 KB
/
global.php
File metadata and controls
83 lines (74 loc) · 1.88 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
//session_start(); - commented! use session_start() on the files you want.
function checklogin() {
if( isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] == true ) {
return true;
} else {
return false;
}
}
function notloggedin($customMessage = false) {
if( $customMessage == false ) {
header("Location: /");
die();
} else {
die($customMessage);
}
}
function ShowError($msg) {
header("Location: /?error=" . base64_encode($msg));
die();
}
function ShowSuccess($msg) {
header("Location: /?success=" . base64_encode($msg));
die();
}
function isProxy($ip) {
$d = file_get_contents("https://db-ip.com/" . $ip);
$hosting = false;
$proxy = false;
if(strpos($d, 'Hosting') !== false) {
$hosting = true;
}
if(strpos($d, 'This IP address is used by a proxy') !== false) {
$proxy = true;
}
if( $hosting == true || $proxy == true ) {
return true;
} else {
return false;
}
}
function getUserIP() {
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
?>