forked from cfinke/anyInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.php
executable file
·69 lines (51 loc) · 2.12 KB
/
environment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// Trim all of the global variables
if (is_array($_GET)) foreach($_GET as $key => $value) if (!is_array($_GET[$key])) $_GET[$key] = trim($value);
if (is_array($_POST)) foreach($_POST as $key => $value) if (!is_array($_POST[$key])) $_POST[$key] = trim($value);
$i = 0;
do {
$found = require_once("DB.php");
$i++;
} while ((!$found) && ($i < 10));
require_once($DIR_PREFIX."functions.php");
// $db_type comes from globals.php
if ($db_type == 'oci8'){
$dsn = "oci8://$db_user:$db_pass@$db_name";
} else {
$dsn = "$db_type://$db_user:$db_pass@$db_host/$db_name";
}
$db = connect_to_database();
$query = "SELECT * FROM " . $db->quoteIdentifier('anyInventory_config')."";
$result = $db->query($query);
if (DB::isError($result)) die($result->getMessage().'<br /><br />'.SUBMIT_REPORT . '<br /><br />'. $query);
while ($row = $result->fetchRow()) define($row["key"],$row["value"]);
require_once($DIR_PREFIX."lang/".LANG.".php");
require_once($DIR_PREFIX."category_class.php");
require_once($DIR_PREFIX."field_class.php");
require_once($DIR_PREFIX."item_class.php");
require_once($DIR_PREFIX."file_class.php");
require_once($DIR_PREFIX."alert_class.php");
require_once($DIR_PREFIX."user_class.php");
if (!stristr($_SERVER["PHP_SELF"], "/login") && !stristr($_SERVER["PHP_SELF"], "/docs")){
if ((($DIR_PREFIX == './') && PP_VIEW && !isset($_SESSION["user"]["id"])) ||
(($DIR_PREFIX == '.././') && PP_ADMIN && !isset($_SESSION["user"]["id"]))){
$return_to = $_SERVER["PHP_SELF"]."?";
foreach($_POST as $key => $value) $return_to .= $key . '=' . $value . '&';
foreach($_GET as $key => $value) $return_to .= $key . '=' . $value . '&';
header("Location: ".$DIR_PREFIX."login.php?return_to=".$return_to);
exit;
}
if (PP_VIEW) $view_user = new user($_SESSION["user"]["id"]);
else $view_user = new user(ADMIN_USER_ID);
if (PP_ADMIN){
$admin_user = new user($_SESSION["user"]["id"]);
if (!isset($_SESSION["user"]["id"])){
$admin_user->user_type = 'User';
$admin_user->categories_admin = array();
}
}
else{
$admin_user = new user(ADMIN_USER_ID);
}
}
?>