http://www.pastie.org/pastes/2946901/text
[php]
<?php
$data = array();
/*
=======================================================
Password protect page By Relevant:
Password Module
Edit $data variables apart from this_page (auto detects)
Apend this entire script before the Entire page you want to protect
*/
//Access Details
$data["username"] = "Relevant";
$data["password"] = "Password";
//color
$data["background"] ="Grey";
$data["box"] ="GhostWhite";
//Incorrect Details message
$data["error_msg"]="Username or Password was wrong!";
/*
=======================================================
*/
$data[‚this_page‘] = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
if(isset($_POST["fuser"]) && isset($_POST["fpass"]))
{
if($_POST["fuser"]==$data["username"] && $_POST["fpass"]==$data["password"])
{
setcookie("_r_user",$data["username"]);
setcookie("_r_pass",$data["password"]);
}
else
{
die(‚
<body style="background:‘.$data["background"].‘;margin:200px;">
<div style="background:‘.$data["box"].‘;border-style:outset;border-color:black;border-width:1px;padding:20px;text-align:center;">
<p style="color:red">‘.$data["error_msg"].'</p>
<form action="‘.$data["this_page"].’" method="post">
Username: <input type="text" name="fuser" /> <br />
Password: <input type="password" name="fpass" /> <br />
<hr style="width:75%" />
<input type="submit" value="Submit" />
</form>
<span style="color:grey">Protection By Relevant</span>
</div>
</body>
‚);
}
}
else
{
$data["accept"]=false;
if(isset($_COOKIE["_r_user"]) && isset($_COOKIE["_r_pass"]))
{
if($_COOKIE["_r_user"]==$data["username"]&&$_COOKIE["_r_pass"]=$data["password"])
{
$data["accept"]=true;
}
}
else
{
$data["accept"]=false;
}
if(!$data["accept"])
{
die(‚
<body style="background:‘.$data["background"].‘;margin:200px;">
<div style="background:‘.$data["box"].‘;border-style:outset;border-color:black;border-width:1px;padding:20px;text-align:center;">
<form action="‘.$data["this_page"].’" method="post">
Username: <input type="text" name="fuser" /> <br />
Password: <input type="password" name="fpass" /> <br />
<hr style="width:75%" />
<input type="submit" value="Submit" />
</form>
<span style="color:grey">Protection By Relevant</span>
</div>
</body>
‚);
}
}
?>
[/php]