00001 <?php
00011 if(!defined('PROFILE')) define('PROFILE', 'web');
00012
00013
00014 require_once(DIR_FS_PRONTO.DS.'core'.DS.'registry.php');
00015 require_once(DIR_FS_PRONTO.DS.'core'.DS.'log.php');
00016 require_once(DIR_FS_PRONTO.DS.'core'.DS.'factory.php');
00017 if(phpversion() < 5) {
00018 require_once(DIR_FS_PRONTO.DS.'core'.DS.'lazyload_php4.php');
00019 } else {
00020 require_once(DIR_FS_PRONTO.DS.'core'.DS.'lazyload_php5.php');
00021 }
00022 require_once(DIR_FS_PRONTO.DS.'core'.DS.'web.php');
00023 require_once(DIR_FS_PRONTO.DS.'core'.DS.'template.php');
00024 require_once(DIR_FS_PRONTO.DS.'core'.DS.'session.php');
00025 require_once(DIR_FS_PRONTO.DS.'core'.DS.'access.php');
00026 require_once(DIR_FS_PRONTO.DS.'core'.DS.'validator.php');
00027 require_once(DIR_FS_PRONTO.DS.'core'.DS.'i18n.php');
00028 require_once(DIR_FS_PRONTO.DS.'core'.DS.'cache.php');
00029 require_once(DIR_FS_PRONTO.DS.'core'.DS.'util.php');
00030
00031
00032 require_once(DIR_FS_APP.DS.'config'.DS.'urls.php');
00033 Registry::set('pronto:urls', $URLS);
00034 unset($URLS);
00035
00036
00037 if(!function_exists('json_encode')) {
00038 require_once(DIR_FS_PRONTO.DS.'extlib'.DS.'json-php4.php');
00039 }
00040
00041 if(DEBUG === true && isset($_GET['phpinfo'])) {
00042 phpinfo();
00043 die;
00044 }
00045
00046
00047
00048
00049 $l = new Logger();
00050 if(file_exists(DIR_FS_APP.DS.'config'.DS.'log.php')) {
00051 require_once(DIR_FS_APP.DS.'config'.DS.'log.php');
00052 $l->clear_routes();
00053 $l->add_routes($LOG_ROUTES);
00054 }
00055 Registry::set('pronto:logger', $l);
00056 unset($l);
00057
00058
00059
00060
00061 if(USE_CACHE === true && defined('CACHE_DRIVER')) {
00062 require_once(DIR_FS_PRONTO.DS.'core'.DS.'cache'.DS.CACHE_DRIVER.'.php');
00063 $cn = "Cache_".CACHE_DRIVER;
00064 $cache = new $cn();
00065 unset($cn);
00066
00067
00068 if(DEBUG === true) {
00069 if(isset($_GET['cache_flush'])) {
00070 echo "<pre>Flushing Cache...</pre><br>\n";
00071 $cache->flush();
00072 }
00073 if(isset($_GET['cache_stats'])) {
00074 echo "<pre>".print_r($cache->stats(),true)."</pre><br>\n";
00075 }
00076 }
00077 } else {
00078 $cache = new Cache();
00079 }
00080 $cache->gc();
00081 Registry::set('pronto:cache', $cache);
00082
00083
00084
00085
00086 if(defined('MODULES')) {
00087 foreach(explode(' ', MODULES) as $modname) {
00088 $modpath = DIR_FS_APP.DS.'modules'.DS.$modname.DS.'config'.DS;
00089 if(file_exists($modpath.'config.php')) require_once($modpath.'config.php');
00090 if(file_exists($modpath.'urls.php')) {
00091 $old = Registry::get('pronto:urls');
00092 require_once($modpath.'urls.php');
00093 $URLS += $old;
00094 Registry::set('pronto:urls', $URLS);
00095 unset($old, $URLS);
00096 }
00097 if(file_exists($modpath.'log.php')) {
00098 $l =& Registry::get('pronto:logger');
00099 require_once($modpath.'log.php');
00100 $l->add_routes($LOG_ROUTES);
00101 unset($l);
00102 }
00103 }
00104 unset($modname, $modpath);
00105 }
00106
00107
00108
00109
00110 ini_set('default_charset', 'UTF-8');
00111 if(extension_loaded('mbstring')) {
00112 mb_internal_encoding(CHARSET);
00113 }
00114
00115
00116
00117
00118 if(defined('DB_NAME')) {
00119 $db =& Factory::db(array(
00120 'dsn' => DB_DSN,
00121 'file' => DB_FILE,
00122 'host' => DB_HOST,
00123 'user' => DB_USER,
00124 'pass' => DB_PASS,
00125 'name' => DB_NAME));
00126 Registry::set('pronto:db:main', $db);
00127 } else {
00128 require_once(DIR_FS_APP.DS.'config'.DS.'databases.php');
00129 foreach($DATABASES as $key=>$dbcfg) {
00130 $db =& Factory::db($dbcfg);
00131 Registry::set('pronto:db:'.$key, $db);
00132 }
00133 unset($key, $dbcfg);
00134 }
00135
00136
00137
00138
00139 if(isset($_COOKIE[SESSION_COOKIE])) {
00140
00141 start_session();
00142 }
00143
00144
00145
00146
00147 $access = new Access();
00148 define('ACCESS_ID', $access->get_id());
00149 Registry::set('pronto:access', $access);
00150
00151
00152
00153
00154 $i18n = new I18N();
00155 $i18n->autoset_language('en');
00156 define('LANG', $i18n->get_language());
00157 Registry::set('pronto:i18n', $i18n);
00158
00159
00160
00161
00162 $web = new Web(__FILE__);
00163 $web->template_layout = 'layout.php';
00164 Registry::set('pronto:web', $web);
00165
00166
00167
00168
00169 foreach(explode(' ', PLUGINS) as $p) {
00170 if($p) Factory::plugin($p, 'page');
00171 }
00172 unset($p);
00173
00174
00175
00176
00177 $p = new Validator();
00178 Registry::set('pronto:validator', $p);
00179 unset($p);
00180
00181
00182
00183
00184 $old = error_reporting(E_ALL & ~E_NOTICE);
00185 if(DEBUG === true) {
00186 $web->enable_debug();
00187 $db =& Registry::get('pronto:db:main');
00188 if($db) $db->profile = true;
00189 }
00190
00191
00192
00193
00194 set_error_handler('pronto_error');
00195 if(phpversion() >= 5) {
00196 set_exception_handler('pronto_exception');
00197 }
00198
00199
00200
00201
00202 $urls = Registry::get('pronto:urls');
00203 $web->run($urls);
00204
00205 ?>