<?php
/*
* buzzword
* Copyright (c) 2003 Jon Tai
*
* $Id: index.php 267 2004-03-31 03:14:55Z bradt $
*
* This file is part of buzzword.
*
* buzzword is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* buzzword is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with buzzword; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once './config.inc';
// credentials were supplied
if (get_request_var('admin-login')) {
// check password
if (md5(get_request_var('password')) == ADMIN_PASSWORD) {
// generate token
$token = md5(uniqid(mt_rand(),TRUE));
// store token in server session
$_SESSION['token'] = $token;
// store token in client cookie
setcookie('token', $token, 0, '/');
}
// refresh page
header('Location: index.php?l=1');
exit;
}
// logout was requested
if (get_request_var('admin-logout')) {
// destroy session
session_destroy();
setcookie(ini_get('session.name'), '', (time() - 3600), '/');
// destroy token cookie
setcookie('token', '', (time() - 3600), '/');
// refresh page
header('Location: index.php');
exit;
}
include_once '../includes/header.inc';
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td id="content">
<?php
if (defined('ADMIN_LOGGED_IN')) {
?>
<h1>logged in</h1>
<div class="content-container">
<p>administration mode has been enabled.</p>
</div>
<?php
} else {
?>
<h1>log in</h1>
<div class="content-container">
<p><?php
echo (!empty($_REQUEST['l'])) ?
'incorrect password.':
'you must log in to continue.';
?></p>
<form name="login" method="post" action="index.php">
<input type="hidden" name="admin-login" value="1">
<input type="password" name="password">
<input type="submit" value="log in" class="submit">
</form>
<script language="JavaScript" type="text/javascript">document.login.password.focus();</script>
</div>
<?php
}
?>
</td>
</tr>
</table>
<?php
include_once '../includes/footer.inc';
?>