Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
- |
|
2 |
|
- |
|
3 |
// add ./include and ./library to the include path
|
- |
|
4 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . __DIR__ . '/include' . PATH_SEPARATOR . __DIR__ . '/library' );
|
- |
|
5 |
session_start();
|
- |
|
6 |
|
- |
|
7 |
if ( ! isset( $_SESSION[ 'app directories' ] ) ) {
|
- |
|
8 |
/*
|
- |
|
9 |
* Since this file is in the root of the application, which may not be
|
- |
|
10 |
* the same as DocumentRoot, we'll get the info from here and make it
|
2 |
global $loggingIn;
|
11 |
* global.
|
- |
|
12 |
*/
|
- |
|
13 |
// file system path to root of app
|
- |
|
14 |
$_SESSION[ 'app directories' ]['file system'][ 'app root' ] = __DIR__;
|
- |
|
15 |
if(substr($_SESSION[ 'app directories' ]['file system'][ 'app root' ], -1) == '/') {
|
- |
|
16 |
$_SESSION[ 'app directories' ]['file system'][ 'app root' ] =
|
- |
|
17 |
substr($_SESSION[ 'app directories' ]['file system'][ 'app root' ], 0, -1);
|
- |
|
18 |
}
|
- |
|
19 |
// URL path to root of app
|
- |
|
20 |
$_SESSION[ 'app directories' ]['url system'][ 'app root' ] = pathinfo( $_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME );
|
- |
|
21 |
if(substr($_SESSION[ 'app directories' ]['url system'][ 'app root' ], -1) == '/') {
|
- |
|
22 |
$_SESSION[ 'app directories' ]['url system'][ 'app root' ] =
|
- |
|
23 |
substr($_SESSION[ 'app directories' ]['url system'][ 'app root' ], 0, -1);
|
- |
|
24 |
}
|
3 |
$loggingIn = true;
|
25 |
// host name
|
- |
|
26 |
$_SESSION[ 'app directories' ][ 'hostname' ] = $_SERVER[ 'HTTP_HOST' ];
|
- |
|
27 |
// document root, which may be different from app root
|
- |
|
28 |
$_SESSION[ 'app directories' ]['file system']['document root'] = realpath( $_SERVER['DOCUMENT_ROOT'] );
|
- |
|
29 |
if(substr($_SESSION[ 'app directories' ]['file system'][ 'document root' ], -1) == '/') {
|
- |
|
30 |
$_SESSION[ 'app directories' ]['file system'][ 'document root' ] =
|
- |
|
31 |
substr($_SESSION[ 'app directories' ]['file system'][ 'document root' ], 0, -1);
|
- |
|
32 |
}
|
- |
|
33 |
// document root URL, which is always /
|
- |
|
34 |
$_SESSION[ 'app directories' ]['url system']['document root' ] = '';
|
- |
|
35 |
if(substr($_SESSION[ 'app directories' ]['url system'][ 'document root' ], -1) == '/') {
|
- |
|
36 |
$_SESSION[ 'app directories' ]['url system'][ 'document root' ] =
|
- |
|
37 |
substr($_SESSION[ 'app directories' ]['url system'][ 'document root' ], 0, -1);
|
- |
|
38 |
}
|
- |
|
39 |
|
- |
|
40 |
// set up our include directories
|
- |
|
41 |
foreach ( array( '/include', '/library' ) as $toInclude ) {
|
- |
|
42 |
$_SESSION[ 'includes' ][] = $_SESSION[ 'app directories' ]['file system'][ 'app root' ] . $toInclude;
|
- |
|
43 |
} // foreach
|
- |
|
44 |
|
- |
|
45 |
include_once( 'include/config.php' );
|
- |
|
46 |
$_SESSION['database']['username'] = $db_username;
|
- |
|
47 |
$_SESSION['database']['password'] = $db_password;
|
- |
|
48 |
$_SESSION['database']['name'] = $db_name;
|
- |
|
49 |
$_SESSION['database']['host'] = $db_hostname;
|
- |
|
50 |
} // if we have not initialized the session
|
- |
|
51 |
|
- |
|
52 |
include_once( 'functions.php' );
|
4 |
include_once("header.php");
|
53 |
include_once( 'Auth.class.php' );
|
- |
|
54 |
DBQuery::connect( $_SESSION['database'] );
|
- |
|
55 |
|
- |
|
56 |
$debug = array();
|
- |
|
57 |
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
5 |
if ( isset( $_REQUEST['login'] ) ) {
|
58 |
if ( isset( $_REQUEST['login'] ) ) {
|
- |
|
59 |
$debug[] = 'Inside Login';
|
6 |
$_SESSION["authorization information"] = new Auth( array( 'login page' => $_SERVER['PHP_SELF'] ) );
|
60 |
$_SESSION["authorization information"] = new Auth( array( 'login page' => $_SERVER['PHP_SELF'] ) );
|
7 |
if ( $_SESSION["authorization information"]->verifyLogin ( $_REQUEST['login'], $_REQUEST['pass'] ) ) {
|
61 |
$debug[] = 'created Auth, values ' . print_r( $_SESSION["authorization information"], true );
|
8 |
$logginIn = false;
|
- |
|
9 |
$_SESSION['file system root'] = dirname($_SERVER['SCRIPT_FILENAME']);
|
- |
|
10 |
$_SESSION['html root'] = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH));
|
62 |
if ( $_SESSION["authorization information"]->verifyLogin ( $_REQUEST['password'], $_REQUEST['username'] ) ) {
|
11 |
header ('Location: ' . $_SESSION['html root'] );
|
63 |
header ('Location: ' . $_SESSION[ 'app directories' ]['url system']['app root'] );
|
12 |
} // if we logged in
|
64 |
} // if we logged in
|
- |
|
65 |
$message = 'Unknown Username or Password';
|
13 |
} // some username was entered
|
66 |
} // some username was entered
|
- |
|
67 |
//session_destroy();
|
- |
|
68 |
|
14 |
?>
|
69 |
?>
|
15 |
|
70 |
|
16 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
71 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
17 |
<html>
|
72 |
<html>
|
18 |
|
73 |
|
19 |
<head>
|
74 |
<head>
|
20 |
<title>Computer Asset Manager - Login</title>
|
75 |
<title>Computer Asset Manager - Login</title>
|
21 |
<meta name="GENERATOR" content="Quanta Plus">
|
- |
|
22 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
76 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
23 |
<script language="javascript" type="text/javascript">
|
77 |
<script language="javascript" type="text/javascript">
|
24 |
// <!--
|
78 |
// <!--
|
25 |
|
79 |
|
26 |
// -->
|
80 |
// -->
|
27 |
</script>
|
81 |
</script>
|
28 |
</head>
|
82 |
</head>
|
29 |
<body>
|
83 |
<body onload='login.username.focus()'>
|
30 |
<h1 align='center'>Computer Asset Manager</h1>
|
84 |
<h1 align='center'>Computer Asset Manager</h1>
|
31 |
<h4 align='center'>version <?php echo VERSION . '<BR>' . BUILD_DATE; ?></h4>
|
- |
|
32 |
<h3 align="center">Daily Data, Inc.</h2>
|
85 |
<h3 align="center">Daily Data, Inc.</h2>
|
33 |
<h2 align='center'>Log In</h2>
|
86 |
<h2 align='center'>Log In</h2>
|
34 |
<?php if (isset($_REQUEST['message'])) print '<h3 style="color : red; text-align : center;">' . $_REQUEST['message'] . '</h3>'; ?>
|
87 |
<h3 style="color : red; text-align : center;">
|
- |
|
88 |
<?php
|
- |
|
89 |
if (isset($message))
|
- |
|
90 |
print $message;
|
- |
|
91 |
?>
|
- |
|
92 |
</h3>
|
35 |
<h3 align='center'>Enter your username and password below</h3>
|
93 |
<h3 align='center'>Enter your username and password below</h3>
|
36 |
<FORM action="login.html" method="POST" enctype="multipart/form-data">
|
94 |
<form method="POST" enctype="multipart/form-data" name='login'>
|
37 |
<table border="1" cellpadding="2" align="center">
|
95 |
<table border="1" cellpadding="2" align="center">
|
38 |
<tbody>
|
96 |
<tbody>
|
39 |
<tr>
|
97 |
<tr>
|
40 |
<td>User Name</td>
|
98 |
<td>User Name</td>
|
41 |
<td><input type='text' name='login' size='10'></td>
|
99 |
<td><input type='text' name='username' size='10'></td>
|
42 |
</tr>
|
100 |
</tr>
|
43 |
<tr>
|
101 |
<tr>
|
44 |
<td>Password</td>
|
102 |
<td>Password</td>
|
45 |
<td><input type='password' name='pass' size='10'></td>
|
103 |
<td><input type='password' name='password' size='10'></td>
|
46 |
</tr>
|
104 |
</tr>
|
- |
|
105 |
<tr>
|
- |
|
106 |
<td colspan="2" align="center">
|
47 |
<tr><TD colspan="2" align="center"><INPUT type="submit" name="Login" value="Log In"></TD></tr>
|
107 |
<input type="submit" name="login" value="Log In">
|
- |
|
108 |
</td>
|
- |
|
109 |
</tr>
|
48 |
</tbody>
|
110 |
</tbody>
|
49 |
</table>
|
111 |
</table>
|
- |
|
112 |
</form>
|
- |
|
113 |
<h4 align='center'>version <?php echo VERSION . '<BR>' . BUILD_DATE; ?></h4>
|
- |
|
114 |
<?php
|
- |
|
115 |
print '<pre>';
|
- |
|
116 |
print implode( "\n", $debug );
|
- |
|
117 |
print_r( $_SESSION );
|
- |
|
118 |
print "</pre>";
|
50 |
</FORM>
|
119 |
?>
|
51 |
</body>
|
120 |
</body>
|
52 |
</html>
|
121 |
</html>
|