Elgg  Version master
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 ];
51 foreach ($requiredExtensions as $extension) {
52  $icon = $icon_ok;
53  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
54  $value = elgg_echo('status:enabled');
55  $subtext = '';
56 
57  if (!in_array($extension, $extensions)) {
59  $value = elgg_echo('status:unavailable');
60  $subtext = elgg_echo('admin:server:requirements:php_extension:required');
61  }
62 
64 }
65 
66 // php recommended extensions
68  'mbstring',
69 ];
70 foreach ($recommendedExtensions as $extension) {
71  $icon = $icon_ok;
72  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
73  $value = elgg_echo('status:enabled');
74  $subtext = '';
75 
76  if (!in_array($extension, $extensions)) {
78  $value = elgg_echo('status:unavailable');
79  $subtext = elgg_echo('admin:server:requirements:php_extension:recommended');
80  }
81 
83 }
84 
85 // php ini
86 if (empty(ini_get('session.gc_probability')) || empty(ini_get('session.gc_divisor'))) {
87  $title = elgg_echo('admin:server:requirements:gc');
88  $subtext = elgg_echo('admin:server:requirements:gc:info');
89  echo $view_module($icon_warning, $title, elgg_echo('status:disabled'), $subtext);
90 }
91 
92 // db server information
94 $version = $db->getServerVersion();
96 $server = $db->isMariaDB() ? 'mariadb' : $db->getConnection(DbConfig::READ_WRITE)->getDatabasePlatform()->getName();
97 $subtext = '';
98 $icon = $icon_ok;
99 
100 if (!in_array($server, ['mysql', 'mariadb']) || version_compare($version ?: '0', $min_version, '<')) {
101  $subtext = elgg_echo('admin:server:requirements:database:server:required_version', [$min_version]);
102  $icon = $icon_error;
103 }
104 
105 echo $view_module($icon, elgg_echo('admin:server:requirements:database:server'), "{$server} v{$version}", $subtext);
106 
107 // db client information
108 $client_parts = explode('\\', get_class($db->getConnection(DbConfig::READ_WRITE)->getDriver()));
109 $client_parts = array_slice($client_parts, 3);
111 
112 $subtext = '';
113 $icon = $icon_ok;
114 
115 if ($client !== 'PDO MySQL Driver') {
116  $subtext = elgg_echo('admin:server:requirements:database:client:required');
117  $icon = $icon_error;
118 }
119 
120 echo $view_module($icon, elgg_echo('admin:server:requirements:database:client'), $client, $subtext);
121 
122 // rewrite test
123 $url = elgg_http_add_url_query_elements(Request::REWRITE_TEST_TOKEN, [
124  Request::REWRITE_TEST_TOKEN => 1,
125 ]);
127 
129 
130 $icon = $icon_ok;
131 $title = elgg_echo('admin:server:requirements:rewrite');
132 $value = elgg_echo('ok');
133 $subtext = '';
134 
135 if (!$tester->runRewriteTest($url)) {
136  $icon = $icon_error;
137  $value = elgg_echo('error');
138  $subtext = elgg_echo('admin:server:requirements:rewrite:fail');
139 }
140 
142 
143 $icon = _elgg_services()->imageService->hasWebPSupport() ? $icon_ok : $icon_error;
144 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:160
$server
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:919
$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.
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:181
$body
Definition: useradd.php:55
$extensions
elgg_view_icon(string $name, array $vars=[])
View an icon glyph.
Definition: views.php:1274
foreach($requiredExtensions as $extension) $recommendedExtensions
$min_version
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
$url
$icon_warning
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:130
$title
const PHP_MINIMAL_VERSION
$extension
Definition: default.php:25