* @version 1.2.0 (January 01, 2006)
*
* @copyright Copyright (C) 2002-2006 Justin Hagstrom
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
*
* @link http://autoindex.sourceforge.net
*/
/*
AutoIndex PHP Script is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AutoIndex PHP Script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!defined('IN_AUTOINDEX') || !IN_AUTOINDEX)
{
die();
}
$strings = array('base_dir', 'icon_path', 'language', 'template', 'log_file',
'description_file', 'user_list', 'download_count', 'hidden_files',
'banned_list');
$checkboxes = array('show_dir_size', 'use_login_system', 'force_download',
'search_enabled', 'anti_leech', 'must_login_to_download', 'archive',
'parse_htaccess');
$numbers = array('days_new', 'thumbnail_height', 'bandwidth_limit', 'md5_show',
'entries_per_page');
if (count($_POST) >= count($strings) + count($numbers))
{
$directories = array('base_dir', 'icon_path', 'template');
$output = "'
. htmlentities($setting) . ' not set.'));
}
if ($_POST[$setting] == '')
{
$output .= "$setting\tfalse\n";
continue;
}
$_POST[$setting] = str_replace('\\', '/', $_POST[$setting]);
if (in_array($setting, $directories) && !preg_match('#/$#', $_POST[$setting]))
//make sure there is a slash at the end of directories
{
$_POST[$setting] .= '/';
}
$output .= "$setting\t{$_POST[$setting]}\n";
}
foreach ($checkboxes as $setting)
{
$output .= "$setting\t" . (isset($_POST[$setting]) ? 'true' : 'false')
. "\n";
}
foreach ($numbers as $setting)
{
if (!isset($_POST[$setting]))
{
die(simple_display('Required setting '
. htmlentities($setting) . ' not set.'));
}
if ($_POST[$setting] == '')
{
$output .= "$setting\t0\n";
continue;
}
if ($_POST[$setting] < 0)
{
die(simple_display('The setting '
. htmlentities($setting) . ' should not be a negitive number.'));
}
$_POST[$setting] = (string)((float)$_POST[$setting]);
$output .= "$setting\t{$_POST[$setting]}\n";
}
$output .= "\n*/\n\n?>";
if (!isset($_POST['force_download']))
{
if (preg_match('#^(/|[a-z]\:)#i', $_POST['base_dir']))
{
die(simple_display('It seems you are using an absolute path for the Base Directory.'
. '
This means you must check the "Pipe downloaded files though the PHP script" box.'));
}
if ((int)$_POST['bandwidth_limit'] !== 0)
{
die(simple_display('For the Bandwidth Limit feature to work, the "force download" feature needs to be on.'
. '
This means you must check the "Pipe downloaded files though the PHP script" box.'));
}
}
if (isset($_POST['must_login_to_download']) && !isset($_POST['use_login_system']))
{
die(simple_display('To enable must_login_to_download, the '
. 'use_login_system option must also be turned on.'));
}
foreach (array('base_dir', 'template') as $valid)
{
if (!@is_dir($_POST[$valid]))
{
die(simple_display(htmlentities($valid)
. ' setting is not a valid directory.'));
}
}
if (@is_file(CONFIG_STORED))
//if the file already exists, back it up
{
$temp_name = CONFIG_STORED . '.bak';
for ($i = 1; @file_exists($temp_name); $i++)
{
$temp_name = CONFIG_STORED . '.bak' . (string)$i;
}
@copy(CONFIG_STORED, $temp_name);
}
$h = @fopen(CONFIG_STORED, 'wb');
if ($h === false)
//the file could not be written to, so now it must be downloaded through the browser
{
header('Content-Type: text/plain; name="' . CONFIG_STORED . '"');
header('Content-Disposition: attachment; filename="' . CONFIG_STORED . '"');
die($output);
}
else
//the file was opened successfully, so write to it
{
fwrite($h, $output);
fclose($h);
//begin display of "configuration complete" page
echo '';
?>
|
Write successful! |