corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
<?php
$version='0.1';
/*
simple php password authentication..
throw this cade at the top of your page, and
keep a config.php with this in it..
«?php
if (@!$in_admin) die("go away!");
$admin_pass = 'mypassword';
?»
except inside real php tags, of course
there's one in this folder
to use:
simply drop this code into the top of your page
now it is password-protected
note:
if you use the same config.php for many pages,
logging into one will log you into them all. handy.
;o)
(c) corz.org 2004->
*/
$in_admin = true;
require('config.php'); // same folder
//require('/home/www/site999/inc/config.php'); // best kept outside your web tree
/*
you could comment out the above two lines, and just throw your
password inside this file, but the above is smarter. */
//$admin_pass = 'password';
// how we begin..
session_start();
$is_admin = false;
/*
auth checking.. */
if ((@$_SESSION['adminpass'] === md5($admin_pass)) or
(@$_POST['password'] == $admin_pass)) {
$is_admin = true;
$_SESSION['adminpass'] = md5($admin_pass);
}
if (isset($_POST['logout'])) {
$is_admin = false;
unset ($_SESSION['adminpass']); // we'll keep any other settings, though
}
if ($is_admin !== true) {
/*
bad password.. */
if (isset($_POST['password'])) {
die('<br /><br /><br /><span class="big"><strong><center><blink>you are not authorised!</blink></center></strong><!--big--></span>');
}
/*
no password.. */
echo '
<head><title>simple php page authorisation script</title></head>
<body><center><br />
<br />
<code>enter your password to access the page..</code><br />
<br />
<form name="adminform" method=post action="',$_SERVER['SCRIPT_NAME'],'">
<input type="password" size="42" name="password" value=""></form>
</center>';
die();
}
?>
<!-- your page goes here.. -->
<head><title>password accepted!</title></head>
<body bgcolor="#FFA8DE"><br />
<br />
<br /><span class="big"><strong><center><span size="+3" color="#D134C2">welcome to secret pete's secret sex secrets page!</span><br />
<br />
<span color="#982997">or whatever..<br />
;o)</span></center></strong><!--big--></span>
<!-- handy thing for your page, a logout form. -->
<table align="center" width="100%" cellpadding=0 cellspacing=0>
<tr>
<td align="center" width=100 height=200 valign="bottom">
<form name="logout_form" action="" method=post>
<input type="submit" value="logout" name="logout">
</form>
</td>
</tr>
</table>