forked from habari/tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequirements.php
262 lines (228 loc) · 7.64 KB
/
requirements.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
define('MIN_PHP_VERSION', '5.2.0');
// Required extensions, this list will augment with time
// Even if they are enabled by default, it seems some install turn them off
// We use the URL in the Installer template to link to the installation page
$required_extensions = array(
'date' => 'http://php.net/datetime',
'pdo' => 'http://php.net/pdo',
'hash' => 'http://php.net/hash',
'json' => 'http://php.net/json',
'mbstring' => 'http://php.net/mbstring',
'pcre' => 'http://php.net/pcre',
'session' => 'http://php.net/session',
'simplexml' => 'http://php.net/simplexml',
'spl' => 'http://php.net/spl',
'tokenizer' => 'http://php.net/tokenizer',
);
$requirements_met = true;
/* Check versions of PHP */
$php_version_ok = version_compare(phpversion(), MIN_PHP_VERSION, '>=');
/* If the version isn't ok, there's no point going any further*/
if (! $php_version_ok) {
$requirements_met = false;
}
else {
/* Check for required extensions */
$missing_extensions = array();
foreach ($required_extensions as $ext_name => $ext_url) {
if (!extension_loaded($ext_name)) {
$missing_extensions[$ext_name] = $ext_url;
$requirements_met = false;
}
}
if ( extension_loaded('pdo') ) {
/* Check for PDO drivers */
$pdo_drivers = PDO::getAvailableDrivers();
if ( ! empty( $pdo_drivers ) ) {
$pdo_drivers = array_combine( $pdo_drivers, $pdo_drivers );
// Include only those drivers that we include database support for
$pdo_schemas = array( 'mysql', 'pgsql', 'sqlite' );
$pdo_drivers = array_intersect(
$pdo_drivers,
$pdo_schemas
);
$pdo_missing_drivers = array_diff(
$pdo_schemas,
$pdo_drivers
);
}
$pdo_drivers_ok = count( $pdo_drivers );
if ( ! $pdo_drivers_ok ) {
$requirements_met = false;
}
if ( $requirements_met && ! preg_match( '/\p{L}/u', 'a' ) ) {
$requirements_met = false;
}
}
else {
$pdo_drivers_ok = false ;
$pdo_drivers = array();
$requirements_met = false;
}
/**
* $local_writable is used in the template, but never set in Habari
* Won't remove the template code since it looks like it should be there
*
* This will only meet the requirement so there's no "undefined variable" exception
*/
$local_writable = true ;
}
/*return $requirements_met;*/
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<meta name="robots" content="no index,no follow">
<title>Habari Requirements Check</title>
<style type="text/css">
body {
font-family: Helvetica Neue, Helvetica, Arial, Sans-Serif;
padding: 0;
margin: 0;
}
#installer {
text-align: center;
min-width: 600px;
background: #f1f1f1;
}
a {
color: #999;
}
#wrapper {
width: 552px;
margin: 0 auto 50px;
}
#masthead {
margin: 30px 0;
}
#masthead h1 {
font-size: 35px;
line-height: 35px;
color: #333;
margin-bottom: 0px;
text-transform: lowercase;
}
#masthead p {
font-size: 11px;
text-transform: lowercase;
color: #666;
margin: 0px;
}
#sitename {
font-weight: bold;
}
#footer a {
font-size: 11px !important;
text-transform: lowercase;
color: #999;
padding: 0 3px;
}
#footer a:hover {
color: #666;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
</style>
</head>
<body id="installer">
<div id="wrapper">
<?php $tab = 1; ?>
<div id="masthead">
<h1>Habari</h1>
<div id="footer">
<p class="left"><a href="http://wiki.habariproject.org/" title="Read the Habari wiki" tabindex="<?php echo $tab++ ?>">Wiki</a> ·
<a href="http://groups.google.com/group/habari-users" title="Ask the community" tabindex="<?php echo $tab++ ?>">Mailing List</a>
</p>
</div>
</div>
<?php if ( $requirements_met == false ) { ?>
<div id="header">
<h1>Before you install <em>Habari</em>...</h1>
</div>
<?php if (! $php_version_ok) { ?>
<h2>PHP Upgrade needed...</h2>
<p class="instructions">
<em>Habari</em> <?php echo('requires PHP 5.2 or newer. Your current PHP version is ' . phpversion()); ?>
</p>
<strong>@todo Upgrading PHP instructions</strong>
<?php } else { ?>
<?php /* This whole chunk can probably be removed */ ?>
<?php if (! $local_writable == true ) {?>
<h2>Writable directory needed...</h2>
<?php if (PHP_OS != 'WIN') {?>
<p class="instructions">
Before you can install Habari, you first need to make the install directory writable by php, so that the installation script can write your configuration information properly. The exact process depends on the web server and the ownership of the directory.
</p>
<p>
If your web server is part of the group which owns the directory, you'll need to add group write permissions to the directory. The procedure for this is as follows:
</p>
<ol>
<li>
Open a terminal window, and then change to the installation directory:
<pre><strong>$></strong> cd <i>/path/to/habari/</i></pre>
</li>
<li>
Change the <em>mode</em> (permissions) of the current directory:
<pre><strong>$></strong> chmod g+w .</pre><br />
<pre><strong>$></strong> chmod g+x .</pre>
<p class="note">
<em>Note</em>: You may need to use <strong>sudo</strong> and enter an administrator password if you do not own the directory.
</p>
</li>
</ol>
<p>
If the web server is not part of the group which owns the directory, you will need to <strong>temporarily</strong> grant world write permissions to the directory:
</p>
<ol>
<li>
<pre><strong>$></strong> chmod o+w .</pre><br />
<pre><strong>$></strong> chmod o+x .</pre>
</li>
</ol>
<p>
<strong>Be sure to remove the write permissions on the directory as soon as the installation is completed.</strong>
</p>
<?php } else {?>
<strong>@todo Windows instructions</strong>
<?php }?>
<?php }?>
<?php if (! empty($missing_extensions)) {
foreach ($missing_extensions as $ext_name => $ext_url) {
$missing_ext_html[]= '<a href="' . $ext_url . '">' . $ext_name . '</a>';
}
$missing_ext_html = implode( ', ', $missing_ext_html );
?>
<h2>Missing Extensions</h2>
<p class="instructions">
<em>Habari</em> requires the following PHP extensions to be installed: <?php echo $missing_ext_html; ?>. Please contact your web hosting provider if you do not have access to your server.
</p>
<?php }?>
<?php if ( extension_loaded( 'pcre' ) && ! preg_match( '/\p{L}/u', 'a' ) ) { ?>
<h2>Unicode support needed...</h2>
<p class="instructions">
<em>Habari</em> requires PHP's PCRE extension to have Unicode support enabled. Please contact your web hosting provider if you do not have access to your server.
</p>
<?php } ?>
<?php if ( ! $pdo_drivers_ok && ! array_key_exists( 'pdo', $missing_extensions ) ) { ?>
<h2>No PDO drivers enabled</h2>
<p class="instructions"><em>Habari</em> requires that at least one <a href="http://www.php.net/pdo">PDO driver</a> be installed. Please ask your hosting provider to enable one of the PDO drivers supported by Habari.</p>
<?php } ?>
<?php } ?>
<?php } else { ?>
<div id="header">
<h1>Your system is ready for Habari!</h1>
</div>
<ul>
<li>Download the <a href="http://www.habariproject.org/en/download">latest stable version of Habari</a></li>
<li>View the <a href="http://wiki.habariproject.org/en/Installation#Installing_Habari">installation instructions</a></li>
<li>Get <a href="http://webchat.freenode.net/?randomnick=1&channels=habari">live help</a></li>
</ul>
<?php } ?>
</div><!-- end wrapper -->
</body>
</html>