fix base path behind proxy

master
Marc Wäckerlin 7 years ago
parent 004037dc53
commit 6539474418
  1. 19
      html/index.php

@ -1,8 +1,13 @@
<?php
mb_internal_encoding("utf8");
$subpath="";
$file="";
$username="";
$subpath = "";
$file = "";
$username = "";
$myurl = (isset($_SERVER['HTTPS']) ? 'https' : 'http')
.'://'.$_SERVER['HTTP_HOST']
.explode('?', (isset($_SERVER['HTTP_X_ORIGINAL_REQUEST'])
? $_SERVER['HTTP_X_ORIGINAL_REQUEST']
: $_SERVER['REQUEST_URI']))[0];
function error_die($reason, $status='500 Internal Server Error') {
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@ -159,8 +164,7 @@ function linkorselect($link, $img, $filename) {
if (!isset($_REQUEST['secret'])) {
if ($username=="") error_die('not authorized', '403 Forbidden');
if (isset($_REQUEST['qrcode'])) {
QRcode::png((isset($_SERVER['HTTPS']) ? 'https' : 'http')
.'://'.$_SERVER['HTTP_HOST'].explode('?', $_SERVER['REQUEST_URI'])[0].'?secret='.$_REQUEST['qrcode']);
QRcode::png($myurl.'?secret='.$_REQUEST['qrcode']);
exit;
} else {
if (isset($_REQUEST['path'])) checkPath($_REQUEST['path']);
@ -280,7 +284,7 @@ if (!isset($_REQUEST['secret'])) {
$message = preg_replace('/PASSWORD/', $_REQUEST['password'], $_REQUEST['mailtext']);
else
$message = $_REQUEST['mailtext']."\n\npassword: ".$REQUEST['password'];
$link = (isset($_SERVER['HTTPS'])?'https://':'http://').$_SERVER['HTTP_HOST'].explode('?', $_SERVER['REQUEST_URI'])[0].'?secret='.$secret;
$link = $myurl.'?secret='.$secret;
if (preg_match('/LINK/', $message))
$message = preg_replace('/LINK/', $link, $message);
else
@ -298,8 +302,7 @@ if (!isset($_REQUEST['secret'])) {
echo '<p>Share files: Tell your friend the password on a separate channel and send this: <a href="?secret
='.$secret.'">Link to Share</a></p>';
?>
<img src="<?php echo (isset($_SERVER['HTTPS']) ? 'https' : 'http')
.'://'.$_SERVER['HTTP_HOST'].explode('?', $_SERVER['REQUEST_URI'])[0].'?qrcode='.$secret; ?>" />
<img src="<?php echo $myurl.'?qrcode='.$secret; ?>" />
<p>or Send Link in E-Mail:</p>
<form method="POST">
<table style="width: 100%"><tr>

Loading…
Cancel
Save