summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--function.php15
-rw-r--r--getheader.php14
-rw-r--r--header.php92
-rw-r--r--index.php45
4 files changed, 37 insertions, 129 deletions
diff --git a/function.php b/function.php
deleted file mode 100644
index 87ec766..0000000
--- a/function.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?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;
-}
diff --git a/getheader.php b/getheader.php
deleted file mode 100644
index 8beeb90..0000000
--- a/getheader.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-require 'function.php';
-
-if($_SERVER['REQUEST_METHOD'] != "POST"){
- header($_SERVER['SERVER_PROTCOL'] . " 301 Moved");
- header("Location: /");
- exit;
-}
-
-$header = getHeader($_POST['url']);
-if ( ! $header ){
- $header = "Couldn't retrieve URL. Please check if the website is available and try again.";
-}
diff --git a/header.php b/header.php
deleted file mode 100644
index 1a41233..0000000
--- a/header.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<!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;
-}
- </style>
- <title>Header: <?php echo htmlentities($_POST['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=""><span class="glyphicon glyphicon-home"></span> Home</a>
- </div>
- </div>
- </nav>
-<div class="container">
- <div class="text-center">
- <div class="row">
- <h3><u><?php echo htmlentities($_POST['url']); ?></u></h3>
- <br>
- <pre>
-<?php
- require 'getheader.php';
- echo htmlentities($header);
-?>
- </pre>
- </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>
diff --git a/index.php b/index.php
index dbbe210..957e0a8 100644
--- a/index.php
+++ b/index.php
@@ -65,10 +65,11 @@ a {
text-decoration: underline;
}
</style>
- <?php if ( $set) ?>
+ <?php if ( ! $set) { ?>
<title>Check HTTP Headers online!</title>
- <?php else
- echo '<title>Header: ' . htmlentities($_POST['url']); .'</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'>
@@ -77,7 +78,19 @@ a {
<nav class="navbar navbar-default navbar-custom" role="navigation">
<div class="container">
<div class="navbar-header">
- <a class="navbar-brand" href=""><span class="glyphicon glyphicon-home"></span> Home</a>
+ <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>
@@ -91,16 +104,32 @@ if ( $set ){
<br>
<pre>
<?php
- require 'getheader.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>
- <h3>Retrieve HTTP Headers Online!</h3>
- <p>Check the response headers for websites. <br> Enter a URL and hit the submit button.</p>
- <br>
<?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>