if (file_exists("settings.php"))
{
include("settings.php");
$path = "";
}
else if (file_exists("../settings.php"))
{
include("../settings.php");
$path = "../";
}
else if (file_exists("../../settings.php"))
{
include("../../settings.php");
$path = "../../";
}
else
{
echo "Can't find settings.php!";
exit;
}
$logout_page = "$path$logout_page";
$login_page = "$path$login_page";
$invalidlogin_page = "$path$invalidlogin_page";
if (!isset($action))
$action = "";
if (!isset($pwd))
$pwd = "";
if (!isset($loginpwd))
$loginpwd = "";
if (!isset($loginuser))
$loginuser = "";
if (!isset($loginname))
$loginname = "";
if (!isset($password))
$password = "";
if ($registerglobal == 0)
{
$loginname = $_REQUEST['loginname'];
$password = $_REQUEST['password'];
$action = $_REQUEST['action'];
$loginpwd = $_COOKIE['loginpwd'];
$loginuser = $_COOKIE['loginuser'];
if (!isset($PHP_SELF))
$PHP_SELF = $_SERVER['PHP_SELF'];
if (!isset($HTTP_HOST))
$HTTP_HOST = $_SERVER['HTTP_HOST'];
}
if ($action == "logout")
{
Setcookie("loginpwd","",(time() - ($expirecookie * 3600)), $CookiePath, $CookieDomain);
Setcookie("loginuser","",(time() - ($expirecookie * 3600)), $CookiePath, $CookieDomain);
include($logout_page);
exit;
}
else if ($action == "login")
{
if (($loginname == "") || ($password == ""))
{
include($invalidlogin_page);
exit;
}
else if (strcmp($user_passwords[$loginname],$password) == 0)
{
Setcookie("loginpwd",$password,time() + ($expirecookie * 3600), $CookiePath, $CookieDomain);
Setcookie("loginuser",$loginname,time() + ($expirecookie * 3600), $CookiePath, $CookieDomain);
}
else
{
include($invalidlogin_page);
exit;
}
}
else if ($action == "file")
{
$p = explode("A",$p);
$time = substr(time(),-8,8);
// $pa = ($p[1] / 2 - 3093) * 100;
$pa = ($p[1] / 39) * 100;
$timeprotection = (($p[2] / 2428) - $FileProtection);
if ($timeprotection == 0)
$timeprotection = 900;
else
$timeprotection = $timeprotection * 60 * 60;
// echo "time: $time
timeprotection: $timeprotection
pa: $pa
p[2]: $p[2]
p[1]: $p[1]";
// exit;
if ((($time + $timeprotection) > $pa) && ($pa > ($time - $timeprotection)))
{
$type = substr($file,-3,3);
if (file_exists("$hiddendirectory/$file"))
{
if (filesize("$hiddendirectory/$file") < 10500)
{
if ($type == "php")
{
echo "$file not found on this server";
exit;
}
else if ($type == "zip" || $type == "exe" || $type == ".gz" || $type == "tar")
$contenttype = "Content-Type: application/$type\nContent-Disposition: attachment; filename=$file";
else if ($type == "jpg" || $type == "gif" || $type == "tif" || $type == "peg" || $type == "bmp" || $type == "iff" || $type == "png")
$contenttype = "Content-Type: image/$type";
else if ($type == "mp3" || $type == "mpg" || $type == "wav" || $type == "mid" || $type == "idi")
$contenttype = "Content-Type: sound/$type";
else
$contenttype = "Content-Type: application/$type\nContent-Disposition: attachment; filename=$file";
Header($contenttype);
$intBytesRead = readfile("$hiddendirectory/$file");
exit;
}
else
{
echo "$file is larger than 10Kb and this version of File Protection doesn't support files larger than 10Kb. To have support for large files, please visit our website and upgrade to the full version.";
exit;
}
}
else
{
echo "$file not found on this server";
// include($invalidlogin_page);
exit;
}
}
else
{
include($invalidlogin_page);
exit;
}
exit;
}
else
{
if (($loginpwd == "") || ($loginuser == ""))
{
include($login_page);
exit;
}
else if (strcmp($user_passwords[$loginuser],$loginpwd) == 0)
{
Setcookie("loginpwd",$loginpwd,time() + ($expirecookie * 3600), $CookiePath, $CookieDomain);
Setcookie("loginuser",$loginuser,time() + ($expirecookie * 3600), $CookiePath, $CookieDomain);
}
else
{
include($invalidlogin_page);
exit;
}
}
function fileprotect($filename,$timeprotection)
{
// $time = substr(time(),-8,6) + 3093 * 2;
$time = substr(time(),-8,6) * 39;
$timeprotection = ($timeprotection + $FileProtection) * 2428;
$url = 'index.php?action=file&p=1957DE2A'. $time .'A'. $timeprotection .'A'. ($time * 9) .'&file='. $filename;
return $url;
}
?>