mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-09-25 05:01:37 +02:00
Moved default.settings.php to default.config.php and refactored code to facilitate this change. Also removed old settings.php from the index.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1 @@
|
||||
settings.ini
|
||||
resources/config.php
|
||||
|
@@ -22,7 +22,7 @@ class DirectoryLister {
|
||||
protected $_directory = NULL;
|
||||
protected $_appDir = NULL;
|
||||
protected $_appURL = NULL;
|
||||
protected $_settings = NULL;
|
||||
protected $_config = NULL;
|
||||
protected $_systemMessage = NULL;
|
||||
|
||||
|
||||
@@ -62,13 +62,16 @@ class DirectoryLister {
|
||||
$this->_appURL = $protocol . $host . $path;
|
||||
|
||||
// Load the configuration file
|
||||
$configFile = $this->_appDir . '/settings.php';
|
||||
$configFile = $this->_appDir . '/config.php';
|
||||
|
||||
if (file_exists($configFile)) {
|
||||
include($configFile);
|
||||
} else {
|
||||
$this->setSystemMessage('error', '<b>ERROR:</b> Unable to locate application config file');
|
||||
}
|
||||
|
||||
// Set the config array to a global variable
|
||||
$this->_config = $config;
|
||||
|
||||
// Get the directory path for listing
|
||||
if (!empty($_GET['dir'])) {
|
||||
@@ -83,7 +86,7 @@ class DirectoryLister {
|
||||
}
|
||||
|
||||
// Prevent access to hidden files
|
||||
if (in_array(strtolower($dir), $this->_settings['hidden_files'])) {
|
||||
if (in_array(strtolower($dir), $this->_config['hidden_files'])) {
|
||||
// Set the error message
|
||||
$this->setSystemMessage('error', '<b>ERROR:</b> Access denied');
|
||||
|
||||
@@ -92,7 +95,7 @@ class DirectoryLister {
|
||||
}
|
||||
|
||||
// Prevent access to dotfiles if specified
|
||||
if ($this->_settings['hide_dot_files']) {
|
||||
if ($this->_config['hide_dot_files']) {
|
||||
if (strlen($dir) > 1 && substr($dir, 0, 1) == '.') {
|
||||
// Set the error message
|
||||
$this->setSystemMessage('error', '<b>ERROR:</b> Access denied');
|
||||
@@ -249,8 +252,8 @@ class DirectoryLister {
|
||||
// Get file extension
|
||||
$fileExt = pathinfo($realPath, PATHINFO_EXTENSION);
|
||||
|
||||
if (isset($this->_settings['file_types'][$fileExt])) {
|
||||
$fileIcon = $this->_settings['file_types'][$fileExt];
|
||||
if (isset($this->_config['file_types'][$fileExt])) {
|
||||
$fileIcon = $this->_config['file_types'][$fileExt];
|
||||
} else {
|
||||
$fileIcon = 'blank.png';
|
||||
}
|
||||
@@ -281,11 +284,11 @@ class DirectoryLister {
|
||||
);
|
||||
}
|
||||
|
||||
} elseif (!in_array($file, $this->_settings['hidden_files'])) {
|
||||
} elseif (!in_array($file, $this->_config['hidden_files'])) {
|
||||
|
||||
// Add all non-hidden files
|
||||
if ($this->_directory == '.' && $file == 'index.php'
|
||||
|| $this->_settings['hide_dot_files'] && substr($file, 0, 1) == '.') {
|
||||
|| $this->_config['hide_dot_files'] && substr($file, 0, 1) == '.') {
|
||||
// This isn't the file you're looking for. Move along...
|
||||
} else {
|
||||
// Add file info to the array
|
||||
|
@@ -4,40 +4,40 @@
|
||||
* Initialize settings array
|
||||
*/
|
||||
|
||||
$this->_settings = array();
|
||||
$config = array();
|
||||
|
||||
/**
|
||||
* Basic settings
|
||||
*/
|
||||
|
||||
$this->_settings['hide_dot_files'] = TRUE;
|
||||
$this->_settings['list_folders_first'] = TRUE;
|
||||
$this->_settings['list_sort_order'] = 'alphabetical';
|
||||
$config['hide_dot_files'] = TRUE;
|
||||
$config['list_folders_first'] = TRUE;
|
||||
$config['list_sort_order'] = 'alphabetical';
|
||||
|
||||
|
||||
/**
|
||||
* Cache settings
|
||||
*/
|
||||
|
||||
// $this->_settings['cache_enable'] = FALSE;
|
||||
// $this->_settings['cache_expire'] = 0;
|
||||
// $config['cache_enable'] = FALSE;
|
||||
// $config['cache_expire'] = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Hidden files
|
||||
*/
|
||||
|
||||
$this->_settings['hidden_files'] = array();
|
||||
$config['hidden_files'] = array();
|
||||
|
||||
$this->_settings['hidden_files'][] = '.htaccess';
|
||||
$this->_settings['hidden_files'][] = '.htpasswd';
|
||||
$this->_settings['hidden_files'][] = 'resources';
|
||||
$config['hidden_files'][] = '.htaccess';
|
||||
$config['hidden_files'][] = '.htpasswd';
|
||||
$config['hidden_files'][] = 'resources';
|
||||
|
||||
/**
|
||||
* Icon settings
|
||||
*/
|
||||
|
||||
$this->_settings['file_types'] = array(
|
||||
$config['file_types'] = array(
|
||||
|
||||
//Applications
|
||||
'app' => 'app.png',
|
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Initialize settings array
|
||||
*/
|
||||
|
||||
$this->_settings = array();
|
||||
|
||||
|
||||
/**
|
||||
* Basic settings
|
||||
*/
|
||||
|
||||
$this->_settings['hide_dot_files'] = TRUE;
|
||||
$this->_settings['list_folders_first'] = TRUE;
|
||||
$this->_settings['list_sort_order'] = 'natcasesort';
|
||||
|
||||
|
||||
/**
|
||||
* Hidden files
|
||||
*/
|
||||
|
||||
$this->_settings['hidden_files'] = array();
|
||||
|
||||
$this->_settings['hidden_files'][] = '.htaccess';
|
||||
$this->_settings['hidden_files'][] = '.htpasswd';
|
||||
// $this->_settings['hidden_files'][] = 'resources';
|
||||
|
||||
|
||||
/**
|
||||
* Cache settings
|
||||
*/
|
||||
|
||||
// $this->_settings['cache_enable'] = FALSE;
|
||||
// $this->_settings['cache_expire'] = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Icon settings
|
||||
*/
|
||||
|
||||
$this->_settings['file_types'] = array(
|
||||
|
||||
//Applications
|
||||
'app' => 'app.png',
|
||||
'bat' => 'app.png',
|
||||
'deb' => 'app.png',
|
||||
'exe' => 'app.png',
|
||||
'msi' => 'app.png',
|
||||
'rpm' => 'app.png',
|
||||
|
||||
// Archives
|
||||
'7z' => 'archive.png',
|
||||
'bz' => 'archive.png',
|
||||
'gz' => 'archive.png',
|
||||
'rar' => 'archive.png',
|
||||
'tar' => 'archive.png',
|
||||
'zip' => 'archive.png',
|
||||
|
||||
// Audio
|
||||
'aac' => 'music.png',
|
||||
'mid' => 'music.png',
|
||||
'midi' => 'music.png',
|
||||
'mp3' => 'music.png',
|
||||
'ogg' => 'music.png',
|
||||
'wma' => 'music.png',
|
||||
'wav' => 'music.png',
|
||||
|
||||
// Code
|
||||
'c' => 'code.png',
|
||||
'cpp' => 'code.png',
|
||||
'css' => 'code.png',
|
||||
'erb' => 'code.png',
|
||||
'htm' => 'code.png',
|
||||
'html' => 'code.png',
|
||||
'java' => 'code.png',
|
||||
'js' => 'code.png',
|
||||
'php' => 'code.png',
|
||||
'pl' => 'code.png',
|
||||
'py' => 'code.png',
|
||||
'rb' => 'code.png',
|
||||
'xhtml' => 'code.png',
|
||||
'xml' => 'code.png',
|
||||
|
||||
// Disc Images
|
||||
'cue' => 'cd.png',
|
||||
'iso' => 'cd.png',
|
||||
'mdf' => 'cd.png',
|
||||
'mds' => 'cd.png',
|
||||
'mdx' => 'cd.png',
|
||||
'nrg' => 'cd.png',
|
||||
|
||||
// Documents
|
||||
'csv' => 'excel.png',
|
||||
'doc' => 'word.png',
|
||||
'docx' => 'word.png',
|
||||
'odt' => 'text.png',
|
||||
'pdf' => 'pdf.png',
|
||||
'xls' => 'excel.png',
|
||||
'xlsx' => 'excel.png',
|
||||
|
||||
// Images
|
||||
'bmp' => 'image.png',
|
||||
'gif' => 'image.png',
|
||||
'jpg' => 'image.png',
|
||||
'jpeg' => 'image.png',
|
||||
'png' => 'image.png',
|
||||
'tga' => 'image.png',
|
||||
|
||||
// Scripts
|
||||
'bat' => 'terminal.png',
|
||||
'cmd' => 'terminal.png',
|
||||
'sh' => 'terminal.png',
|
||||
|
||||
// Text
|
||||
'log' => 'text.png',
|
||||
'rtf' => 'text.png',
|
||||
'txt' => 'text.png',
|
||||
|
||||
// Video
|
||||
'avi' => 'video.png',
|
||||
'mkv' => 'video.png',
|
||||
'mov' => 'video.png',
|
||||
'mp4' => 'video.png',
|
||||
'mpg' => 'video.png',
|
||||
'wmv' => 'video.png',
|
||||
'swf' => 'flash.png',
|
||||
|
||||
// Other
|
||||
'msg' => 'message.png'
|
||||
);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user