diff options
| author | root | 2014-11-10 21:05:59 +0100 |
|---|---|---|
| committer | root | 2014-11-10 21:05:59 +0100 |
| commit | a55573a5aa040d171a8d162db0bbbd4a1bc7a6be (patch) | |
| tree | 594e53154e33a32532a6dadfa4cc7493d52e2817 /index.php | |
| parent | 6b9e4d0310dfcfd6b780046dad76c7c4c80868b1 (diff) | |
| download | httpheader-a55573a5aa040d171a8d162db0bbbd4a1bc7a6be.tar.gz | |
stable
Diffstat (limited to 'index.php')
| -rw-r--r-- | index.php | 91 |
1 files changed, 73 insertions, 18 deletions
@@ -10,6 +10,7 @@ else <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> html { position: relative; @@ -72,7 +73,7 @@ a { } ?> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> + <link rel='shortcut icon' href='favicon.ico' type='image/x-icon'> </head> <body> <nav class="navbar navbar-default navbar-custom" role="navigation"> @@ -81,6 +82,7 @@ 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"> @@ -89,6 +91,7 @@ a { <button type="submit" class="btn btn-default">Look Up!</button> </form> <?php + */ } ?> </div> @@ -99,52 +102,92 @@ a { <div class="row"> <?php if ( $set ){ -?> - <h3><u><?php echo htmlentities($_REQUEST['url']); ?></u></h3> - <br> - <pre> -<?php - function getHeader($url){ + function getInfo($url, $customHeader = array()){ $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); + curl_setopt($ch, CURLINFO_HEADER_OUT, 1); + + 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); - return $header; + $host = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + + $result = array($request, $header, $host); + return $result; } - $header = getHeader($_REQUEST['url']); - if ( ! $header ){ - $header = "Couldn't retrieve URL. Please check if the website is available and try again."; + $header_info = getInfo($_REQUEST['url'], $_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>"; } - 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"> +<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"> + <div class="col-md-5"> <input id="url" name="url" placeholder="Insert URL here." class="form-control input-md" required="" type="text"> - </div> </div> +<br> + +<!-- Text input--> +<div class="form-group"> + <label class="col-md-4 control-label" 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 any header, which are sent to the server.</span> + </div> +</div> + +<span id="moreInput"></span> + <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for=""></label> @@ -165,9 +208,21 @@ if ( $set ){ <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öhring</a></p> + <p><span class="fa fa-copyright"></span> Copyright 2014 <a class="footer-a" href="//www.moehm.org/" target="_blank" title="https://www.moehm.org/">Maximilian Möhring</a></p> </div> </div> </div> </div> +<script src="//code.jquery.com/jquery-1.11.1.min.js"></script> +<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='More header.' class='form-control input-md' ></input></div>"; + document.getElementById(divName).appendChild(newdiv); +} +</script> </body> |
