Rev 1047 | Rev 1073 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1047 | Rev 1050 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. |
8 | * you may not use this file except in compliance with the License. |
9 | * You may obtain a copy of the License at |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | * |
12 | * |
13 | * Unless required by applicable law or agreed to in writing, software |
13 | * Unless required by applicable law or agreed to in writing, software |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
20 | namespace ViaThinkSoft\OIDplus; |
21 | 21 | ||
22 | class OIDplusPageAdminSysteminfo extends OIDplusPagePluginAdmin { |
22 | class OIDplusPageAdminSysteminfo extends OIDplusPagePluginAdmin { |
23 | 23 | ||
24 | public function action($actionID, $params) { |
24 | public function action($actionID, $params) { |
25 | } |
25 | } |
26 | 26 | ||
27 | public function init($html=true) { |
27 | public function init($html=true) { |
28 | } |
28 | } |
29 | 29 | ||
30 | private function getLoadedInis() { |
30 | private function getLoadedInis() { |
31 | $s_inis = ''; |
31 | $s_inis = ''; |
32 | 32 | ||
33 | $inis = array(); |
33 | $inis = array(); |
34 | $main_ini = php_ini_loaded_file(); |
34 | $main_ini = php_ini_loaded_file(); |
35 | if ($main_ini !== false) $s_inis = '<b>'.htmlentities($main_ini).'</b>'; |
35 | if ($main_ini !== false) $s_inis = '<b>'.htmlentities($main_ini).'</b>'; |
36 | 36 | ||
37 | $more_ini = php_ini_scanned_files(); |
37 | $more_ini = php_ini_scanned_files(); |
38 | if ($more_ini !== false) { |
38 | if ($more_ini !== false) { |
39 | $inis = explode(',', $more_ini); |
39 | $inis = explode(',', $more_ini); |
40 | foreach ($inis as $ini) { |
40 | foreach ($inis as $ini) { |
41 | $s_inis .= '<br>'.htmlentities($ini); |
41 | $s_inis .= '<br>'.htmlentities($ini); |
42 | } |
42 | } |
43 | } |
43 | } |
44 | 44 | ||
45 | if ($s_inis == '') $s_inis = _L('n/a'); |
45 | if ($s_inis == '') $s_inis = _L('n/a'); |
46 | 46 | ||
47 | return $s_inis; |
47 | return $s_inis; |
48 | } |
48 | } |
49 | 49 | ||
50 | public function gui($id, &$out, &$handled) { |
50 | public function gui($id, &$out, &$handled) { |
51 | if ($id === 'oidplus:phpinfo') { |
51 | if ($id === 'oidplus:phpinfo') { |
52 | $handled = true; |
52 | $handled = true; |
53 | $out['title'] = _L('PHP information'); |
53 | $out['title'] = _L('PHP information'); |
54 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/php_icon.png'; |
54 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/php_icon.png'; |
55 | 55 | ||
56 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
56 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
57 | $out['icon'] = 'img/error.png'; |
57 | $out['icon'] = 'img/error.png'; |
58 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>'; |
58 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>'; |
59 | return; |
59 | return; |
60 | } |
60 | } |
61 | 61 | ||
62 | $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:systeminfo').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to the system information page').'</a></p>'; |
62 | $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:systeminfo').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to the system information page').'</a></p>'; |
63 | 63 | ||
64 | ob_start(); |
64 | ob_start(); |
65 | $res = phpinfo(); |
65 | $res = phpinfo(); |
66 | $cont = ob_get_contents(); |
66 | $cont = ob_get_contents(); |
67 | ob_end_clean(); |
67 | ob_end_clean(); |
68 | 68 | ||
69 | if (!$res) { |
69 | if (!$res) { |
70 | $out['text'] .= '<p><font color="red">'._L('phpinfo() could not be called').'</font></p>'; |
70 | $out['text'] .= '<p><font color="red">'._L('phpinfo() could not be called').'</font></p>'; |
71 | } else { |
71 | } else { |
72 | // phpinfo() sets "img {float: right; border: 0;}". We don't want that. |
72 | // phpinfo() sets "img {float: right; border: 0;}". We don't want that. |
73 | $cont = str_replace('img {', 'img.phpinfo {', $cont); |
73 | $cont = str_replace('img {', 'img.phpinfo {', $cont); |
74 | $cont = str_replace('<img', '<img class="phpinfo"', $cont); |
74 | $cont = str_replace('<img', '<img class="phpinfo"', $cont); |
75 | 75 | ||
76 | // phpinfo() sets the link colors. We don't want that |
76 | // phpinfo() sets the link colors. We don't want that |
77 | $cont = preg_replace('@a:.+ {.+}@ismU', '', $cont); |
77 | $cont = preg_replace('@a:.+ {.+}@ismU', '', $cont); |
78 | 78 | ||
79 | // phpinfo() sets "h1 {font-size: 150%;}" and "h2 {font-size: 125%;}" |
79 | // phpinfo() sets "h1 {font-size: 150%;}" and "h2 {font-size: 125%;}" |
80 | $cont = preg_replace('@(h1|h2|h3|h4|h5) {.+}@ismU', '', $cont); |
80 | $cont = preg_replace('@(h1|h2|h3|h4|h5) {.+}@ismU', '', $cont); |
81 | 81 | ||
82 | // Make compatible for dark themes by removing all foreground and background colors |
82 | // Make compatible for dark themes by removing all foreground and background colors |
83 | $cont = preg_replace('@(body) {.+}@ismU', '', $cont, 1); |
83 | $cont = preg_replace('@(body) {.+}@ismU', '', $cont, 1); |
84 | $cont = preg_replace('@background-color:(.+)[\\};]@ismU', '', $cont); |
84 | $cont = preg_replace('@background-color:(.+)[\\};]@ismU', '', $cont); |
85 | $cont = '<span style="font-family: sans-serif;">'.$cont.'</span>'; |
85 | $cont = '<span style="font-family: sans-serif;">'.$cont.'</span>'; |
86 | 86 | ||
87 | // Font sizes |
87 | // Font sizes |
88 | $cont = preg_replace('@font-size:\\s*75%;@', '', $cont); |
88 | $cont = preg_replace('@font-size:\\s*75%;@', '', $cont); |
89 | for ($i=5; $i>=1; $i--) { |
89 | for ($i=5; $i>=1; $i--) { |
90 | $cont = str_replace('<h'.$i, '<h'.($i+1), $cont); |
90 | $cont = str_replace('<h'.$i, '<h'.($i+1), $cont); |
91 | $cont = str_replace('</h'.$i, '</h'.($i+1), $cont); |
91 | $cont = str_replace('</h'.$i, '</h'.($i+1), $cont); |
92 | } |
92 | } |
93 | 93 | ||
94 | $out['text'] .= $cont; |
94 | $out['text'] .= $cont; |
95 | } |
95 | } |
96 | } |
96 | } |
97 | else if ($id === 'oidplus:systeminfo') { |
97 | else if ($id === 'oidplus:systeminfo') { |
98 | $handled = true; |
98 | $handled = true; |
99 | $out['title'] = _L('System information'); |
99 | $out['title'] = _L('System information'); |
100 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
100 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
101 | 101 | ||
102 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
102 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
103 | $out['icon'] = 'img/error.png'; |
103 | $out['icon'] = 'img/error.png'; |
104 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>'; |
104 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>'; |
105 | return; |
105 | return; |
106 | } |
106 | } |
107 | 107 | ||
108 | $out['text'] = ''; |
108 | $out['text'] = ''; |
109 | 109 | ||
110 | # --- |
110 | # --- |
111 | 111 | ||
112 | $out['text'] .= '<h2>'._L('OIDplus').'</h2>'; |
112 | $out['text'] .= '<h2>'._L('OIDplus').'</h2>'; |
113 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
113 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
114 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
114 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
115 | $out['text'] .= ' <tr>'; |
115 | $out['text'] .= ' <tr>'; |
116 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
116 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
117 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
117 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
118 | $out['text'] .= ' </tr>'; |
118 | $out['text'] .= ' </tr>'; |
119 | 119 | ||
120 | $sys_title = OIDplus::config()->getValue('system_title'); |
120 | $sys_title = OIDplus::config()->getValue('system_title'); |
121 | $out['text'] .= ' <tr>'; |
121 | $out['text'] .= ' <tr>'; |
122 | $out['text'] .= ' <td>'._L('System title').'</td>'; |
122 | $out['text'] .= ' <td>'._L('System title').'</td>'; |
123 | $out['text'] .= ' <td>'.htmlentities($sys_title).'</td>'; |
123 | $out['text'] .= ' <td>'.htmlentities($sys_title).'</td>'; |
124 | $out['text'] .= ' </tr>'; |
124 | $out['text'] .= ' </tr>'; |
125 | 125 | ||
126 | $out['text'] .= ' <tr>'; |
126 | $out['text'] .= ' <tr>'; |
127 | $out['text'] .= ' <td>'._L('System directory').'</td>'; |
127 | $out['text'] .= ' <td>'._L('System directory').'</td>'; |
128 | $out['text'] .= ' <td>'.(isset($_SERVER['SCRIPT_FILENAME']) ? htmlentities(dirname($_SERVER['SCRIPT_FILENAME'])) : '<i>'._L('unknown').'</i>').'</td>'; |
128 | $out['text'] .= ' <td>'.(isset($_SERVER['SCRIPT_FILENAME']) ? htmlentities(dirname($_SERVER['SCRIPT_FILENAME'])) : '<i>'._L('unknown').'</i>').'</td>'; |
129 | $out['text'] .= ' </tr>'; |
129 | $out['text'] .= ' </tr>'; |
130 | 130 | ||
131 | $sysid_oid = OIDplus::getSystemId(true); |
131 | $sysid_oid = OIDplus::getSystemId(true); |
132 | $out['text'] .= ' <tr>'; |
132 | $out['text'] .= ' <tr>'; |
133 | $out['text'] .= ' <td>'._L('System OID').'</td>'; |
133 | $out['text'] .= ' <td>'._L('System OID').'</td>'; |
134 | $out['text'] .= ' <td>'.(!$sysid_oid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_oid)).'</td>'; |
134 | $out['text'] .= ' <td>'.(!$sysid_oid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_oid)).'</td>'; |
135 | $out['text'] .= ' </tr>'; |
135 | $out['text'] .= ' </tr>'; |
136 | 136 | ||
137 | $sys_url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL); |
137 | $sys_url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL); |
138 | $out['text'] .= ' <tr>'; |
138 | $out['text'] .= ' <tr>'; |
139 | $out['text'] .= ' <td>'._L('System URL').'</td>'; |
139 | $out['text'] .= ' <td>'._L('System URL').'</td>'; |
140 | $out['text'] .= ' <td>'.htmlentities($sys_url).'</td>'; |
140 | $out['text'] .= ' <td>'.htmlentities($sys_url).'</td>'; |
141 | $out['text'] .= ' </tr>'; |
141 | $out['text'] .= ' </tr>'; |
142 | 142 | ||
143 | $sys_ver = OIDplus::getVersion(); |
143 | $sys_ver = OIDplus::getVersion(); |
144 | $out['text'] .= ' <tr>'; |
144 | $out['text'] .= ' <tr>'; |
145 | $out['text'] .= ' <td>'._L('System version').'</td>'; |
145 | $out['text'] .= ' <td>'._L('System version').'</td>'; |
146 | $out['text'] .= ' <td>'.(!$sys_ver ? '<i>'._L('unknown').'</i>' : htmlentities($sys_ver)).'</td>'; |
146 | $out['text'] .= ' <td>'.(!$sys_ver ? '<i>'._L('unknown').'</i>' : htmlentities($sys_ver)).'</td>'; |
147 | $out['text'] .= ' </tr>'; |
147 | $out['text'] .= ' </tr>'; |
148 | 148 | ||
149 | $sys_install_type = OIDplus::getInstallType(); |
149 | $sys_install_type = OIDplus::getInstallType(); |
150 | $out['text'] .= ' <tr>'; |
150 | $out['text'] .= ' <tr>'; |
151 | $out['text'] .= ' <td>'._L('Installation type').'</td>'; |
151 | $out['text'] .= ' <td>'._L('Installation type').'</td>'; |
152 | $out['text'] .= ' <td>'.htmlentities($sys_install_type).'</td>'; |
152 | $out['text'] .= ' <td>'.htmlentities($sys_install_type).'</td>'; |
153 | $out['text'] .= ' </tr>'; |
153 | $out['text'] .= ' </tr>'; |
154 | 154 | ||
155 | $out['text'] .= '</table>'; |
155 | $out['text'] .= '</table>'; |
156 | $out['text'] .= '</div></div>'; |
156 | $out['text'] .= '</div></div>'; |
157 | 157 | ||
158 | # --- |
158 | # --- |
159 | 159 | ||
160 | $out['text'] .= '<h2>'._L('PHP').'</h2>'; |
160 | $out['text'] .= '<h2>'._L('PHP').'</h2>'; |
161 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
161 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
162 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
162 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
163 | $out['text'] .= ' <tr>'; |
163 | $out['text'] .= ' <tr>'; |
164 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
164 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
165 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
165 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
166 | $out['text'] .= ' </tr>'; |
166 | $out['text'] .= ' </tr>'; |
167 | $out['text'] .= ' <tr>'; |
167 | $out['text'] .= ' <tr>'; |
168 | $out['text'] .= ' <td>'._L('PHP version').'</td>'; |
168 | $out['text'] .= ' <td>'._L('PHP version').'</td>'; |
169 | $out['text'] .= ' <td>'.PHP_VERSION.'</td>'; |
169 | $out['text'] .= ' <td>'.PHP_VERSION.'</td>'; |
170 | $out['text'] .= ' </tr>'; |
170 | $out['text'] .= ' </tr>'; |
171 | $out['text'] .= ' <tr>'; |
171 | $out['text'] .= ' <tr>'; |
172 | $out['text'] .= ' <td>'._L('PHP configuration file(s)').'</td>'; |
172 | $out['text'] .= ' <td>'._L('PHP configuration file(s)').'</td>'; |
173 | $out['text'] .= ' <td>'.$this->getLoadedInis().'</td>'; |
173 | $out['text'] .= ' <td>'.$this->getLoadedInis().'</td>'; |
174 | $out['text'] .= ' </tr>'; |
174 | $out['text'] .= ' </tr>'; |
175 | $out['text'] .= ' <tr>'; |
175 | $out['text'] .= ' <tr>'; |
176 | $out['text'] .= ' <td>'._L('Installed extensions').'</td>'; |
176 | $out['text'] .= ' <td>'._L('Installed extensions').'</td>'; |
177 | $out['text'] .= ' <td>'.htmlentities(implode(', ',get_loaded_extensions())).'</td>'; |
177 | $out['text'] .= ' <td>'.htmlentities(implode(', ',get_loaded_extensions())).'</td>'; |
178 | $out['text'] .= ' </tr>'; |
178 | $out['text'] .= ' </tr>'; |
179 | $out['text'] .= '</table>'; |
179 | $out['text'] .= '</table>'; |
180 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:phpinfo').'>'._L('Show PHP server configuration (phpinfo)').'</a></p>'; |
180 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:phpinfo').'>'._L('Show PHP server configuration (phpinfo)').'</a></p>'; |
181 | $out['text'] .= '</div></div>'; |
181 | $out['text'] .= '</div></div>'; |
182 | 182 | ||
183 | # --- |
183 | # --- |
184 | 184 | ||
185 | $out['text'] .= '<h2>'._L('Webserver').'</h2>'; |
185 | $out['text'] .= '<h2>'._L('Webserver').'</h2>'; |
186 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
186 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
187 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
187 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
188 | $out['text'] .= ' <tr>'; |
188 | $out['text'] .= ' <tr>'; |
189 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
189 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
190 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
190 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
191 | $out['text'] .= ' </tr>'; |
191 | $out['text'] .= ' </tr>'; |
192 | $out['text'] .= ' <tr>'; |
192 | $out['text'] .= ' <tr>'; |
193 | $out['text'] .= ' <td>'._L('Server software').'</td>'; |
193 | $out['text'] .= ' <td>'._L('Server software').'</td>'; |
194 | $out['text'] .= ' <td>'.(isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '<i>'._L('unknown').'</i>').'</td>'; |
194 | $out['text'] .= ' <td>'.(isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '<i>'._L('unknown').'</i>').'</td>'; |
195 | $out['text'] .= ' </tr>'; |
195 | $out['text'] .= ' </tr>'; |
196 | $out['text'] .= ' <tr>'; |
196 | $out['text'] .= ' <tr>'; |
197 | $out['text'] .= ' <td>'._L('User account').'</td>'; |
197 | $out['text'] .= ' <td>'._L('User account').'</td>'; |
198 | $current_user = exec('whoami'); |
198 | $current_user = exec('whoami'); |
199 | if ($current_user == '') { |
199 | if ($current_user == '') { |
200 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
200 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
201 | // Windows on an IIS server: |
201 | // Windows on an IIS server: |
202 | // getenv('USERNAME') MARSCHALL$ (That is the "machine account", see https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities#accessing-the-network ) |
202 | // getenv('USERNAME') MARSCHALL$ (That is the "machine account", see https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities#accessing-the-network ) |
203 | // get_current_user() DefaultAppPool |
203 | // get_current_user() DefaultAppPool |
204 | // exec('whoami') iis apppool\defaultapppool |
204 | // exec('whoami') iis apppool\defaultapppool |
205 | // Windows with XAMPP: |
205 | // Windows with XAMPP: |
206 | // getenv('USERNAME') dmarschall |
206 | // getenv('USERNAME') dmarschall |
207 | // get_current_user() dmarschall (even if script has a different NTFS owner!) |
207 | // get_current_user() dmarschall (even if script has a different NTFS owner!) |
208 | // exec('whoami') hickelsoft\dmarschall |
208 | // exec('whoami') hickelsoft\dmarschall |
209 | $current_user = get_current_user(); |
209 | $current_user = get_current_user(); |
210 | if ($current_user == '') $current_user = getenv('USERNAME'); |
210 | if ($current_user == '') $current_user = getenv('USERNAME'); |
211 | } else { |
211 | } else { |
212 | // On Linux: |
212 | // On Linux: |
213 | // get_current_user() will get the owner of the PHP script, not the process owner! |
213 | // get_current_user() will get the owner of the PHP script, not the process owner! |
214 | // We want the process owner, so we use posix_geteuid(). |
214 | // We want the process owner, so we use posix_geteuid(). |
215 | if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { |
215 | if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { |
216 | $uid = posix_geteuid(); |
216 | $uid = posix_geteuid(); |
217 | $current_user = posix_getpwuid($uid); // receive username (required read access to /etc/passwd ) |
217 | $current_user = posix_getpwuid($uid); // receive username (required read access to /etc/passwd ) |
218 | } else { |
218 | } else { |
219 | $uid = -1; |
219 | $uid = -1; |
220 | } |
220 | } |
221 | if ($current_user == '') $current_user = get_current_user(); |
221 | if ($current_user == '') $current_user = get_current_user(); |
222 | if (($current_user == '') && ($uid >= 0)) $current_user = '#'.$uid; |
222 | if (($current_user == '') && ($uid >= 0)) $current_user = '#'.$uid; |
223 | } |
223 | } |
224 | } |
224 | } |
225 | $out['text'] .= ' <td>'.($current_user == '' ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>'; |
225 | $out['text'] .= ' <td>'.($current_user == '' ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>'; |
226 | $out['text'] .= ' </tr>'; |
226 | $out['text'] .= ' </tr>'; |
227 | $out['text'] .= '</table>'; |
227 | $out['text'] .= '</table>'; |
228 | $out['text'] .= '</div></div>'; |
228 | $out['text'] .= '</div></div>'; |
229 | 229 | ||
230 | # --- |
230 | # --- |
231 | 231 | ||
232 | $out['text'] .= '<h2>'._L('Database').'</h2>'; |
232 | $out['text'] .= '<h2>'._L('Database').'</h2>'; |
233 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
233 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
234 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
234 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
235 | $out['text'] .= ' <tr>'; |
235 | $out['text'] .= ' <tr>'; |
236 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
236 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
237 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
237 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
238 | $out['text'] .= ' </tr>'; |
238 | $out['text'] .= ' </tr>'; |
239 | 239 | ||
240 | $out['text'] .= ' <tr>'; |
240 | $out['text'] .= ' <tr>'; |
241 | $out['text'] .= ' <td>'._L('Database provider').'</td>'; |
241 | $out['text'] .= ' <td>'._L('Database provider').'</td>'; |
242 | $out['text'] .= ' <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>'; |
242 | $out['text'] .= ' <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>'; |
243 | $out['text'] .= ' </tr>'; |
243 | $out['text'] .= ' </tr>'; |
244 | 244 | ||
245 | $out['text'] .= ' <tr>'; |
245 | $out['text'] .= ' <tr>'; |
246 | $out['text'] .= ' <td>'._L('SQL slang').'</td>'; |
246 | $out['text'] .= ' <td>'._L('SQL slang').'</td>'; |
247 | $out['text'] .= ' <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>'; |
247 | $out['text'] .= ' <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>'; |
248 | $out['text'] .= ' </tr>'; |
248 | $out['text'] .= ' </tr>'; |
249 | 249 | ||
250 | $table_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX'); |
250 | $table_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX'); |
251 | $out['text'] .= ' <tr>'; |
251 | $out['text'] .= ' <tr>'; |
252 | $out['text'] .= ' <td>'._L('Table name prefix').'</td>'; |
252 | $out['text'] .= ' <td>'._L('Table name prefix').'</td>'; |
253 | $out['text'] .= ' <td>'.(!empty($table_prefix) ? htmlentities($table_prefix) : '<i>'._L('none').'</i>').'</td>'; |
253 | $out['text'] .= ' <td>'.(!empty($table_prefix) ? htmlentities($table_prefix) : '<i>'._L('none').'</i>').'</td>'; |
254 | $out['text'] .= ' </tr>'; |
254 | $out['text'] .= ' </tr>'; |
255 | $out['text'] .= ' <tr>'; |
255 | $out['text'] .= ' <tr>'; |
256 | $out['text'] .= ' <td>'._L('Server time').'</td>'; |
256 | $out['text'] .= ' <td>'._L('Server time').'</td>'; |
257 | $tmp = OIDplus::db()->query('select '.OIDplus::db()->sqlDate().' as tmp'); |
257 | $tmp = OIDplus::db()->query('select '.OIDplus::db()->sqlDate().' as tmp'); |
258 | if ($tmp) $tmp = $tmp->fetch_array(); |
258 | if ($tmp) $tmp = $tmp->fetch_array(); |
259 | $tmp = isset($tmp['tmp']) ? $tmp['tmp'] : _L('n/a'); |
259 | $tmp = isset($tmp['tmp']) ? $tmp['tmp'] : _L('n/a'); |
260 | $out['text'] .= ' <td>'.$tmp.'</td>'; |
260 | $out['text'] .= ' <td>'.$tmp.'</td>'; |
261 | $out['text'] .= ' </tr>'; |
261 | $out['text'] .= ' </tr>'; |
262 | $out['text'] .= '</table>'; |
262 | $out['text'] .= '</table>'; |
263 | $out['text'] .= '</div></div>'; |
263 | $out['text'] .= '</div></div>'; |
264 | 264 | ||
265 | // TODO: can we somehow get the DBMS version, connection string etc? |
265 | // TODO: can we somehow get the DBMS version, connection string etc? |
266 | 266 | ||
267 | # --- |
267 | # --- |
268 | 268 | ||
269 | $out['text'] .= '<h2>'._L('Operating System').'</h2>'; |
269 | $out['text'] .= '<h2>'._L('Operating System').'</h2>'; |
270 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
270 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
271 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
271 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
272 | $out['text'] .= ' <tr>'; |
272 | $out['text'] .= ' <tr>'; |
273 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
273 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
274 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
274 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
275 | $out['text'] .= ' </tr>'; |
275 | $out['text'] .= ' </tr>'; |
276 | if (php_uname("m") == php_uname("n")) { |
276 | if (php_uname("m") == php_uname("n")) { |
277 | // At some hosts like Strato, php_uname() always returns the same string |
277 | // At some hosts like Strato, php_uname() always returns the same string |
278 | // "Linux localhost 3.10.0-1127.10.1.el7.x86_64 #1 SMP" |
278 | // "Linux localhost 3.10.0-1127.10.1.el7.x86_64 #1 SMP" |
279 | $out['text'] .= ' <tr>'; |
279 | $out['text'] .= ' <tr>'; |
280 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
280 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
281 | $out['text'] .= ' <td>'.htmlentities(PHP_OS).'</td>'; |
281 | $out['text'] .= ' <td>'.htmlentities(PHP_OS).'</td>'; |
282 | $out['text'] .= ' </tr>'; |
282 | $out['text'] .= ' </tr>'; |
283 | $out['text'] .= ' <tr>'; |
283 | $out['text'] .= ' <tr>'; |
284 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
284 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
285 | $out['text'] .= ' <td>'.htmlentities(gethostname()).'</td>'; |
285 | $out['text'] .= ' <td>'.htmlentities(gethostname()).'</td>'; |
286 | $out['text'] .= ' </tr>'; |
286 | $out['text'] .= ' </tr>'; |
287 | } else { |
287 | } else { |
288 | $out['text'] .= ' <tr>'; |
288 | $out['text'] .= ' <tr>'; |
289 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
289 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
290 | $out['text'] .= ' <td>'.htmlentities(php_uname("s").' '.php_uname("r").' '.php_uname("v")).'</td>'; |
290 | $out['text'] .= ' <td>'.htmlentities(php_uname("s").' '.php_uname("r").' '.php_uname("v")).'</td>'; |
291 | $out['text'] .= ' </tr>'; |
291 | $out['text'] .= ' </tr>'; |
292 | $out['text'] .= ' <tr>'; |
292 | $out['text'] .= ' <tr>'; |
293 | $out['text'] .= ' <td>'._L('Machine type').'</td>'; |
293 | $out['text'] .= ' <td>'._L('Machine type').'</td>'; |
294 | $out['text'] .= ' <td>'.htmlentities(php_uname("m")).'</td>'; |
294 | $out['text'] .= ' <td>'.htmlentities(php_uname("m")).'</td>'; |
295 | $out['text'] .= ' </tr>'; |
295 | $out['text'] .= ' </tr>'; |
296 | $out['text'] .= ' <tr>'; |
296 | $out['text'] .= ' <tr>'; |
297 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
297 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
298 | $out['text'] .= ' <td>'.htmlentities(php_uname("n")).'</td>'; |
298 | $out['text'] .= ' <td>'.htmlentities(php_uname("n")).'</td>'; |
299 | $out['text'] .= ' </tr>'; |
299 | $out['text'] .= ' </tr>'; |
300 | } |
300 | } |
301 | $out['text'] .= ' <tr>'; |
301 | $out['text'] .= ' <tr>'; |
302 | $out['text'] .= ' <td>'._L('Server time').'</td>'; |
302 | $out['text'] .= ' <td>'._L('Server time').'</td>'; |
303 | $out['text'] .= ' <td>'.htmlentities(date('Y-m-d H:i:s P')).'</td>'; |
303 | $out['text'] .= ' <td>'.htmlentities(date('Y-m-d H:i:s P')).'</td>'; |
304 | $out['text'] .= ' </tr>'; |
304 | $out['text'] .= ' </tr>'; |
305 | $out['text'] .= '</table>'; |
305 | $out['text'] .= '</table>'; |
306 | $out['text'] .= '</div></div>'; |
306 | $out['text'] .= '</div></div>'; |
307 | 307 | ||
308 | # --- |
308 | # --- |
309 | 309 | ||
310 | } |
310 | } |
311 | } |
311 | } |
312 | 312 | ||
313 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
313 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
314 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
314 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
315 | 315 | ||
316 | if (file_exists(__DIR__.'/img/main_icon16.png')) { |
316 | if (file_exists(__DIR__.'/img/main_icon16.png')) { |
317 | $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png'; |
317 | $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png'; |
318 | } else { |
318 | } else { |
319 | $tree_icon = null; // default icon (folder) |
319 | $tree_icon = null; // default icon (folder) |
320 | } |
320 | } |
321 | 321 | ||
322 | if (file_exists(__DIR__.'/img/php_icon16.png')) { |
322 | if (file_exists(__DIR__.'/img/php_icon16.png')) { |
323 | $tree_icon_php = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/php_icon16.png'; |
323 | $tree_icon_php = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/php_icon16.png'; |
324 | } else { |
324 | } else { |
325 | $tree_icon_php = null; // default icon (folder) |
325 | $tree_icon_php = null; // default icon (folder) |
326 | } |
326 | } |
327 | 327 | ||
328 | $json[] = array( |
328 | $json[] = array( |
329 | 'id' => 'oidplus:systeminfo', |
329 | 'id' => 'oidplus:systeminfo', |
330 | 'icon' => $tree_icon, |
330 | 'icon' => $tree_icon, |
331 | 'text' => _L('System information'), |
331 | 'text' => _L('System information'), |
332 | 'children' => array(array( |
332 | 'children' => array(array( |
333 | 'id' => 'oidplus:phpinfo', |
333 | 'id' => 'oidplus:phpinfo', |
334 | 'icon' => $tree_icon_php, |
334 | 'icon' => $tree_icon_php, |
335 | 'text' => _L('PHP information') |
335 | 'text' => _L('PHP information') |
336 | )) |
336 | )) |
337 | ); |
337 | ); |
338 | 338 | ||
339 | return true; |
339 | return true; |
340 | } |
340 | } |
341 | 341 | ||
342 | public function tree_search($request) { |
342 | public function tree_search($request) { |
343 | return false; |
343 | return false; |
344 | } |
344 | } |
345 | 345 | ||
346 | public function implementsFeature($id) { |
346 | public function implementsFeature($id) { |
347 | return false; |
347 | return false; |
348 | } |
348 | } |
349 | } |
349 | } |
350 | 350 |