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