Elgg  Version 4.3
requirements.php
Go to the documentation of this file.
1 <?php
11 
13 $icon_warning = elgg_view_icon('exclamation-triangle');
15 
16 $view_module = function($icon, $title, $value = '', $subtext = '') {
17  $body = elgg_format_element('strong', [], $title);
18  if (!elgg_is_empty($value)) {
19  $body .= elgg_format_element('span', ['class' => 'mlm'], $value);
20  }
21 
22  if (!elgg_is_empty($subtext)) {
23  $body .= elgg_format_element('div', ['class' => 'elgg-subtext'], $subtext);
24  }
25 
26  return elgg_view_image_block($icon, $body, ['class' => 'elgg-admin-information-row']);
27 };
28 
29 // php version
31 $title = elgg_echo('admin:server:label:php_version');
32 $value = PHP_VERSION;
33 $subtext = '';
34 
35 if (version_compare(PHP_VERSION, \ElggInstaller::PHP_MINIMAL_VERSION, '<')) {
37  $subtext = elgg_echo('admin:server:label:php_version:required_version', [\ElggInstaller::PHP_MINIMAL_VERSION]);
38 }
39 
41 
42 // php required extensions
43 $extensions = get_loaded_extensions();
45  'pdo_mysql',
46  'json',
47  'xml',
48  'gd',
49 ];
50 foreach ($requiredExtensions as $extension) {
51  $icon = $icon_ok;
52  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
53  $value = elgg_echo('status:enabled');
54  $subtext = '';
55 
56  if (!in_array($extension, $extensions)) {
58  $value = elgg_echo('status:unavailable');
59  $subtext = elgg_echo('admin:server:requirements:php_extension:required');
60  }
61 
63 }
64 
65 // php recommended extensions
67  'mbstring',
68 ];
69 foreach ($recommendedExtensions as $extension) {
70  $icon = $icon_ok;
71  $title = elgg_echo('admin:server:requirements:php_extension', [$extension]);
72  $value = elgg_echo('status:enabled');
73  $subtext = '';
74 
75  if (!in_array($extension, $extensions)) {
77  $value = elgg_echo('status:unavailable');
78  $subtext = elgg_echo('admin:server:requirements:php_extension:recommended');
79  }
80 
82 }
83 
84 // php ini
85 if (empty(ini_get('session.gc_probability')) || empty(ini_get('session.gc_divisor'))) {
86  $title = elgg_echo('admin:server:requirements:gc');
87  $subtext = elgg_echo('admin:server:requirements:gc:info');
88  echo $view_module($icon_warning, $title, elgg_echo('status:disabled'), $subtext);
89 }
90 
91 // db server information
93 $version = $db->getServerVersion();
95 $server = $db->isMariaDB() ? 'mariadb' : $db->getConnection(DbConfig::READ_WRITE)->getDatabasePlatform()->getName();
96 $subtext = '';
97 $icon = $icon_ok;
98 
99 if (!in_array($server, ['mysql', 'mariadb']) || version_compare($version ?: '0', $min_version, '<')) {
100  $subtext = elgg_echo('admin:server:requirements:database:server:required_version', [$min_version]);
101  $icon = $icon_error;
102 }
103 
104 echo $view_module($icon, elgg_echo('admin:server:requirements:database:server'), "{$server} v{$version}", $subtext);
105 
106 // db client information
107 $client_parts = explode('\\', get_class($db->getConnection(DbConfig::READ_WRITE)->getDriver()));
108 $client_parts = array_slice($client_parts, 3);
110 
111 $subtext = '';
112 $icon = $icon_ok;
113 
114 if ($client !== 'PDO MySQL Driver') {
115  $subtext = elgg_echo('admin:server:requirements:database:client:required');
116  $icon = $icon_error;
117 }
118 echo $view_module($icon, elgg_echo('admin:server:requirements:database:client'), $client, $subtext);
119 
120 // rewrite test
121 $url = elgg_http_add_url_query_elements(Request::REWRITE_TEST_TOKEN, [
122  Request::REWRITE_TEST_TOKEN => 1,
123 ]);
125 
127 
128 $icon = $icon_ok;
129 $title = elgg_echo('admin:server:requirements:rewrite');
130 $value = elgg_echo('ok');
131 $subtext = '';
132 
133 if (!$tester->runRewriteTest($url)) {
134  $icon = $icon_error;
135  $value = elgg_echo('error');
136  $subtext = elgg_echo('admin:server:requirements:rewrite:fail');
137 }
138 
140 
141 $icon = _elgg_services()->imageService->hasWebPSupport() ? $icon_ok : $icon_error;
142 echo $view_module($icon, elgg_echo('admin:server:requirements:webp'));
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:481
$icon
$requiredExtensions
$client_parts
$server
Elgg RewriteTester.
$subtext
$value
$icon_ok
$version
elgg_normalize_site_url($unsafe_url)
From untrusted input, get a site URL safe for forwarding.
Definition: output.php:166
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
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:179
elgg_view_image_block($image, $body, $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:923
$client
$tester
const MYSQL_MINIMAL_VERSION
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
$icon_error
$view_module
$body
Definition: useradd.php:59
$extensions
foreach($requiredExtensions as $extension) $recommendedExtensions
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1297
$min_version
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
$url
elgg echo
Translates a string.
Definition: deprecated.js:530
$icon_warning
$title
const PHP_MINIMAL_VERSION
$extension
Definition: default.php:25