Update test_www.php
This commit is contained in:
47
test_www.php
47
test_www.php
@@ -4,24 +4,46 @@ header('Content-Type: text/html; charset=utf-8');
|
||||
$responseHeaders = '';
|
||||
$responseCode = 0;
|
||||
$url = '';
|
||||
$timeout = 5; // domyślny timeout
|
||||
$timeout = 5;
|
||||
$userAgent = '';
|
||||
$customUserAgent = '';
|
||||
|
||||
$standardUserAgents = [
|
||||
'Chrome' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
|
||||
'Firefox' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0',
|
||||
'Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15',
|
||||
'Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.0.0',
|
||||
'curl' => 'curl/7.88.1'
|
||||
];
|
||||
|
||||
if (isset($_GET['url']) && filter_var($_GET['url'], FILTER_VALIDATE_URL)) {
|
||||
$url = $_GET['url'];
|
||||
|
||||
// Pobierz i sprawdź timeout z formularza
|
||||
if (isset($_GET['timeout'])) {
|
||||
$t = intval($_GET['timeout']);
|
||||
if ($t > 0 && $t <= 30) { // ograniczenie timeout do 30s
|
||||
if ($t > 0 && $t <= 30) {
|
||||
$timeout = $t;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['userAgent'])) {
|
||||
$userAgent = $_GET['userAgent'];
|
||||
}
|
||||
|
||||
if (isset($_GET['customUserAgent']) && trim($_GET['customUserAgent']) !== '') {
|
||||
$customUserAgent = trim($_GET['customUserAgent']);
|
||||
$userAgent = $customUserAgent;
|
||||
} elseif (isset($_GET['userAgent']) && array_key_exists($_GET['userAgent'], $standardUserAgents)) {
|
||||
$userAgent = $standardUserAgents[$_GET['userAgent']];
|
||||
} else {
|
||||
$userAgent = "PHP script"; // fallback
|
||||
}
|
||||
|
||||
$opts = [
|
||||
"http" => [
|
||||
"method" => "GET",
|
||||
"timeout" => $timeout,
|
||||
"header" => "User-Agent: PHP script\r\n"
|
||||
"header" => "User-Agent: " . $userAgent . "\r\n"
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($opts);
|
||||
@@ -62,9 +84,26 @@ if (isset($_GET['url']) && filter_var($_GET['url'], FILTER_VALIDATE_URL)) {
|
||||
<input type="text" id="url" name="url" size="50"
|
||||
value="<?php echo htmlspecialchars($url); ?>" required>
|
||||
<br><br>
|
||||
|
||||
<label for="timeout">Timeout (1-30 sekund):</label>
|
||||
<input type="number" id="timeout" name="timeout" min="1" max="30" value="<?php echo $timeout; ?>" required>
|
||||
<br><br>
|
||||
|
||||
<label for="userAgent">User-Agent (wybierz z listy):</label>
|
||||
<select id="userAgent" name="userAgent">
|
||||
<?php foreach ($standardUserAgents as $key => $ua): ?>
|
||||
<option value="<?php echo $key; ?>" <?php echo (isset($_GET['userAgent']) && $_GET['userAgent'] === $key) ? 'selected' : ''; ?>>
|
||||
<?php echo $key; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br><br>
|
||||
|
||||
<label for="customUserAgent">Lub wpisz własny User-Agent:</label>
|
||||
<input type="text" id="customUserAgent" name="customUserAgent" size="50"
|
||||
value="<?php echo htmlspecialchars(isset($_GET['customUserAgent']) ? $_GET['customUserAgent'] : ''); ?>">
|
||||
<br><br>
|
||||
|
||||
<input type="submit" value="Sprawdź">
|
||||
</form>
|
||||
|
||||
|
Reference in New Issue
Block a user