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