Subversion Repositories computer_asset_manager_v2

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 rodolico 1
<?php
20 rodolico 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
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
      }
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' );
53
   include_once( 'Auth.class.php' );
54
   DBQuery::connect( $_SESSION['database'] );
55
 
56
   $debug = array();
57
   $message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
1 rodolico 58
   if ( isset( $_REQUEST['login'] ) ) {
20 rodolico 59
      $debug[] = 'Inside Login';
1 rodolico 60
      $_SESSION["authorization information"] = new Auth( array(  'login page' => $_SERVER['PHP_SELF'] ) );
20 rodolico 61
      $debug[] = 'created Auth, values ' . print_r( $_SESSION["authorization information"], true );
62
      if ( $_SESSION["authorization information"]->verifyLogin ( $_REQUEST['password'], $_REQUEST['username'] ) ) {
63
         header ('Location: ' . $_SESSION[ 'app directories' ]['url system']['app root'] );
1 rodolico 64
      } // if we logged in
20 rodolico 65
      $message = 'Unknown Username or Password';
1 rodolico 66
   } // some username was entered
20 rodolico 67
   //session_destroy();
68
 
1 rodolico 69
?>
70
 
71
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
72
<html>
73
 
74
<head>
75
  <title>Computer Asset Manager - Login</title>
76
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
77
  <script language="javascript" type="text/javascript">
78
  // <!--
79
 
80
  // -->
81
  </script>
82
</head>
20 rodolico 83
   <body onload='login.username.focus()'>
84
      <h1 align='center'>Computer Asset Manager</h1>
85
      <h3 align="center">Daily Data, Inc.</h2>
86
      <h2 align='center'>Log In</h2>
87
      <h3  style="color : red; text-align : center;">
88
      <?php 
89
         if (isset($message)) 
90
            print $message; 
91
      ?>
92
      </h3>
93
      <h3 align='center'>Enter your username and password below</h3>
94
      <form method="POST" enctype="multipart/form-data" name='login'>
95
         <table border="1" cellpadding="2" align="center">
96
            <tbody>
97
               <tr>
98
                  <td>User Name</td>
99
                  <td><input type='text' name='username' size='10'></td>
100
               </tr>
101
               <tr>
102
                  <td>Password</td>
103
                  <td><input type='password' name='password' size='10'></td>
104
               </tr>
105
               <tr>
106
                  <td colspan="2" align="center">
107
                     <input type="submit" name="login" value="Log In">
108
                  </td>
109
               </tr>
110
            </tbody>
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>";
119
      ?>
120
   </body>
1 rodolico 121
</html>