Parašė avice· 2011 Geg. 10 20:05:34
#19
maniskis toks :
<?php
$adminuser = "demo";
$adminpass = "demo";
function page_protect() {
session_start();
if (isset($_SESSION['HTTP_USER_AGENT']))
{
if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT']))
{
unset($_SESSION['authuser']);
session_destroy();
unset($_SESSION['HTTP_USER_AGENT']);
header("Location: index.php");
exit;
}
}
}
function loginpage($error) {
echo "<form action='" . $_SERVER['REQUEST_URI'] . "' method='post'>
<div align='center'>
<input class='login' type='text' name='username' id='username' /></div>
<div align='center'><input class='login' type='password' name='password' id='password'></div>
<div align='center'><input class='migtukas' type='submit' value=' Login » ' name='login'></div>";
exit;
}
$username = $_POST['username'];
$password = $_POST['password'];
$login = $_POST['login'];
session_start();
if($_SERVER['QUERY_STRING'] == "logout") {
unset($_SESSION['authuser']);
session_destroy();
unset($_SESSION['HTTP_USER_AGENT']);
header("Location: index.php");
exit;
}
if($_SESSION['authuser'] != $adminuser) {
if(!$login) {
loginpage(false);
}
elseif(($username != $adminuser) || ($password != $adminpass)) {
loginpage(true);
}
else {
$_SESSION['authuser'] = $adminuser;
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
header("Location: " . $_SERVER['REQUEST_URI']);
}
}
function iMEMBER() {
if ($_SESSION['authuser'] == $adminuser) {
return 1;
} else { return 0 ;
}
}
session_write_close();
?>
kiekviename puslapije dejau:
<?php
include "login.php";
page_protect();
?>