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
36 rodolico 2
   $VERSION='2.0a';
3
   $BUILD_DATE='20181118';
4
   $DB_REQUIRED_VERSION = '0.1';
45 rodolico 5
   include_once( dirname(__FILE__) . '/include/functions.php');
6
   global $configuration;
36 rodolico 7
   $error = '';
1 rodolico 8
 
45 rodolico 9
   $configStuff = loadConfig();
10
   if ( $configStuff['error'] ) {
11
      print $configStuff['error'];
12
      die;
13
   } else {
14
      $configuration = $configStuff['configuration'];
15
      $configPath = $configStuff['path'];
16
      unset( $configStuff );
17
   }
18
 
19
   // get include directories for libraries
20
   foreach ( $configuration['locations']['include_dirs'] as $dir ) {
21
      ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $dir );
22
   }
23
 
24
   //print "<pre>configuration\n" . print_r( $configuration, true ) . '</pre>'; die ;
36 rodolico 25
   //print_r( ini_get('include_path') ); die;
45 rodolico 26
   //print "<pre>\n" . yaml_emit($configuration, true) . '</pre>'; die;
36 rodolico 27
 
45 rodolico 28
   include_once( 'UsersPermissions.class.php' );
29
   include_once( 'UsersPermissionsDataSourceMySQLi.class.php' );
36 rodolico 30
   include_once( 'DBQuery.class.php' );
45 rodolico 31
   include_once( 'functions.php' );
32
 
33
   // since we are storing some user defined classes in the session, session
34
   // MUST be started after the class definitions are loaded
35
   session_start();
36
 
36 rodolico 37
   // make the database connection
38
   $dbVersion = '';
45 rodolico 39
   $dbConnection = new DBQuery( $configuration['database']['dbserver'],$configuration['database']['dbusername'], $configuration['database']['dbpassword'], $configuration['database']['dbname'] );
36 rodolico 40
   if ( $dbConnection->connect_errno ) {
41
      $error = "Failed to connect to MySQL: (" . $dbConnection->connect_errno . ") " . $dbConnection->connect_error;
42
   } else {
43
      $dbVersion = $dbConnection->getOneDBValue( "select key_value from _system where group_name = 'database' and key_name = 'version'" );
21 rodolico 44
   }
20 rodolico 45
 
45 rodolico 46
   //print "<pre>\nSession" . print_r($configuration,true) . '</pre>';
47
 
36 rodolico 48
 
45 rodolico 49
   // create a connection for the Users class
50
   global $connection;
51
   $connection = new usersPermissionsDataSourceMySQLi( 
52
         $dbConnection,
53
         $configuration['customUsersFields']
54
      );
55
   // if they are not logged in, set up for logging in
56
   if ( ! isset( $_SESSION['user'] ) ) { 
57
      $_SESSION['user'] = new UsersPermissions( $configuration['customUsersFields'] );
58
   }
36 rodolico 59
 
45 rodolico 60
 
61
   // check if the user has request a log out.
62
   if ( isset( $_REQUEST['logout'] ) )
63
      $_SESSION['user']->logout();
36 rodolico 64
   //Setup our HTML header here.
65
   if(!isset($page_title)) { $page_title = "Untitled"; }
45 rodolico 66
   // set up our "here I am" variable
67
   $url = htmlentities($configuration['locations']['base_url'] . '/' . $configuration['locations']['main_script'] );
68
   $baseURL = htmlentities($configuration['locations']['base_url'] );
69
 
36 rodolico 70
?>
45 rodolico 71
 
36 rodolico 72
<html>
42 rodolico 73
   <head>
74
      <title><?php echo $page_title;?></title>
75
      <script language="javascript"> 
76
         function eToggle(anctag,darg) {
77
            var ele = document.getElementById(darg);
78
            var text = document.getElementById(anctag);
79
            if(ele.style.display == "block") {
80
               ele.style.display = "none";
81
               text.innerHTML = "Show " + darg;
82
            } else {
83
               ele.style.display = "block";
84
               text.innerHTML = "Hide " + darg;
85
            }
86
         } 
87
      </script>
88
      <link type="text/css" rel="stylesheet" href="style.css">
89
      <link rel="stylesheet" type="text/css" href="camp.css">
90
   </head>
91
   <body>
45 rodolico 92
 
42 rodolico 93
      <div id="titleimage">
94
         <h1>
95
            Computer Asset Management Program 
96
         </h1>
97
         <h2>
98
            Version <?php print "$VERSION, $BUILD_DATE"; ?>
99
         </h2>
100
      </div>
101
      <?php
102
         if ( $error ) {
103
            print "<h1>Serious Error encountered</h1><p>$error</p>";
104
            die($error);
105
         }
106
         if ( $dbVersion != $DB_REQUIRED_VERSION ) {
107
            print "<h1><b>Warning</b>: Database is version $dbVersion, but requires version $DB_REQUIRED_VERSION. Repair immediately</h1>";
108
            die;
109
         }
110
      ?>
111
      <div class='login'>
112
         <?php
45 rodolico 113
            if ( isset( $_SESSION['user'] ) ) {
114
               print $_SESSION['user']->HTML($connection);
42 rodolico 115
            }
116
         ?>
117
      </div>
45 rodolico 118
 
119