source: trunk/docs/examples/_config.inc.php @ 295

Last change on this file since 295 was 295, checked in by quinn, 16 years ago

Updated example config file. Added admin2.inc.css and minor corrections into HTML. Module maker fixes.

File size: 4.9 KB
Line 
1<?php
2/** * _config.inc.php lives in the document root of the site/application. It is the beginning of everything.
3 *
4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.
5 * @author  Quinn Comendant <quinn@strangecode.com>
6 * @version 1.3
7 * @since   03 Dec 2005 19:09:32
8 */
9 
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';
12if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) {
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);
14}
15
16// First things first. Define the globally used directory paths.
17// The parent directory of all application DocRoots.
18define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
19
20// The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the
21// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
22define('SITE_BASE', dirname(__FILE__));
23
24// Set include path for all templates.
25ini_set('include_path', join(PATH_SEPARATOR, array(
26    COMMON_BASE,
27    SITE_BASE . '/_templates',
28    get_include_path(),
29)));
30
31// Include core libraries.
32require_once 'codebase/lib/Utilities.inc.php';
33require_once 'codebase/lib/App.inc.php';
34
35// Primary application class.
36$app =& App::getInstance('public');
37$app->setParam(array(
38    'site_name' => 'WWW Public Site',
39    'site_email' => 'hello@example.com',
40    'redirect_home_url' => '/',
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
47    'enable_session' => true,
48    'enable_db_session_handler' => false,
49    'session_use_cookies' => true,
50    'session_use_trans_sid' => true, // Disable this for high-security sites where session-ID theft is a risk.
51
52    // 'ssl_domain' => 'www.example.com',
53    // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'),
54
55    'enable_db' => true,
56    'db_always_debug' => false,
57    'db_debug' => true,
58    'db_die_on_failure' => true,
59    'db_create_tables' => true, // Disable after site launch.
60
61    'display_errors' => true,
62
63    'log_directory' => COMMON_BASE . '/log',
64    'log_filename' => 'site_log',
65    'log_file_priority' => LOG_DEBUG,
66    'log_email_priority' => false,
67    'log_sms_priority' => false,
68    'log_screen_priority' => false,
69    'log_to_email_address' => 'log@strangecode.com',
70    'log_to_sms_address' => 'sms-quinn@strangecode.com',
71));
72
73if (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
80// Start application-based functionality: database, session, environment, ini setup, etc.
81// Most configuration parameters must be set before starting the App.
82$app->start();
83
84// Global DB object. Automatically pre-configured by $app->start().
85$db =& DB::getInstance();
86
87// Global Auth object.
88require_once 'codebase/lib/Auth_SQL.inc.php';
89$auth = new Auth_SQL('public');
90$auth->setParam(array(
91    'db_table'          => 'user_tbl',
92    'db_primary_key'    => 'user_id',
93    'login_url'         => '/login.php',
94    'login_timeout' => 260000, // 72 hours
95    'idle_timeout' => 86400, // 24 hours
96));
97
98// Load preferences for the user.
99require_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.
114require_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.
123require_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.
128require_once 'codebase/lib/CSS.inc.php';
129$css = new CSS();
130$css->setParam(array('cache_css' => false)); /// Enable caching after site launch.
131$css->setFile('codebase/css/codebase.inc.css');
132$css->setFile('codebase/css/utilities.inc.css');
133// $css->setFile('html/css/screen.inc.css');
134
135// Nav class for titles, breadcrumbs, and page features.
136// Global navigation titles, breadcrumbs, and page features.
137require_once 'codebase/lib/Navigation.inc.php';
138$nav = new Navigation(array(
139    'path_delimiter' => ' / ',
140    'last_crumb_format' => '<b>%s</b>',
141));
142
143// Global site-specific configuration.
144// $cfg = array();
145// require_once 'global/config.inc.php';
146
147?>
Note: See TracBrowser for help on using the repository browser.