Elgg  Version 5.1
generic.php
Go to the documentation of this file.
1 <?php
7 echo elgg_view('output/longtext', [
8  'value' => elgg_echo('admin:performance:generic:description'),
9 ]);
10 
12 $icon_warning = elgg_view_icon('exclamation-triangle');
14 
15 $view_module = function($icon, $title, $value = '', $subtext = '') {
16  $body = elgg_format_element('strong', [], $title);
17  if (!elgg_is_empty($value)) {
18  $body .= elgg_format_element('span', ['class' => 'mlm'], $value);
19  }
20 
21  if (!elgg_is_empty($subtext)) {
22  $body .= elgg_format_element('div', ['class' => 'elgg-subtext'], $subtext);
23  }
24 
25  return elgg_view_image_block($icon, $body, ['class' => 'elgg-admin-information-row']);
26 };
27 
28 // apache version
29 // Check if the function exists before callling it else it may fail in case of Nginx or other Non Apache servers
30 if (function_exists('apache_get_version')) {
31  if (apache_get_version() !== false) {
33  $title = elgg_echo('admin:performance:apache:mod_cache');
34  $value = elgg_echo('status:unavailable');
35  $subtext = '';
36 
37  if (in_array('mod_cache', apache_get_modules())) {
38  $icon = $icon_ok;
39  $value = elgg_echo('status:enabled');
40  } else {
41  $subtext = elgg_echo('admin:performance:apache:mod_cache:warning');
42  }
43 
44  echo $view_module($icon, $title, $value, $subtext);
45  }
46 }
47 
48 // open_basedir
50 $title = elgg_echo('admin:performance:php:open_basedir');
51 $value = elgg_echo('admin:performance:php:open_basedir:not_configured');
52 $subtext = '';
53 
54 $open_basedirs = ini_get('open_basedir');
55 if (!empty($open_basedirs)) {
57  $value = elgg_format_element('span', ['class' => ['elgg-subtext']], $open_basedirs);
58 
59  $separator = ':';
60  if (stripos(PHP_OS, 'WIN') === 0) {
61  $separator = ';';
62  }
63 
64  $parsed_open_basedirs = explode($separator, $open_basedirs);
65 
66  if (count($parsed_open_basedirs) > 5) {
68  $subtext = elgg_echo('admin:performance:php:open_basedir:error');
69  } else {
70  $subtext = elgg_echo('admin:performance:php:open_basedir:warning');
71  }
72 
73  $subtext .= ' ' . elgg_echo('admin:performance:php:open_basedir:generic');
74 }
75 
76 echo $view_module($icon, $title, $value, $subtext);
77 
78 // opcache
80 $title = elgg_echo('admin:server:label:opcache');
81 $value = elgg_echo('status:unavailable');
82 $subtext = '';
83 
84 if (function_exists('opcache_get_status')) {
86  $opcache_status = opcache_get_status(false);
87 
88  if (!empty($opcache_status)) {
89  $icon = $icon_ok;
90  $value = elgg_echo('status:enabled');
91  } else {
92  $value = elgg_echo('status:disabled');
93  $subtext = elgg_echo('admin:server:opcache:inactive');
94  }
95 }
96 
97 echo $view_module($icon, $title, $value, $subtext);
98 
99 // memcache
101 $title = elgg_echo('admin:server:label:memcache');
102 $value = elgg_echo('status:unavailable');
103 $subtext = '';
104 
105 if (\Elgg\Cache\CompositeCache::isMemcacheAvailable()) {
107 
108  if (elgg_get_config('memcache') && !empty(elgg_get_config('memcache_servers'))) {
109  $icon = $icon_ok;
110  $value = elgg_echo('status:enabled');
111  } else {
112  $value = elgg_echo('status:disabled');
113  $subtext = elgg_echo('admin:server:memcache:inactive');
114  }
115 }
116 
117 echo $view_module($icon, $title, $value, $subtext);
118 
119 // redis
121 $title = elgg_echo('admin:server:label:redis');
122 $value = elgg_echo('status:unavailable');
123 $subtext = '';
124 
125 if (\Elgg\Cache\CompositeCache::isRedisAvailable()) {
127 
128  if (elgg_get_config('redis') && !empty(elgg_get_config('redis_servers'))) {
129  $icon = $icon_ok;
130  $value = elgg_echo('status:enabled');
131  } else {
132  $value = elgg_echo('status:disabled');
133  $subtext = elgg_echo('admin:server:redis:inactive');
134  }
135 }
136 
137 echo $view_module($icon, $title, $value, $subtext);
138 
139 // simplecache
141 $title = elgg_view('output/url', [
142  'text' => elgg_echo('admin:performance:simplecache'),
143  'href' => elgg_generate_url('admin', [
144  'segments' => 'site_settings',
145  ]) . '#elgg-settings-advanced-caching',
146  'is_trusted' => true,
147 ]);
148 $value = elgg_echo('status:disabled');
149 $subtext = elgg_echo('installation:simplecache:description');
150 
152  $icon = $icon_ok;
153  $value = elgg_echo('status:enabled');
154 
155  if (!elgg()->config->hasInitialValue('simplecache_enabled')) {
157  $subtext = elgg_echo('admin:performance:simplecache:settings:warning');
158  }
159 }
160 
161 echo $view_module($icon, $title, $value, $subtext);
162 
163 // systemcache
165 $title = elgg_view('output/url', [
166  'text' => elgg_echo('admin:performance:systemcache'),
167  'href' => elgg_generate_url('admin', [
168  'segments' => 'site_settings',
169  ]) . '#elgg-settings-advanced-caching',
170  'is_trusted' => true,
171 ]);
172 $value = elgg_echo('status:disabled');
173 $subtext = elgg_echo('installation:systemcache:description');
174 
176  $icon = $icon_ok;
177  $value = elgg_echo('status:enabled');
178  $subtext = '';
179 }
180 
181 echo $view_module($icon, $title, $value, $subtext);
$open_basedirs
Definition: generic.php:54
$subtext
Definition: generic.php:52
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:919
$icon_error
Definition: generic.php:13
$opcache_status
Definition: opcache.php:7
$title
Definition: generic.php:50
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$value
Definition: generic.php:51
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
$view_module
Definition: generic.php:15
$separator
Definition: tags.php:56
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
if(function_exists('apache_get_version')) $icon
Definition: generic.php:49
$icon_ok
Generic performance overview, more detailed information can be added to additional tabs in /admin/per...
Definition: generic.php:11
$body
Definition: useradd.php:55
elgg_view_icon(string $name, array $vars=[])
View an icon glyph.
Definition: views.php:1282
elgg_is_simplecache_enabled()
Is simple cache enabled.
Definition: cache.php:149
$icon_warning
Definition: generic.php:12
elgg_is_system_cache_enabled()
Is system cache enabled.
Definition: cache.php:66
elgg_generate_url(string $name, array $parameters=[])
Generate a URL for named route.
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
var elgg
Definition: elgglib.js:4