From 12289bbe0e4ea8836ed631a1dec743b0e11f28f6 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 9 Jul 2020 11:32:49 +0100 Subject: Redirect to HTTP or HTTPS depending on which protocol the request came from. --- submit.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) mode change 100755 => 100644 submit.php diff --git a/submit.php b/submit.php old mode 100755 new mode 100644 index 2be2b1b..5bbc1bf --- a/submit.php +++ b/submit.php @@ -7,15 +7,21 @@ $hostname = $_SERVER['SERVER_NAME']; } + if ($_SERVER['HTTPS'] == "on") { + $protocol = "https"; + } else { + $protocol = "http"; + } + 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://" . $hostname . $path . $id ); + header( "Location: " . $protocol . "://" . $hostname . $path . $id ); } else { - header( "Location: http://" . $hostname . $path ); + header( "Location: " . $protocol . "://" . $hostname . $path ); } ?> -- cgit v1.2.3