-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
119 lines (97 loc) · 3.32 KB
/
config.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/* NOTE! User configuration is now added in `config.local.php`. See
* `config.default.php` for help. */
require('config.default.php');
if ( file_exists('config.local.php') ){
require('config.local.php');
}
if ( substr($root, 0, 1) != '/' ) $root = "/$root"; /* force leading slash */
if ( substr($root, -1, 1) != '/' ) $root = "$root/"; /* force trailing slash */
$index = $root . 'index.php';
$ajax = $root . 'ajax.php';
function expand_path($value){
global $prefix, $sysconfdir, $localstatedir;
$path = str_replace(array('{PREFIX}', '{SYSCONFDIR}', '{LOCALSTATEDIR}'),
array($prefix, $sysconfdir, $localstatedir),
$value);
if ( substr($path, -1) != "/" ) $path .= '/'; /* force trailing slash */
return $path;
}
/* expand paths */
if ( substr($prefix, -1) != "/" ) $prefix .= '/'; /* force trailing slash */
$sysconfdir = expand_path($sysconfdir);
$localstatedir = expand_path($localstatedir);
$rrdbase = expand_path($rrdbase);
$cachedir = expand_path($cachedir);
$version = "0.7.1";
$dbversion = 7;
/* store config errors, if count() != 0 the config errorpage is shown */
$config_error = array();
/* Check for all required extensions */
foreach ( array('posix', 'mysqli', 'gd') as $ext ){
if ( !extension_loaded($ext) ){
$config_error[] = array('message' => "Required PHP extension '$ext' not loaded.");
}
}
/* required for BasicObject */
$db = @new mysqli($DB_SERVER, $user, $password, $DATABASE);
define('HTML_ACCESS', 1);
if ( mysqli_connect_error() ){
$config_error[] = array(
"message" => "Unable to connect to MySQL database.",
"error" => mysqli_connect_error(),
);
}
/* required for legacy database connections */
$Connect = mysqli_connect($DB_SERVER, $user, $password,$DATABASE);
/* mysqli_select_db($DATABASE,$Connect); */
if ( isset($skip_config_check) ){
return;
}
$groupname = $usergroup;
$usergroup = posix_getgrnam($groupname);
$groupinfo = posix_getpwuid(posix_geteuid());
$max_size=1000000;
$sql_update="SELECT * FROM guiconfig WHERE selected=1";
$result=mysqli_query($db, $sql_update);
if(!$result) {
print "MySQL error: " . mysqli_error($db);
exit;
}
if(mysqli_num_rows($result)>0) {
$row = mysqli_fetch_array($result);
$pageStyle=$row["pageStyle"];
$pageStyleBad=$row["pageStyleBad"];
$projectName=$row["projectName"];
$selectedID=$row["id"];
} else { // PRoblems. Use some default
$pageStyle="";
$pageStyleBad="";
$projectName='MArCd';
$selectedID=-1;
}
$result = mysqli_query($Connect, "SELECT 1 FROM `information_schema`.`tables` WHERE `table_schema` = '$DATABASE' AND `table_name`='version' LIMIT 1");
if ( mysqli_num_rows($result) == 1 ){
} else {
$config_error[] = array(
"message" => "MySQL schema too old, please upgrade using upgrade/v0.7.1.php (and subsequential files in order) in a shell.",
"error" => "version too old",
);
}
$result = mysqli_query($Connect, "SELECT `num` FROM `version` LIMIT 1");
$row = mysqli_fetch_array($result);
if ( $row[0] < $dbversion ){
$config_error[] = array(
"message" => "MySQL schema too old, please execute all upgrade scripts under upgrade/*.php in a shell.",
"error" => "version too old",
"current" => $row[0],
"required" => $dbversion,
);
}
if ( count($config_error) > 0 ){
if ( $_SERVER['REQUEST_URI'] != "{$root}config_error.php" ){
header("Location: {$root}config_error.php");
exit;
}
}
?>