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

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

Added example cli script, updated Cart.inc.php

File size: 5.0 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 and libraries.
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    'images_path' => '/i',
42
43    'date_format' => 'd M Y',
44    'sql_date_format' => '%e %b %Y',
45    'sql_time_format' => '%k:%i',
46    'character_set' => 'utf-8',
47
48    'enable_session' => true,
49    'enable_db_session_handler' => false,
50    'session_use_cookies' => true,
51    'session_use_trans_sid' => true, // Disable this for high-security sites where session-ID theft is a risk.
52
53    // 'ssl_domain' => 'www.example.com',
54    // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'),
55
56    'enable_db' => true,
57    'db_always_debug' => false,
58    'db_debug' => true,
59    'db_die_on_failure' => true,
60    'db_create_tables' => true, // Disable after site launch.
61
62    'display_errors' => true,
63
64    'log_directory' => COMMON_BASE . '/log',
65    'log_filename' => 'site_log',
66    'log_file_priority' => LOG_DEBUG,
67    'log_email_priority' => false,
68    'log_sms_priority' => false,
69    'log_screen_priority' => false,
70    'log_to_email_address' => 'log@strangecode.com',
71    'log_to_sms_address' => 'sms-quinn@strangecode.com',
72));
73
74if (defined('_CLI')) {
75    // DB credentials for command line scripts stored in a file with read rights
76    // given only to the user who will be executing the scripts: -rw-------
77    // This file includes $app-> method calls so this must be included after App::getInstance().
78    require_once 'global/db_auth.inc.php';
79}
80
81// Start application-based functionality: database, session, environment, ini setup, etc.
82// Most configuration parameters must be set before starting the App.
83$app->start();
84
85// Global DB object. Automatically pre-configured by $app->start().
86$db =& DB::getInstance();
87
88// Global Auth object.
89require_once 'codebase/lib/Auth_SQL.inc.php';
90$auth = new Auth_SQL('public');
91$auth->setParam(array(
92    'db_table'          => 'user_tbl',
93    'db_primary_key'    => 'user_id',
94    'login_url'         => '/login.php',
95    'login_timeout' => 260000, // 72 hours
96    'idle_timeout' => 86400, // 24 hours
97));
98
99// Load preferences for the user.
100require_once 'codebase/lib/Prefs.inc.php';
101$prefs = new Prefs('permanent');
102$prefs->setParam(array(
103    'persistent' => $auth->isLoggedIn(),
104    'user_id' => $auth->get('user_id'),
105));
106$prefs->setDefaults(array(
107));
108$prefs->load();
109// Temporary prefs.
110$tmp_prefs = new Prefs('temporary');
111$tmp_prefs->setDefaults(array(
112));
113
114// Global record-locking object.
115require_once 'codebase/lib/Lock.inc.php';
116$lock =& Lock::getInstance($auth);
117$lock->setParam(array(
118    'timeout' => 0,
119    'auto_timeout' => 1800,
120    'error_url' => '/lock.php',
121));
122
123// Global cache object.
124require_once 'codebase/lib/Cache.inc.php';
125$cache = new Cache('global');
126$cache->setParam(array('enabled' => true));
127
128// Setup CSS files to include. These will always be available.
129require_once 'codebase/lib/CSS.inc.php';
130$css = new CSS();
131$css->setParam(array('cache_css' => false)); /// Enable caching after site launch.
132$css->setFile('codebase/css/codebase.inc.css');
133$css->setFile('codebase/css/utilities.inc.css');
134// $css->setFile('html/css/screen.inc.css');
135
136// Nav class for titles, breadcrumbs, and page features.
137// Global navigation titles, breadcrumbs, and page features.
138require_once 'codebase/lib/Navigation.inc.php';
139$nav = new Navigation(array(
140    'path_delimiter' => ' / ',
141    'last_crumb_format' => '<b>%s</b>',
142));
143
144// Global site-specific configuration.
145// $cfg = array();
146// require_once 'global/config.inc.php';
147
148?>
Note: See TracBrowser for help on using the repository browser.