-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.php
202 lines (180 loc) · 7.4 KB
/
installer.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
<?php
/*
|--------------------------------------------------------------------------
| Statamic is a PHP Application
|--------------------------------------------------------------------------
|
| If you see this text, your server is not running PHP. You'll need to
| contact your system administrator, webhost, or Google to enable it,
| or maybe try a different host.
|
*/
$success = true;
/*
|--------------------------------------------------------------------------
| Error Reporting
|--------------------------------------------------------------------------
|
| Let's crank up that error reporting to catch the edge cases.
|
*/
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| Requirements and recommendations
|--------------------------------------------------------------------------
|
| Let's take a look under the hood.
|
*/
$requirements = [
'PHP >= 5.5.9' => version_compare(PHP_VERSION, '5.5.9', '>=')
? ['s' => true, 't' => PHP_VERSION. ' ✔']
: ['s' => false, 't' => PHP_VERSION.' ✘'],
'OpenSSL PHP Extension' => extension_loaded('openssl'),
'Mbstring PHP Extension' => extension_loaded('mbstring'),
'Tokenizer PHP Extension' => extension_loaded('tokenizer')
];
$recommendations = [
'Mod Rewrite' => hasModRewrite('mod_rewrite')
? ['s' => true, 't' => 'Pass']
: ['s' => false, 't' => 'Unknown*'],
'Timezone Set' => ini_get('date.timezone') !== '',
'GD Library for image manipulation' => (extension_loaded('gd') && function_exists('gd_info')),
'Memory Limit at least 256M' => strpos(ini_get('memory_limit'), 'G') !== false || ini_get('memory_limit') >= 256
? ['s' => true, 't' => ini_get('memory_limit')]
: ['s' => false, 't' => ini_get('memory_limit')],
'FileInfo Extension for image manipulation' => extension_loaded('fileinfo'),
'Zip archive support for updater backups' => class_exists('ZipArchive')
];
// PHP 5.6 does a stupid deprecation warning that breaks things. It needs to be disabled.
if (version_compare(PHP_VERSION, '7.0.0', '<') && version_compare(PHP_VERSION, '5.6.0', '>=')) {
$requirements['always_populate_raw_post_data=-1'] = ini_get('always_populate_raw_post_data') === '-1';
}
foreach ($requirements as $item) {
if (! $item) {
$success = false;
break;
}
}
function hasApacheModule($module)
{
if (function_exists('apache_get_modules')) {
return in_array($module, apache_get_modules());
}
return false;
}
function hasModRewrite()
{
$check = hasApacheModule('mod_rewrite');
if (! $check && function_exists('shell_exec')) {
$check = strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false;
}
return $check;
}
function url($url)
{
$url = pathinfo($_SERVER['SCRIPT_NAME'])['dirname'] . '/index.php' . $url;
// Convert backslashes - generated by Windows paths - to forward
// slashes, since PHP understands forward slashes on Windows.
$url = str_replace('\\', '/', $url);
return str_replace('//', '/', $url);
}
/*
|--------------------------------------------------------------------------
| The moment of truth
|--------------------------------------------------------------------------
|
| Let's see how you went...
|
*/
?>
<!doctype html>
<head>
<meta charset="utf-8" />
<title>Statamic</title>
<link href="//fonts.googleapis.com/css?family=Lato:700,400,400italic,700italic" rel="stylesheet" />
<style>
body { width: 555px; margin: 0 auto; font: normal 14px/1.42 "Lato", sans-serif; background: url(<?= url("/_resources/cp/img/blurry.jpg"); ?>) top center no-repeat fixed; background-size: cover; padding-top: 75px; }
.logo { width: 100px; display: block; fill: rgba(0, 0, 0, .3); margin: 0 auto 50px; }
.card { background: white; border-radius: 2px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.24); margin: 0 auto; }
h1 { font: normal 21px/1.1 "Lato", sans-serif; padding: 15px 30px; margin: 0; }
table { width: 100%; border-collapse: collapse; }
tr { border-top: 1px solid #e0e0e0; }
td { padding: 10px 30px; }
td.result { text-align: right; }
th { text-align: left; padding: 30px 30px 10px 30px; }
th small { display: block; font-weight: normal; color: #777; }
p { text-align: center; }
.fail { color: #E75650; font-weight: bold; }
.asterisk { margin: 20px auto 0; font-size: 11px; }
.install { font-size: 20px; text-decoration: none; display: block; margin-top: 20px; padding: 10px 20px; background: #3aa3e3; color: white; border-radius: 3px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.24); }
.fail-message { font-size: 20px; background: #E75650; color: white; padding: 10px 20px; border-radius: 3px; }
</style>
</head>
<body>
<div class="logo">
<?= file_get_contents(__DIR__.'/statamic/resources/dist/svg/statamic-mark.svg') ?>
</div>
<div class="card">
<h1>Checking Server Compatibility</h1>
<table>
<tr>
<th colspan="2">
Requirements
<small>You aren't getting far without these.</small>
</th>
</tr>
<?php foreach ($requirements as $name => $result): ?>
<tr>
<td>
<?php echo $name; ?>
</td>
<td class="result">
<?php if (is_array($result)): ?>
<?php if ($result['s']): ?>
<?= $result['t']; ?>
<?php else: ?>
<span class="fail"><?= $result['t']; ?></span>
<?php endif; ?>
<?php else: ?>
<?= ($result) ? '✔' : '<span class="fail">✘</span>' ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<th colspan="2">
Recommendations
<small>These aren't required, but you might encounter problems without them.</small>
</th>
</tr>
<?php foreach ($recommendations as $name => $result): ?>
<tr>
<td><?= $name ?></td>
<td class="result">
<?php if (is_array($result)): ?>
<?php if ($result['s']): ?>
<?= $result['t']; ?>
<?php else: ?>
<span class="fail"><?= $result['t']; ?></span>
<?php endif; ?>
<?php else: ?>
<?= ($result) ? '✔' : '<span class="fail">✘</span>' ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php if ($success): ?>
<p><a href="<?= url('/installer'); ?>" class="install">Server looks compatible. Continue to next step →</a></p>
<?php else: ?>
<p class="fail-message">Uh oh, there's a problem.</p>
<?php endif; ?>
<?php if (!$recommendations['Mod Rewrite']['s']): ?>
<p class="asterisk">* mod_rewrite can't be detected when PHP is running as CGI</p>
<?php endif; ?>
</body>
</html>