summaryrefslogtreecommitdiff
path: root/index.php
blob: 957e0a8960fc6c7c68489c2bae37380fd52cdaad (plain)
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
<?php

if ( isset($_REQUEST['url']) && $_REQUEST['url'] != "" )
	$set = true;
else
	$set = false;
?>
<!doctype html>
<html>
<head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<style>
		html {
        position: relative;
        min-height: 100%;
}

body {
        margin-bottom: 60px;
}

a {
        color: #3083D6;
}

/* navbar */

.navbar-default {
    background-color: #3083D6 ;
    border-color: #3083D6 ;
    background: #3083D6 ;
}

.navbar-default .navbar-brand {
        color: white;
}

.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
}

.navbar-default .navbar-nav > li > a { 
        color: white;
}


/* footer */

.footer {
    background-color: #3083D6 ;
    border-color: #3083D6 ;
    background: #3083D6 ;
    color: white ;
    position: absolute;
    bottom: 0;
    width: 100%;
}

.footer-a {
    color: white;
}
.footer-a:hover {
    color: white;
    text-decoration: underline;
}
	</style>
	<?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='/favicon.ico' type='image/x-icon'>
</head>
<body>
        <nav class="navbar navbar-default navbar-custom" role="navigation">
                <div class="container">
                        <div class="navbar-header">
                                <a class="navbar-brand" href="?url="><span class="glyphicon glyphicon-home"></span> Home</a>

			<?php if ( $set ){
			?>
				<form class="navbar-form navbar-left"> 
					<div class="form-group">
						<input name="url" type="text" class="form-control" placeholder="Insert another URL here.">
					</div>
					<button type="submit" class="btn btn-default">Look Up!</button>
				</form>
			<?php
			}
			?>
                        </div>
                </div>
        </nav>
<div class="container">
	<div class="text-center">
		<div class="row">
<?php 
if ( $set ){
?>
		<h3><u><?php echo htmlentities($_REQUEST['url']); ?></u></h3>
		<br>
			<pre>
<?php
	function getHeader($url){
		$agent = "Retrieve HTTP headers online. v0.1";
		$ch = curl_init($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);

		$response = curl_exec($ch);
		$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
		$header = substr($response, 0, $header_size);
		return $header;
	}
	$header = getHeader($_REQUEST['url']);
	if ( ! $header ){
		$header = "Couldn't retrieve URL. Please check if the website is available and try again.";
	}
	echo htmlentities($header);
?>
			</pre>
<?php
} else {
?>
		<h3>Retrieve HTTP Headers Online!</h3>
		<p>Check the response headers for websites. <br> Enter a URL and hit the submit button.</p>
		<br>
<form class="form-horizontal"> 
<fieldset>

<legend></legend>
<!-- Form Name -->

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="textinput">http://</label>  
  <div class="col-md-4">
  <input id="url" name="url" placeholder="Insert URL here." class="form-control input-md" required="" type="text">
    
  </div>
</div>

<!-- 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>
		<div class="footer">
			<div class="container">
				<div class="row">
					<div class="text-right">
						<p>Copyright 2014 <a class="footer-a" href="//www.moehm.org/"  target="_blank" title="https://www.moehm.org/">Maximilian M&ouml;hring</a></p>
					</div>
				</div>
			</div>
		</div>
</body>