Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Betriebsystem des Servers

Empfohlene Antworten

Hallo zusammen,

ich suche eine Möglichkeit per PHP herauszufinden, welches Betriebsystem auf dem Server installiert ist.

Ich möchte abhängig davon den Include_path setzen, da dieser bei Windows mit ";" seperiert ist und bei UNIX mit ":".

hmm, nen befehl kenne ich nicht, aber VIELLEICHT nen workaround.

schau doch ob ne phpinfo.php auf dem server existiert. wenn nicht, schreib die ausgabe der phpinfo() function in ne neu zu ertsellende datei phpinfo.php und parse dir dort irgendiwe das betriebssystem aus der System textzeile raus.

vielleicht hilfts, wie gesagt nen befehl habe ich dafür noch nicht gesehn...

Hi!

Quick'n'Dirty:


ob_start();
phpinfo(INFO_MODULES);
$string = ob_get_contents();
ob_end_clean();
$pieces = explode("<h2", $string);
$settings = array();

foreach($pieces as $val) {
preg_match("/<a name=\"module_([^<>]*)\">/", $val, $sub_key);
preg_match_all("/<tr[^>]*>
<td[^>]*>(.*)<\/td>
<td[^>]*>(.*)<\/td>/Ux", $val, $sub);
preg_match_all("/<tr[^>]*>
<td[^>]*>(.*)<\/td>
<td[^>]*>(.*)<\/td>
<td[^>]*>(.*)<\/td>/Ux", $val, $sub_ext);

foreach($sub[0] as $key => $val) {
$settings[$sub_key[1]][strip_tags($sub[1][$key])] = array(strip_tags($sub[2][$key]));
}
foreach($sub_ext[0] as $key => $val) {
$settings[$sub_key[1]][strip_tags($sub_ext[1][$key])] = array(strip_tags($sub_ext[2][$key]), strip_tags($sub_ext[3][$key]));
}
}

if (strpos($settings['']['PATH '][0], ';')) {
echo 'Windows';
} else {
echo 'Unix';
}
[/PHP]

Gruß Tobias

wie gesagt, ist nur um den seperator für den include dir zu setzen.

habe mich hier bedient:


Example 2. A few OS related constant examples

<?php
// *nix
echo DIRECTORY_SEPARATOR; // /
echo PHP_SHLIB_SUFFIX; // so
echo PATH_SEPARATOR; // :

// Win*
echo DIRECTORY_SEPARATOR; // \
echo PHP_SHLIB_SUFFIX; // dll
echo PATH_SEPARATOR; // ;
?>
[/PHP]

wie wärs mit

<?php
echo $_ENV["OS"];
?>[/PHP]

Die Lösung meines Problems, habe ich in meinem letzten Post geschrieben :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.