diff options
Diffstat (limited to 'index.php')
| -rw-r--r-- | index.php | 45 |
1 files changed, 37 insertions, 8 deletions
@@ -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> |
