Subversion Repositories computer_asset_manager_v2

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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'] ) {
20 rodolico 66
         header ('Location: ' . $_SESSION[ 'app directories' ]['url system']['app root'] );
1 rodolico 67
      } // if we logged in
20 rodolico 68
      $message = 'Unknown Username or Password';
1 rodolico 69
   } // some username was entered
21 rodolico 70
   session_destroy();
20 rodolico 71
 
1 rodolico 72
?>
73
 
74
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
75
<html>
76
 
77
<head>
78
  <title>Computer Asset Manager - Login</title>
79
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
80
  <script language="javascript" type="text/javascript">
81
  // <!--
82
 
83
  // -->
84
  </script>
85
</head>
20 rodolico 86
   <body onload='login.username.focus()'>
87
      <h1 align='center'>Computer Asset Manager</h1>
88
      <h3 align="center">Daily Data, Inc.</h2>
89
      <h2 align='center'>Log In</h2>
90
      <h3  style="color : red; text-align : center;">
91
      <?php 
92
         if (isset($message)) 
93
            print $message; 
94
      ?>
95
      </h3>
96
      <h3 align='center'>Enter your username and password below</h3>
97
      <form method="POST" enctype="multipart/form-data" name='login'>
98
         <table border="1" cellpadding="2" align="center">
99
            <tbody>
100
               <tr>
101
                  <td>User Name</td>
102
                  <td><input type='text' name='username' size='10'></td>
103
               </tr>
104
               <tr>
105
                  <td>Password</td>
106
                  <td><input type='password' name='password' size='10'></td>
107
               </tr>
108
               <tr>
109
                  <td colspan="2" align="center">
110
                     <input type="submit" name="login" value="Log In">
111
                  </td>
112
               </tr>
113
            </tbody>
114
         </table>
115
      </form>
116
      <h4 align='center'>version <?php echo VERSION . '<BR>' . BUILD_DATE; ?></h4>
117
      <?php
118
         print '<pre>';
21 rodolico 119
         print_r( $DEBUG );
20 rodolico 120
         print_r( $_SESSION );
121
         print "</pre>";
122
      ?>
123
   </body>
1 rodolico 124
</html>