This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
forked from craftsmancoding/modx_utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modx_ready.php
122 lines (110 loc) · 4.09 KB
/
modx_ready.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
<?php
/**
* SUMMARY:
* This script tests whether a server is capable of running MODX.
* It is NOT conclusive, but it should help narrow things down for you.
* Sometimes MODX fails when the script says things are Ok, and sometimes
* MODX works fine when the script indicates there may be a problem.
* Take the results with a grain of salt.
*
* See http://rtfm.modx.com/display/revolution20/Server+Requirements
*
* USAGE:
* 1. Upload this script to the server where you want to run MODX, e.g. to the web root.
* 2. Run the script, e.g. by visiting it in a browser: http://yoursite.com/modx_ready.php
* and use any reported error messages to help you to update your server..
* 3. After you have cleaned up any configuration errors, delete this script from the site.
*
*
* AUTHOR:
* Everett Griffiths ([email protected])
* http://craftsmancoding.com/
*
* LAST UPDATED:
* 2013-10-09 MODX 2.2.10
*/
//------------------------------------------------------------------------------
// DO NOT EDIT BELOW THIS LINE
//------------------------------------------------------------------------------
$req_min_php_version = '5.1.2';
$req_ext = array('zlib','json','gd','PDO','pdo_mysql','curl','SimpleXML','mysql');
$req_functions = array('mb_strpos');
function print_errors($e) {
$error_list = implode('<br/>',$e);
print '<div style="margin:10px; padding:20px; border:1px solid red; background-color:pink; border-radius: 5px; width:500px;">
<span style="color:red; font-weight:bold;">MODX Cannot Run on this Server</span><br />
<p>The following errors were detected:</p>'.$error_list.'
<p><em>This test is not comprehensive and it may not adequately test your particular server environment.</em</p>
</div>';
}
function print_success() {
print '<div style="margin:10px; padding:20px; border:1px solid green; background-color:#00CC66; border-radius: 5px; width:500px;">
<span style="color:green; font-weight:bold;">Success!</span>
<p>Your server seems to have what it takes to run MODX. This does not guarantee that everything will
work, but at least your server is not missing anything obvious.</p>
</div>';
}
$errors = array();
// Test PHP version
if ( version_compare( phpversion(), $req_min_php_version, '<') ) {
$errors[] = sprintf('MODX requires PHP %s or newer.', $req_min_php_version);
}
if ( version_compare( phpversion(), '5.1.6', '=') ) {
$errors[] = 'MODX cannot run using PHP 5.1.6.';
}
if ( version_compare( phpversion(), '5.2.0', '=') ) {
$errors[] = 'MODX cannot run using PHP 5.2.0.';
}
// Test for req'd modules
foreach ($req_ext as $e) {
if (!extension_loaded($e)) {
$errors[] = sprintf('MODX requires that PHP has the %s extension.', '<code>'.$e.'</code>');
}
}
// Image Magick (optional)
if(!class_exists('Imagick')) {
// $errors[] = 'MODX prefers to have ImageMagick installed for thumbnail generation.';
print 'Could not find ImageMagick, but it is optional... Skipping...<br/>';
}
// Test for mod_rewrite
if (function_exists('apache_get_modules')) {
if (!in_array('mod_rewrite', apache_get_modules())) {
$errors[] = 'MODX works best if Apache includes the <code>mod_rewrite</code> module.';
}
}
else {
print 'Could not test Apache modules. Skipping...<br/>';
}
// Safe Mode off
if(ini_get('safe_mode')) {
$errors[] = "MODX requires PHP's <code>safe_mode</code> to be disabled.";
}
// Globals off
if(ini_get('register_globals')) {
$errors[] = "MODX requires PHP's <code>register_globals</code> to be disabled.";
}
// Magic quotes off
if(ini_get('magic_quotes_gpc') || function_exists('magic_quotes_gpc')) {
$errors[] = "MODX requires PHP's <code>magic_quotes_gpc</code> to be disabled.";
}
// Memory Limit
$ram = ini_get('memory_limit');
$ram = preg_replace('/[^0-9]/', '', $ram);
if ($ram < 24) {
$errors[] = 'MODX requires at least 24M of memory.';
}
// Test for req'd functions
foreach ($req_functions as $f) {
if (!function_exists($f)) {
$errors[] = sprintf('MODX requires the %s function', '<code>'.$e.'</code>');
}
}
// Summary
if (!empty($errors)) {
print_errors($errors);
exit;
}
else {
print_success();
}
/*EOF*/