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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
<?php
if ( isset($_REQUEST['url']) && $_REQUEST['url'] != "" )
$set = true;
else
$set = false;
require '../tools/config.php';
if ( $_SERVER["HTTP_HOST"] == "header.iamfabulous.de"){
header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved Permanently");
header("Location: " . __domain_ . "/header/");
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<style>
<?php echo file_get_contents("../tools/style.css"); ?>
</style>
<noscript><style>.navbar{margin-bottom:0;}</style></noscript>
<?php if ( ! $set) { ?>
<title>Check HTTP Headers online!</title>
<?php } else {
echo '<title>Header: ' . htmlentities($_REQUEST['url']) .'</title>';
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' href='<?php echo __domain_; ?>/tools/favicon.ico' type='image/x-icon'>
</head>
<body>
<?php require("../tools/navbar.php"); ?>
<div class="container">
<div class="text-center">
<div class="row">
<?php
if ( $set ){
function getInfo($url, $method = "get", $customHeader = array()){
require '../tools/class/redis.php';
function ipv6($ip){
if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) {
return true;
}
return false;
}
$redis = new Database(REDIS_CONNECT, 9);
$key = md5( $url . $method . serialize($customHeader) );
if( $redis->exists( $key ) ){
return unserialize( $redis->get( $key ) );
}
$agent = "Retrieve HTTP headers online. v0.1";
$ch = curl_init();
if ( ipv6($url) ){
$url = "[".$url."]";
curl_setopt($ch,CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
}
curl_setopt ($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
switch($method){
case("head"):
curl_setopt($ch, CURLOPT_NOBODY, true);
break;
case("post"):
curl_setopt($ch, CURLOPT_POST, true);
default:
break;
}
if ( ! empty($customHeader) ){
curl_setopt($ch, CURLOPT_HTTPHEADER, $customHeader);
}
$response = curl_exec($ch);
if ( ! $response )
return false;
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$host = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$result = array($request, $header, $host);
# redis. remove this line if no redis
$redis->set( $key, serialize($result), 60 );
return $result;
}
if ( ! isset($_REQUEST['method']) || $_REQUEST['method'] == "" ){
$_REQUEST['method'] = 'get';
} else {
$_REQUEST['method'] = strtolower($_REQUEST['method']);
}
$header_info = getInfo($_REQUEST['url'], $_REQUEST['method'], $_REQUEST['header']);
if ( ! $header_info ){
echo "<h1>Failure!</h1><h3>Requested URL: \"".htmlentities($_REQUEST['url'])."\"</h3><hr></pre><pre>Couldn't retrieve URL. Please check whether the website is available and try again.</pre>";
} else {
?>
<h1>Success!</h1>
<br>
<h4><pre>Requested URL: "<u><?php echo strtolower(htmlentities($_REQUEST['url'])); ?></u>"
Host: "<u><?php echo strtolower(htmlentities($header_info[2])); ?></u>"</pre></h4>
<br>
<h3>Request Header:</h3>
<?php
echo "<pre>".htmlentities($header_info[0])."</pre>";
?>
<h3>Response Header:</h3>
<?php
echo "<pre>";
echo htmlentities($header_info[1]);
echo "</pre>";
}
?>
<p>Entries are cached for 60 seconds.</p>
<?php
} else {
?>
<form class="form-horizontal">
<fieldset>
<legend>
<h1>Retrieve HTTP Headers Online!</h1>
<p>Check the response headers for websites. </p>
</legend>
<!-- Form Name -->
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">http://</label>
<div class="col-md-5">
<input id="url" name="url" placeholder="Insert URL here." class="form-control input-md" required="" type="text">
</div>
</div>
<!-- Multiple Radios (inline) -->
<div class="form-group">
<label class="col-md-4 control-label" for="method">Request method</label>
<div class="col-md-4">
<div class="text-left">
<label class="radio-inline" for="method-0">
<input name="method" id="method-0" value="GET" checked="checked" type="radio">
GET
</label>
<label class="radio-inline" for="method-1">
<input name="method" id="method-1" value="POST" type="radio">
POST
</label>
<label class="radio-inline" for="method-2">
<input name="method" id="method-2" value="HEAD" type="radio">
HEAD
</label>
</div>
</div>
</div>
<br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label grey" for="header[]">(optional)</label>
<div class="col-md-4">
<div class="input-group">
<input name="header[]" placeholder="Custom request header here." class="form-control input-md" type="text">
<span class="input-group-btn">
<button type="button" class="btn btn-default addButton" title="Add more header." onclick="addInput('moreInput')"><i class="fa fa-plus"></i></button>
</span>
</div>
<span class="help-block text-left">Add additional header, which are sent with the request.</span>
</div>
</div>
<span id="moreInput"></span>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for=""></label>
<div class="col-md-4">
<button id="" name="" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
<?php
}
?>
</div>
</div>
</div>
<?php require("../tools/footer.php"); ?>
<script>
//window.onload = function(){
//};
function addInput(divName){
var newdiv = document.createElement('div');
newdiv.className = newdiv.className + "form-group"
newdiv.innerHTML = "<label class='col-md-4 control-label' for='header[]'></label><div class='col-md-4'> <input type='text' name='header[]' placeholder='Add more header.' class='form-control input-md' ></input></div>";
document.getElementById(divName).appendChild(newdiv);
}
</script>
</body>
|