Changeset 803
- Timestamp:
- Jan 13, 2024 5:55:53 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/examples/_config.inc.php
r679 r803 25 25 * 26 26 * @author Quinn Comendant <quinn@strangecode.com> 27 * @version 1. 327 * @version 1.4 28 28 * @since 03 Dec 2005 19:09:32 29 29 */ … … 44 44 45 45 // Set include path for all templates and libraries. 46 ini_set('include_path', join(PATH_SEPARATOR, array(46 ini_set('include_path', join(PATH_SEPARATOR, [ 47 47 COMMON_BASE, 48 48 SITE_BASE . '/_templates', 49 49 get_include_path(), 50 ))); 50 ])); 51 52 // Define server environments. 53 // Use this to toggle feature flags via, e.g., `if (ENVIRONMENT === PRODUCTION) { seriousStuff(); }` 54 define('PRODUCTION', 'production'); 55 define('DEVELOPMENT', 'development'); 56 define('LOCAL', 'local'); 57 switch (getenv('ENVIRONMENT')) { 58 case 'production': 59 define('ENVIRONMENT', PRODUCTION); 60 break; 61 case 'dev': 62 case 'staging': 63 define('ENVIRONMENT', DEVELOPMENT); 64 break; 65 case 'local': 66 define('ENVIRONMENT', LOCAL); 67 break; 68 } 51 69 52 70 // Include core libraries. … … 56 74 // Primary application class. 57 75 $app =& App::getInstance('public'); 58 $app->setParam( array(76 $app->setParam([ 59 77 'site_name' => 'WWW Public Site', 60 78 'site_email' => 'hello@example.com', … … 75 93 76 94 // 'ssl_domain' => 'www.example.com', 77 // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'),95 // 'ssl_enabled' => ENVIRONMENT === PRODUCTION, 78 96 79 97 'enable_db' => true, 80 98 'db_always_debug' => false, 81 'db_debug' => true,99 'db_debug' => false, 82 100 'db_die_on_failure' => true, 83 'db_create_tables' => true, // Disable after site launch.101 'db_create_tables' => true, /// Disable after site launch. 84 102 85 'display_errors' => true,103 'display_errors' => ENVIRONMENT !== PRODUCTION, 86 104 'error_reporting' => E_ALL & ~E_DEPRECATED & ~E_STRICT, 87 105 88 106 'log_directory' => '/tmp', 89 107 'log_filename' => 'site_log', 90 'log_file_priority' => LOG_DEBUG,91 'log_email_priority' => false,92 'log_sms_priority' => false,93 'log_screen_priority' => false,108 'log_file_priority' => ENVIRONMENT === PRODUCTION ? LOG_DEBUG : LOG_DEBUG, 109 'log_email_priority' => ENVIRONMENT === PRODUCTION ? LOG_WARNING : false, 110 'log_sms_priority' => ENVIRONMENT === PRODUCTION ? LOG_ALERT : false, 111 'log_screen_priority' => ENVIRONMENT === PRODUCTION ? LOG_WARNING : LOG_INFO, 94 112 // Email address to receive log event emails. Use multiple addresses by separating them with commas. 95 113 'log_to_email_address' => 'my-emailalert-address@example.com', 96 114 // SMS Email address to receive log event SMS messages. Use multiple addresses by separating them with commas. 97 115 'log_to_sms_address' => 'my-smsalert-address@example.com', 98 ));99 116 100 if ($app->isCLI()) { 101 // DB credentials for command line scripts stored in a file with read rights 102 // given only to the user who will be executing the scripts: -rw------- 103 // This file includes $app-> method calls so this must be included after App::getInstance(). 104 require_once 'global/db_auth.inc.php'; 105 } 117 // Prettify json when testing. 118 'json_options' => ENVIRONMENT === PRODUCTION ? 0 : JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES, 119 ]); 106 120 107 121 // Start application-based functionality: database, session, environment, ini setup, etc. … … 115 129 require_once 'codebase/lib/Auth_SQL.inc.php'; 116 130 $auth = new Auth_SQL('public'); 117 $auth->setParam( array(131 $auth->setParam([ 118 132 'db_table' => 'user_tbl', 119 133 'db_primary_key' => 'user_id', … … 121 135 'login_timeout' => 260000, // 72 hours 122 136 'idle_timeout' => 86400, // 24 hours 123 ));137 ]); 124 138 125 139 // Load preferences for the user. 126 140 require_once 'codebase/lib/Prefs.inc.php'; 127 $prefs = new Prefs('permanent', array(141 $prefs = new Prefs('permanent', [ 128 142 'storagetype' => ($auth->isLoggedIn() ? 'database' : 'session'), 129 143 'user_id' => $auth->get('user_id'), 130 ));131 $prefs->setDefaults( array(132 // ...133 ));144 ]); 145 $prefs->setDefaults([ 146 'dark-mode' => true, 147 ]); 134 148 $prefs->load(); 135 // Load preferences for temporary usage.136 require_once 'codebase/lib/Prefs.inc.php';137 $c_prefs = new Prefs('config');138 $c_prefs->setParam(array(139 'storagetype' => 'cookie',140 ));141 // Temporary prefs.142 $c_prefs = new Prefs('settings');143 $c_prefs->setDefaults(array(144 ));145 149 146 150 // Global record-locking object. 147 151 require_once 'codebase/lib/Lock.inc.php'; 148 152 $lock =& Lock::getInstance($auth); 149 $lock->setParam( array(153 $lock->setParam([ 150 154 'timeout' => 0, 151 155 'auto_timeout' => 1800, 152 156 'error_url' => '/lock.php', 153 ));157 ]); 154 158 155 159 // Global cache object. 156 160 require_once 'codebase/lib/Cache.inc.php'; 157 161 $cache = new Cache('global'); 158 $cache->setParam( array('enabled' => true)); // TODO: Enable caching after site launch.162 $cache->setParam(['enabled' => ENVIRONMENT === PRODUCTION]); 159 163 160 164 // Setup CSS files to include. These will always be available. 161 165 require_once 'codebase/lib/CSS.inc.php'; 162 166 $css = new CSS(); 163 $css->setParam( array('cache_css' => false)); // TODO: Enable caching after site launch.167 $css->setParam(['cache_css' => ENVIRONMENT === PRODUCTION]); 164 168 $css->setFile('codebase/css/codebase.inc.css'); 165 169 $css->setFile('codebase/css/utilities.inc.css'); … … 169 173 // Global navigation titles, breadcrumbs, and page features. 170 174 require_once 'codebase/lib/Navigation.inc.php'; 171 $nav = new Navigation( array(175 $nav = new Navigation([ 172 176 'path_delimiter' => ' / ', 173 177 'last_crumb_format' => '<b>%s</b>', 174 ));178 ]); 175 179 176 180 // Global site-specific configuration. 177 // $cfg = array();181 // $cfg = []; 178 182 // require_once 'global/config.inc.php'; 179
Note: See TracChangeset
for help on using the changeset viewer.