added warning message if upload forbidden instead of just 401 error

This commit is contained in:
Chris
2020-06-23 09:26:39 +02:00
parent 0250b6a577
commit 8de53d1ea7
2 changed files with 11 additions and 3 deletions

View File

@@ -25,12 +25,12 @@ function architect($url)
if( ( (!defined('UPLOAD_FORM_LOCATION') || (defined('UPLOAD_FORM_LOCATION') && !UPLOAD_FORM_LOCATION)) && count($u)==0) || (defined('UPLOAD_FORM_LOCATION') && UPLOAD_FORM_LOCATION && '/'.implode('/',$u)==UPLOAD_FORM_LOCATION) ) if( ( (!defined('UPLOAD_FORM_LOCATION') || (defined('UPLOAD_FORM_LOCATION') && !UPLOAD_FORM_LOCATION)) && count($u)==0) || (defined('UPLOAD_FORM_LOCATION') && UPLOAD_FORM_LOCATION && '/'.implode('/',$u)==UPLOAD_FORM_LOCATION) )
{ {
// check if client address is allowed // check if client address is allowed
$forbidden = false;
if(defined('ALLOWED_SUBNET') && !isIPInRange( getUserIP(), ALLOWED_SUBNET )) if(defined('ALLOWED_SUBNET') && !isIPInRange( getUserIP(), ALLOWED_SUBNET ))
{ {
header("HTTP/1.1 401 Unauthorized"); $forbidden = true;
exit;
} }
renderTemplate('main'); renderTemplate('main',array('forbidden'=>$forbidden));
return; return;
} }

View File

@@ -42,6 +42,13 @@
echo '<div class="alert alert-warning" role="alert">'.file_get_contents(ROOT.DS.'notice.txt').'</div>'; echo '<div class="alert alert-warning" role="alert">'.file_get_contents(ROOT.DS.'notice.txt').'</div>';
?> ?>
<div class="well"> <div class="well">
<?php if($forbidden===true) { ?>
<h2>Upload forbidden</h2>
<p>Due to configured restrictions, you are not allowed to upload files at this time</p>
<?php } else { ?>
<div id="uploadinfo"></div> <div id="uploadinfo"></div>
<p> <p>
<?php <?php
@@ -54,6 +61,7 @@
<input name="file" type="file" multiple /> <input name="file" type="file" multiple />
</div> </div>
</form> </form>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>