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

Last change on this file since 468 was 468, checked in by anonymous, 10 years ago

Completed integrating /branches/eli_branch into /trunk. Changes include:

  • Removed closing ?> from end of files
  • Upgrade old-style contructor methods to use construct() instead.
  • Class properties and methods defined as public, private, static or protected
  • Ensure code runs under E_ALL with only mysql_* deprecated warnings
  • Search for the '@' symbol anywhere it might be used to supress runtime errors, then replace with proper error recovery.
  • Run the php cli -l option to check files for syntax errors.
  • Bring tests up-to-date with latest version and methods of PHPUnit
File size: 6.1 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2012 Strangecode, LLC
6 *
7 * This file is part of The Strangecode Codebase.
8 *
9 * The Strangecode Codebase is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * The Strangecode Codebase is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/**
24 * _config.inc.php lives in the document root of the site/application. It is the beginning of everything.
25 *
26 * @author  Quinn Comendant <quinn@strangecode.com>
27 * @version 1.3
28 * @since   03 Dec 2005 19:09:32
29 */
30
31// The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows.
32// To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php';
33if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) {
34    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);
35}
36
37// First things first. Define the globally used directory paths.
38// The parent directory of all application DocRoots.
39define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
40
41// The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the
42// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
43define('SITE_BASE', dirname(__FILE__));
44
45// Set include path for all templates and libraries.
46ini_set('include_path', join(PATH_SEPARATOR, array(
47    COMMON_BASE,
48    SITE_BASE . '/_templates',
49    get_include_path(),
50)));
51
52// Include core libraries.
53require_once 'codebase/lib/Utilities.inc.php';
54require_once 'codebase/lib/App.inc.php';
55
56// Primary application class.
57$app =& App::getInstance('public');
58$app->setParam(array(
59    'site_name' => 'WWW Public Site',
60    'site_email' => 'hello@example.com',
61    'redirect_home_url' => '/',
62    'images_path' => '/i',
63
64    'date_format' => 'd M Y',
65    'sql_date_format' => '%e %b %Y',
66    'sql_time_format' => '%k:%i',
67    'character_set' => 'utf-8',
68
69    'enable_session' => true,
70    'enable_db_session_handler' => false,
71    'session_use_cookies' => true,
72    'session_use_trans_sid' => false, // Disable this for high-security sites where session-ID theft is a risk.
73
74    // 'ssl_domain' => 'www.example.com',
75    // 'ssl_enabled' => ($_SERVER['SERVER_NAME'] == 'www.example.com'),
76
77    'enable_db' => true,
78    'db_always_debug' => false,
79    'db_debug' => true,
80    'db_die_on_failure' => true,
81    'db_create_tables' => true, // Disable after site launch.
82
83    'display_errors' => true,
84    'error_reporting' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
85
86    'log_directory' => COMMON_BASE . '/log',
87    'log_filename' => 'site_log',
88    'log_file_priority' => LOG_DEBUG,
89    'log_email_priority' => false,
90    'log_sms_priority' => false,
91    'log_screen_priority' => false,
92    // Email address to receive log event emails. Use multiple addresses by separating them with commas.
93    'log_to_email_address' => 'my-emailalert-address@example.com',
94    // SMS Email address to receive log event SMS messages. Use multiple addresses by separating them with commas.
95    'log_to_sms_address' => 'my-smsalert-address@example.com',
96));
97
98if (defined('_CLI')) {
99    // DB credentials for command line scripts stored in a file with read rights
100    // given only to the user who will be executing the scripts: -rw-------
101    // This file includes $app-> method calls so this must be included after App::getInstance().
102    require_once 'global/db_auth.inc.php';
103}
104
105// Start application-based functionality: database, session, environment, ini setup, etc.
106// Most configuration parameters must be set before starting the App.
107$app->start();
108
109// Global DB object. Automatically pre-configured by $app->start().
110$db =& DB::getInstance();
111
112// Global Auth object.
113require_once 'codebase/lib/Auth_SQL.inc.php';
114$auth = new Auth_SQL('public');
115$auth->setParam(array(
116    'db_table'          => 'user_tbl',
117    'db_primary_key'    => 'user_id',
118    'login_url'         => '/login.php',
119    'login_timeout' => 260000, // 72 hours
120    'idle_timeout' => 86400, // 24 hours
121));
122
123// Load preferences for the user.
124require_once 'codebase/lib/Prefs.inc.php';
125$prefs = new Prefs('permanent');
126$prefs->setParam(array(
127    'persistent' => $auth->isLoggedIn(),
128    'user_id' => $auth->get('user_id'),
129));
130$prefs->setDefaults(array(
131));
132$prefs->load();
133// Temporary prefs.
134$tmp_prefs = new Prefs('temporary');
135$tmp_prefs->setDefaults(array(
136));
137
138// Global record-locking object.
139require_once 'codebase/lib/Lock.inc.php';
140$lock =& Lock::getInstance($auth);
141$lock->setParam(array(
142    'timeout' => 0,
143    'auto_timeout' => 1800,
144    'error_url' => '/lock.php',
145));
146
147// Global cache object.
148require_once 'codebase/lib/Cache.inc.php';
149$cache = new Cache('global');
150$cache->setParam(array('enabled' => true)); // TODO: Enable caching after site launch.
151
152// Setup CSS files to include. These will always be available.
153require_once 'codebase/lib/CSS.inc.php';
154$css = new CSS();
155$css->setParam(array('cache_css' => false)); // TODO: Enable caching after site launch.
156$css->setFile('codebase/css/codebase.inc.css');
157$css->setFile('codebase/css/utilities.inc.css');
158// $css->setFile('html/css/screen.inc.css');
159
160// Nav class for titles, breadcrumbs, and page features.
161// Global navigation titles, breadcrumbs, and page features.
162require_once 'codebase/lib/Navigation.inc.php';
163$nav = new Navigation(array(
164    'path_delimiter' => ' / ',
165    'last_crumb_format' => '<b>%s</b>',
166));
167
168// Global site-specific configuration.
169// $cfg = array();
170// require_once 'global/config.inc.php';
171
Note: See TracBrowser for help on using the repository browser.