Changeset 803 for trunk/docs


Ignore:
Timestamp:
Jan 13, 2024 5:55:53 PM (4 months ago)
Author:
anonymous
Message:

Bring config file up-to-date

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/examples/_config.inc.php

    r679 r803  
    2525 *
    2626 * @author  Quinn Comendant <quinn@strangecode.com>
    27  * @version 1.3
     27 * @version 1.4
    2828 * @since   03 Dec 2005 19:09:32
    2929 */
     
    4444
    4545// Set include path for all templates and libraries.
    46 ini_set('include_path', join(PATH_SEPARATOR, array(
     46ini_set('include_path', join(PATH_SEPARATOR, [
    4747    COMMON_BASE,
    4848    SITE_BASE . '/_templates',
    4949    get_include_path(),
    50 )));
     50]));
     51
     52// Define server environments.
     53// Use this to toggle feature flags via, e.g., `if (ENVIRONMENT === PRODUCTION) { seriousStuff(); }`
     54define('PRODUCTION', 'production');
     55define('DEVELOPMENT', 'development');
     56define('LOCAL', 'local');
     57switch (getenv('ENVIRONMENT')) {
     58case 'production':
     59    define('ENVIRONMENT', PRODUCTION);
     60    break;
     61case 'dev':
     62case 'staging':
     63    define('ENVIRONMENT', DEVELOPMENT);
     64    break;
     65case 'local':
     66    define('ENVIRONMENT', LOCAL);
     67    break;
     68}
    5169
    5270// Include core libraries.
     
    5674// Primary application class.
    5775$app =& App::getInstance('public');
    58 $app->setParam(array(
     76$app->setParam([
    5977    'site_name' => 'WWW Public Site',
    6078    'site_email' => 'hello@example.com',
     
    7593
    7694    // 'ssl_domain' => 'www.example.com',
    77     // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'),
     95    // 'ssl_enabled' => ENVIRONMENT === PRODUCTION,
    7896
    7997    'enable_db' => true,
    8098    'db_always_debug' => false,
    81     'db_debug' => true,
     99    'db_debug' => false,
    82100    'db_die_on_failure' => true,
    83     'db_create_tables' => true, // Disable after site launch.
     101    'db_create_tables' => true, /// Disable after site launch.
    84102
    85     'display_errors' => true,
     103    'display_errors' => ENVIRONMENT !== PRODUCTION,
    86104    'error_reporting' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
    87105
    88106    'log_directory' => '/tmp',
    89107    '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,
    94112    // Email address to receive log event emails. Use multiple addresses by separating them with commas.
    95113    'log_to_email_address' => 'my-emailalert-address@example.com',
    96114    // SMS Email address to receive log event SMS messages. Use multiple addresses by separating them with commas.
    97115    'log_to_sms_address' => 'my-smsalert-address@example.com',
    98 ));
    99116
    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]);
    106120
    107121// Start application-based functionality: database, session, environment, ini setup, etc.
     
    115129require_once 'codebase/lib/Auth_SQL.inc.php';
    116130$auth = new Auth_SQL('public');
    117 $auth->setParam(array(
     131$auth->setParam([
    118132    'db_table'          => 'user_tbl',
    119133    'db_primary_key'    => 'user_id',
     
    121135    'login_timeout' => 260000, // 72 hours
    122136    'idle_timeout' => 86400, // 24 hours
    123 ));
     137]);
    124138
    125139// Load preferences for the user.
    126140require_once 'codebase/lib/Prefs.inc.php';
    127 $prefs = new Prefs('permanent', array(
     141$prefs = new Prefs('permanent', [
    128142    'storagetype' => ($auth->isLoggedIn() ? 'database' : 'session'),
    129143    'user_id' => $auth->get('user_id'),
    130 ));
    131 $prefs->setDefaults(array(
    132     // ...
    133 ));
     144]);
     145$prefs->setDefaults([
     146    'dark-mode' => true,
     147]);
    134148$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 ));
    145149
    146150// Global record-locking object.
    147151require_once 'codebase/lib/Lock.inc.php';
    148152$lock =& Lock::getInstance($auth);
    149 $lock->setParam(array(
     153$lock->setParam([
    150154    'timeout' => 0,
    151155    'auto_timeout' => 1800,
    152156    'error_url' => '/lock.php',
    153 ));
     157]);
    154158
    155159// Global cache object.
    156160require_once 'codebase/lib/Cache.inc.php';
    157161$cache = new Cache('global');
    158 $cache->setParam(array('enabled' => true)); // TODO: Enable caching after site launch.
     162$cache->setParam(['enabled' => ENVIRONMENT === PRODUCTION]);
    159163
    160164// Setup CSS files to include. These will always be available.
    161165require_once 'codebase/lib/CSS.inc.php';
    162166$css = new CSS();
    163 $css->setParam(array('cache_css' => false)); // TODO: Enable caching after site launch.
     167$css->setParam(['cache_css' => ENVIRONMENT === PRODUCTION]);
    164168$css->setFile('codebase/css/codebase.inc.css');
    165169$css->setFile('codebase/css/utilities.inc.css');
     
    169173// Global navigation titles, breadcrumbs, and page features.
    170174require_once 'codebase/lib/Navigation.inc.php';
    171 $nav = new Navigation(array(
     175$nav = new Navigation([
    172176    'path_delimiter' => ' / ',
    173177    'last_crumb_format' => '<b>%s</b>',
    174 ));
     178]);
    175179
    176180// Global site-specific configuration.
    177 // $cfg = array();
     181// $cfg = [];
    178182// require_once 'global/config.inc.php';
    179 
Note: See TracChangeset for help on using the changeset viewer.