Hello. I wanted to make a php whitelist for my script’s secure. I just started php 1 days ago so i dont know what is wrong with that. Also i need tips to make a limit for IP Changing on a key.
Like people can change 3 times IP in 1 month.
<?php
$keys = array("asadfassafas",);
$ips = array();
$key = $_GET["key"];
$ip = $_SERVER["REMOTE_ADDR"];
$protocol = $_SERVER["SERVER_PROTOCOL"];
$port = $SERVER["REMOTE_PORT"];
if(strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== FALSE) {echo("You cant see this script with MSIE");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Trident") !== FALSE){echo("You cant see this script with Trident");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Firefox") !== FALSE){echo("You cant see this script with Firefox");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Chrome") !== FALSE){echo("You cant see this script with Chrome");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Opera Mini") !== FALSE){echo("You cant see this script with Opera Mini");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Opera") !== FALSE){echo("You cant see this script with Opera");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Safari") !== FALSE){echo("You cant see this script with Safari");}
elseif(strpos($_SERVER["HTTP_USER_AGENT"], "Mozilla") !== FALSE){echo("You cant see this script with Mozilla");}
$proxy_headers = array(
"HTTP_VIA",
"HTTP_X_FORWARDED_FOR",
"HTTP_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_FORWARDED",
"HTTP_CLIENT_IP",
"HTTP_FORWARDED_FOR_IP",
"VIA",
"X_FORWARDED_FOR",
"FORWARDED_FOR",
"X_FORWARDED",
"FORWARDED",
"CLIENT_IP",
"FORWARDED_FOR_IP",
"HTTP_PROXY_CONNECTION"
);
foreach($proxy_headers as $x){
if (isset($_SERVER[$x])) die("Proxys not allowed!");
}
if (in_array($key, $keys, TRUE)) {
if (array_search($key, $keys)) {
if (in_array($key[1], $keys)) if (in_array($key[1], $keys)) == "$ip" {
echo "You are whitelisted.";
} elseif {
if (in_array($key[2], $keys)) >= 3 {
echo "You are not whitelisted.";
} else {
array_push($keys, $key[2] =+ 1);
}
}
{ else {
echo "You are not whitelisted.";
}
}
?>