Changeset 7010
- Timestamp:
- 11/18/08 16:43:37 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 13 modified
-
dispatcher.php (modified) (4 diffs)
-
library/context.php (modified) (1 diff)
-
library/data/POD.php (modified) (1 diff)
-
library/environment/config.php (modified) (3 diffs)
-
library/include.php (modified) (1 diff)
-
library/includeForBlog.php (modified) (1 diff)
-
library/includeForBlogOwner.php (modified) (1 diff)
-
library/includeForFeeder.php (modified) (1 diff)
-
library/includeForIcon.php (modified) (1 diff)
-
library/includeForReader.php (modified) (1 diff)
-
library/initialize.php (modified) (1 diff)
-
library/loader.php (modified) (1 diff)
-
library/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dispatcher.php
r7007 r7010 11 11 define('ROOT', '.'); 12 12 13 /// Load config.php. 14 if (file_exists(ROOT.'/config.php')) { 15 require_once(ROOT.'/config.php'); 16 } else { 13 /// Check config.php. 14 if (!file_exists(ROOT.'/config.php')) { 17 15 require(ROOT.'/setup.php'); 18 16 exit; … … 25 23 $config = Config::getInstance(); 26 24 27 / /Parse and normalize URI. */25 /** Parse and normalize URI. */ 28 26 /* TODO: Unify the environment and do work-arounds. (For IIS, Apache - mod_php or fastcgi, lighttpd, and etc.) */ 29 27 // Structure of fancy URL: 30 28 // host + blog prefix + interface path + pagination info + extra arguments not in $_REQUEST 31 29 // TODO: Apply this structure to $context->accessInfo... 30 32 31 try { 33 32 $context = Context::getInstance(); // automatic initialization via first instanciation … … 39 38 } 40 39 41 / * Special pre-handlers. (favicon.ico, index.gif) */40 /// Special pre-handlers. (favicon.ico, index.gif) 42 41 if ($context->accessInfo['prehandler']) { 43 42 // Skip further processes such as session management. … … 46 45 } 47 46 48 /* TODO: Session management. */ 47 /// Input Validation 48 // Basic POST/GET variable validation. 49 if (isset($IV)) { 50 if (!Validator::validate($IV)) { 51 header('HTTP/1.1 404 Not Found'); 52 exit; 53 } 54 } 55 // Basic SERVER variable validation. 56 $basicIV = array( 57 'SCRIPT_NAME' => array('string'), 58 'REQUEST_URI' => array('string'), 59 'REDIRECT_URL' => array('string', 'mandatory' => false) 60 ); 61 Validator::validateArray($_SERVER, $basicIV); 62 /*if(isset($accessInfo)) { 63 $basicIV = array( 64 'fullpath' => array('string'), 65 'input' => array('string'), 66 'position' => array('string'), 67 'root' => array('string'), 68 'input' => array('string', 'mandatory' => false) 69 ); 70 $accessInfo['fullpath'] = urldecode($accessInfo['fullpath']); 71 Validator::validateArray($accessInfo, $basicIV); 72 }*/ 49 73 50 // TODO: Do input validation as soon as possible? 74 /* TODO: Database Initialization (if necessary) 75 /* TODO: Parse virtual blog information (if necessary) 76 /* TODO: Session management. (if necessary) */ 77 /* TODO: ACL validation */ 78 51 79 /* Load final interface handler. */ 52 80 // Each interface... -
trunk/library/context.php
r7007 r7010 97 97 98 98 // TODO: Parse $_GET, $_POST, and etc. 99 99 if(isset($accessInfo['URLfragment'][0]) && $accessInfo['URLfragment'][0] == 'owner') $this->mode = 'owner'; 100 else $this->mode = 'blog'; 100 101 $this->accessInfo = $accessInfo; 101 102 } -
trunk/library/data/POD.php
r6989 r7010 19 19 /** Initialization **/ 20 20 function __construct($domain = null, $type = null, $prefix = '') { 21 requireComponent('Needlworks.Cache.PageCache');22 21 global $_pod_setting; 23 22 if($domain != null) $this->_domain = $domain; -
trunk/library/environment/config.php
r6998 r7010 22 22 global $database, $service, $blog, $memcache; 23 23 24 // Default configuration. 24 25 $database['server'] = 'localhost'; 25 26 $database['database'] = ''; … … 33 34 $service['language'] = 'ko'; 34 35 $service['timezone'] = 'Asia/Seoul'; 35 $service['encoding'] = ' EUC-KR';36 $service['encoding'] = 'UTF-8'; 36 37 $service['umask'] = 0; 37 38 $service['skin'] = 'coolant'; … … 54 55 $service['debug_rewrite_module'] = false; 55 56 $service['useNumericURLonRSS'] = false; 56 // Map port setting. 57 if (@is_numeric($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != 80) && ($_SERVER['SERVER_PORT'] != 443)) 58 $service['port'] = $_SERVER['SERVER_PORT']; 59 60 // Include installation configuration. 61 $service['session_cookie_path'] = '/'; 62 if(!defined('__TEXTCUBE_SETUP__')) @include ROOT . '/config.php'; 63 64 // Set resource path. 65 if($service['externalresources']) { 66 if(isset($service['resourceURL']) && !empty($service['resourceURL'])) 67 $service['resourcepath'] = $service['resourceURL']; 68 else 69 $service['resourcepath'] = TEXTCUBE_RESOURCE_URL; 70 } else { 71 $service['resourcepath'] = $service['path'].'/resources'; 72 } 73 74 // Database setting. 75 if(isset($service['dbms'])) { 76 if($service['dbms'] == 'mysql' && class_exists('mysqli')) $service['dbms'] = 'mysqli'; 77 } 78 79 // Debug mode configuration. 80 if($service['debugmode'] == true) { 81 if(isset($service['dbms'])) { 82 switch($service['dbms']) { 83 case 'mysqli': requireLibrary("debug/MySQLi"); break; 84 case 'mysql': default: requireLibrary("debug/MySQL"); break; 85 } 86 } else requireLibrary("debug/MySQL"); 87 } 88 89 // Session cookie patch. 90 if(!empty($service['domain']) && strstr( $_SERVER['HTTP_HOST'], $service['domain'] ) ) { 91 $service['session_cookie_domain'] = $service['domain']; 92 } else { 93 $service['session_cookie_domain'] = $_SERVER['HTTP_HOST']; 94 } 95 96 // Basic POST/GET variable validation. 97 if (isset($IV)) { 98 if (!Validator::validate($IV)) { 99 header('HTTP/1.1 404 Not Found'); 100 exit; 101 } 102 } 103 // Basic SERVER variable validation. 104 $basicIV = array( 105 'SCRIPT_NAME' => array('string'), 106 'REQUEST_URI' => array('string'), 107 'REDIRECT_URL' => array('string', 'mandatory' => false) 108 ); 109 Validator::validateArray($_SERVER, $basicIV); 110 if(isset($accessInfo)) { 111 $basicIV = array( 112 'fullpath' => array('string'), 113 'input' => array('string'), 114 'position' => array('string'), 115 'root' => array('string'), 116 'input' => array('string', 'mandatory' => false) 117 ); 118 $accessInfo['fullpath'] = urldecode($accessInfo['fullpath']); 119 Validator::validateArray($accessInfo, $basicIV); 120 } 57 $service['dbms'] = 'mysql'; 121 58 ?> -
trunk/library/include.php
r7009 r7010 40 40 } 41 41 42 /***** Autoload components *****/43 class Autoload {44 private static $drivers = array(45 'auth' => array('Auth','OpenID',array('Privilege'=>'Auth','Acl'=>'Auth')),46 'cache' => array('PageCache'),47 'data' => array('BlogSetting','BlogStatistics','DailyStatistics',48 'DataMaintenance','Filter','Image','MySQL','MySQLi','POD','RSS',49 'RefererLog','RefererStatistics','ServiceSetting','Setting',50 'Statistics','SubscriptionLog','SubscriptionStatistics','Syndication',51 'TData','UserInfo','UserSetting'),52 'entry' => array(53 'Attachment','Category','Comment','CommentNotified','CommentNotifiedSiteInfo',54 'Feed','GuestComment','Keyword','Link','Notice','PluginSetting',55 'Post','RemoteResponse','SkinSetting','Tag','Trackback','TrackbackLog'),56 'environment' => array(57 'Base64Stream','HTTPRequest','OutputWriter','XMLRPC',58 array('XMLRPCFault'=>'XMLRPC','XMLCustomType'=>'XMLRPC'),59 'XMLTree','Pop3'),60 'plugin' => array('Misc','PluginCustomConfig'),61 'session' => array('Session'),62 'skin' => array('BlogSkin'),63 'view' => array('BlogView','Paging','Respond'));64 private static $relation = array();65 public static function register() {66 foreach (self::$drivers as $namespace => $classes) {67 if(!empty($classes)) foreach($classes as $class) {68 if(is_array($class)) {69 foreach($class as $module => $file) self::$relation[$module] = $namespace.'/'.$file;70 } else self::$relation[$class] = $namespace.'/'.$class;71 }72 }73 }74 public static function load($name) {75 global $service;76 $name = ucfirst($name);77 if(empty(self::$relation)) {self::register();}78 if (in_array($name,array('DBQuery'))) {79 if (!isset($service['dbms'])) $service['dbms'] = 'mysql';80 require_once(ROOT . "/library/data/".$service['dbms']."/Adapter.php");81 require_once(ROOT . "/library/data/Database.php");82 } else if(self::$relation[$name] == 'session' && isset($service['memcached']) && $service['memcached'] == true) {83 require_once(ROOT . "/library/session/Session_Memcached.php");84 } else if(empty(self::$relation[$name])) {85 if(defined('TCDEBUG')) print "Textcube: Unregisterred auto load class: $name<br/>\n";86 } else {87 require_once(ROOT . "/library/".self::$relation[$name]."/".$name.".php");88 }89 90 }91 }92 spl_autoload_register(array('Autoload', 'load'));93 94 42 /***** Pre-define basic components *****/ 95 43 $__coreLibrary = array( 96 44 'environment/Needlworks.PHP.UnifiedEnvironment', 97 'environment/Needlworks.PHP.Core',45 // 'environment/Needlworks.PHP.Core', 98 46 'environment/Locale', 99 47 'data/Core', -
trunk/library/includeForBlog.php
r7004 r7010 6 6 $__requireComponent = array(); 7 7 $__requireBasics = array( 8 'environment/config',// Basics8 // Basics 9 9 'function/string', 10 10 'function/time', -
trunk/library/includeForBlogOwner.php
r6999 r7010 7 7 $__requireComponent = array(); 8 8 $__requireBasics = array( 9 'environment/config', // Basics10 9 'function/string', 11 10 'function/time', -
trunk/library/includeForFeeder.php
r6999 r7010 8 8 $__requireComponent = array(); 9 9 $__requireBasics = array( // Basics 10 'environment/config',11 10 'function/string', 12 11 'function/time', -
trunk/library/includeForIcon.php
r6999 r7010 8 8 $__requireComponent = array(); 9 9 $__requireBasics = array( // Basics 10 'environment/config',11 10 'function/file'); 12 11 $__requireLibrary = array( // Library -
trunk/library/includeForReader.php
r6999 r7010 7 7 $__requireComponent = array(); 8 8 $__requireBasics = array( // Basics 9 'environment/config',10 9 'function/string', 11 10 'function/time', -
trunk/library/initialize.php
r6985 r7010 112 112 $adminSkinSetting['editorTemplate'] = "/resources/style/default-wysiwyg.css"; 113 113 } 114 if (!file_exists(ROOT . '/config.php')) {115 header('Location: ' . ROOT . '/setup.php');116 exit;117 }118 114 } 119 115 ?> -
trunk/library/loader.php
r7007 r7010 6 6 final class FrameworkAutoloader 7 7 { 8 private static $classPaths = array( 9 'Context' => './library/context.php', 10 'Debug' => './library/debug.php', 11 'IModel' => './library/data/IAdapter.php', 12 'DBException' => './library/data/IAdapter.php', 13 'DBConnectionError' => './library/data/IAdapter.php', 14 'DBQueryError' => './library/data/IAdapter.php', 15 'IAdapter' => './library/data/IModel.php', 16 'ICache' => './library/cache/ICache.php', 17 'Entry' => './library/model/Entry.php', 8 private static $classInfo = array( 9 'auth' => array('Auth','OpenID',array('Privilege'=>'Auth','Acl'=>'Auth')), 10 'cache' => array('PageCache','ICache'), 11 'data' => array('BlogSetting','BlogStatistics','DailyStatistics', 12 'DataMaintenance','Filter','Image','MySQL','MySQLi','POD','RSS', 13 'RefererLog','RefererStatistics','ServiceSetting','Setting', 14 'Statistics','SubscriptionLog','SubscriptionStatistics','Syndication', 15 'TData','UserInfo','UserSetting', 16 array('IAdapter'=>'IModel','DBQueryError'=>'IAdapter', 17 'DBConnectionError'=>'IAdapter','DBException'=>'IAdapter') 18 ), 19 'entry' => array( 20 'Attachment','Category','Comment','CommentNotified','CommentNotifiedSiteInfo', 21 'Feed','GuestComment','Keyword','Link','Notice','PluginSetting', 22 'Post','RemoteResponse','SkinSetting','Tag','Trackback','TrackbackLog'), 23 'environment' => array( 24 'Base64Stream','HTTPRequest','OutputWriter','XMLRPC', 25 'XMLTree','Pop3', 26 array('XMLRPCFault'=>'XMLRPC','XMLCustomType'=>'XMLRPC', 27 'Validator'=>'Needlworks.PHP.Core')), 28 'plugin' => array('Misc','PluginCustomConfig'), 29 'session' => array('Session'), 30 'skin' => array('BlogSkin'), 31 'view' => array('BlogView','Paging','Respond'), 32 'root' => array('Context','Debug') 18 33 ); 19 34 20 35 static function init() { 21 36 $config = Config::getInstance(); 22 23 37 // Set paths for DB classes according to the current backend configuration. 24 self::$classPaths['Adapter'] = './data/' . $config->backend_name . '/Adapter.php';25 self::$classPaths['Model'] = './data/' . $config->backend_name . '/Model.php';38 array_push(self::$classInfo['data'],array('IAdapter'=>'data/'.$config->backend_name.'/Adapter.php')); 39 array_push(self::$classInfo['data'],array('IModel'=>'data/'.$config->backend_name.'/Model.php')); 26 40 } 27 41 28 static function autoload($name) { 29 if (isset(self::$classPaths[$name])) 30 require_once(self::$classPaths[$name]); 31 // Because multiple autoload functions can be defined, we don't throw any exception here. 32 // If PHP finally fails finding the class, it will say FATAL error. 42 private static $relation = array(); 43 44 public static function register() { 45 foreach (self::$classInfo as $namespace => $classes) { 46 if(!empty($classes)) { 47 foreach($classes as $class) { 48 if($namespace == 'root') self::$relation[$class] = $class; 49 else if(is_array($class)) { 50 foreach($class as $module => $file) self::$relation[$module] = $namespace.'/'.$file; 51 } else self::$relation[$class] = $namespace.'/'.$class; 52 } 53 } 54 } 55 } 56 public static function autoload($name) { 57 global $service; 58 $name = ucfirst($name); 59 if(empty(self::$relation)) {self::register();} 60 if (in_array($name,array('DBQuery'))) { 61 if (!isset($service['dbms'])) $service['dbms'] = 'mysql'; 62 require_once(ROOT . "/library/data/".$service['dbms']."/Adapter.php"); 63 require_once(ROOT . "/library/data/Database.php"); 64 } else if(self::$relation[$name] == 'session' && isset($service['memcached']) && $service['memcached'] == true) { 65 require_once(ROOT . "/library/session/Session_Memcached.php"); 66 } else if(empty(self::$relation[$name])) { 67 if(defined('TCDEBUG')) print "Textcube: Unregisterred auto load class: $name<br/>\n"; 68 } else { 69 require_once(ROOT . "/library/".self::$relation[$name].".php"); 70 } 33 71 } 34 72 } 35 36 73 FrameworkAutoloader::init(); 37 74 spl_autoload_register(array('FrameworkAutoloader', 'autoload')); -
trunk/library/settings.php
r7007 r7010 12 12 13 13 protected function __construct() { 14 global $database, $service; 15 14 16 $this->settings = array(); 17 require_once(ROOT.'/library/environment/config.php'); // Loading default configuration 18 if (file_exists(ROOT.'/config.php')) require_once(ROOT.'/config.php'); // Override configuration 19 // Map port setting. 20 if (@is_numeric($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != 80) && ($_SERVER['SERVER_PORT'] != 443)) 21 $service['port'] = $_SERVER['SERVER_PORT']; 22 23 // Include installation configuration. 24 $service['session_cookie_path'] = '/'; 25 if(!defined('__TEXTCUBE_SETUP__')) @include ROOT . '/config.php'; 26 27 // Set resource path. 28 if($service['externalresources']) { 29 if(isset($service['resourceURL']) && !empty($service['resourceURL'])) 30 $service['resourcepath'] = $service['resourceURL']; 31 else 32 $service['resourcepath'] = TEXTCUBE_RESOURCE_URL; 33 } else { 34 $service['resourcepath'] = $service['path'].'/resources'; 35 } 36 37 // Database setting. 38 if(isset($service['dbms'])) { 39 if($service['dbms'] == 'mysql' && class_exists('mysqli')) $service['dbms'] = 'mysqli'; 40 } 41 42 // Debug mode configuration. 43 if($service['debugmode'] == true) { 44 if(isset($service['dbms'])) { 45 switch($service['dbms']) { 46 case 'mysqli': require_once(ROOT. "/library/debug/MySQLi.php"); break; 47 case 'mysql': default: require_once(ROOT. "/library/debug/MySQL.php"); break; 48 } 49 } else requireLibrary("debug/MySQL"); 50 } 51 52 // Session cookie patch. 53 if(!empty($service['domain']) && strstr( $_SERVER['HTTP_HOST'], $service['domain'] ) ) { 54 $service['session_cookie_domain'] = $service['domain']; 55 } else { 56 $service['session_cookie_domain'] = $_SERVER['HTTP_HOST']; 57 } 15 58 16 // TODO: Temporary implementation: just import from config.php's global variables17 global $database, $service;18 59 $this->database = $database; 19 60 $this->service = $service; 20 $this->backend_name = isset($service['dbms']) ? $service['dbms'] : 'mysql';61 $this->backend_name = $service['dbms']; 21 62 } 22 63
