Elgg  Version 6.1
requirements.php
Go to the documentation of this file.
1 <?php
12 
14 $icon_warning = elgg_view_icon('exclamation-triangle');
16 
17 $view_module = function($icon, $title, $value = '', $subtext = '') {
18  $body = elgg_format_element('strong', [], $title);
19  if (!elgg_is_empty($value)) {
20  $body .= elgg_format_element('span', ['class' => 'mlm'], $value);
21  }
22 
23  if (!elgg_is_empty($subtext)) {
24  $body .= elgg_format_element('div', ['class' => 'elgg-subtext'], $subtext);
25  }
26 
27  return elgg_view_image_block($icon, $body, ['class' => 'elgg-admin-information-row']);
28 };
29 
30 // php version
32 $title = elgg_echo('admin:server:label:php_version');
33 $value = PHP_VERSION;
34 $subtext = '';
35 
36 if (version_compare(PHP_VERSION, \ElggInstaller::PHP_MINIMAL_VERSION, '<')) {
38  $subtext = elgg_echo('admin:server:label:php_version:required_version', [\ElggInstaller::PHP_MINIMAL_VERSION]);
39 }
40 
42 
43 // php required extensions
44 $extensions = get_loaded_extensions();
46  'pdo_mysql',
47  'json',
48  'xml',
49  'gd',
50  'intl',
51 ];
52 foreach ($requiredExtensions as $extension) {
53  $icon = $icon_ok;
54  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
55  $value = elgg_echo('status:enabled');
56  $subtext = '';
57 
58  if (!in_array($extension, $extensions)) {
60  $value = elgg_echo('status:unavailable');
61  $subtext = elgg_echo('admin:server:requirements:php_extension:required');
62  }
63 
65 }
66 
67 // php recommended extensions
69  'mbstring',
70 ];
71 foreach ($recommendedExtensions as $extension) {
72  $icon = $icon_ok;
73  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
74  $value = elgg_echo('status:enabled');
75  $subtext = '';
76 
77  if (!in_array($extension, $extensions)) {
79  $value = elgg_echo('status:unavailable');
80  $subtext = elgg_echo('admin:server:requirements:php_extension:recommended');
81  }
82 
84 }
85 
86 // php ini
87 if (empty(ini_get('session.gc_probability')) || empty(ini_get('session.gc_divisor'))) {
88  $title = elgg_echo('admin:server:requirements:gc');
89  $subtext = elgg_echo('admin:server:requirements:gc:info');
90  echo $view_module($icon_warning, $title, elgg_echo('status:disabled'), $subtext);
91 }
92 
93 // db server information
95 $version = $db->getServerVersion();
97 
98 if ($db->isMariaDB()) {
99  $server = 'mariadb';
100 } elseif ($db->isMySQL()) {
101  $server = 'mysql';
102 } else {
103  $server = substr(strrchr($db->getConnection(DbConfig::READ_WRITE)->getDatabasePlatform()::class, '\\'), 1);
104 }
105 
106 $subtext = '';
107 $icon = $icon_ok;
108 
109 if (!in_array($server, ['mysql', 'mariadb']) || version_compare($version ?: '0', $min_version, '<')) {
110  $subtext = elgg_echo('admin:server:requirements:database:server:required_version', [$min_version]);
111  $icon = $icon_error;
112 }
113 
114 echo $view_module($icon, elgg_echo('admin:server:requirements:database:server'), "{$server} v{$version}", $subtext);
115 
116 // db client information
117 $client_parts = explode('\\', get_class($db->getConnection(DbConfig::READ_WRITE)->getDriver()));
118 $client_parts = array_slice($client_parts, 3);
120 
121 $subtext = '';
122 $icon = $icon_ok;
123 
124 if ($client !== 'PDO MySQL Driver') {
125  $subtext = elgg_echo('admin:server:requirements:database:client:required');
126  $icon = $icon_error;
127 }
128 
129 echo $view_module($icon, elgg_echo('admin:server:requirements:database:client'), $client, $subtext);
130 
131 // rewrite test
132 $url = elgg_http_add_url_query_elements(Request::REWRITE_TEST_TOKEN, [
133  Request::REWRITE_TEST_TOKEN => 1,
134 ]);
136 
138 
139 $icon = $icon_ok;
140 $title = elgg_echo('admin:server:requirements:rewrite');
141 $value = elgg_echo('ok');
142 $subtext = '';
143 
144 if (!$tester->runRewriteTest($url)) {
145  $icon = $icon_error;
146  $value = elgg_echo('error');
147  $subtext = elgg_echo('admin:server:requirements:rewrite:fail');
148 }
149 
151 
152 $icon = _elgg_services()->imageService->hasWebPSupport() ? $icon_ok : $icon_error;
153 echo $view_module($icon, elgg_echo('admin:server:requirements:webp'));
$icon
$requiredExtensions
$client_parts
elgg_normalize_site_url(string $unsafe_url)
From untrusted input, get a site URL safe for forwarding.
Definition: output.php:175
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:898
$subtext
$value
$icon_ok
$version
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
Test if URL rewriting is working.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
const MARIADB_MINIMAL_VERSION
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
$client
$tester
const MYSQL_MINIMAL_VERSION
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
$icon_error
$view_module
elgg_http_add_url_query_elements(string $url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:183
$body
Definition: useradd.php:55
$extensions
elgg_view_icon(string $name, array $vars=[])
View an icon glyph.
Definition: views.php:1261
foreach($requiredExtensions as $extension) $recommendedExtensions
$min_version
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
$url
$icon_warning
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$title
const PHP_MINIMAL_VERSION
$extension
Definition: default.php:25