summaryrefslogtreecommitdiff
path: root/submit.php
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2013-02-15 14:54:53 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2013-02-15 14:54:53 +0000
commitb20a972de085d327fe5ad25e02a449a5cb1b0a69 (patch)
tree63ca2f738a2515279f81264cc97f99372f2d5f4a /submit.php
parente84100d615f7bcfb7d43d183491b4dd067c538cc (diff)
Make redirect work with any hostname or path
Diffstat (limited to 'submit.php')
-rwxr-xr-xsubmit.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/submit.php b/submit.php
index 538fee9..2be2b1b 100755
--- a/submit.php
+++ b/submit.php
@@ -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 );
}
?>