From e8359b6599ccd081c6659c071102aed7f32bb3d6 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Wed, 8 Jan 2020 23:18:26 -0700 Subject: [PATCH] Preparing v3.0.0 import --- .github/FUNDING.yml | 3 - .gitignore | 2 - COPYING | 19 - README.md | 71 -- index.php | 52 - resources/DirectoryLister.php | 918 ------------------ resources/default.config.php | 61 -- resources/fileTypes.php | 132 --- resources/themes/bootstrap/css/style.css | 142 --- resources/themes/bootstrap/default_footer.php | 5 - resources/themes/bootstrap/default_header.php | 0 resources/themes/bootstrap/img/folder.png | Bin 537 -> 0 bytes resources/themes/bootstrap/index.php | 170 ---- .../themes/bootstrap/js/directorylister.js | 66 -- 14 files changed, 1641 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .gitignore delete mode 100644 COPYING delete mode 100644 README.md delete mode 100644 index.php delete mode 100644 resources/DirectoryLister.php delete mode 100644 resources/default.config.php delete mode 100644 resources/fileTypes.php delete mode 100644 resources/themes/bootstrap/css/style.css delete mode 100644 resources/themes/bootstrap/default_footer.php delete mode 100644 resources/themes/bootstrap/default_header.php delete mode 100644 resources/themes/bootstrap/img/folder.png delete mode 100644 resources/themes/bootstrap/index.php delete mode 100644 resources/themes/bootstrap/js/directorylister.js diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 9b32da7..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: PHLAK -patreon: PHLAK -custom: https://paypal.me/ChrisKankiewicz diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 96a920c..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -analytics.inc -resources/config.php diff --git a/COPYING b/COPYING deleted file mode 100644 index 56c6042..0000000 --- a/COPYING +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2017 Chris Kankiewicz - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index f008f4b..0000000 --- a/README.md +++ /dev/null @@ -1,71 +0,0 @@ -Directory Lister - The simple PHP directory lister -================================================== -Created by, [Chris Kankiewicz](http://www.ChrisKankiewicz.com) - - -Introduction ------------- - -Directory Lister is a simple PHP script that lists the contents of any web-accessable directory and -allows navigating there within. Simply upload Directory Lister to any directory and get immediate -access to all files and sub-direcories under that directory. Directory Lister is written in PHP and -distributed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). - -Like this project? Want to keep it free? [Make a donation](https://cash.me/$ChrisKankiewicz). - -More info available at - - -Features --------- - - * Extremely simple installation - * Creates on-the-fly listing of any web-accessable directory - * Custimizable sort order of files/folders - * Easily define hidden files to be excluded from the listing - - -Requirements ------------- - -Directory Lister requires PHP 5.3+ to work properly. For more information on PHP, please visit -. - - -Installation ------------- - - 1. Copy `resources/default.config.php` to `resources/config.php` - 2. Upload `index.php` and the `resources` folder to the folder you want listed - 3. Upload additional files to the same directory as index.php - - -Troubleshooting ---------------- - -Ensure you have the latest version of Directory Lister installed. - -Verify that you have PHP 5.3 or later installed. You can verify your PHP version by running: - - php --version - - -Contact Info ------------- - -Contact us via our mailling list at [Directory-Lister@GoogleGroups.com](mailto:Directory-Lister@GoogleGroups.com) -or [join our Google Group](https://groups.google.com/forum/?fromgroups#!forum/directory-lister) online. - -Follow Directory Lister on Twitter at [@DirectoryLister](https://twitter.com/directorylister) or -follow the developer at [@PHLAK](https://twitter.com/PHLAK) - -Find a problem or bug with Directory Lister? -[Open an issue](https://github.com/DirectoryLister/DirectoryLister/issues) on GitHub. - - -License -------- - -Directory Lister is distributed under the terms of the -[MIT License](http://www.opensource.org/licenses/mit-license.php). -Copyright 2017 [Chris Kankiewicz](http://www.chriskankiewicz.com) diff --git a/index.php b/index.php deleted file mode 100644 index 6f69a18..0000000 --- a/index.php +++ /dev/null @@ -1,52 +0,0 @@ -getFileHash($_GET['hash']); - $data = json_encode($hashes); - - // Return the data - die($data); - - } - - if (isset($_GET['zip'])) { - - $dirArray = $lister->zipDirectory($_GET['zip']); - - } else { - - // Initialize the directory array - if (isset($_GET['dir'])) { - $dirArray = $lister->listDirectory($_GET['dir']); - } else { - $dirArray = $lister->listDirectory('.'); - } - - // Define theme path - if (!defined('THEMEPATH')) { - define('THEMEPATH', $lister->getThemePath()); - } - - // Set path to theme index - $themeIndex = $lister->getThemePath(true) . '/index.php'; - - // Initialize the theme - if (file_exists($themeIndex)) { - include($themeIndex); - } else { - die('ERROR: Failed to initialize theme'); - } - - } diff --git a/resources/DirectoryLister.php b/resources/DirectoryLister.php deleted file mode 100644 index 7ddfeff..0000000 --- a/resources/DirectoryLister.php +++ /dev/null @@ -1,918 +0,0 @@ -_appDir = __DIR__; - - // Build the application URL - $this->_appURL = $this->_getAppUrl(); - - // Load the configuration file - $configFile = $this->_appDir . '/config.php'; - - // Set the config array to a global variable - if (file_exists($configFile)) { - $this->_config = require_once($configFile); - } else { - die('ERROR: Missing application config file at ' . $configFile); - } - - // Set the file types array to a global variable - $this->_fileTypes = require_once($this->_appDir . '/fileTypes.php'); - - // Set the theme name - $this->_themeName = $this->_config['theme_name']; - - } - - /** - * If it is allowed to zip whole directories - * - * @param string $directory Relative path of directory to list - * @return true or false - * @access public - */ - public function isZipEnabled() { - foreach ($this->_config['zip_disable'] as $disabledPath) { - if (fnmatch($disabledPath, $this->_directory)) { - return false; - } - } - return $this->_config['zip_dirs']; - } - - /** - * Creates zipfile of directory - * - * @param string $directory Relative path of directory to list - * @access public - */ - public function zipDirectory($directory) { - - if ($this->_config['zip_dirs']) { - - // Cleanup directory path - $directory = $this->setDirectoryPath($directory); - - if ($directory != '.' && $this->_isHidden($directory)) { - echo "Access denied."; - } - - $filename_no_ext = basename($directory); - - if ($directory == '.') { - $filename_no_ext = $this->_config['home_label']; - } - - // We deliver a zip file - header('Content-Type: archive/zip'); - - // Filename for the browser to save the zip file - header("Content-Disposition: attachment; filename=\"$filename_no_ext.zip\""); - - //change directory so the zip file doesnt have a tree structure in it. - chdir($directory); - - // TODO: Probably we have to parse exclude list more carefully - $exclude_list = implode(' ', array_merge($this->_config['hidden_files'], array('index.php'))); - $exclude_list = str_replace("*", "\*", $exclude_list); - - if ($this->_config['zip_stream']) { - - // zip the stuff (dir and all in there) into the streamed zip file - $stream = popen('/usr/bin/zip -' . $this->_config['zip_compression_level'] . ' -r -q - * -x ' . $exclude_list, 'r'); - - if ($stream) { - fpassthru($stream); - fclose($stream); - } - - } else { - - // get a tmp name for the .zip - $tmp_zip = tempnam('tmp', 'tempzip') . '.zip'; - - // zip the stuff (dir and all in there) into the tmp_zip file - exec('zip -' . $this->_config['zip_compression_level'] . ' -r ' . $tmp_zip . ' * -x ' . $exclude_list); - - // calc the length of the zip. it is needed for the progress bar of the browser - $filesize = filesize($tmp_zip); - header("Content-Length: $filesize"); - - // deliver the zip file - $fp = fopen($tmp_zip, 'r'); - echo fpassthru($fp); - - // clean up the tmp zip file - unlink($tmp_zip); - - } - } - - } - - - /** - * Creates the directory listing and returns the formatted XHTML - * - * @param string $directory Relative path of directory to list - * @return array Array of directory being listed - * @access public - */ - public function listDirectory($directory) { - - // Set directory - $directory = $this->setDirectoryPath($directory); - - // Set directory variable if left blank - if ($directory === null) { - $directory = $this->_directory; - } - - // Get the directory array - $directoryArray = $this->_readDirectory($directory); - - // Return the array - return $directoryArray; - } - - - /** - * Parses and returns an array of breadcrumbs - * - * @param string $directory Path to be breadcrumbified - * @return array Array of breadcrumbs - * @access public - */ - public function listBreadcrumbs($directory = null) { - - // Set directory variable if left blank - if ($directory === null) { - $directory = $this->_directory; - } - - // Explode the path into an array - $dirArray = explode('/', $directory); - - // Statically set the Home breadcrumb - $breadcrumbsArray[] = array( - 'link' => $this->_appURL, - 'text' => $this->_config['home_label'] - ); - - // Generate breadcrumbs - $dirPath = null; - - foreach ($dirArray as $key => $dir) { - - if ($dir != '.') { - - // Build the directory path - $dirPath = is_null($dirPath) ? $dir : $dirPath . '/' . $dir; - - // Combine the base path and dir path - $link = $this->_appURL . '?dir=' . rawurlencode($dirPath); - - $breadcrumbsArray[] = array( - 'link' => $link, - 'text' => $dir - ); - - } - - } - - // Return the breadcrumb array - return $breadcrumbsArray; - } - - - /** - * Determines if a directory contains an index file - * - * @param string $dirPath Path to directory to be checked for an index - * @return boolean Returns true if directory contains a valid index file, false if not - * @access public - */ - public function containsIndex($dirPath) { - - // Check if links_dirs_with_index is enabled - if ($this->linksDirsWithIndex()) { - - // Check if directory contains an index file - foreach ($this->_config['index_files'] as $indexFile) { - - if (file_exists($dirPath . '/' . $indexFile)) { - - return true; - - } - - } - - } - - - return false; - - } - - - /** - * Get path of the listed directory - * - * @return string Path of the listed directory - * @access public - */ - public function getListedPath() { - - // Build the path - if ($this->_directory == '.') { - $path = $this->_appURL; - } else { - $path = $this->_appURL . $this->_directory; - } - - // Return the path - return $path; - } - - - /** - * Returns the theme name. - * - * @return string Theme name - * @access public - */ - public function getThemeName() { - // Return the theme name - return $this->_config['theme_name']; - } - - - /** - * Returns open links in another window - * - * @return boolean Returns true if in config is enabled open links in another window, false if not - * @access public - */ - public function externalLinksNewWindow() { - return $this->_config['external_links_new_window']; - } - - - /** - * Returns use real url for indexed directories - * - * @return boolean Returns true if in config is enabled links for directories with index, false if not - * @access public - */ - public function linksDirsWithIndex() - { - return $this->_config['links_dirs_with_index']; - } - - - /** - * Returns the path to the chosen theme directory - * - * @param bool $absolute Whether or not the path returned is absolute (default = false). - * @return string Path to theme - * @access public - */ - public function getThemePath($absolute = false) { - if ($absolute) { - // Set the theme path - $themePath = $this->_appDir . '/themes/' . $this->_themeName; - } else { - // Get relative path to application dir - $realtivePath = $this->_getRelativePath(getcwd(), $this->_appDir); - - // Set the theme path - $themePath = $realtivePath . '/themes/' . $this->_themeName; - } - - return $themePath; - } - - - /** - * Get an array of error messages or false when empty - * - * @return array|bool Array of error messages or false - * @access public - */ - public function getSystemMessages() { - if (isset($this->_systemMessage) && is_array($this->_systemMessage)) { - return $this->_systemMessage; - } else { - return false; - } - } - - - /** - * Returns string of file size in human-readable format - * - * @param string $filePath Path to file - * @return string Human-readable file size - * @access public - */ - function getFileSize($filePath) { - - // Get file size - $bytes = filesize($filePath); - - // Array of file size suffixes - $sizes = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); - - // Calculate file size suffix factor - $factor = floor((strlen($bytes) - 1) / 3); - - // Calculate the file size - $fileSize = sprintf('%.2f', $bytes / pow(1024, $factor)) . $sizes[$factor]; - - return $fileSize; - - } - - - /** - * Returns array of file hash values - * - * @param string $filePath Path to file - * @return array Array of file hashes - * @access public - */ - public function getFileHash($filePath) { - - // Placeholder array - $hashArray = array(); - - // Verify file path exists and is a directory - if (!file_exists($filePath)) { - return json_encode($hashArray); - } - - // Prevent access to hidden files - if ($this->_isHidden($filePath)) { - return json_encode($hashArray); - } - - // Prevent access to parent folders - if (strpos($filePath, '<') !== false || strpos($filePath, '>') !== false - || strpos($filePath, '..') !== false || strpos($filePath, '/') === 0) { - return json_encode($hashArray); - } - - // Prevent hashing if file is too big - if (filesize($filePath) > $this->_config['hash_size_limit']) { - - // Notify user that file is too large - $hashArray['md5'] = '[ File size exceeds threshold ]'; - $hashArray['sha1'] = '[ File size exceeds threshold ]'; - - } else { - - // Generate file hashes - $hashArray['md5'] = hash_file('md5', $filePath); - $hashArray['sha1'] = hash_file('sha1', $filePath); - - } - - // Return the data - return $hashArray; - - } - - - /** - * Set directory path variable - * - * @param string $path Path to directory - * @return string Sanitizd path to directory - * @access public - */ - public function setDirectoryPath($path = null) { - - // Set the directory global variable - $this->_directory = $this->_setDirectoryPath($path); - - return $this->_directory; - - } - - /** - * Get directory path variable - * - * @return string Sanitizd path to directory - * @access public - */ - public function getDirectoryPath() { - return $this->_directory; - } - - - /** - * Add a message to the system message array - * - * @param string $type The type of message (ie - error, success, notice, etc.) - * @param string $message The message to be displayed to the user - * @return bool true on success - * @access public - */ - public function setSystemMessage($type, $text) { - - // Create empty message array if it doesn't already exist - if (isset($this->_systemMessage) && !is_array($this->_systemMessage)) { - $this->_systemMessage = array(); - } - - // Set the error message - $this->_systemMessage[] = array( - 'type' => $type, - 'text' => $text - ); - - return true; - } - - - /** - * Validates and returns the directory path - * - * @param string $dir Directory path - * @return string Directory path to be listed - * @access protected - */ - protected function _setDirectoryPath($dir) { - - // Check for an empty variable - if (empty($dir) || $dir == '.') { - return '.'; - } - - // Eliminate double slashes - while (strpos($dir, '//')) { - $dir = str_replace('//', '/', $dir); - } - - // Remove trailing slash if present - if(substr($dir, -1, 1) == '/') { - $dir = substr($dir, 0, -1); - } - - // Verify file path exists and is a directory - if (!file_exists($dir) || !is_dir($dir)) { - // Set the error message - $this->setSystemMessage('danger', 'ERROR: File path does not exist'); - - // Return the web root - return '.'; - } - - // Prevent access to hidden files - if ($this->_isHidden($dir)) { - // Set the error message - $this->setSystemMessage('danger', 'ERROR: Access denied'); - - // Set the directory to web root - return '.'; - } - - // Prevent access to parent folders - if (strpos($dir, '<') !== false || strpos($dir, '>') !== false - || strpos($dir, '..') !== false || strpos($dir, '/') === 0) { - // Set the error message - $this->setSystemMessage('danger', 'ERROR: An invalid path string was detected'); - - // Set the directory to web root - return '.'; - } else { - // Should stop all URL wrappers (Thanks to Hexatex) - $directoryPath = $dir; - } - - // Return - return $directoryPath; - } - - - /** - * Loop through directory and return array with file info, including - * file path, size, modification time, icon and sort order. - * - * @param string $directory Directory path - * @param string $sort Sort method (default = natcase) - * @return array Array of the directory contents - * @access protected - */ - protected function _readDirectory($directory, $sort = 'natcase') { - - // Initialize array - $directoryArray = array(); - - // Get directory contents - $files = scandir($directory); - - // Read files/folders from the directory - foreach ($files as $file) { - - if ($file != '.') { - - // Get files relative path - $relativePath = $directory . '/' . $file; - - if (substr($relativePath, 0, 2) == './') { - $relativePath = substr($relativePath, 2); - } - - // Don't check parent dir if we're in the root dir - if ($this->_directory == '.' && $file == '..'){ - - continue; - - } else { - - // Get files absolute path - $realPath = realpath($relativePath); - - // Determine file type by extension - if (is_dir($realPath)) { - $iconClass = 'fa-folder'; - $sort = 1; - } else { - // Get file extension - $fileExt = strtolower(pathinfo($realPath, PATHINFO_EXTENSION)); - - if (isset($this->_fileTypes[$fileExt])) { - $iconClass = $this->_fileTypes[$fileExt]; - } else { - $iconClass = $this->_fileTypes['blank']; - } - - $sort = 2; - } - - } - - if ($file == '..') { - - if ($this->_directory != '.') { - // Get parent directory path - $pathArray = explode('/', $relativePath); - unset($pathArray[count($pathArray)-1]); - unset($pathArray[count($pathArray)-1]); - $directoryPath = implode('/', $pathArray); - - if (!empty($directoryPath)) { - $directoryPath = '?dir=' . rawurlencode($directoryPath); - } - - // Add file info to the array - $directoryArray['..'] = array( - 'file_path' => $this->_appURL . $directoryPath, - 'url_path' => $this->_appURL . $directoryPath, - 'file_size' => '-', - 'mod_time' => date($this->_config['date_format'], filemtime($realPath)), - 'icon_class' => 'fa-level-up', - 'sort' => 0 - ); - } - - } elseif (!$this->_isHidden($relativePath)) { - - // Add all non-hidden files to the array - if ($this->_directory != '.' || $file != 'index.php') { - - // Build the file path - $urlPath = implode('/', array_map('rawurlencode', explode('/', $relativePath))); - - if (is_dir($relativePath)) { - $urlPath = $this->containsIndex($relativePath) ? $relativePath : '?dir=' . $urlPath; - } - - // Add the info to the main array - $directoryArray[pathinfo($relativePath, PATHINFO_BASENAME)] = array( - 'file_path' => $relativePath, - 'url_path' => $urlPath, - 'file_size' => is_dir($realPath) ? '-' : $this->getFileSize($realPath), - 'mod_time' => date($this->_config['date_format'], filemtime($realPath)), - 'icon_class' => $iconClass, - 'sort' => $sort - ); - } - - } - } - - } - - // Sort the array - $reverseSort = in_array($this->_directory, $this->_config['reverse_sort']); - $sortedArray = $this->_arraySort($directoryArray, $this->_config['list_sort_order'], $reverseSort); - - // Return the array - return $sortedArray; - - } - - - /** - * Sorts an array by the provided sort method. - * - * @param array $array Array to be sorted - * @param string $sortMethod Sorting method (acceptable inputs: natsort, natcasesort, etc.) - * @param boolen $reverse Reverse the sorted array order if true (default = false) - * @return array - * @access protected - */ - protected function _arraySort($array, $sortMethod, $reverse = false) { - // Create empty arrays - $sortedArray = array(); - $finalArray = array(); - - // Create new array of just the keys and sort it - $keys = array_keys($array); - - switch ($sortMethod) { - case 'asort': - asort($keys); - break; - case 'arsort': - arsort($keys); - break; - case 'ksort': - ksort($keys); - break; - case 'krsort': - krsort($keys); - break; - case 'natcasesort': - natcasesort($keys); - break; - case 'natsort': - natsort($keys); - break; - case 'shuffle': - shuffle($keys); - break; - } - - // Loop through the sorted values and move over the data - if ($this->_config['list_folders_first']) { - - foreach ($keys as $key) { - if ($array[$key]['sort'] == 0) { - $sortedArray['0'][$key] = $array[$key]; - } - } - - foreach ($keys as $key) { - if ($array[$key]['sort'] == 1) { - $sortedArray[1][$key] = $array[$key]; - } - } - - foreach ($keys as $key) { - if ($array[$key]['sort'] == 2) { - $sortedArray[2][$key] = $array[$key]; - } - } - - if ($reverse) { - $sortedArray[1] = array_reverse($sortedArray[1]); - $sortedArray[2] = array_reverse($sortedArray[2]); - } - - } else { - - foreach ($keys as $key) { - if ($array[$key]['sort'] == 0) { - $sortedArray[0][$key] = $array[$key]; - } - } - - foreach ($keys as $key) { - if ($array[$key]['sort'] > 0) { - $sortedArray[1][$key] = $array[$key]; - } - } - - if ($reverse) { - $sortedArray[1] = array_reverse($sortedArray[1]); - } - - } - - // Merge the arrays - foreach ($sortedArray as $array) { - if (empty($array)) continue; - foreach ($array as $key => $value) { - $finalArray[$key] = $value; - } - } - - // Return sorted array - return $finalArray; - - } - - - /** - * Determines if a file is specified as hidden - * - * @param string $filePath Path to file to be checked if hidden - * @return boolean Returns true if file is in hidden array, false if not - * @access protected - */ - protected function _isHidden($filePath) { - - // Add dot files to hidden files array - if ($this->_config['hide_dot_files']) { - - $this->_config['hidden_files'] = array_merge( - $this->_config['hidden_files'], - array('.*', '*/.*') - ); - - } - - // Compare path array to all hidden file paths - foreach ($this->_config['hidden_files'] as $hiddenPath) { - - if (fnmatch($hiddenPath, $filePath)) { - - return true; - - } - - } - - return false; - - } - - - /** - * Builds the root application URL from server variables. - * - * @return string The application URL - * @access protected - */ - protected function _getAppUrl() { - - // Get the server protocol - if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { - $protocol = 'https://'; - } else { - $protocol = 'http://'; - } - - // Get the server hostname - if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; - } else { - $host = $_SERVER['HTTP_HOST']; - } - - // Get the URL path - $pathParts = pathinfo($_SERVER['PHP_SELF']); - $path = $pathParts['dirname']; - - // Remove backslash from path (Windows fix) - if (substr($path, -1) == '\\') { - $path = substr($path, 0, -1); - } - - // Ensure the path ends with a forward slash - if (substr($path, -1) != '/') { - $path = $path . '/'; - } - - // Build the application URL - $appUrl = $protocol . $host . $path; - - // Return the URL - return $appUrl; - } - - - /** - * Compares two paths and returns the relative path from one to the other - * - * @param string $fromPath Starting path - * @param string $toPath Ending path - * @return string $relativePath Relative path from $fromPath to $toPath - * @access protected - */ - protected function _getRelativePath($fromPath, $toPath) { - - // Define the OS specific directory separator - if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR); - - // Remove double slashes from path strings - $fromPath = str_replace(DS . DS, DS, $fromPath); - $toPath = str_replace(DS . DS, DS, $toPath); - - // Explode working dir and cache dir into arrays - $fromPathArray = explode(DS, $fromPath); - $toPathArray = explode(DS, $toPath); - - // Remove last fromPath array element if it's empty - $x = count($fromPathArray) - 1; - - if(!trim($fromPathArray[$x])) { - array_pop($fromPathArray); - } - - // Remove last toPath array element if it's empty - $x = count($toPathArray) - 1; - - if(!trim($toPathArray[$x])) { - array_pop($toPathArray); - } - - // Get largest array count - $arrayMax = max(count($fromPathArray), count($toPathArray)); - - // Set some default variables - $diffArray = array(); - $samePath = true; - $key = 1; - - // Generate array of the path differences - while ($key <= $arrayMax) { - - // Get to path variable - $toPath = isset($toPathArray[$key]) ? $toPathArray[$key] : null; - - // Get from path variable - $fromPath = isset($fromPathArray[$key]) ? $fromPathArray[$key] : null; - - if ($toPath !== $fromPath || $samePath !== true) { - - // Prepend '..' for every level up that must be traversed - if (isset($fromPathArray[$key])) { - array_unshift($diffArray, '..'); - } - - // Append directory name for every directory that must be traversed - if (isset($toPathArray[$key])) { - $diffArray[] = $toPathArray[$key]; - } - - // Directory paths have diverged - $samePath = false; - } - - // Increment key - $key++; - } - - // Set the relative thumbnail directory path - $relativePath = implode('/', $diffArray); - - // Return the relative path - return $relativePath; - - } - -} diff --git a/resources/default.config.php b/resources/default.config.php deleted file mode 100644 index ec48964..0000000 --- a/resources/default.config.php +++ /dev/null @@ -1,61 +0,0 @@ - 'Home', - 'hide_dot_files' => true, - 'list_folders_first' => true, - 'list_sort_order' => 'natcasesort', - 'theme_name' => 'bootstrap', - 'date_format' => 'Y-m-d H:i:s', // See: http://php.net/manual/en/function.date.php - - // Hidden files - 'hidden_files' => array( - '.ht*', - '*/.ht*', - 'resources', - 'resources/*', - 'analytics.inc', - 'header.php', - 'footer.php' - ), - - // If set to 'true' an directory with an index file (as defined below) will - // become a direct link to the index page instead of a browsable directory - 'links_dirs_with_index' => false, - - // Make linked directories open in a new (_blank) tab - 'external_links_new_window' => true, - - // Files that, if present in a directory, make the directory - // a direct link rather than a browse link. - 'index_files' => array( - 'index.htm', - 'index.html', - 'index.php' - ), - - // File hashing threshold - 'hash_size_limit' => 268435456, // 256 MB - - // Custom sort order - 'reverse_sort' => array( - // 'path/to/folder' - ), - - // Allow to download directories as zip files - 'zip_dirs' => false, - - // Stream zip file content directly to the client, - // without any temporary file - 'zip_stream' => true, - - 'zip_compression_level' => 0, - - // Disable zip downloads for particular directories - 'zip_disable' => array( - // 'path/to/folder' - ), - -); diff --git a/resources/fileTypes.php b/resources/fileTypes.php deleted file mode 100644 index 55a77af..0000000 --- a/resources/fileTypes.php +++ /dev/null @@ -1,132 +0,0 @@ - 'fa-file-archive-o', - 'bz' => 'fa-file-archive-o', - 'gz' => 'fa-file-archive-o', - 'rar' => 'fa-file-archive-o', - 'tar' => 'fa-file-archive-o', - 'zip' => 'fa-file-archive-o', - - // Audio - 'aac' => 'fa-music', - 'flac' => 'fa-music', - 'mid' => 'fa-music', - 'midi' => 'fa-music', - 'mp3' => 'fa-music', - 'ogg' => 'fa-music', - 'wma' => 'fa-music', - 'wav' => 'fa-music', - - // Code - 'c' => 'fa-code', - 'class' => 'fa-code', - 'cpp' => 'fa-code', - 'css' => 'fa-code', - 'erb' => 'fa-code', - 'htm' => 'fa-code', - 'html' => 'fa-code', - 'java' => 'fa-code', - 'js' => 'fa-code', - 'php' => 'fa-code', - 'pl' => 'fa-code', - 'py' => 'fa-code', - 'rb' => 'fa-code', - 'xhtml' => 'fa-code', - 'xml' => 'fa-code', - - // Databases - 'accdb' => 'fa-hdd-o', - 'db' => 'fa-hdd-o', - 'dbf' => 'fa-hdd-o', - 'mdb' => 'fa-hdd-o', - 'pdb' => 'fa-hdd-o', - 'sql' => 'fa-hdd-o', - - // Documents - 'csv' => 'fa-file-text', - 'doc' => 'fa-file-text', - 'docx' => 'fa-file-text', - 'odt' => 'fa-file-text', - 'pdf' => 'fa-file-text', - 'xls' => 'fa-file-text', - 'xlsx' => 'fa-file-text', - - // Executables - 'app' => 'fa-list-alt', - 'bat' => 'fa-list-alt', - 'com' => 'fa-list-alt', - 'exe' => 'fa-list-alt', - 'jar' => 'fa-list-alt', - 'msi' => 'fa-list-alt', - 'vb' => 'fa-list-alt', - - // Fonts - 'eot' => 'fa-font', - 'otf' => 'fa-font', - 'ttf' => 'fa-font', - 'woff' => 'fa-font', - - // Game Files - 'gam' => 'fa-gamepad', - 'nes' => 'fa-gamepad', - 'rom' => 'fa-gamepad', - 'sav' => 'fa-floppy-o', - - // Images - 'bmp' => 'fa-picture-o', - 'gif' => 'fa-picture-o', - 'jpg' => 'fa-picture-o', - 'jpeg' => 'fa-picture-o', - 'png' => 'fa-picture-o', - 'psd' => 'fa-picture-o', - 'tga' => 'fa-picture-o', - 'tif' => 'fa-picture-o', - - // Package Files - 'box' => 'fa-archive', - 'deb' => 'fa-archive', - 'rpm' => 'fa-archive', - - // Scripts - 'bat' => 'fa-terminal', - 'cmd' => 'fa-terminal', - 'sh' => 'fa-terminal', - - // Text - 'cfg' => 'fa-file-text', - 'ini' => 'fa-file-text', - 'log' => 'fa-file-text', - 'md' => 'fa-file-text', - 'rtf' => 'fa-file-text', - 'txt' => 'fa-file-text', - - // Vector Images - 'ai' => 'fa-picture-o', - 'drw' => 'fa-picture-o', - 'eps' => 'fa-picture-o', - 'ps' => 'fa-picture-o', - 'svg' => 'fa-picture-o', - - // Video - 'avi' => 'fa-youtube-play', - 'flv' => 'fa-youtube-play', - 'mkv' => 'fa-youtube-play', - 'mov' => 'fa-youtube-play', - 'mp4' => 'fa-youtube-play', - 'mpg' => 'fa-youtube-play', - 'ogv' => 'fa-youtube-play', - 'webm' => 'fa-youtube-play', - 'wmv' => 'fa-youtube-play', - 'swf' => 'fa-youtube-play', - - // Other - 'bak' => 'fa-floppy', - 'msg' => 'fa-envelope', - - // Blank - 'blank' => 'fa-file' - -); diff --git a/resources/themes/bootstrap/css/style.css b/resources/themes/bootstrap/css/style.css deleted file mode 100644 index 66809c8..0000000 --- a/resources/themes/bootstrap/css/style.css +++ /dev/null @@ -1,142 +0,0 @@ -/* ---------------------------------------------------------------------------------------------- */ -/* -----| GENERAL |------------------------------------------------------------------------------ */ -/* ---------------------------------------------------------------------------------------------- */ - -body { - padding: 70px 0 0; -} - -body.breadcrumb-fixed { - padding-top: 56px; -} - -.container { - max-width: 960px; -} - - -/* -------------------------------------------------------------------------- */ -/* -----| HEADER |----------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -#page-navbar .navbar-text { - display: block; - float: left; - font-family: 'Cutive Mono', monospace, serif; - max-width: 80%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - - -/* ---------------------------------------------------------------------------------------------- */ -/* -----| DIRECTORY LISTER |--------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------------------------------- */ - -#directory-list-header { - font-family: 'Cutive Mono', monospace, serif; - font-weight: bold; - padding: 10px 15px; -} - -#directory-listing { - font-family: 'Cutive Mono', monospace, serif; -} - -#directory-listing li { - position: relative; -} - -.file-name { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.file-name i { - color: #555; -} - -.file-info-button, -.web-link-button { - display: inline-block; - cursor: pointer; - margin-left: 100%; - padding: 6px 10px !important; - position: absolute !important; - top: 4px; -} - -.web-link-button i, -.file-info-button i { - color: #999; -} - - -/* ---------------------------------------------------------------------------------------------- */ -/* -----| FOOTER |------------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------------------------------- */ - -.footer { - margin: 20px; - text-align: center; -} - - -/* ---------------------------------------------------------------------------------------------- */ -/* -----| CHECKSUM MODAL |----------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------------------------------- */ - -#file-info { - margin: 0; -} - -#file-info .table-title { - font-weight: bold; - text-align: right; -} - -#file-info .md5-hash, -#file-info .sha1-hash { - font-family: 'Cutive Mono', monospace, serif; -} - - -/* -------------------------------------------------------------------------- */ -/* -----| RESPONSIVE |------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -@media (max-width: 767px) { - - .navbar-nav { - float: left; - margin: 0; - padding-bottom: 0; - padding-top: 0; - } - - .navbar-nav > li { - float: left; - } - - .navbar-nav > li > a { - padding-bottom: 15px; - padding-top: 15px; - } - - .navbar-right { - float: right !important; - } - - #page-navbar .navbar-text { - margin-left: 15px; - margin-right: 15px; - max-width: 75%; - } - - .file-info-button { - display: none !important; - } - -} diff --git a/resources/themes/bootstrap/default_footer.php b/resources/themes/bootstrap/default_footer.php deleted file mode 100644 index 0241d74..0000000 --- a/resources/themes/bootstrap/default_footer.php +++ /dev/null @@ -1,5 +0,0 @@ -
- - diff --git a/resources/themes/bootstrap/default_header.php b/resources/themes/bootstrap/default_header.php deleted file mode 100644 index e69de29..0000000 diff --git a/resources/themes/bootstrap/img/folder.png b/resources/themes/bootstrap/img/folder.png deleted file mode 100644 index 784e8fa48234f4f64b6922a6758f254ee0ca08ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 537 zcmV+!0_OdRP)x(K@^6+>g^d@v4;gkbWsEoXE%32*i1tcpTNXd5CcIl)ECgqz|2rE6EW}s7R?kl za1q`0GCkMruC6-2LANtwVlsgzsp4?{@7$`KBv!G66>Vie3h?3OmEEkjwdLG0PgLVi z`!N((f$A@n17Ldj#`};0I3@iHJ5M{#IZz|UIYRm4(!uV7eYIYIwQf&}_2J~}>pQ^n z6o8--^T(=hkBNQ_k{-_GWE;FMW7!p}f{NG3nHZ{D5<3d8&tLh%a4AqqnjMkr3m&fkMdECD3N5}Unig5wy40;>lo4j~k+e}v)` zR6)J8Mk*u=SpB`p6o)7j?S0T@9?bz#m@l>gc*zk__|*!FMcHwP!gwLJvS~9c0px8E zW - - - - - - Directory listing of <?php echo $lister->getListedPath(); ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - getThemePath(true) . "/default_header.php"); ?> - - getSystemMessages()): ?> - getSystemMessages() as $message): ?> -
- - × -
- - - -
-
-
File
-
Size
- -
-
- - -
- - getThemePath(true) . "/default_footer.php"); ?> - - - - - - diff --git a/resources/themes/bootstrap/js/directorylister.js b/resources/themes/bootstrap/js/directorylister.js deleted file mode 100644 index a533d58..0000000 --- a/resources/themes/bootstrap/js/directorylister.js +++ /dev/null @@ -1,66 +0,0 @@ -$(document).ready(function() { - - // Get page-content original position - var contentTop = $('#page-content').offset().top; - - // Show/hide top link on page load - showHideTopLink(contentTop); - - // Show/hide top link on scroll - $(window).scroll(function() { - showHideTopLink(contentTop); - }); - - // Scroll page on click action - $('#page-top-link').click(function() { - $('html, body').animate({ scrollTop: 0 }, 'fast'); - return false; - }); - - // Hash button on click action - $('.file-info-button').click(function(event) { - - // Get the file name and path - var name = $(this).closest('li').attr('data-name'); - var path = $(this).closest('li').attr('data-href'); - - // Set modal title value - $('#file-info-modal .modal-title').text(name); - - $('#file-info .md5-hash').text('Loading...'); - $('#file-info .sha1-hash').text('Loading...'); - $('#file-info .filesize').text('Loading...'); - - $.ajax({ - url: '?hash=' + path, - type: 'get', - success: function(data) { - - // Parse the JSON data - var obj = jQuery.parseJSON(data); - - // Set modal pop-up hash values - $('#file-info .md5-hash').text(obj.md5); - $('#file-info .sha1-hash').text(obj.sha1); - $('#file-info .filesize').text(obj.size); - - } - }); - - // Show the modal - $('#file-info-modal').modal('show'); - - // Prevent default link action - event.preventDefault(); - - }); - -}); - -function showHideTopLink(elTop) { - if($('#page-navbar').offset().top + $('#page-navbar').height() >= elTop) { - $('#page-top-nav').show(); - } else { - $('#page-top-nav').hide(); - } -}