[5] | 1 | <?php |
---|
[362] | 2 | /** |
---|
| 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[376] | 5 | * Copyright 2001-2010 Strangecode, LLC |
---|
[362] | 6 | * |
---|
| 7 | * This file is part of The Strangecode Codebase. |
---|
[5] | 8 | * |
---|
[362] | 9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License as published by the |
---|
| 11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
| 12 | * any later version. |
---|
| 13 | * |
---|
| 14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 17 | * details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License along with |
---|
| 20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * _config.inc.php lives in the document root of the site/application. It is the beginning of everything. |
---|
| 25 | * |
---|
[5] | 26 | * @author Quinn Comendant <quinn@strangecode.com> |
---|
[295] | 27 | * @version 1.3 |
---|
[27] | 28 | * @since 03 Dec 2005 19:09:32 |
---|
[5] | 29 | */ |
---|
[295] | 30 | |
---|
[27] | 31 | // The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows. |
---|
| 32 | // To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php'; |
---|
| 33 | if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) { |
---|
[42] | 34 | trigger_error('_config.inc.php include must be specified with an absolute file path (eg: "require_once dirname(__FILE__) . \'/_config.inc.php\';"', E_USER_ERROR); |
---|
[5] | 35 | } |
---|
| 36 | |
---|
[27] | 37 | // First things first. Define the globally used directory paths. |
---|
| 38 | // The parent directory of all application DocRoots. |
---|
[5] | 39 | define('COMMON_BASE', realpath(dirname(__FILE__) . '/../')); |
---|
[27] | 40 | |
---|
[295] | 41 | // The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the |
---|
[27] | 42 | // latter does not change when using the apache Alias directive or URL Rewriting to define a site. |
---|
[5] | 43 | define('SITE_BASE', dirname(__FILE__)); |
---|
| 44 | |
---|
[339] | 45 | // Set include path for all templates and libraries. |
---|
[94] | 46 | ini_set('include_path', join(PATH_SEPARATOR, array( |
---|
| 47 | COMMON_BASE, |
---|
| 48 | SITE_BASE . '/_templates', |
---|
[101] | 49 | get_include_path(), |
---|
[94] | 50 | ))); |
---|
[5] | 51 | |
---|
| 52 | // Include core libraries. |
---|
| 53 | require_once 'codebase/lib/Utilities.inc.php'; |
---|
[27] | 54 | require_once 'codebase/lib/App.inc.php'; |
---|
[5] | 55 | |
---|
[27] | 56 | // Primary application class. |
---|
[295] | 57 | $app =& App::getInstance('public'); |
---|
[5] | 58 | $app->setParam(array( |
---|
[295] | 59 | 'site_name' => 'WWW Public Site', |
---|
[5] | 60 | 'site_email' => 'hello@example.com', |
---|
[252] | 61 | 'redirect_home_url' => '/', |
---|
[316] | 62 | 'images_path' => '/i', |
---|
[5] | 63 | |
---|
| 64 | 'date_format' => 'd M Y', |
---|
| 65 | 'sql_date_format' => '%e %b %Y', |
---|
| 66 | 'sql_time_format' => '%k:%i', |
---|
| 67 | 'character_set' => 'utf-8', |
---|
| 68 | |
---|
[295] | 69 | 'enable_session' => true, |
---|
[27] | 70 | 'enable_db_session_handler' => false, |
---|
[5] | 71 | 'session_use_cookies' => true, |
---|
[295] | 72 | 'session_use_trans_sid' => true, // Disable this for high-security sites where session-ID theft is a risk. |
---|
[5] | 73 | |
---|
[295] | 74 | // 'ssl_domain' => 'www.example.com', |
---|
| 75 | // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'), |
---|
| 76 | |
---|
| 77 | 'enable_db' => true, |
---|
[5] | 78 | 'db_always_debug' => false, |
---|
| 79 | 'db_debug' => true, |
---|
| 80 | 'db_die_on_failure' => true, |
---|
[295] | 81 | 'db_create_tables' => true, // Disable after site launch. |
---|
[5] | 82 | |
---|
| 83 | 'display_errors' => true, |
---|
| 84 | |
---|
| 85 | 'log_directory' => COMMON_BASE . '/log', |
---|
[256] | 86 | 'log_filename' => 'site_log', |
---|
[5] | 87 | 'log_file_priority' => LOG_DEBUG, |
---|
| 88 | 'log_email_priority' => false, |
---|
| 89 | 'log_sms_priority' => false, |
---|
| 90 | 'log_screen_priority' => false, |
---|
[295] | 91 | 'log_to_email_address' => 'log@strangecode.com', |
---|
| 92 | 'log_to_sms_address' => 'sms-quinn@strangecode.com', |
---|
[5] | 93 | )); |
---|
| 94 | |
---|
[295] | 95 | if (defined('_CLI')) { |
---|
| 96 | // DB credentials for command line scripts stored in a file with read rights |
---|
| 97 | // given only to the user who will be executing the scripts: -rw------- |
---|
| 98 | // This file includes $app-> method calls so this must be included after App::getInstance(). |
---|
| 99 | require_once 'global/db_auth.inc.php'; |
---|
| 100 | } |
---|
| 101 | |
---|
[136] | 102 | // Start application-based functionality: database, session, environment, ini setup, etc. |
---|
[27] | 103 | // Most configuration parameters must be set before starting the App. |
---|
[5] | 104 | $app->start(); |
---|
| 105 | |
---|
[295] | 106 | // Global DB object. Automatically pre-configured by $app->start(). |
---|
[136] | 107 | $db =& DB::getInstance(); |
---|
| 108 | |
---|
[295] | 109 | // Global Auth object. |
---|
| 110 | require_once 'codebase/lib/Auth_SQL.inc.php'; |
---|
| 111 | $auth = new Auth_SQL('public'); |
---|
[5] | 112 | $auth->setParam(array( |
---|
[252] | 113 | 'db_table' => 'user_tbl', |
---|
| 114 | 'db_primary_key' => 'user_id', |
---|
[295] | 115 | 'login_url' => '/login.php', |
---|
| 116 | 'login_timeout' => 260000, // 72 hours |
---|
| 117 | 'idle_timeout' => 86400, // 24 hours |
---|
[5] | 118 | )); |
---|
| 119 | |
---|
[295] | 120 | // Load preferences for the user. |
---|
| 121 | require_once 'codebase/lib/Prefs.inc.php'; |
---|
| 122 | $prefs = new Prefs('permanent'); |
---|
| 123 | $prefs->setParam(array( |
---|
| 124 | 'persistent' => $auth->isLoggedIn(), |
---|
| 125 | 'user_id' => $auth->get('user_id'), |
---|
| 126 | )); |
---|
| 127 | $prefs->setDefaults(array( |
---|
| 128 | )); |
---|
| 129 | $prefs->load(); |
---|
| 130 | // Temporary prefs. |
---|
| 131 | $tmp_prefs = new Prefs('temporary'); |
---|
| 132 | $tmp_prefs->setDefaults(array( |
---|
| 133 | )); |
---|
| 134 | |
---|
| 135 | // Global record-locking object. |
---|
| 136 | require_once 'codebase/lib/Lock.inc.php'; |
---|
| 137 | $lock =& Lock::getInstance($auth); |
---|
| 138 | $lock->setParam(array( |
---|
| 139 | 'timeout' => 0, |
---|
| 140 | 'auto_timeout' => 1800, |
---|
| 141 | 'error_url' => '/lock.php', |
---|
| 142 | )); |
---|
| 143 | |
---|
| 144 | // Global cache object. |
---|
| 145 | require_once 'codebase/lib/Cache.inc.php'; |
---|
| 146 | $cache = new Cache('global'); |
---|
| 147 | $cache->setParam(array('enabled' => true)); |
---|
| 148 | |
---|
| 149 | // Setup CSS files to include. These will always be available. |
---|
[5] | 150 | require_once 'codebase/lib/CSS.inc.php'; |
---|
| 151 | $css = new CSS(); |
---|
[295] | 152 | $css->setParam(array('cache_css' => false)); /// Enable caching after site launch. |
---|
[27] | 153 | $css->setFile('codebase/css/codebase.inc.css'); |
---|
| 154 | $css->setFile('codebase/css/utilities.inc.css'); |
---|
[295] | 155 | // $css->setFile('html/css/screen.inc.css'); |
---|
[5] | 156 | |
---|
[295] | 157 | // Nav class for titles, breadcrumbs, and page features. |
---|
| 158 | // Global navigation titles, breadcrumbs, and page features. |
---|
[202] | 159 | require_once 'codebase/lib/Navigation.inc.php'; |
---|
| 160 | $nav = new Navigation(array( |
---|
| 161 | 'path_delimiter' => ' / ', |
---|
| 162 | 'last_crumb_format' => '<b>%s</b>', |
---|
| 163 | )); |
---|
[5] | 164 | |
---|
[295] | 165 | // Global site-specific configuration. |
---|
| 166 | // $cfg = array(); |
---|
| 167 | // require_once 'global/config.inc.php'; |
---|
| 168 | |
---|
[5] | 169 | ?> |
---|