Rev 27 | Blame | Last modification | View Log | Download | RSS feed
<?php
$loggingIn = true;
include( 'header.php' );
global $DEBUG;
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;
$_SESSION['DEBUG']['File Name'] = $debug_file;
$_SESSION['DEBUG']['level'] = $debug_level;
} // if we have not initialized the session
DBQuery::connect( $_SESSION['database'] );
$DEBUG = new DebugFile( $_SESSION['DEBUG']['File Name'], $_SESSION['DEBUG']['level'] );
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
if ( isset( $_REQUEST['login'] ) ) {
$DEBUG->writeLog( 1, 'Inside Login' );
$auth = new Auth( array( 'login page' => $_SERVER['PHP_SELF'], 'logName' => '/tmp/auth.log', 'logLevel' => 5 ) );
$DEBUG->writeLog( 3, 'created Auth, values ' . print_r( $auth, true ) );
$_SESSION['authorization information'] = $auth->verifyLogin ( $_REQUEST['password'], $_REQUEST['username'] );
if ( $_SESSION['authorization information'] ) {
setupSession();
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_r( $DEBUG );
print_r( $_SESSION );
print "</pre>";
?>
</body>
</html>