-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
116 lines (111 loc) · 3.35 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTTP Header Checker Tool by WebSniffer</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}
form {
display: flex;
flex-direction: column;
width: 100%;
max-width: 500px;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
label, select, input[type="text"], input[type="submit"] {
margin: 10px 0;
}
input[type="text"], select {
padding: 10px;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 5px;
}
input[type="submit"] {
background-color: #007bff;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
@media (max-width: 600px) {
form {
width: 90%;
margin: 20px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>HTTP Header Checker Tool</h1>
<form method="post">
<label for="url">Enter a website URL:</label>
<input type="text" id="url" name="url" required>
<br>
<label for="request">Choose a request type:</label>
<select id="request" name="request">
<option value="GET">GET</option>
<option value="POST">POST</option>
</select>
<br>
<input type="submit" value="Submit">
</form>
<p style="max-width: 500px;">The HTTP Header Checker tool allows you to check the HTTP headers of any web page. Simply enter the URL of the website you wish to inspect and select the request type (GET or POST). The tool will then display the HTTP response headers and content of the page. This service is <a href="https://github.com/WebSnifferHQ/WebSniffer-PHP" title="GitHub repo" target="_blank">open-source</a>, provided under the MIT license, and freely offered by <a href="https://websniffer.com/" title="WebSniffer" target="_blank">WebSniffer</a>.</p>
</div>
<?php
// Check if the form has been submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the URL and request type from the form input
$url = $_POST["url"];
$request_type = $_POST["request"];
// Send a GET or POST request to the URL
if ($request_type == "GET") {
$response = file_get_contents($url);
} elseif ($request_type == "POST") {
$data = array('key1' => 'value1', 'key2' => 'value2');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
}
// Get the HTTP response header and content
$http_response_header = $http_response_header ?? null;
$http_response_content = $response ?? null;
// Display the HTTP response header and content
echo "<h2>HTTP Response Header:</h2>";
echo "<pre>";
if (is_array($http_response_header)) {
foreach ($http_response_header as $header) {
echo htmlspecialchars($header) . "\n";
}
}
echo "</pre>";
echo "<h2>HTTP Response Content:</h2>";
echo "<pre>";
echo htmlentities($http_response_content);
echo "</pre>";
}
?>
</body>
</html>