diff options
| -rw-r--r-- | function.php | 12 | ||||
| -rw-r--r-- | getheader.php | 12 | ||||
| -rw-r--r-- | header.php | 30 | ||||
| -rw-r--r-- | index.php | 49 |
4 files changed, 103 insertions, 0 deletions
diff --git a/function.php b/function.php new file mode 100644 index 0000000..9d957a5 --- /dev/null +++ b/function.php @@ -0,0 +1,12 @@ +<?php + +function getHeader($url){ + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + + $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 new file mode 100644 index 0000000..a27400e --- /dev/null +++ b/getheader.php @@ -0,0 +1,12 @@ +<?php + +require 'function.php'; + +if($_SERVER['REQUEST_METHOD'] != "POST"){ + header($_SERVER['SERVER_PROTCOL'] . " 301 Moved"); + header("Location: /"); + exit; +} + +$header = getHeader($_POST['url']); + diff --git a/header.php b/header.php new file mode 100644 index 0000000..082135a --- /dev/null +++ b/header.php @@ -0,0 +1,30 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> + <title>Check HTTP Headers online!</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="">Home</a> + </div> + </div> + </nav> +<div class="container"> + <div class="text-center"> + <div class="row"> + <pre> +<?php + require 'getheader.php'; + echo $header; +?> + </pre> + </div> + </div> +</div> +</body> diff --git a/index.php b/index.php new file mode 100644 index 0000000..6f8cd48 --- /dev/null +++ b/index.php @@ -0,0 +1,49 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> + <title>Check HTTP Headers online!</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="">Home</a> + </div> + </div> + </nav> +<div class="container"> + <div class="text-center"> + <div class="row"> +<form class="form-horizontal" action="/header" method="POST"> +<fieldset> + +<!-- Form Name --> +<legend>Insert URL</legend> + +<!-- Text input--> +<div class="form-group"> + <label class="col-md-4 control-label" for="textinput">URL:</label> + <div class="col-md-4"> + <input id="url" name="url" placeholder="http://example.com" 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> + </div> + </div> +</div> +</body> |
