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