forked from mana/manaweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
416 lines (354 loc) · 14.1 KB
/
setup.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<?php
/*
* The Mana Server Account Manager
* Copyright 2009 The Mana Project Development Team
*
* This file is part of The Mana Server.
*
* The Mana Server is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or any later version.
*
* The Mana Server is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with The Mana Server; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
define('FCPATH', __FILE__);
require_once 'ext/php-gettext/gettext.inc';
function print_check( $msg, $result, $required="", $state="", $ann="" )
{
echo "
<tr>
<td>$msg</td>
<td>$required</td>
<td>$state</td>
<td width=\"50\" class=\"$result\">" . strtoupper($result) . "</td>
</tr>\n";
if (strlen($ann) > 0)
{
echo "
<tr>
<td colspan=\"3\" style=\"padding-left: 15px;\">$ann</td>
<td> </td>
</tr>\n";
}
ob_flush();
flush();
}
function print_header($name)
{
echo "<tr><td colspan=\"4\" style=\"background-color: #dbbba4;\"><strong>$name</strong></td></tr>\n";
}
function print_message($msg)
{
echo "<tr><td colspan=\"4\"><em>$msg</em></td></tr>\n";
}
function check_file_exists($filename, $annotation="", $vital=true)
{
if (file_exists($filename))
{
print_check( "Checking existence of file <tt>$filename</tt>", "ok" );
return true;
}
else
{
if ($vital) {
print_check( "Checking existence of file <tt>$filename</tt>", "failed", "", "", $annotation );
} else {
print_check( "Checking existence of file <tt>$filename</tt>", "warning", "", "", $annotation );
}
return false;
}
}
function try_read_dir($directory, $annotation="")
{
if (!is_dir($directory))
{
print_check( "Checking existence of directory <tt>$directory</tt>", "failed", "", "",
"<strong><tt>$directory</tt> is not a valid directory.</strong><br />" . $annotation);
return false;
}
try {
scandir($directory);
print_check( "Checking read permissions of directory <tt>$directory</tt>", "ok" );
return true;
} catch(Exception $e)
{
print_check( "Checking read permissions of directory <tt>$directory</tt>", "failed", "", "",
"<strong>The webserver cannot read the contents of the directory <tt>$directoy</tt>. Please check permissions!</strong><br />" . $annotation);
return false;
}
}
function try_write_dir($directory, $annotation="")
{
if (!is_dir($directory))
{
print_check( "Checking existence of directory <tt>$directory</tt>", "failed", "", "",
"<strong><tt>$directory</tt> is not a valid directory.</strong><br />" . $annotation);
return false;
}
try {
// try to create file and write to it
$fp = @fopen($directory."/tempfile.tmp", "w+" );
@fputs($fp, "content");
@fclose($fp);
if (!is_file($directory."/tempfile.tmp"))
{
throw new Exception();
}
@unlink($directory."/tempfile.tmp");
print_check( "Checking write permissions of directory <tt>$directory</tt>", "ok" );
return true;
} catch(Exception $e) {
print_check( "Checking write permissions of directory <tt>$directory</tt>", "failed", "", "",
"<strong>The webserver cannot write to directory <tt>$directory</tt>. Please check permissions!</strong><br />" . $annotation);
return false;
}
}
function run_checks()
{
print_header("Checking technical prerequisits");
// check version of php, should be >= 5.1
if (intval(substr(PHP_VERSION, 0, 1)) < 4)
{
print_check( "checking version of PHP", "failed", ">= 5.1", PHP_VERSION,
"Your installed Version of PHP doesn't match the requirements. ".
"Please update to a least 5.1" );
return;
}
else
{
if (intval(substr(PHP_VERSION, 2, 1)) < 1)
{
print_check( "checking version of PHP", "failed", ">= 5.1", PHP_VERSION,
"Your installed Version of PHP doesn't match the requirements. ".
"Please update to a least 5.1" );
return;
}
else
{
print_check( "checking version of PHP", "ok", ">= 5.1", PHP_VERSION );
}
}
// check existence of config files
print_header("Checking existance of config files");
if (!check_file_exists('system/application/config/config.php',
"This configuration file is the basic configuration of your Account Manager installation and is therefore ".
"vital for any further step. Something is really wrong if you don't have a copy of this file...")) return;
// requiring config file
define('BASEPATH', '.');
require('./system/application/config/config.php');
print_message("File ./system/application/config/config.php loaded.");
if (!check_file_exists('system/application/config/database.php',
"This configuration file determines which database system you are using for manaserv and/or the account manager and ".
"how we can connect to this database. You can find a template for the configuation file called <tt>database.default.php</tt> ".
"in the directory <tt>system/application/config</tt>. Just copy and rename this file to <tt>database.php</tt> and ".
"make your modifications.")) return;
if (!check_file_exists('system/application/config/email.php',
"To be able to send emails to the user, you have to configure which method should be used. ".
"You can find a template for the configuation file called <tt>email.default.php</tt> ".
"in the directory <tt>system/application/config</tt>. Just copy and rename this file to <tt>email.php</tt> and ".
"make your modifications.")) return;
// try to write to directories
print_header("Checking directory permissions");
if (!try_write_dir("./data",
"This directory is used by manaweb to store cached item or map informations, so make sure it is writeable by the webserver.")) return;
// checking wheter a custom logpath is set
if (strlen($config['log_path']) > 0)
{
$logdir = $config['log_path'];
}
else
{
$logdir = "./system/logs";
}
if (!try_write_dir($logdir,
"According to your configured parameter <tt>log_threshold</tt> in the <tt>config.php</tt> file, manaweb will ".
"log debug or error messages to this directory.")) return;
// checking wheter a custom cachepath is set
if (strlen($config['cache_path']) > 0)
{
$cachedir = $config['cache_path'];
}
else
{
$cachedir = "./system/cache";
}
if (!try_write_dir($cachedir,
"To increase performance of page rendering, manaweb is able to cache static content for faster access. The directory " .
"therefore needs to be writeable by the webserver to store caching information.")) return;
// checking mana_options
print_header("Checking manaweb specific configuration.");
require_once('./system/application/config/mana_config.php');
print_message("File ./system/application/config/mana_config.php loaded.");
if (file_exists('./system/application/config/mana_config.user.php'))
{
require_once('./system/application/config/mana_config.user.php');
print_message("File ./system/application/config/mana_config.user.php loaded.");
}
else
{
$msg = "File ./system/application/config/mana_config.user.php not found.";
print_check( $msg, "warning", "", "",
"This file is not vital for running manaweb. But you should use it to configure ".
"individual parameters. If you use the mana_config.php directly, you will have to ".
"be aware during updates." );
}
if ($config['base_url'] == "http://manaweb.example.org")
{
print_check( "parameter <tt>base_url</tt>", "failed", "", "",
"This option is necessary to build correct internal links. Please set this parameter to the correct root of ".
"your manaweb installation. " );
return;
}
else
{
print_check( "parameter <tt>base_url</tt>", "ok" );
}
if (!try_read_dir($config['manadata_path'],
'Manaweb needs a local copy of the clients data directory.'
)) return;
if (!try_read_dir($config['manaserv-data_path'],
'Manaweb needs a local copy of the servers data directory.'
)) return;
print_header("Checking database configuration and connection.");
require_once('./system/application/config/database.php');
if ($db[$active_group]['dbdriver'] != "pdo")
{
print_check( "Used database driver", "failed", $db[$active_group]['dbdriver'], "pdo" );
return;
}
else
{
print_check( "Used database driver", "ok", $db[$active_group]['dbdriver'], "pdo" );
}
if(substr($db[$active_group]['database'], 0, 6) == "sqlite")
{
print_message(" Found sqlite as database backend...");
}
elseif(substr($db[$active_group]['database'], 0, 5) == "mysql")
{
print_message(" Found mysql as database backend...");
}
else
{
print_check( "Used database backend", "failed", $db[$active_group]['database'], "(sqlite|mysql)..." );
return;
}
if(file_exists('data/config_required'))
{
@unlink('data/config_required');
}
print_header( "Setup is complete." );
print_message( "<a href='" . $config['base_url'] . "' title='Continue'>Continue</a> to your installation." );
}
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\" ?>"; ?>
<!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">
<head>
<title>The Mana Source Account Manager</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta http-equiv="Content-Language" content="en"/>
<meta name="description" content="The Mana Server is a free MMORPG game for Linux, MacOS X and Windows"/>
<meta name="keywords" content="The Mana Server, Mana, Mana Source, MMORPG, 2D, RPG, free, GPL"/>
<meta name="author" content="The Mana Server Dev Team"/>
<link rel="shortcut icon" href="./images/icon16.png" type="image/png"/>
<link rel="icon" href="./images/icon16.png" type="image/png"/>
<style type="text/css">
@import url( "data/themes/default/default.css");
</style>
<style type="text/css">
.ok {
font-weight: bold;
color: green;
background-color: #00ff00;
}
.failed {
font-weight: bold;
color: #000000;
background-color: #ff6666;
}
.warning {
font-weight: bold;
color: #000000;
background-color: #ffff66;
}
</style>
</head>
<body>
<a name="top"></a>
<div id="logo"></div>
<div id="page">
<div id="irc_info">
<a href="irc://irc.freenode.net/themanaworld" title="IRC">
#themanaworld<br />
irc.freenode.net
</a>
</div>
<div id="title">
<h1><span>The Mana Server</span></h1>
</div>
<div id="main_topleft">
<div id="main_rightrepeat">
<div id="main_topright">
<div id="main_bottomright">
<div id="main">
<div style="clear: both;"></div>
<div id="sidebar">
<!-- This empty div fixes a rendering issue with IE 7 -->
<div></div>
</div> <!-- /sidebar -->
<div id="contents_leftrepeat">
<div id="contents_topleft">
<div id="contents_bottomleft">
<div id="contents_rightrepeat">
<div id="contents_topright">
<div id="contents_bottomright">
<div id="contents">
<div class="main_title_topright">
<div class="main_title_bottomright">
<div class="main_title_topleft">
<h2>The Mana Server Account Manager - Setup</h2>
</div>
</div>
</div>
<table class="datatable">
<tr>
<th>Action</th>
<th>Required Value</th>
<th>Your value</th>
<th>Success</th>
</tr>
<?php
ob_start();
run_checks();
?>
</table>
<div style="clear: both"></div>
</div> <!-- /contents -->
</div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- /main -->
</div>
</div>
</div>
</div>
<div id="footer">
© 2004-2008 The Mana Server Dev Team -
[<a href="http://validator.w3.org/check?uri=referer">xhtml</a>] [<a href="http://jigsaw.w3.org/css-validator/check/referer">css</a>]
</div>
</div> <!-- /page -->
</body>
</html>