source: trunk/docs/example_config.inc.php @ 252

Last change on this file since 252 was 252, checked in by quinn, 17 years ago

Made the example_config file more generic and safe to deploy.

File size: 3.6 KB
Line 
1<?php
2/**
3 * _config.inc.php lives in the document root of the site/application. It is the beginning of everything.
4 *
5 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.
6 * @author  Quinn Comendant <quinn@strangecode.com>
7 * @version 1.2
8 * @since   03 Dec 2005 19:09:32
9 */
10
11// The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows.
12// To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php';
13if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) {
14    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);
15}
16
17// First things first. Define the globally used directory paths.
18// The parent directory of all application DocRoots.
19define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
20
21// The DocRoot for this application. SITE_BASE is ifferent from $_SERVER['DOCUMENT_ROOT'] because the
22// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
23define('SITE_BASE', dirname(__FILE__));
24
25// Set include path for all tempates.
26ini_set('include_path', join(PATH_SEPARATOR, array(
27    COMMON_BASE,
28    SITE_BASE . '/_templates',
29    get_include_path(),
30)));
31
32// Include core libraries.
33require_once 'codebase/lib/Utilities.inc.php';
34require_once 'codebase/lib/Auth_SQL.inc.php';
35require_once 'codebase/lib/App.inc.php';
36
37// Primary application class.
38$app =& App::getInstance('example.org');
39$app->setParam(array(
40    'site_name' => 'My example site',
41    'site_email' => 'hello@example.com',
42    'redirect_home_url' => '/',
43
44    'date_format' => 'd M Y',
45    'sql_date_format' => '%e %b %Y',
46    'sql_time_format' => '%k:%i',
47    'character_set' => 'utf-8',
48
49    'enable_session' => false,
50    'enable_db_session_handler' => false,
51    'session_use_cookies' => true,
52
53    'enable_db' => false,
54    'db_always_debug' => false,
55    'db_debug' => true,
56    'db_die_on_failure' => true,
57    'db_create_tables' => true, /// Disable after site launch.
58
59    'display_errors' => true,
60
61    'log_directory' => COMMON_BASE . '/log',
62    'log_filename' => 'site.log',
63    'log_file_priority' => LOG_DEBUG,
64    'log_email_priority' => false,
65    'log_sms_priority' => false,
66    'log_screen_priority' => false,
67    'log_to_email_address' => 'log@example.com',
68    'log_to_sms_address' => 'sms@example.com',
69));
70// DB credentials for command line scripts stored in a file with read rights
71// given only to the user who will be executing the scripts: -rw-------
72// This file includes $app-> method calls so must be included after App.
73// require_once 'global/db_auth.inc.php';
74
75// Start application-based functionality: database, session, environment, ini setup, etc.
76// Most configuration parameters must be set before starting the App.
77$app->start();
78
79// Global DB object. Automatically preconfigured by $app->start().
80$db =& DB::getInstance();
81
82// User authentication.
83$auth = new Auth_SQL('user');
84$auth->setParam(array(
85    'db_table'          => 'user_tbl',
86    'db_primary_key'    => 'user_id',
87    'login_url'         => '/login.php'
88));
89
90// Set CSS files.
91require_once 'codebase/lib/CSS.inc.php';
92$css = new CSS();
93$css->setParam(array('cache_css' => true));
94$css->setFile('codebase/css/codebase.inc.css');
95$css->setFile('codebase/css/utilities.inc.css');
96$css->setFile('html/css/screen.inc.css');
97
98// Global navigation elements object.
99require_once 'codebase/lib/Navigation.inc.php';
100$nav = new Navigation(array(
101    'path_delimiter' => ' / ',
102    'last_crumb_format' => '<b>%s</b>',
103));
104
105?>
Note: See TracBrowser for help on using the repository browser.