From 4168f7aff52f6e7cf7320e42252227dac5169c4a Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 16 Nov 2014 21:20:41 +0100 Subject: Initial commit. --- header/index.php | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 header/index.php (limited to 'header/index.php') diff --git a/header/index.php b/header/index.php new file mode 100644 index 0000000..1a027ab --- /dev/null +++ b/header/index.php @@ -0,0 +1,200 @@ + + + + + + + + + + + Check HTTP Headers online! + Header: ' . htmlentities($_REQUEST['url']) .''; + } + ?> + + + + + +
+
+
+connect("/var/run/redis/redis.sock"); + $redis->ping(); + $redis->select(9); + + $key = md5( $url . serialize($customHeader) ); + + if( $redis->exists( $key ) ){ + return unserialize( $redis->get( $key ) ); + } + + $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); + + switch($method){ + case("head"): + curl_setopt($ch, CURLOPT_NOBODY, true); + break; + case("post"): + curl_setopt($ch, CURLOPT_POST, true); + default: + break; + } + + 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); + $host = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + + $result = array($request, $header, $host); + + # redis. remove this line if no redis + $redis->set( $key, serialize($result), 60 ); + + return $result; + } + if ( ! isset($_REQUEST['method']) || $_REQUEST['method'] != "" ){ + $_REQUEST['method'] = 'get'; + } else { + $_REQUEST['method'] = strtolower($_REQUEST['method']); + } + $header_info = getInfo($_REQUEST['url'], $_REQUEST['method'], $_REQUEST['header']); + if ( ! $header_info ){ + echo "

Failure!

Requested URL: \"".htmlentities($_REQUEST['url'])."\"


Couldn't retrieve URL. Please check whether the website is available and try again.
"; + } else { + ?> +

Success!

+
+

Requested URL: ""
+Host: ""

+
+ +

Request Header:

+ ".htmlentities($header_info[0]).""; + ?> +

Response Header:

+ "; + echo htmlentities($header_info[1]); + echo ""; + } + ?> +

Entries are cached for 60 seconds.

+ +

Retrieve HTTP Headers Online!

+

Check the response headers for websites.
Enter a URL and hit the submit button.

+
+
+
+ + + + + + +
+ +
+ +
+
+ + +
+ +
+ + + +
+
+ +
+ + +
+ +
+
+ + + + + +
+ Add any header, which are sent to the server. +
+
+ + + + +
+ +
+ +
+
+ +
+
+ + +
+
+
+ + + -- cgit v1.2.3