Location: PHPKode > projects > PHPSiteStats > phpsitestats/inc.login.php
<?php

//logged in code
if (!isset($_POST['do_login']) && !isset($_GET['do_logout']) && isset($_SESSION['logged'])) {
	echo "<b>Logged in : </b><a href=index.php?do_logout=yes>(logout)</a><br>";
}
//login code
if (isset($_POST['pass']) && !isset($_SESSION['logged'])) {
                if ($cfg_pass == $_POST['pass']){
		echo "<img src=gfx/ico_yes.gif align=absmiddle> Login was succesfull.<br>";
		$_SESSION['logged'] = "logged_in";
                } else {
		echo "<p>&nbsp;</p><img src=gfx/ico_warn.gif align=absmiddle> Login failed.<br>";
		die;
		}
}
//login form
if (!isset($_SESSION['logged']) && !isset($_GET['do_logout']) && !isset($_GET['do_login'])) {
		echo "<p>&nbsp;</p>
		<form action='index.php' method='post'>
		<img src=gfx/ico_notice.gif align=absmiddle> Please login with admin pass<br>
		<input class=input class=td type='password' name='pass'>
		<input class=input type='submit' name='login' value='Login'>
		</form>
		";
		die;
}
//logout code
if (isset($_GET['do_logout'])){
	if (session_destroy()) {
		echo "<p>&nbsp;</p><img src=gfx/ico_yes.gif align=absmiddle> You are logged out...<br>";
		$_SESSION = array();
		die;
	} else {
		echo "<p>&nbsp;</p><img src=gfx/ico_warn.gif align=absmiddle> Error logging out<br>";
		die;
	}
}
//any other case
if (!isset($_SESSION['logged'])) {
    die;
}


?>

<p>&nbsp;</p>
Return current item: PHPSiteStats