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