diff options
author | Luke Bratch <l_bratch@yahoo.co.uk> | 2013-02-15 14:54:53 +0000 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2013-02-15 14:54:53 +0000 |
commit | b20a972de085d327fe5ad25e02a449a5cb1b0a69 (patch) | |
tree | 63ca2f738a2515279f81264cc97f99372f2d5f4a /submit.php | |
parent | e84100d615f7bcfb7d43d183491b4dd067c538cc (diff) |
Make redirect work with any hostname or path
Diffstat (limited to 'submit.php')
-rwxr-xr-x | submit.php | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -1,13 +1,21 @@ <?php + $path = str_replace( basename( $_SERVER['SCRIPT_NAME'] ), "", $_SERVER['SCRIPT_NAME'] ); + + if ( isset( $_SERVER['HTTP_HOST'] ) ) { + $hostname = $_SERVER['HTTP_HOST']; + } else { + $hostname = $_SERVER['SERVER_NAME']; + } + if( isset( $_POST["paste"]) && $_POST["paste"] != "" ) { $paste = $_POST["paste"]; $id = dechex( crc32( $paste ) ); $fh = fopen( $id, "w" ); fwrite( $fh, $paste ); fclose( $fh ); - header( "Location: http://p.of.je/$id" ); + header( "Location: http://" . $hostname . $path . $id ); } else { - header( "Location: http://p.of.je" ); + header( "Location: http://" . $hostname . $path ); } ?> |