Rev 1178 | Rev 1186 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1178 | Rev 1180 | ||
---|---|---|---|
Line 246... | Line 246... | ||
246 | $out['text'] .= ' <td>'._L('Server software').'</td>'; |
246 | $out['text'] .= ' <td>'._L('Server software').'</td>'; |
247 | $out['text'] .= ' <td>'.($_SERVER['SERVER_SOFTWARE'] ?? '<i>' . _L('unknown') . '</i>').'</td>'; |
247 | $out['text'] .= ' <td>'.($_SERVER['SERVER_SOFTWARE'] ?? '<i>' . _L('unknown') . '</i>').'</td>'; |
248 | $out['text'] .= ' </tr>'; |
248 | $out['text'] .= ' </tr>'; |
249 | $out['text'] .= ' <tr>'; |
249 | $out['text'] .= ' <tr>'; |
250 | $out['text'] .= ' <td>'._L('User account').'</td>'; |
250 | $out['text'] .= ' <td>'._L('User account').'</td>'; |
251 | $current_user = exec('whoami'); |
- | |
252 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
- | |
253 | try { |
- | |
254 | if (function_exists('mb_convert_encoding')) { |
- | |
255 | $current_user = @mb_convert_encoding($current_user, "UTF-8", "cp850"); |
- | |
256 | } else if (function_exists('iconv')) { |
- | |
257 | $current_user = @iconv("cp850", "UTF-8", $current_user); |
- | |
258 | } |
- | |
259 | } catch (\Exception $e) {} |
- | |
260 | if (function_exists('mb_strtoupper')) { |
- | |
261 | $current_user = mb_strtoupper($current_user); // just cosmetics |
- | |
262 | } |
- | |
263 | } |
- | |
264 | if ($current_user == '') { |
- | |
265 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
- | |
266 | // Windows on an IIS server: |
- | |
267 | // 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 ) |
- | |
268 | // get_current_user() DefaultAppPool |
- | |
269 | // exec('whoami') iis apppool\defaultapppool |
- | |
270 | // Windows with XAMPP: |
- | |
271 | // getenv('USERNAME') dmarschall |
- | |
272 | // get_current_user() dmarschall (even if script has a different NTFS owner!) |
- | |
273 | // exec('whoami') hickelsoft\dmarschall |
- | |
274 | $current_user = get_current_user(); |
251 | $current_user = get_own_username(); |
275 | if ($current_user == '') $current_user = getenv('USERNAME'); |
- | |
276 | } else { |
- | |
277 | // On Linux: |
- | |
278 | $current_user = exec('id -un'); |
- | |
279 | if ($current_user == '') { |
- | |
280 | // get_current_user() will get the owner of the PHP script, not the process owner! |
- | |
281 | // We want the process owner, so we use posix_geteuid(). |
- | |
282 | if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { |
- | |
283 | $uid = posix_geteuid(); |
- | |
284 | $current_user = posix_getpwuid($uid); // receive username (required read access to /etc/passwd ) |
- | |
285 | if ($current_user !== false) $current_user = $current_user['name']; |
- | |
286 | } else { |
- | |
287 | $uid = -1; |
- | |
288 | } |
- | |
289 | if ($current_user == '') $current_user = get_current_user(); |
- | |
290 | if (($current_user == '') && ($uid >= 0)) $current_user = '#' . $uid; |
- | |
291 | } |
- | |
292 | } |
- | |
293 | } |
- | |
294 | $out['text'] .= ' <td>'.($current_user == '' ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>'; |
252 | $out['text'] .= ' <td>'.($current_user === false ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>'; |
295 | $out['text'] .= ' </tr>'; |
253 | $out['text'] .= ' </tr>'; |
296 | $out['text'] .= '</tbody>'; |
254 | $out['text'] .= '</tbody>'; |
297 | $out['text'] .= '</table>'; |
255 | $out['text'] .= '</table>'; |
298 | $out['text'] .= '</div></div>'; |
256 | $out['text'] .= '</div></div>'; |
299 | 257 |