Rev 1 | Rev 21 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
// add ./include and ./library to the include path
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . __DIR__ . '/include' . PATH_SEPARATOR . __DIR__ . '/library' );
session_start();
if ( ! isset( $_SESSION[ 'app directories' ] ) ) {
/*
* Since this file is in the root of the application, which may not be
* the same as DocumentRoot, we'll get the info from here and make it
* global.
*/
// file system path to root of app
$_SESSION[ 'app directories' ]['file system'][ 'app root' ] = __DIR__;
if(substr($_SESSION[ 'app directories' ]['file system'][ 'app root' ], -1) == '/') {
$_SESSION[ 'app directories' ]['file system'][ 'app root' ] =
substr($_SESSION[ 'app directories' ]['file system'][ 'app root' ], 0, -1);
}
// URL path to root of app
$_SESSION[ 'app directories' ]['url system'][ 'app root' ] = pathinfo( $_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME );
if(substr($_SESSION[ 'app directories' ]['url system'][ 'app root' ], -1) == '/') {
$_SESSION[ 'app directories' ]['url system'][ 'app root' ] =
substr($_SESSION[ 'app directories' ]['url system'][ 'app root' ], 0, -1);
}
// host name
$_SESSION[ 'app directories' ][ 'hostname' ] = $_SERVER[ 'HTTP_HOST' ];
// document root, which may be different from app root
$_SESSION[ 'app directories' ]['file system']['document root'] = realpath( $_SERVER['DOCUMENT_ROOT'] );
if(substr($_SESSION[ 'app directories' ]['file system'][ 'document root' ], -1) == '/') {
$_SESSION[ 'app directories' ]['file system'][ 'document root' ] =
substr($_SESSION[ 'app directories' ]['file system'][ 'document root' ], 0, -1);
}
// document root URL, which is always /
$_SESSION[ 'app directories' ]['url system']['document root' ] = '';
if(substr($_SESSION[ 'app directories' ]['url system'][ 'document root' ], -1) == '/') {
$_SESSION[ 'app directories' ]['url system'][ 'document root' ] =
substr($_SESSION[ 'app directories' ]['url system'][ 'document root' ], 0, -1);
}
// set up our include directories
foreach ( array( '/include', '/library' ) as $toInclude ) {
$_SESSION[ 'includes' ][] = $_SESSION[ 'app directories' ]['file system'][ 'app root' ] . $toInclude;
} // foreach
include_once( 'include/config.php' );
$_SESSION['database']['username'] = $db_username;
$_SESSION['database']['password'] = $db_password;
$_SESSION['database']['name'] = $db_name;
$_SESSION['database']['host'] = $db_hostname;
} // if we have not initialized the session
include_once( 'functions.php' );
include_once( 'Auth.class.php' );
DBQuery::connect( $_SESSION['database'] );
$debug = array();
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
if ( isset( $_REQUEST['login'] ) ) {
$debug[] = 'Inside Login';
$_SESSION["authorization information"] = new Auth( array( 'login page' => $_SERVER['PHP_SELF'] ) );
$debug[] = 'created Auth, values ' . print_r( $_SESSION["authorization information"], true );
if ( $_SESSION["authorization information"]->verifyLogin ( $_REQUEST['password'], $_REQUEST['username'] ) ) {
header ('Location: ' . $_SESSION[ 'app directories' ]['url system']['app root'] );
} // if we logged in
$message = 'Unknown Username or Password';
} // some username was entered
//session_destroy();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Computer Asset Manager - Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" type="text/javascript">
// <!--
// -->
</script>
</head>
<body onload='login.username.focus()'>
<h1 align='center'>Computer Asset Manager</h1>
<h3 align="center">Daily Data, Inc.</h2>
<h2 align='center'>Log In</h2>
<h3 style="color : red; text-align : center;">
<?php
if (isset($message))
print $message;
?>
</h3>
<h3 align='center'>Enter your username and password below</h3>
<form method="POST" enctype="multipart/form-data" name='login'>
<table border="1" cellpadding="2" align="center">
<tbody>
<tr>
<td>User Name</td>
<td><input type='text' name='username' size='10'></td>
</tr>
<tr>
<td>Password</td>
<td><input type='password' name='password' size='10'></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="login" value="Log In">
</td>
</tr>
</tbody>
</table>
</form>
<h4 align='center'>version <?php echo VERSION . '<BR>' . BUILD_DATE; ?></h4>
<?php
print '<pre>';
print implode( "\n", $debug );
print_r( $_SESSION );
print "</pre>";
?>
</body>
</html>