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