- allow setting path-to-file or simple-string as error-document (only file is valid for lighttpd), fixes #267
This commit is contained in:
68
lib/functions/froxlor/function.CorrectErrorDocument.php
Normal file
68
lib/functions/froxlor/function.CorrectErrorDocument.php
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user