00001 <?php
00011 set_time_limit(0);
00012 if(!defined('PROFILE')) define('PROFILE', 'cmdline');
00013
00014
00015 require_once(DIR_FS_PRONTO.DS.'core'.DS.'registry.php');
00016 require_once(DIR_FS_PRONTO.DS.'core'.DS.'log.php');
00017 require_once(DIR_FS_PRONTO.DS.'core'.DS.'factory.php');
00018 if(phpversion() < 5) {
00019 require_once(DIR_FS_PRONTO.DS.'core'.DS.'lazyload_php4.php');
00020 } else {
00021 require_once(DIR_FS_PRONTO.DS.'core'.DS.'lazyload_php5.php');
00022 }
00023 require_once(DIR_FS_PRONTO.DS.'core'.DS.'template.php');
00024 require_once(DIR_FS_PRONTO.DS.'core'.DS.'validator.php');
00025 require_once(DIR_FS_PRONTO.DS.'core'.DS.'i18n.php');
00026 require_once(DIR_FS_PRONTO.DS.'core'.DS.'cache.php');
00027 require_once(DIR_FS_PRONTO.DS.'core'.DS.'util.php');
00028
00029
00030 require_once(DIR_FS_APP.DS.'config'.DS.'urls.php');
00031 Registry::set('pronto:urls', $URLS);
00032 unset($URLS);
00033
00034
00035
00036
00037 $l = new Logger();
00038 if(file_exists(DIR_FS_APP.DS.'config'.DS.'log.php')) {
00039 require_once(DIR_FS_APP.DS.'config'.DS.'log.php');
00040 $l->clear_routes();
00041 $l->add_routes($LOG_ROUTES);
00042 }
00043 Registry::set('pronto:logger', $l);
00044 unset($l);
00045
00046
00047
00048
00049 if(USE_CACHE === true && defined('CACHE_DRIVER')) {
00050 require_once(DIR_FS_PRONTO.DS.'core'.DS.'cache'.DS.CACHE_DRIVER.'.php');
00051 $cn = "Cache_".CACHE_DRIVER;
00052 $cache = new $cn();
00053 unset($cn);
00054 } else {
00055 $cache = new Cache();
00056 }
00057 $cache->gc();
00058 Registry::set('pronto:cache', $cache);
00059
00060
00061
00062
00063 if(defined('MODULES')) {
00064 foreach(explode(' ', MODULES) as $modname) {
00065 $modpath = DIR_FS_APP.DS.'modules'.DS.$modname.DS.'config'.DS;
00066 if(file_exists($modpath.'config.php')) require_once($modpath.'config.php');
00067 if(file_exists($modpath.'urls.php')) {
00068 $old = Registry::get('pronto:urls');
00069 require_once($modpath.'urls.php');
00070 $URLS += $old;
00071 Registry::set('pronto:urls', $URLS);
00072 unset($old, $URLS);
00073 }
00074 if(file_exists($modpath.'log.php')) {
00075 $l =& Registry::get('pronto:logger');
00076 require_once($modpath.'log.php');
00077 $l->add_routes($LOG_ROUTES);
00078 unset($l);
00079 }
00080 }
00081 unset($modname, $modpath);
00082 }
00083
00084
00085
00086
00087 ini_set('default_charset', 'UTF-8');
00088 if(extension_loaded('mbstring')) {
00089 mb_internal_encoding(CHARSET);
00090 }
00091
00092
00093
00094
00095 if(defined('DB_NAME')) {
00096 $db =& Factory::db(array(
00097 'dsn' => DB_DSN,
00098 'file' => DB_FILE,
00099 'host' => DB_HOST,
00100 'user' => DB_USER,
00101 'pass' => DB_PASS,
00102 'name' => DB_NAME));
00103 Registry::set('pronto:db:main', $db);
00104 } else {
00105 require_once(DIR_FS_APP.DS.'config'.DS.'databases.php');
00106 foreach($DATABASES as $key=>$dbcfg) {
00107 $db =& Factory::db($dbcfg);
00108 Registry::set('pronto:db:'.$key, $db);
00109 }
00110
00111 unset($key, $dbcfg);
00112 }
00113
00114
00115
00116
00117 $i18n = new I18N();
00118 $i18n->autoset_language('en');
00119 define('LANG', $i18n->get_language());
00120 Registry::set('pronto:i18n', $i18n);
00121
00122
00123
00124
00125 foreach(explode(' ', PLUGINS) as $p) {
00126 if($p) Factory::plugin($p, 'page');
00127 }
00128 unset($p);
00129 $plugins =& Registry::get('pronto:plugins');
00130
00131
00132
00133
00134 $p = new Validator();
00135 Registry::set('pronto:validator', $p);
00136 unset($p);
00137
00138
00139
00140
00141 error_reporting(E_ALL & ~E_NOTICE);
00142 if(DEBUG === true) {
00143 $db =& Registry::get('pronto:db:main');
00144 if($db) $db->profile = true;
00145 }
00146
00147
00148
00149
00150 function script_lock($name)
00151 {
00152 if(file_exists("/tmp/$name.lck")) {
00153 echo "Script is already locked -- skipping execution\n";
00154 mail(ADMIN_EMAIL, SITE_NAME.': skipping script', "$name is already running.\n");
00155 exit;
00156 }
00157 touch("/tmp/$name.lck");
00158 }
00159
00160 function script_unlock($name)
00161 {
00162 @unlink("/tmp/$name.lck");
00163 }
00164
00165 ?>