- 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

@ -309,35 +309,9 @@ elseif($page == 'htaccess')
$options_cgi = '0';
}
if(($_POST['error404path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error404path']))))
{
$error404path = $_POST['error404path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error403path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error403path']))))
{
$error403path = $_POST['error403path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error500path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error500path']))))
{
$error500path = $_POST['error500path'];
}
else
{
standard_error('mustbeurl');
}
$error404path = correctErrorDocument($_POST['error404path']);
$error403path = correctErrorDocument($_POST['error403path']);
$error500path = correctErrorDocument($_POST['error500path']);
if($path_dupe_check['path'] == $path)
{
@ -397,35 +371,9 @@ elseif($page == 'htaccess')
$options_cgi = '0';
}
if(($_POST['error404path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error404path']))))
{
$error404path = $_POST['error404path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error403path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error403path']))))
{
$error403path = $_POST['error403path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error500path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error500path']))))
{
$error500path = $_POST['error500path'];
}
else
{
standard_error('mustbeurl');
}
$error404path = correctErrorDocument($_POST['error404path']);
$error403path = correctErrorDocument($_POST['error403path']);
$error500path = correctErrorDocument($_POST['error500path']);
if(($option_indexes != $result['options_indexes'])
|| ($error404path != $result['error404path'])

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;
}

View File

@ -171,10 +171,10 @@ $lng['extras']['error404path'] = '404';
$lng['extras']['error403path'] = '403';
$lng['extras']['error500path'] = '500';
$lng['extras']['error401path'] = '401';
$lng['extras']['errordocument404path'] = 'URL to ErrorDocument 404';
$lng['extras']['errordocument403path'] = 'URL to ErrorDocument 403';
$lng['extras']['errordocument500path'] = 'URL to ErrorDocument 500';
$lng['extras']['errordocument401path'] = 'URL to ErrorDocument 401';
$lng['extras']['errordocument404path'] = 'ErrorDocument 404';
$lng['extras']['errordocument403path'] = 'ErrorDocument 403';
$lng['extras']['errordocument500path'] = 'ErrorDocument 500';
$lng['extras']['errordocument401path'] = 'ErrorDocument 401';
/**
* Errors
@ -1464,5 +1464,8 @@ $lng['serversettings']['perl']['suexecworkaround']['title'] = 'Enable SuExec wor
$lng['serversettings']['perl']['suexecworkaround']['description'] = 'Enable only if customer docroots are not within the apache suexec path.<br />If enabled, Froxlor will generate a symlink from the customers perl-enabled directory + /cgi-bin/ to the given path.<br />Note that perl will then only work in the folders subdirectory /cgi-bin/ and not in the folder itself (as it does without this fix!)';
$lng['serversettings']['perl']['suexeccgipath']['title'] = 'Path for customer perl-enabled directory symlinks';
$lng['serversettings']['perl']['suexeccgipath']['description'] = 'You only need to set this if the SuExec-workaround is enabled.<br />ATTENTION: Be sure this path is within the suexec path or else this workaround is uselsess';
$lng['panel']['descriptionerrordocument'] = 'Can be an URL, path to a file or just a string wrapped around " "<br />Leave empty to use server default value.';
$lng['error']['stringerrordocumentnotvalidforlighty'] = 'A string as ErrorDocument does not work in lighttpd, please specify a path to a file';
$lng['error']['urlerrordocumentnotvalidforlighty'] = 'An URL as ErrorDocument does not work in lighttpd, please specify a path to a file';
?>

View File

@ -171,10 +171,10 @@ $lng['extras']['error404path'] = '404';
$lng['extras']['error403path'] = '403';
$lng['extras']['error500path'] = '500';
$lng['extras']['error401path'] = '401';
$lng['extras']['errordocument404path'] = 'URL zum Fehlerdokument 404';
$lng['extras']['errordocument403path'] = 'URL zum Fehlerdokument 403';
$lng['extras']['errordocument500path'] = 'URL zum Fehlerdokument 500';
$lng['extras']['errordocument401path'] = 'URL zum Fehlerdokument 401';
$lng['extras']['errordocument404path'] = 'Fehlerdokument 404';
$lng['extras']['errordocument403path'] = 'Fehlerdokument 403';
$lng['extras']['errordocument500path'] = 'Fehlerdokument 500';
$lng['extras']['errordocument401path'] = 'Fehlerdokument 401';
/**
* Errors
@ -1447,5 +1447,8 @@ $lng['serversettings']['perl']['suexecworkaround']['title'] = 'Aktiviere SuExec
$lng['serversettings']['perl']['suexecworkaround']['description'] = 'Aktivieren Sie den Workaround nur, wenn die Kunden-Heimatverzeichnise sich nicht unterhalb des suexec-Pfades liegen.<br />Wenn aktiviert erstellt Froxlor eine Verkn&uuml;pfung des vom Kunden f&uuml;r Perl aktiviertem Pfad + /cgi-bin/ im angegebenen suexec-Pfad.<br />Bitte beachten Sie, dass Perl dann nur im Unterordner /cgi-bin/ des Kunden-Ordners funktioniert und nicht direkt in diesem Ordner (wie es ohne den Workaround w&auml;re!)';
$lng['serversettings']['perl']['suexeccgipath']['title'] = 'Pfad f&uuml;r Verkn&uuml;pfungen zu Kunden-Perl-Verzeichnis';
$lng['serversettings']['perl']['suexeccgipath']['description'] = 'Diese Einstellung wird nur ben&ouml;tigt, wenn der SuExec-Workaround aktiviert ist.<br />ACHTUNG: Stellen Sie sicher, dass sich der angegebene Pfad innerhalb des Suexec-Pfades befindet ansonsten ist der Workaround nutzlos';
$lng['panel']['descriptionerrordocument'] = 'M&ouml;gliche Werte sind: URL, Pfad zu einer Datei oder ein Text umgeben von Anf&uuml;hrungszeichen (" ")<br />Leer f&uuml;r Server-Standardwerd.';
$lng['error']['stringerrordocumentnotvalidforlighty'] = 'Ein Text als Fehlerdokument funktioniert leider in LigHTTPd nicht, bitte geben Sie einen Pfad zu einer Datei an';
$lng['error']['urlerrordocumentnotvalidforlighty'] = 'Eine URL als Fehlerdokument funktioniert leider in LigHTTPd nicht, bitte geben Sie einen Pfad zu einer Datei an';
?>

View File

@ -19,17 +19,17 @@ $header
<td class="main_field_display" nowrap="nowrap">$options_indexes</td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument404path']}:</b><br />{$lng['panel']['emptyfordefault']}</td>
<td class="main_field_name"><b>{$lng['extras']['errordocument404path']}:</b><br />{$lng['panel']['descriptionerrordocument']}</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error404path" value="" size="30" maxlength="255" /></td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument403path']}:</b><br />{$lng['panel']['emptyfordefault']}
<td class="main_field_name"><b>{$lng['extras']['errordocument403path']}:</b><br />{$lng['panel']['descriptionerrordocument']}
<if $settings['system']['webserver'] == 'lighttpd'><div style="color:red">{$lng['panel']['not_supported']}lighttpd</div></if>
</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error403path" value="" size="30" maxlength="255" /></td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument500path']}:</b><br />{$lng['panel']['emptyfordefault']}
<td class="main_field_name"><b>{$lng['extras']['errordocument500path']}:</b><br />{$lng['panel']['descriptionerrordocument']}
<if $settings['system']['webserver'] == 'lighttpd'><div style="color:red">{$lng['panel']['not_supported']}lighttpd</div></if>
</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error500path" value="" size="30" maxlength="255" /></td>

View File

@ -17,17 +17,17 @@ $header
<td class="main_field_display" nowrap="nowrap">$options_indexes</td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument404path']}:</b><br />{$lng['panel']['emptyfordefault']}</td>
<td class="main_field_name"><b>{$lng['extras']['errordocument404path']}:</b><br />{$lng['panel']['descriptionerrordocument']}</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error404path" value="{$result['error404path']}" size="30" maxlength="255" /></td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument403path']}:</b><br />{$lng['panel']['emptyfordefault']}
<td class="main_field_name"><b>{$lng['extras']['errordocument403path']}:</b><br />{$lng['panel']['descriptionerrordocument']}
<if $settings['system']['webserver'] == 'lighttpd'><div style="color:red">{$lng['panel']['not_supported']}lighttpd</div></if>
</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error403path" value="{$result['error403path']}" size="30" maxlength="255" /></td>
</tr>
<tr>
<td class="main_field_name"><b>{$lng['extras']['errordocument500path']}:</b><br />{$lng['panel']['emptyfordefault']}
<td class="main_field_name"><b>{$lng['extras']['errordocument500path']}:</b><br />{$lng['panel']['descriptionerrordocument']}
<if $settings['system']['webserver'] == 'lighttpd'><div style="color:red">{$lng['panel']['not_supported']}lighttpd</div></if>
</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="error500path" value="{$result['error500path']}" size="30" maxlength="255" /></td>