- allow setting path-to-file or simple-string as error-document (only file is valid for lighttpd), fixes #267

This commit is contained in:
Michael Kaufmann (d00p)
2010-08-05 07:10:27 +00:00
parent 0f0ae6eb6d
commit 74da53c822
6 changed files with 94 additions and 72 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/*
* this functions validates a given value as ErrorDocument
* refs #267
*
* @param string error-document-string
*
* @return string error-document-string
*
*/
function correctErrorDocument($errdoc = null)
{
global $idna_convert;
if($errdoc !== null && $errdoc != '')
{
// not a URL
if(!validateUrl($idna_convert->encode($errdoc)))
{
// a file
if(substr($errdoc, 0, 1) != '"')
{
$errdoc = makeCorrectFile($errdoc);
// apache needs a starting-slash (starting at the domains-docroot)
if(!substr($errdoc, 0, 1) == '/') {
$errdoc = '/'.$errdoc;
}
}
// a string (check for ending ")
else
{
// string won't work for lighty
if($settings['system']['webserver'] == 'lighttpd')
{
standard_error('stringerrordocumentnotvalidforlighty');
}
elseif(substr($errdoc, -1) != '"')
{
$errdoc .= '"';
}
}
}
else
{
if($settings['system']['webserver'] == 'lighttpd')
{
standard_error('urlerrordocumentnotvalidforlighty');
}
}
}
return $errdoc;
}