mirror of
https://github.com/jimeh/dlist.git
synced 2026-02-19 07:56:41 +00:00
- added language support (still needs some tweaking, and swedish language file needs correct locale settings)
- removed timer.exc.php and put the needed intializer directly in view.php to get a more accurate reading from $timer->end() - updated .htaccess settings to they for once work 100% as they should, and added httpd_dlist.conf to respository to keep track of any changes/updates needed to the .htaccess file or apache config file (depending how you implement dList) git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@11 a5845835-ea0f-0410-a762-dd0bfe9bfde8
This commit is contained in:
24
config.php
24
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',
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
63
exec/language.exc.php
Normal file
63
exec/language.exc.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php die();
|
||||
|
||||
//
|
||||
// Exec: language
|
||||
//
|
||||
// Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||
// zynode@gmail.com
|
||||
//
|
||||
|
||||
//_HEAD;
|
||||
/* --- Configuration ---
|
||||
Name: language
|
||||
Priority: 40
|
||||
Author: Jim Myhrberg
|
||||
*/
|
||||
//_SCRIPT;
|
||||
|
||||
//==========================
|
||||
//>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;
|
||||
?>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php die();
|
||||
|
||||
//
|
||||
// Exec: timer
|
||||
//
|
||||
// Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||
// zynode@gmail.com
|
||||
//
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Intializes $timer at beginning of exec code, use
|
||||
$timer->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;
|
||||
?>
|
||||
18
httpd_dlist.conf
Normal file
18
httpd_dlist.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
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
|
||||
</IfModule>
|
||||
40
languages/english.lang.php
Normal file
40
languages/english.lang.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class lang {
|
||||
|
||||
// Language settings
|
||||
var $_language = 'english';
|
||||
var $_version = 1.0;
|
||||
|
||||
|
||||
// Locale settings
|
||||
var $_locale = array('en', 'en_US');
|
||||
|
||||
|
||||
// General strings
|
||||
var $index_of = 'Index of';
|
||||
|
||||
var $name = 'Name';
|
||||
var $size = 'Size';
|
||||
var $mtime = 'Date Modified';
|
||||
var $perms = 'Permissions';
|
||||
var $chmod = 'CHMOD';
|
||||
var $owner = 'Owner';
|
||||
var $group = 'Group';
|
||||
var $owner_id = 'Owner ID';
|
||||
var $group_id = 'Group ID';
|
||||
|
||||
var $page_generated = 'Page generated in';
|
||||
var $seconds = 'seconds';
|
||||
|
||||
|
||||
// Smart Date
|
||||
var $sd_tomorrow = 'Tomorrow';
|
||||
var $sd_today = 'Today';
|
||||
var $sd_yesterday = 'Yesterday';
|
||||
var $sd_2_days_ago = '2 days ago';
|
||||
var $sd_3_days_ago = '3 days ago';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
40
languages/swedish.lang.php
Normal file
40
languages/swedish.lang.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class lang {
|
||||
|
||||
// Language settings
|
||||
var $_language = 'svenska';
|
||||
var $_version = 1.0;
|
||||
|
||||
|
||||
// Locale settings
|
||||
var $_locale = array('sv', 'sv_SV'); // incorrect
|
||||
|
||||
|
||||
// General
|
||||
var $index_of = 'Index av';
|
||||
|
||||
var $name = 'Namn';
|
||||
var $size = 'Storlek';
|
||||
var $mtime = 'Datum Ändrad';
|
||||
var $perms = 'Rättigheter';
|
||||
var $chmod = 'CHMOD';
|
||||
var $owner = 'Ägare';
|
||||
var $group = 'Grupp';
|
||||
var $owner_id = 'Ägare ID';
|
||||
var $group_id = 'Grupp ID';
|
||||
|
||||
var $page_generated = 'Sidan genererades på';
|
||||
var $seconds = 'sekunder';
|
||||
|
||||
|
||||
// Smart Date
|
||||
var $sd_tomorrow = 'Imorgon';
|
||||
var $sd_today = 'Idag';
|
||||
var $sd_yesterday = 'Igår';
|
||||
var $sd_2_days_ago = '2 dar sen';
|
||||
var $sd_3_days_ago = '3 dar sen';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<title>Index of <?=DIR_URL?></title>
|
||||
<title><?=$lang->index_of.' '.DIR_URL?></title>
|
||||
<style type="text/css" media="screen">
|
||||
/* <![CDATA[ */
|
||||
<? include(TPL_PATH.'stylesheets/screen.css') ?>
|
||||
@@ -12,18 +12,18 @@
|
||||
</head>
|
||||
<body id="index">
|
||||
<div id="header">
|
||||
Index of <?=DIR_URL?>
|
||||
<?=$lang->index_of.' '.DIR_URL?>
|
||||
</div>
|
||||
<table border="0" cellspacing="1" cellpadding="0" id="list">
|
||||
<tr>
|
||||
<th class="icon"></th>
|
||||
<th class="name">Name</th>
|
||||
<th class="size">Size</th>
|
||||
<th class="mtime">Date Modified</th>
|
||||
<th class="perms">Permissions</th>
|
||||
<th class="owner">Owner</th>
|
||||
<th class="name"><?=$lang->name?></th>
|
||||
<th class="size"><?=$lang->size?></th>
|
||||
<th class="mtime"><?=$lang->mtime?></th>
|
||||
<th class="perms"><?=$lang->perms?></th>
|
||||
<th class="owner"><?=$lang->owner?></th>
|
||||
</tr>
|
||||
<? if (!empty($parent['name']) || $parent['name'] != '/'): ?>
|
||||
<? if ( DIR_URL != '' && DIR_URL != '/'): ?>
|
||||
<tr>
|
||||
<td class="icon"><a href="../" title="Parent Directory"><img src="<?=Icon::get_parent($config->tpl_icon_size)?>" class="" alt="" /></a></td>
|
||||
<td class="name"><a href="../" title="Parent Directory">..</a></td>
|
||||
@@ -49,7 +49,7 @@
|
||||
<? endforeach ?>
|
||||
</table>
|
||||
<div id="stats">
|
||||
Page generated in <?=$timer->end()?> seconds.
|
||||
<?=$lang->page_generated.' '.$timer->end(6).' '.$lang->seconds?>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
//_HEAD;
|
||||
/* --- Configuration ---
|
||||
Name: render/simple
|
||||
Name: simple/render
|
||||
Priority: 40
|
||||
Author: Jim Myhrberg
|
||||
*/
|
||||
|
||||
14
view.php
14
view.php
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
|
||||
dList v2.0 beta
|
||||
dList v2.1.1 beta
|
||||
|
||||
Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||
zynode@gmail.com
|
||||
@@ -23,8 +23,12 @@ require_once('libs/dirlist.lib.php');
|
||||
require_once('libs/exechandler.lib.php');
|
||||
|
||||
|
||||
// initialize debug stopwatch
|
||||
if ($config->debug) $debug_timer = new speedometer();
|
||||
// initialize $timer
|
||||
$timer = new speedometer();
|
||||
|
||||
|
||||
// autodetect dList's install URL if not set
|
||||
if ( empty($config->dlist_url) ) $config->dlist_url = preg_replace("/(.*)\/(.*?)$/i", "$1/", $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
|
||||
// initialize execHandler and main scripts
|
||||
@@ -55,10 +59,8 @@ include($exec->include_file);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($config->debug) {
|
||||
$debug_timer->end();
|
||||
echo "<br />\npage generated in ".$debug_timer->time." sec.<br />\n";
|
||||
echo "<br />\npage generated in ".$timer->end(8)." sec.<br />\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user