mirror of
https://github.com/BeitDina/AutoIndex.git
synced 2026-02-27 21:10:42 +01:00
Update config.php for request class
This commit is contained in:
committed by
GitHub
parent
b42a187a96
commit
d768b14066
172
config.php
172
config.php
@@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* When a file with the stored config data is not present, this file is
|
||||
* automatically included to create a new one.
|
||||
*
|
||||
* @package AutoIndex
|
||||
* @author Justin Hagstrom <JustinHagstrom@yahoo.com>, FlorinCB <orynider@users.sourceforge.net>
|
||||
* @version 2.4.5-pl7 (January 01, 2019 / 30, Octomber, 2013)
|
||||
* @version 2.2.7 (January 13, 2019 / November 13, 2023)
|
||||
*
|
||||
* @copyright Copyright (C) 2002-2006 Justin Hagstrom
|
||||
* @copyright Copyright (C) 2002-2008 Justin Hagstrom
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
|
||||
*
|
||||
* @link http://autoindex.sourceforge.net
|
||||
@@ -46,109 +45,99 @@ $numbers = array('days_new', 'thumbnail_height', 'bandwidth_limit', 'md5_show',
|
||||
|
||||
if (count($_POST) >= count($strings) + count($numbers))
|
||||
{
|
||||
|
||||
$directories = array('base_dir', 'icon_path', 'flag_path', 'assets_path', 'template');
|
||||
$output = "<?php\n\n/* AutoIndex PHP Script config file\n\n";
|
||||
$request_post_setting = '';
|
||||
foreach ($strings as $setting)
|
||||
{
|
||||
if (!isset($_POST[$setting]))
|
||||
if (!$request->is_post($setting))
|
||||
{
|
||||
die(simple_display('Required setting <em>' . htmlentities($setting) . '</em> not set.'));
|
||||
}
|
||||
if ($_POST[$setting] == '')
|
||||
if ($request->is_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
|
||||
$request_post_setting = str_replace('\\', '/', $request->post($setting, TYPE_NO_TAGS)); //make sure there is a slash at the end of directories
|
||||
if (in_array($setting, $directories) && !preg_match('#/$#', $request_post_setting))
|
||||
{
|
||||
$_POST[$setting] .= '/';
|
||||
$request_post_setting .= '/';
|
||||
}
|
||||
$output .= "$setting\t{$_POST[$setting]}\n";
|
||||
$output .= "$setting\t{$request_post_setting}\n";
|
||||
}
|
||||
foreach ($checkboxes as $setting)
|
||||
{
|
||||
$output .= "$setting\t" . (isset($_POST[$setting]) ? 'true' : 'false')
|
||||
. "\n";
|
||||
$output .= "$setting\t" . ($request->is_post($setting) ? 'true' : 'false') . "\n";
|
||||
}
|
||||
foreach ($numbers as $setting)
|
||||
{
|
||||
if (!isset($_POST[$setting]))
|
||||
if (!$request->is_post($setting))
|
||||
{
|
||||
die(simple_display('Required setting <em>'
|
||||
. htmlentities($setting) . '</em> not set.'));
|
||||
die(simple_display('Required setting <em>' . htmlentities($setting) . '</em> not set.'));
|
||||
}
|
||||
if ($_POST[$setting] == '')
|
||||
if ($request->is_post($setting))
|
||||
{
|
||||
$output .= "$setting\t0\n";
|
||||
continue;
|
||||
}
|
||||
if ($_POST[$setting] < 0)
|
||||
$request_post_setting = str_replace('\\', '/', $request->post($setting, TYPE_NO_TAGS));
|
||||
if ($request_post_setting < 0)
|
||||
{
|
||||
die(simple_display('The setting <em>'
|
||||
. htmlentities($setting) . '</em> should not be a negitive number.'));
|
||||
die(simple_display('The setting <em>' . htmlentities($setting) . '</em> should not be a negitive number.'));
|
||||
}
|
||||
$_POST[$setting] = (string)((float)$_POST[$setting]);
|
||||
$output .= "$setting\t{$_POST[$setting]}\n";
|
||||
$request_post_setting = (string)((float)$request_post_setting);
|
||||
$output .= "$setting\t{$request_post_setting}\n";
|
||||
}
|
||||
$output .= "\n*/\n\n?>";
|
||||
|
||||
if (!isset($_POST['force_download']))
|
||||
if (!$request->is_post('force_download'))
|
||||
{
|
||||
if (preg_match('#^(/|[a-z]\:)#i', $_POST['base_dir']))
|
||||
if (preg_match('#^(/|[a-z]\:)#i', $request->post('base_dir', TYPE_NO_TAGS)))
|
||||
{
|
||||
die(simple_display('It seems you are using an absolute path for the Base Directory.'
|
||||
. '<br />This means you must check the "Pipe downloaded files though the PHP script" box.'));
|
||||
die(simple_display('It seems you are using an absolute path for the Base Directory.' . '<br />This means you must check the "Pipe downloaded files though the PHP script" box.'));
|
||||
}
|
||||
if ((int)$_POST['bandwidth_limit'] !== 0)
|
||||
if ((int)$request->post('bandwidth_limit', TYPE_INT) !== 0)
|
||||
{
|
||||
die(simple_display('For the Bandwidth Limit feature to work, the "force download" feature needs to be on.'
|
||||
. '<br />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']))
|
||||
if ($request->is_post('must_login_to_download') && !$request->is_post('use_login_system'))
|
||||
{
|
||||
die(simple_display('To enable <em>must_login_to_download</em>, the '
|
||||
. '<em>use_login_system</em> option must also be turned on.'));
|
||||
die(simple_display('To enable <em>must_login_to_download</em>, the ' . '<em>use_login_system</em> option must also be turned on.'));
|
||||
}
|
||||
foreach (array('base_dir', 'template') as $valid)
|
||||
{
|
||||
if (!@is_dir($_POST[$valid]))
|
||||
if (!@is_dir($request->post($valid, TYPE_NO_TAGS)))
|
||||
{
|
||||
//die(simple_display(htmlentities($valid) . ' setting is not a valid directory.'));
|
||||
}
|
||||
}
|
||||
|
||||
if (@is_file(CONFIG_STORED))
|
||||
//if the file already exists, back it up
|
||||
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++)
|
||||
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
|
||||
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
|
||||
else //the file was opened successfully, so write to it
|
||||
{
|
||||
fwrite($h, $output);
|
||||
fclose($h);
|
||||
|
||||
fclose($h);
|
||||
//begin display of "configuration complete" page
|
||||
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
|
||||
echo '<?xml version="1.0" encoding="iso-8859-2" ?>';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
@@ -193,19 +182,19 @@ if (count($_POST) >= count($strings) + count($numbers))
|
||||
<table border="0" cellpadding="5" cellspacing="0">
|
||||
<tr><td>
|
||||
<p>Write successful!<br />AutoIndex configuration is finished.</p>
|
||||
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Continue.</a></p>
|
||||
<p><a href="<?php echo $request->server('PHP_SELF'); ?>">Continue.</a></p>
|
||||
</td></tr></table>
|
||||
</body></html>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
//list of default settings
|
||||
$settings = array(
|
||||
'base_dir' => './',
|
||||
'assets_path' => 'assets/',
|
||||
'icon_path' => 'index_icons/winxp/',
|
||||
'icon_path' => 'index_icons/winvista/',
|
||||
'flag_path' => 'flags/language/',
|
||||
'language' => 'en',
|
||||
'template' => './templates/default/',
|
||||
@@ -222,28 +211,24 @@ $settings = array(
|
||||
'anti_leech' => 'false',
|
||||
'must_login_to_download' => 'false',
|
||||
'archive' => 'false',
|
||||
'days_new' => '0',
|
||||
'entries_per_page' => '0',
|
||||
'thumbnail_height' => '0',
|
||||
'days_new' => '2',
|
||||
'entries_per_page' => '300',
|
||||
'thumbnail_height' => '100',
|
||||
'bandwidth_limit' => '0',
|
||||
'md5_show' => '0',
|
||||
'parse_htaccess' => 'true'
|
||||
);
|
||||
|
||||
global $config;
|
||||
if (isset($config))
|
||||
//if we're reconfiguring the script, use the current settings
|
||||
if (isset($config)) //if we're reconfiguring the script, use the current settings
|
||||
{
|
||||
foreach ($settings as $key => $data)
|
||||
{
|
||||
$settings[$key] = $config -> __get($key);
|
||||
$settings[$key] = $config->__get($key);
|
||||
}
|
||||
}
|
||||
|
||||
//begin display of main configuration page:
|
||||
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
|
||||
echo '<?xml version="1.0" encoding="iso-8859-2" ?>';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
@@ -294,8 +279,7 @@ echo '<?xml version="1.0" encoding="iso-8859-1"?>';
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=config">
|
||||
|
||||
<form method="post" action="<?php echo $request->server('PHP_SELF'); ?>?action=config">
|
||||
<h3>
|
||||
<a href="http://autoindex.sourceforge.net/">AutoIndex PHP Script</a>
|
||||
<br />Configuration
|
||||
@@ -303,9 +287,7 @@ echo '<?xml version="1.0" encoding="iso-8859-1"?>';
|
||||
<p>
|
||||
The default options are currently selected, so just press the configure button at the bottom to use them.
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
Base Directory: <input type="text" name="base_dir" value="<?php if ($settings['base_dir'] != 'false') echo $settings['base_dir']; ?>" />
|
||||
@@ -314,8 +296,8 @@ Base Directory: <input type="text" name="base_dir" value="<?php if ($settings['b
|
||||
<br />This will be the starting point for the script. Nothing above this directory can be viewed, but its subfolders can.
|
||||
<br />Make sure to use a path relative to this index.php file if you can.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
Icon Path: <input type="text" name="icon_path" value="<?php if ($settings['icon_path'] != 'false') echo $settings['icon_path']; ?>" />
|
||||
@@ -324,8 +306,8 @@ Icon Path: <input type="text" name="icon_path" value="<?php if ($settings['icon_
|
||||
<br />The included icon sets are <em>apache</em>, <em>kde</em>, <em>osx</em>, and <em>winxp</em>.
|
||||
<br />You can leave it blank to not show icons.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
Flag Path: <input type="text" name="flag_path" value="<?php if ($settings['flag_path'] != 'false') echo $settings['flag_path']; ?>" />
|
||||
@@ -334,8 +316,8 @@ Flag Path: <input type="text" name="flag_path" value="<?php if ($settings['flag_
|
||||
<br />The included icon sets are <em>country</em>, <em>language</em>.
|
||||
<br />You can leave it blank to not show icons.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<input type="checkbox" name="show_dir_size" value="true"<?php if ($settings['show_dir_size'] != 'false') echo ' checked="checked"'; ?> /> Show Directory Size
|
||||
@@ -344,8 +326,8 @@ Flag Path: <input type="text" name="flag_path" value="<?php if ($settings['flag_
|
||||
<br />Otherwise, it will display "[dir]" under size.
|
||||
<br />NOTE: If you are trying to index many files (meaning a few thousand), you will notice a speed improvement with this turned off.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<input type="checkbox" name="search_enabled" value="true"<?php if ($settings['search_enabled'] != 'false') echo ' checked="checked"'; ?> /> Enable Searching
|
||||
@@ -354,21 +336,21 @@ Flag Path: <input type="text" name="flag_path" value="<?php if ($settings['flag_
|
||||
<br />It will search the folder you are currently in, and all subfolders.
|
||||
<br />Searching is not case sensitive.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
Template Directory: <input type="text" name="template" value="<?php if ($settings['template'] != 'false') echo $settings['template']; ?>" />
|
||||
<p class="small">
|
||||
This is the path where the *.tpl template files are located (relative to this index.php file).
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<input type="checkbox" name="use_login_system" value="true"<?php if ($settings['use_login_system'] != 'false') echo ' checked="checked"'; ?> /> Enable Login System
|
||||
<input type="checkbox" name="use_login_system" value="true"<?php if ($settings['use_login_system'] != 'true') echo ' checked="checked"'; ?> /> Enable Login System
|
||||
<br /><input type="checkbox" name="must_login_to_download" value="true"<?php if ($settings['must_login_to_download'] != 'false') echo ' checked="checked"'; ?> /> Users must login to view/download
|
||||
<br />User List: <input type="text" name="user_list" value="<?php if ($settings['user_list'] != 'false') echo $settings['user_list']; ?>" />
|
||||
<br />User List: <input type="text" name="user_list" value="<?php if ($settings['user_list'] != 'true') echo $settings['user_list']; ?>" />
|
||||
<p class="small">
|
||||
User List contains the path to the text file where the usernames and encrypted passwords are stored.
|
||||
<br />Make sure the file is chmod'ed so PHP can read and write to it.
|
||||
@@ -472,33 +454,34 @@ Image Thumbnail Height: <input type="text" name="thumbnail_height" size="3" valu
|
||||
The file to write IP addresses and hostnames that are blocked from accessing this script.
|
||||
<br />The contents of the list are editable when you login as an admin.
|
||||
</span></p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<input type="checkbox" name="archive" value="true"<?php if ($settings['archive'] != 'false') echo ' checked="checked"'; ?> /> Allow folder archive downloading
|
||||
<p class="small">
|
||||
If this box is checked, users will be able to download the folder's contents as a tar archive file.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<input type="checkbox" name="parse_htaccess" value="true"<?php if ($settings['parse_htaccess'] != 'false') echo ' checked="checked"'; ?> /> Parse .htaccess files
|
||||
<p class="small">
|
||||
If this box is checked, .htaccess files will be parsed and used by AutoIndex.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
<table width="650" cellpadding="8">
|
||||
<tr><td>
|
||||
<p>MD5 calculation max size: <input type="text" name="md5_show" size="3" value="<?php if ($settings['md5_show'] != 'false') echo $settings['md5_show']; ?>" /> MB</p>
|
||||
<p class="small">
|
||||
Setting this to 0 will disable this feature, and setting it to any other number will set the maximum size of a file to allow users to find the md5sum of (in megabytes).
|
||||
<br />(10 is a good setting to start with.)
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p />
|
||||
<table width="650" cellpadding="8"><tr><td>
|
||||
Default Language: <select name="language">
|
||||
@@ -521,10 +504,10 @@ Default Language: <select name="language">
|
||||
not available in AutoIndex. In that case, the language selected here is
|
||||
used.
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
<p /><hr /><p />
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
<p /><hr />
|
||||
<p />
|
||||
<p>
|
||||
<input type="submit" value="Configure" />
|
||||
</p>
|
||||
@@ -533,17 +516,12 @@ Default Language: <select name="language">
|
||||
<br />If it cannot (for example if it does not have write permission in the directory) the config file will be downloaded, and you will have to upload it to your server.
|
||||
<br />(It should be named <em><?php echo CONFIG_STORED; ?></em> and put in the same folder as <em>index.php</em>)
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
<!--
|
||||
|
||||
Powered by AutoIndex PHP Script (version <?php echo VERSION; ?>)
|
||||
Copyright (C) 2002-2007 Justin Hagstrom
|
||||
Copyright (C) 2002-2008 Justin Hagstrom
|
||||
http://autoindex.sourceforge.net
|
||||
|
||||
Page generated in <?php echo round((microtime(true) - START_TIME) * 1000, 1); ?> milliseconds.
|
||||
|
||||
-->
|
||||
|
||||
</body></html>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user