diff --git a/config.php b/config.php
index f211e9d..b2ca3bf 100644
--- a/config.php
+++ b/config.php
@@ -7,28 +7,44 @@
*/
-$config = array(
+$config = array(
// Main settings
- 'dlist_url' => '/dlist/',
- 'debug' => true,
+ # leave blank to autodetect from $_SERVER['SCRIPT_NAME']
+ 'dlist_url' => '',
+
+ # show debug messages, for exechandler to always re-parse all files
+ 'debug' => true,
// File system settings
+ # show hidden files & folders who's names begin with . (dot)
'show_hidden' => false,
// Display settings
+ # if the corresponding language file can't be found
+ # dList will default to english.
+ 'language' => 'english',
+
+ # Smart Date shows relative time stamps ("Yesterday, 09:34") when applicable
+ 'smartdate' => true,
+
+
+// Template & Icon settings
+
'template' => 'simple',
'iconset' => 'osx',
'allow_override' => true,
-// dList internal path settings
+// dList internal settings - don't change if you don't know what you're doing
+ 'default_lang' => 'english',
+ 'default_locale' => array('en', 'en_US'),
'path_plugins' => array('plugins'),
'path_cache' => 'cache',
diff --git a/exec/core.exc.php b/exec/core.exc.php
index 7890491..09c2031 100644
--- a/exec/core.exc.php
+++ b/exec/core.exc.php
@@ -63,6 +63,7 @@ if ( $do_readdir ) {
$dlist->sort_items = false;
} elseif (!empty($do_sort_reverse)) $dlist->reverse = true;
if ($config->show_hidden) $dlist->show_hidden = true;
+ if ( !$config->smartdate ) $dlist->use_smartdate = false;
//>Section> readdir.read
$dlist->read(DIR_PATH);
//>Section> readdir.end
diff --git a/exec/language.exc.php b/exec/language.exc.php
new file mode 100644
index 0000000..c88b286
--- /dev/null
+++ b/exec/language.exc.php
@@ -0,0 +1,63 @@
+STAGE> init
+//==========================
+
+
+//>Section> init:10
+if ( empty($config->language) ) $config->language = 'english';
+
+if ( is_readable('languages/'.$config->language.'.lang.php') ) {
+ include('languages/'.$config->language.'.lang.php');
+} elseif ( is_readable('languages/'.$config->default_lang.'.lang.php') ) {
+ include('languages/'.$config->default_lang.'.lang.php');
+} else {
+ die("ERROR: Can't open language file.");
+}
+
+$lang = new lang();
+setlocale(LC_ALL, array_merge($lang->_locale, $config->default_locale));
+
+
+//==========================
+//>STAGE> init
+//==========================
+
+
+//>After> core.define_constants
+define('LANG', $lang->_language);
+define('LANG_VER', $lang->_version);
+
+
+//==========================
+//>STAGE> main
+//==========================
+
+
+//>After> core.readdir.options
+$dlist->lang_tomorrow = $lang->sd_tomorrow;
+$dlist->lang_today = $lang->sd_today;
+$dlist->lang_yesterday = $lang->sd_yesterday;
+$dlist->lang_2_days_ago = $lang->sd_2_days_ago;
+$dlist->lang_3_days_ago = $lang->sd_3_days_ago;
+
+
+
+//_END;
+?>
\ No newline at end of file
diff --git a/exec/timer.exc.php b/exec/timer.exc.php
deleted file mode 100644
index 15dc2fa..0000000
--- a/exec/timer.exc.php
+++ /dev/null
@@ -1,38 +0,0 @@
-end(); in your template to get script
- execution time.
-
-*/
-
-
-//_HEAD;
-/* --- Configuration ---
-Name: timer
-Priority: 10
-Author: Jim Myhrberg
-*/
-//_SCRIPT;
-
-//==========================
-//>STAGE> init
-//==========================
-
-
-//>Section> start
-$timer = new speedometer();
-
-
-//_END;
-?>
\ No newline at end of file
diff --git a/httpd_dlist.conf b/httpd_dlist.conf
new file mode 100644
index 0000000..da69ed8
--- /dev/null
+++ b/httpd_dlist.conf
@@ -0,0 +1,18 @@
+
+Options +FollowSymlinks
+RewriteEngine On
+
+# if dir requested without trailing slash,
+# rewrite to dList which redirects to the
+# dir with the trailing slash added.
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteCond %{REQUEST_URI} !/$
+RewriteCond %{REQUEST_URI} ^(.+)$ [OR]
+RewriteRule !^(.*)/$ /dlist/view.php?shit
+
+# rewrite to dList if no index files found
+RewriteCond %{REQUEST_FILENAME}/index.html !-f [NC]
+RewriteCond %{REQUEST_FILENAME}/index.php !-f [NC]
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteRule ^(.*)$ /dlist/view.php
+
\ No newline at end of file
diff --git a/languages/english.lang.php b/languages/english.lang.php
new file mode 100644
index 0000000..0ea1603
--- /dev/null
+++ b/languages/english.lang.php
@@ -0,0 +1,40 @@
+
\ No newline at end of file
diff --git a/languages/swedish.lang.php b/languages/swedish.lang.php
new file mode 100644
index 0000000..e757acf
--- /dev/null
+++ b/languages/swedish.lang.php
@@ -0,0 +1,40 @@
+
\ No newline at end of file
diff --git a/libs/config.lib.php b/libs/config.lib.php
index ae611c7..4e20375 100644
--- a/libs/config.lib.php
+++ b/libs/config.lib.php
@@ -22,7 +22,7 @@ class config {
if ( is_array($input) ) {
$this->parse_array($input, $overwrite);
} elseif ( is_string($input) ) {
- if ( preg_match("/.php$/", $input) ) {
+ if ( preg_match("/.*\.php$/", $input) ) {
$this->parse_php_file($input, 'config', $overwrite);
} else {
$this->parse_ini_file($input);
diff --git a/libs/dirlist.lib.php b/libs/dirlist.lib.php
index e54ac3a..a2f5f8f 100644
--- a/libs/dirlist.lib.php
+++ b/libs/dirlist.lib.php
@@ -4,7 +4,7 @@ class dirList {
/*
- Class: dirList v2.0.2 beta
+ Class: dirList v2.0.4 beta
Copyright © 2006 Jim Myhrberg. All rights reserved.
zynode@gmail.com
@@ -23,9 +23,23 @@ class dirList {
// Smart date formatting
var $use_smartdate = true;
var $smartdate = '{date}, {time}';
+ var $smartdate_date = '%B %d, %Y';
+ var $smartdate_time = '%H:%M';
+ var $standard_date_format = '%B %d, %Y, %H:%M';
+
+ /*
+ var $smartdate = '{date}, {time}';
var $smartdate_date = 'F d, Y';
var $smartdate_time = 'H:i';
var $standard_date_format = 'F d, Y, H:i';
+ */
+
+ // Smart date language settings
+ var $lang_tomorrow = 'Tomorrow';
+ var $lang_today = 'Today';
+ var $lang_yesterday = 'Yesterday';
+ var $lang_2_days_ago = '2 days ago';
+ var $lang_3_days_ago = '3 days ago';
// Internals
@@ -149,15 +163,20 @@ class dirList {
$types = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
for($n = 0; $bytes >= 1024; $n++) $bytes = $bytes / 1024;
$bytes = number_format($bytes, 2);
- if ( preg_match("/([0-9]+)\.([0-9]+)/", $bytes, $bytes) ) {
- $bytes[2] = rtrim($bytes[2], '0');
- $bytes = ( !empty($bytes[2]) ) ? $bytes[1].'.'.$bytes[2] : $bytes[1] ;
+ if ( preg_match("/^([0-9]+)(\.|,)([0-9]+0)$/", $bytes, $split) ) {
+ $bytes = ( ($split[3] = rtrim($split[3], '0')) == '' ) ? $split[1] : $split[1].$split[2].$split[3] ;
}
return $bytes.' '.$types[$n];
}
- function smartDate ($timestamp, $datef='jS M, Y', $timef='H:i', $mainf='{date}, {time}') {
- $array = array('Today'=>0, 'Yesterday'=>-1, '2 days ago'=>-2, '3 days ago'=>-3, 'Tomorrow'=>1);
+ function smartDate ($timestamp, $datef='%B %d, %Y', $timef='%H:%M', $mainf='{date}, {time}') {
+ $array = array(
+ $this->lang_tomorrow => 1,
+ $this->lang_today => 0,
+ $this->lang_yesterday => -1,
+ $this->lang_2_days_ago => -2,
+ $this->lang_3_days_ago => -3,
+ );
$now = time();
// check if timestamp is more than 96 hours ago
if ( $timestamp >= ($now - 345600) ) {
@@ -166,12 +185,12 @@ class dirList {
$test = date("d:m:Y", ($now + (86400 * $value) ) );
if( $check == $test ) {
$return = str_replace('{date}', $key, $mainf);
- return str_replace('{time}', date($timef, $timestamp), $return);
+ return str_replace('{time}', strftime($timef, $timestamp), $return);
}
}
}
- $return = str_replace('{date}', date($datef, $timestamp), $mainf);
- return str_replace('{time}', date($timef, $timestamp), $return);
+ $return = str_replace('{date}', strftime($datef, $timestamp), $mainf);
+ return str_replace('{time}', strftime($timef, $timestamp), $return);
}
function format_perms($perms) {
diff --git a/libs/speedometer.lib.php b/libs/speedometer.lib.php
index 265ae03..4df82e4 100644
--- a/libs/speedometer.lib.php
+++ b/libs/speedometer.lib.php
@@ -4,7 +4,7 @@ class speedometer {
/*
- Class: Speedometer v0.1
+ Class: Speedometer v0.1.1
Created to simplify script execution statistics...
*/
@@ -19,9 +19,10 @@ class speedometer {
$this->start = $this->getmicrotime();
}
- function end () {
+ function end ($digits=false) {
$end = $this->getmicrotime();
- return $this->time = number_format( ($end - $this->start), $this->digits);
+ $digits = ( preg_match("/[0-9]{1,2}/", $digits) ) ? $digits : $this->digits ;
+ return $this->time = number_format( ($end - $this->start), $digits);
}
function getmicrotime () {
diff --git a/resources/init.php b/resources/init.php
index 1266725..31ddda6 100644
--- a/resources/init.php
+++ b/resources/init.php
@@ -11,37 +11,40 @@
// Server configuration
-$config['index_files'] = array('index.html', 'index.php', 'index.htm');
+$config['index_files'] = array('index.html', 'index.php');
$config['default_scheme'] = 'http';
// process requested path
-if ( stristr($_SERVER['REQUEST_URI'], '?') !== false ) {
- $dir_url = explode('?', $_SERVER['REQUEST_URI']);
- $query_string = $dir_url[1];
- $dir_url = urldecode($dir_url[0]);
+if ( preg_match("/^(.*?)\?(.*)$/i", $_SERVER['REQUEST_URI'], $dir_url) ) {
+ $query_string = $dir_url[2];
+ $dir_url = urldecode($dir_url[1]);
} else {
$query_string = '';
$dir_url = urldecode($_SERVER['REQUEST_URI']);
}
-
-// path lookup
-$dir_path = apache_lookup_uri($dir_url);
-$dir_path = ( is_array($dir_path) ) ? $dir_path['filename'] : $dir_path->filename ;
-if(!preg_match("/\/$/", $dir_path)) $dir_path .= '/';
if(!preg_match("/\/$/", $dir_url)) $redirect = '/';
-// check for index files and redirect if found
+
if ( empty($redirect) ) {
+
+ // path lookup
+ $dir_path = apache_lookup_uri($dir_url);
+ $dir_path = ( is_array($dir_path) ) ? $dir_path['filename'] : $dir_path->filename ;
+ if(!preg_match("/\/$/", $dir_path)) $dir_path .= '/';
+
+ // check for index files and redirect if found
foreach($config['index_files'] as $what) {
if ( file_exists($dir_path.$what) ) {
$redirect = basename($what);
break;
}
}
+
}
+
if ( !empty($redirect) ) {
if(!empty($_SERVER['SCRIPT_URI'])) {
$scheme = parse_url($_SERVER['SCRIPT_URI']);
diff --git a/templates/simple/index.phtml b/templates/simple/index.phtml
index 8d7a596..77d62cd 100644
--- a/templates/simple/index.phtml
+++ b/templates/simple/index.phtml
@@ -3,7 +3,7 @@
- Index of =DIR_URL?>
+ =$lang->index_of.' '.DIR_URL?>