| [ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // --------------------------------------------------- 4 // Directories 5 // --------------------------------------------------- 6 7 define('ROOT', dirname(__FILE__)); 8 9 define('APPLICATION_PATH', ROOT . '/application'); 10 define('LIBRARY_PATH', ROOT . '/library'); 11 define('FILES_DIR', ROOT . '/upload'); // place where we will upload project files 12 define('CACHE_DIR', ROOT . '/cache'); 13 define('THEMES_DIR', ROOT . '/public/assets/themes'); 14 15 set_include_path(ROOT . PATH_SEPARATOR . APPLICATION_PATH); 16 17 // --------------------------------------------------- 18 // Fix some $_SERVER vars (taken from wordpress code) 19 // --------------------------------------------------- 20 21 // Fix for IIS, which doesn't set REQUEST_URI 22 if(!isset($_SERVER['REQUEST_URI']) || trim($_SERVER['REQUEST_URI']) == '') { 23 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI? 24 25 // Append the query string if it exists and isn't null 26 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 27 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 28 } // if 29 } // if 30 31 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 32 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) { 33 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 34 } // if 35 36 // Fix for Dreamhost and other PHP as CGI hosts 37 if(strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) unset($_SERVER['PATH_INFO']); 38 39 if(trim($_SERVER['PHP_SELF']) == '') $_SERVER['PHP_SELF'] = preg_replace("/(\?.*)?$/",'', $_SERVER["REQUEST_URI"]); 40 41 // --------------------------------------------------- 42 // Check if script is installed 43 // --------------------------------------------------- 44 45 // If script is not installed config.php will return false. Othervise it will 46 // return NULL. If we get false redirect to install folder 47 if(!include_once (ROOT . '/config/config.php')) { 48 print "ProjectPier is not installed. Please redirect your browser to <b><a href=\"./". PUBLIC_FOLDER . "/install\">" . PUBLIC_FOLDER . "/install</a></b> folder and follow installation procedure"; 49 die(); 50 } // if 51 52 // --------------------------------------------------- 53 // config.php + extended config 54 // --------------------------------------------------- 55 56 define('PRODUCT_NAME', 'ProjectPier'); 57 if(!defined('PRODUCT_VERSION')) { 58 define('PRODUCT_VERSION', '0.8'); 59 } // if 60 61 define('MAX_SEARCHABLE_FILE_SIZE', 1048576); // if file type is searchable script will load its content into search index. Using this constant you can set the max filesize of the file that will be imported. Noone wants 500MB in search index for single file 62 define('SESSION_LIFETIME', 3600); 63 define('REMEMBER_LOGIN_LIFETIME', 1209600); // two weeks 64 65 // Defaults 66 define('DEFAULT_CONTROLLER', 'dashboard'); 67 define('DEFAULT_ACTION', 'index'); 68 define('DEFAULT_THEME', 'default'); 69 70 // Default cookie settings... 71 define('COOKIE_PATH', '/'); 72 define('COOKIE_DOMAIN', ''); 73 define('COOKIE_SECURE', false); 74 75 // --------------------------------------------------- 76 // Init... 77 // --------------------------------------------------- 78 79 include_once 'environment/environment.php'; 80 81 // Lets prepare everything for autoloader 82 require APPLICATION_PATH . '/functions.php'; // __autoload() function is defined here... 83 @include ROOT . '/cache/autoloader.php'; 84 85 // Prepare logger... We might need it early... 86 if(!Env::isDebugging()) { 87 Logger::setSession(new Logger_Session('default')); 88 Logger::setBackend(new Logger_Backend_File(CACHE_DIR . '/log.php')); 89 90 set_error_handler('__production_error_handler'); 91 set_exception_handler('__production_exception_handler'); 92 } // if 93 94 register_shutdown_function('__shutdown'); 95 96 // Connect to database... 97 try { 98 DB::connect(DB_ADAPTER, array( 99 'host' => DB_HOST, 100 'user' => DB_USER, 101 'pass' => DB_PASS, 102 'name' => DB_NAME, 103 'persist' => DB_PERSIST 104 )); // connect 105 if(defined('DB_CHARSET') && trim(DB_CHARSET)) { 106 DB::execute("SET NAMES ?", DB_CHARSET); 107 } // if 108 } catch(Exception $e) { 109 if(Env::isDebugging()) { 110 Env::dumpError($e); 111 } else { 112 Logger::log($e, Logger::FATAL); 113 Env::executeAction('error', 'db_connect'); 114 } // if 115 } // try 116 117 // Init application 118 if(Env::isDebugging()) { 119 benchmark_timer_set_marker('Init application'); 120 } // if 121 122 // We need to call application.php after the routing is executed because 123 // some of the application classes may need CONTROLLER, ACTION or $_GET 124 // data collected by the matched route 125 require_once 'application.php'; 126 127 // Set handle request timer... 128 if(Env::isDebugging()) { 129 benchmark_timer_set_marker('Handle request'); 130 } // if 131 132 // Get controller and action and execute... 133 try { 134 Env::executeAction(request_controller(), request_action()); 135 } catch(Exception $e) { 136 if(Env::isDebugging()) { 137 Env::dumpError($e); 138 } else { 139 Logger::log($e, Logger::FATAL); 140 redirect_to(get_url('error', 'execute_action')); 141 } // if 142 } // try 143 144 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Sep 25 23:40:09 2007 | Cross-referenced by PHPXref 0.7 |