mirror of
https://github.com/jimeh/dlist.git
synced 2026-02-19 07:56:41 +00:00
updates, edits and shit...
- changed configuration system, so at the point init.php runs only settings needed by init.php are set, the rest are loaded later if init.php doesn't redirect to an index file... git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@8 a5845835-ea0f-0410-a762-dd0bfe9bfde8
This commit is contained in:
@@ -12,8 +12,7 @@ $config = array(
|
|||||||
|
|
||||||
// Main settings
|
// Main settings
|
||||||
|
|
||||||
'dlist_url' => '/dlist/',
|
'dlist_url' => '/dlist/',
|
||||||
'index_files' => array('index.html', 'index.php', 'index.htm'),
|
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
|
|
||||||
|
|
||||||
@@ -27,9 +26,11 @@ $config = array(
|
|||||||
'iconset' => 'osx',
|
'iconset' => 'osx',
|
||||||
'allow_override' => true,
|
'allow_override' => true,
|
||||||
|
|
||||||
// Server settings
|
|
||||||
|
// dList internal path settings
|
||||||
|
|
||||||
'default_scheme' => 'http',
|
'path_plugins' => array('plugins'),
|
||||||
|
'path_cache' => 'cache',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ if ( $do_readdir ) {
|
|||||||
|
|
||||||
//>Section> echo
|
//>Section> echo
|
||||||
print_r($dlist->list);
|
print_r($dlist->list);
|
||||||
print_r($config);
|
|
||||||
|
|
||||||
|
|
||||||
//_END;
|
//_END;
|
||||||
|
|||||||
31
exec/icons.exc.php
Normal file
31
exec/icons.exc.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php die();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Exec: icons
|
||||||
|
//
|
||||||
|
// Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||||
|
// zynode@gmail.com
|
||||||
|
//
|
||||||
|
|
||||||
|
//_HEAD;
|
||||||
|
/* --- Configuration ---
|
||||||
|
Name: icons
|
||||||
|
Priority: 40
|
||||||
|
Author: Jim Myhrberg
|
||||||
|
*/
|
||||||
|
//_SCRIPT;
|
||||||
|
|
||||||
|
//==========================
|
||||||
|
//>STAGE> init
|
||||||
|
//==========================
|
||||||
|
|
||||||
|
|
||||||
|
//>After> core.define_constants
|
||||||
|
define('ICONS_PATH', '/icons/'.$config->iconset.'/');
|
||||||
|
define('ICONS_URL', DLIST_URL.ICONS_PATH);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//_END;
|
||||||
|
?>
|
||||||
@@ -7,6 +7,16 @@
|
|||||||
// zynode@gmail.com
|
// zynode@gmail.com
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Intializes $timer at beginning of exec code, use
|
||||||
|
$timer->end(); in your template to get script
|
||||||
|
execution time.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
//_HEAD;
|
//_HEAD;
|
||||||
/* --- Configuration ---
|
/* --- Configuration ---
|
||||||
Name: timer
|
Name: timer
|
||||||
@@ -24,13 +34,5 @@ Author: Jim Myhrberg
|
|||||||
$timer = new speedometer();
|
$timer = new speedometer();
|
||||||
|
|
||||||
|
|
||||||
//==========================
|
|
||||||
//>STAGE> render
|
|
||||||
//==========================
|
|
||||||
|
|
||||||
|
|
||||||
//>Section> end
|
|
||||||
$timer->end();
|
|
||||||
|
|
||||||
//_END;
|
//_END;
|
||||||
?>
|
?>
|
||||||
@@ -16,6 +16,7 @@ class config {
|
|||||||
if ( !empty($input) ) $this->parse($input);
|
if ( !empty($input) ) $this->parse($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main function
|
||||||
function parse ($input, $overwrite=true) {
|
function parse ($input, $overwrite=true) {
|
||||||
if ( is_array($input) ) {
|
if ( is_array($input) ) {
|
||||||
$this->parse_array($input, $overwrite);
|
$this->parse_array($input, $overwrite);
|
||||||
@@ -28,6 +29,7 @@ class config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse settings from an array
|
||||||
function parse_array ($input, $overwrite=true) {
|
function parse_array ($input, $overwrite=true) {
|
||||||
if ( is_array($input) ) {
|
if ( is_array($input) ) {
|
||||||
foreach( $input as $key => $value ) {
|
foreach( $input as $key => $value ) {
|
||||||
@@ -44,7 +46,9 @@ class config {
|
|||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse settings from a defined array inside a php file,
|
||||||
|
// $var is the name of the variable inside the php to parse.
|
||||||
function parse_php_file ($file, $var='config', $overwrite=true) {
|
function parse_php_file ($file, $var='config', $overwrite=true) {
|
||||||
if ( is_readable($file) ) {
|
if ( is_readable($file) ) {
|
||||||
include($file);
|
include($file);
|
||||||
@@ -53,9 +57,10 @@ class config {
|
|||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_ini_file ($file, $overwrite=true) {
|
// Parse settings from an ini file.
|
||||||
|
function parse_ini_file ($file, $overwrite=true, $parse_sections=true) {
|
||||||
if ( is_readable($file) ) {
|
if ( is_readable($file) ) {
|
||||||
$this->parse_array(parse_ini_file($file, true), $overwrite);
|
$this->parse_array(parse_ini_file($file, $parse_sections), $overwrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class execHandler {
|
|||||||
var $cache_data = '.data.cache.php';
|
var $cache_data = '.data.cache.php';
|
||||||
var $cache_details = '.details.cache.php';
|
var $cache_details = '.details.cache.php';
|
||||||
var $cache_time = '.time.cache.php';
|
var $cache_time = '.time.cache.php';
|
||||||
var $update_frequency = 0;
|
var $update_frequency = 10;
|
||||||
var $php_opentag = "<?php\n";
|
var $php_opentag = "<?php\n";
|
||||||
var $php_closetag = "\n?>";
|
var $php_closetag = "\n?>";
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ class execHandler {
|
|||||||
|
|
||||||
var $default_stages = array(
|
var $default_stages = array(
|
||||||
'init' => 10,
|
'init' => 10,
|
||||||
|
'query' => 20,
|
||||||
'main' => 50,
|
'main' => 50,
|
||||||
'render' => 80,
|
'render' => 80,
|
||||||
'term' => 90,
|
'term' => 90,
|
||||||
@@ -421,9 +422,10 @@ class execHandler {
|
|||||||
|
|
||||||
// Compiling
|
// Compiling
|
||||||
|
|
||||||
function clean_up_code ($string, $comments=true, $emptylines=true) {
|
function clean_up_code ($string, $comments=true, $emptylines=true, $indents=false) {
|
||||||
if ( $comments ) $string = $this->remove_comments($string);
|
if ( $comments ) $string = $this->remove_comments($string);
|
||||||
if ( $emptylines ) $string = $this->remove_empty_lines($string);
|
if ( $emptylines ) $string = $this->remove_empty_lines($string);
|
||||||
|
if ( $indents ) $string = $this->remove_indents($string);
|
||||||
return trim($string);
|
return trim($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,6 +440,11 @@ class execHandler {
|
|||||||
$string = preg_replace("/\n+/m", "\n", $string);
|
$string = preg_replace("/\n+/m", "\n", $string);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_indents ($string) {
|
||||||
|
$string = preg_replace("/\n\s+(.*)/", "\n$1", $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
|
|||||||
@@ -9,6 +9,14 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Server configuration
|
||||||
|
|
||||||
|
$config['index_files'] = array('index.html', 'index.php', 'index.htm');
|
||||||
|
$config['default_scheme'] = 'http';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// process requested path
|
// process requested path
|
||||||
if ( stristr($_SERVER['REQUEST_URI'], '?') !== false ) {
|
if ( stristr($_SERVER['REQUEST_URI'], '?') !== false ) {
|
||||||
$dir_url = explode('?', $_SERVER['REQUEST_URI']);
|
$dir_url = explode('?', $_SERVER['REQUEST_URI']);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
//_HEAD;
|
//_HEAD;
|
||||||
/* --- Configuration ---
|
/* --- Configuration ---
|
||||||
Name: render
|
Name: simple/render
|
||||||
Priority: 40
|
Priority: 40
|
||||||
Author: Jim Myhrberg
|
Author: Jim Myhrberg
|
||||||
*/
|
*/
|
||||||
|
|||||||
25
view.php
25
view.php
@@ -2,32 +2,33 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
dList v0.7 beta
|
dList v2.0 beta
|
||||||
|
|
||||||
Copyright © 2006 Jim Myhrberg. All rights reserved.
|
Copyright © 2006 Jim Myhrberg. All rights reserved.
|
||||||
zynode@gmail.com
|
zynode@gmail.com
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('config.php');
|
|
||||||
require_once('resources/init.php');
|
require_once('resources/init.php');
|
||||||
require_once('libs/speedometer.lib.php');
|
|
||||||
require_once('libs/config.lib.php');
|
require_once('libs/config.lib.php');
|
||||||
|
$config = new config($config);
|
||||||
|
$config->parse_php_file('config.php');
|
||||||
|
|
||||||
|
require_once('libs/speedometer.lib.php');
|
||||||
require_once('libs/dirlist.lib.php');
|
require_once('libs/dirlist.lib.php');
|
||||||
require_once('libs/exechandler.lib.php');
|
require_once('libs/exechandler.lib.php');
|
||||||
|
|
||||||
|
|
||||||
// initialize config object
|
|
||||||
$config = new config($config);
|
|
||||||
|
|
||||||
|
|
||||||
// initialize debug stopwatch
|
// initialize debug stopwatch
|
||||||
if ($config->debug) $debug_time = new speedometer();
|
if ($config->debug) $debug_timer = new speedometer();
|
||||||
|
|
||||||
|
|
||||||
|
// initialize config object
|
||||||
|
|
||||||
|
|
||||||
// initialize execHandler and main scripts
|
// initialize execHandler and main scripts
|
||||||
$exec = new execHandler();
|
$exec = new execHandler();
|
||||||
$exec->cache_dir = 'cache/exec/';
|
$exec->cache_dir = $config->path_cache.'/exec/';
|
||||||
|
|
||||||
// debug?
|
// debug?
|
||||||
if ( $config->debug ) $exec->debug = true;
|
if ( $config->debug ) $exec->debug = true;
|
||||||
@@ -38,17 +39,17 @@ $exec->addPath(
|
|||||||
'exec/core.exc.php',
|
'exec/core.exc.php',
|
||||||
'exec/*',
|
'exec/*',
|
||||||
'templates/'.$config->template.'/render.exc.php',
|
'templates/'.$config->template.'/render.exc.php',
|
||||||
'plugins/*.exc.php',
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$exec->addPath($config->path_plugins);
|
||||||
$exec->cache();
|
$exec->cache();
|
||||||
include($exec->include_file);
|
include($exec->include_file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($config->debug) {
|
if ($config->debug) {
|
||||||
$debug_time->end();
|
$debug_timer->end();
|
||||||
echo "<br />\npage generated in ".$debug_time->time." sec.<br />\n";
|
echo "<br />\npage generated in ".$debug_timer->time." sec.<br />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user