-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
189 lines (158 loc) · 10.1 KB
/
install.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/**
* Kontrollbase
*
* An open source MySQL monitoring and analytics application
* ID: $Id$
* @package Kontrollbase
* @author Matt Reid
* @copyright Copyright (c) 2009 Matt Reid, Kontrollbase LLC
* @license http://kontrollsoft.com/kontrollbase/userguide/general-LICENSE.php
* @link http://kontrollbase.com
*/
function head_d($nroot,$syspath,$w_logs,$w_includes,$w_config) {
$d_logs = "$syspath/system/logs";
$d_includes = "$syspath/includes";
$d_config = "$syspath/system/application/config";
if($w_logs == 1) { $w_logs = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
else { $w_logs = '<img src="includes/images/check-red.png" width="16" height="20">'; }
if($w_includes == 1) { $w_includes = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
else { $w_includes = '<img src="includes/images/check-red.png" width="16" height="20">'; }
if($w_config == 1) { $w_config = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
else { $w_config = '<img src="includes/images/check-red.png" width="16" height="20">'; }
print<<<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
<link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
<script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
<script type='text/javascript'>
Ext.onReady(function(){ Ext.Msg.alert('Installation Failure.', '<table><tr><td colspan="2">Directory Check:</td></td></tr><tr><td align="left">$d_logs</td><td align="center">$w_logs</td></tr><tr><td align="left">$d_includes</td><td align="center">$w_includes</td></tr><tr><td align="left">$d_config</td><td align="center">$w_config</td></tr><tr><td colspan="2"> </td></tr><tr><td colspan="2">Directories must be writeable by the webserver user and group</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache includes</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache system/logs</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache system/application/config</td></tr><tr><td colspan="2"> </td></tr><tr><td colspan="2">Run the proper commands, then refresh this screen to continue.</td></tr></table>', function(btn, text){
if (btn == 'ok'){
var redirect = '$nroot/install.php';
window.location = redirect;
}
})});
</script>
</head>
<body>
HEAD;
}
function head_m($nroot,$syspath,$install_sc,$install_sd) {
$sysconfig="system/application/config/config.php";
$sysdatabase="system/application/config/database.php";
if($install_sc == 1) { $install_sc = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
else { $install_sc = '<img src="includes/images/check-red.png" width="16" height="20">'; }
if($install_sd == 1) { $install_sd = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
else { $install_sd = '<img src="includes/images/check-red.png" width="16" height="20">'; }
print<<<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
<link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
<script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
<script type='text/javascript'>
Ext.onReady(function(){
Ext.Msg.alert('Installation Failure.', '<table><tr><td colspan="2">Config files check</td></tr><tr><td>$sysconfig</td><td>$install_sc</td></tr><tr><td>$sysdatabase</td><td>$install_sd</td></tr><tr><td colspan="2">Remove the config files to continue.</td></tr></table>', function(btn, text){
if (btn == 'ok'){
var redirect = '$nroot/install.php';
window.location = redirect;
}
})});
</script>
</head>
<body>
HEAD;
}
function head_i($nroot,$syspath,$d_logs,$d_includes,$d_config) {
$len = ((strlen($syspath)) + 1) ;
$d_logs = substr($d_logs,$len);
$d_includes = substr($d_includes,$len);
$d_config = substr($d_config,$len);
print<<<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
<link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
<script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
<script type='text/javascript'>
Ext.onReady(function(){
Ext.Msg.alert('The Kontrollbase Installer', '<table><tr><td align="left">Config File Check</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_logs:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_includes:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_config:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr></table>', function(btn, text){
if (btn == 'ok'){
var redirect = '$nroot/install/overview.php';
window.location = redirect;
}
})});
</script>
</head>
<body>
HEAD;
}
function dir_writeable($file) {
if(is_writable($file)) {
return 0;
}
else {
return 1;
}
}
function check_install() {
$nroot = $_SERVER['PHP_SELF'];
$server = $_SERVER['SERVER_NAME'];
$nroot = rtrim($nroot, "/install.php");
$syspath = $_SERVER['SCRIPT_FILENAME'];
$syspath = rtrim($syspath, ".php");
$syspath = rtrim($syspath, "/install");
$sysconfig="$syspath/system/application/config/config.php";
$sysdatabase="$syspath/system/application/config/database.php";
// $d_cache = "$syspath/system/cache"; // might want to be checking this too...
$d_logs = "$syspath/system/logs";
$d_includes = "$syspath/includes";
$d_config = "$syspath/system/application/config";
//check to see if config files exist
$install_sc = exists($sysconfig);
$install_sd = exists($sysdatabase);
$w_logs = dir_writeable($d_logs);
$w_includes = dir_writeable($d_includes);
$w_config = dir_writeable($d_config);
if(($install_sc == 0) && ($install_sd == 0) && ($w_logs == 0) && ($w_includes == 0) && ($w_config == 0)) {
head_i($nroot,$syspath,$d_logs,$d_includes,$d_config);
}
elseif(($install_sc == 1) || ($install_sd == 1)) {
head_m($nroot,$syspath,$install_sc,$install_sd);
}
else {
head_d($nroot,$syspath,$w_logs,$w_includes,$w_config);
}
}
function exists($file) {
if (file_exists($file)) {
return 1;
}
else {
return 0;
}
}
check_install();
?>