rendered paste body<?php
//this php is allowed to execute other includes
define( '_VALID_CALL', 1 );
require_once( 'config.php' );
require_once( 'lib/database.php' );
require_once( 'lib/template.php' );
require_once( 'index.html.php' );
// FORM INPUTS
$userTbl = array();
$user = secure( $_POST['user'] );
$pass = secure( $_POST['pass'] );
session_start();
if( $_POST['action'] == "logout" ){
$_SESSION = array();
}
// HANDLES authentication attempt
if( (($user != NULL) || ($pass != NULL)) && !$_SESSION['authed'] ){
$query = "SELECT *"
. " FROM `users`"
. " WHERE `user` = $user"
. " AND `pass` = PASSWORD('$pass')";
$result = mysql_query($query);
if($result != NULL){
if($userTbl = mysql_fetch_array($result, MYSQL_ASSOC)){
$_SESSION['authed'] = true;
$_SESSION['userTbl'] = $userTbl;
}
}
}
// HANDLES active session
if ( $_SESSION['authed'] ){
$userTbl = $_SESSION['userTbl'];
}
// logged-in page
if( $_SESSION['authed'] ){
index_html::mainPage();
}
// not logged-in page
else {
index_html::frontPage();
}
function secure($data) {
return preg_replace("'[\041-\100]|[\133-\140]|[\173-\176]'", '', $data);
}
?>