3 * This file loads configuration settings from the data file settings.php and
4 * sets up some needed variables.
6 * The settings.php file is created during installation using the web-based db
7 * setup page (install/index.php).
10 * DO NOT EDIT THIS FILE!
12 * (Versions 0.9.44 and older required users to edit this file to configure
13 * WebCalendar. Version 0.9.45 and later requires editing the settings.php
16 * @package WebCalendar
19 require_once('../../env.inc.php');
20 require_once $gfwww.'include/pre.php';
22 if ( empty ( $PHP_SELF ) && ! empty ( $_SERVER ) &&
23 ! empty ( $_SERVER['PHP_SELF'] ) ) {
24 $PHP_SELF = $_SERVER['PHP_SELF'];
26 if ( ! empty ( $PHP_SELF ) && preg_match ( "/\/includes\//", $PHP_SELF ) ) {
27 die ( "You can't access this file directly!" );
30 // Unset some variables in case the server has register_globals
31 // enabled. This will prevent users from settings these values
33 // http://localhost/calendar/month.php?includedir=http://xxx/bad-guy
34 unset ( $includedir );
36 unset ( $db_database );
38 unset ( $db_password );
39 unset ( $db_persistent );
40 unset ( $single_user_login );
43 unset ( $use_http_auth );
44 unset ( $single_user );
46 unset ( $includedir );
50 $PROGRAM_VERSION = "v1.0.4";
51 $PROGRAM_DATE = "07 Jun 2006";
52 $PROGRAM_NAME = "WebCalendar $PROGRAM_VERSION ($PROGRAM_DATE)";
53 $PROGRAM_URL = "http://webcalendar.sourceforge.net/";
55 $TROUBLE_URL = "docs/WebCalendar-SysAdmin.html#trouble";
58 * Prints a fatal error message to the user along with a link to the
59 * Troubleshooting section of the WebCalendar System Administrator's Guide.
61 * Execution is aborted.
63 * @param string $error The error message to display
65 * @internal We don't normally put functions in this file. But, since this
66 * file is included before some of the others, this function either
67 * goes here or we repeat this code in multiple files.
69 function die_miserable_death ( $error )
72 echo "<html><head><title>WebCalendar: Fatal Error</title></head>\n" .
73 "<body><h2>WebCalendar Error</h2>\n" .
74 "<p>$error</p>\n<hr />" .
75 "<p><a href=\"$TROUBLE_URL\" target=\"_blank\">" .
76 "Troubleshooting Help</a></p></body></html>\n";
82 $db_type = 'postgresql';
83 $settings['db_type'] = 'postgresql';
84 $settings['db_host'] = forge_get_config('database_host');
85 $settings['db_database'] = forge_get_config('database_name');
86 $settings['db_login'] = forge_get_config('database_user');
87 $settings['db_password'] = forge_get_config('database_password');
88 $settings['db_persistent'] = 'true';
89 $settings['readonly'] = 'false';
90 $settings['user_inc'] = 'user.php';
91 $settings['install_password'] = '';
92 $settings['single_user_login'] = '';
93 $settings['use_http_auth'] = 'false';
94 $settings['single_user'] = 'false';
95 $settings['user_inc'] = 'user.php';
97 // Extract db settings into global vars
98 $db_type = $settings['db_type'];
99 $db_host = $settings['db_host'];
100 $db_login = $settings['db_login'];
101 $db_password = $settings['db_password'];
102 $db_database = $settings['db_database'];
103 $db_persistent = preg_match ( "/(1|yes|true|on)/i",
104 $settings['db_persistent'] ) ? '1' : '0';
106 foreach ( array ( "db_type", "db_host", "db_login", "db_password" ) as $s ) {
107 if ( empty ( $settings[$s] ) ) {
108 die_miserable_death ( "Could not find <tt>$s</tt> defined in " .
109 "your <tt>settings.php</tt> file.\n" );
113 $readonly = preg_match ( "/(1|yes|true|on)/i",
114 $settings['readonly'] ) ? 'Y' : 'N';
117 $single_user = preg_match ( "/(1|yes|true|on)/i",
118 $settings['single_user'] ) ? 'Y' : 'N';
119 if ( $single_user == 'Y' )
120 $single_user_login = $settings['single_user_login'];
122 if ( $single_user == 'Y' && empty ( $single_user_login ) ) {
123 die_miserable_death ( "You must define <tt>single_user_login</tt> in " .
124 "the settings.php file.\n" );
128 $use_http_auth = preg_match ( "/(1|yes|true|on)/i",
129 $settings['use_http_auth'] ) ? true : false;
131 // Type of user authentication
132 $user_inc = $settings['user_inc'];
134 // We can add extra 'nonuser' calendars such as a corporate calendar,
135 // holiday calendar, departmental calendar, etc. We need a unique prefix
136 // for these calendars as not to get mixed up with real logins. This prefix
137 // should be a Maximum of 5 characters and should NOT change once set!
138 $NONUSER_PREFIX = '_NUC_';
140 // Language options The first is the name presented to users while
141 // the second is the filename (without the ".txt") that must exist
142 // in the translations subdirectory.
144 "Browser-defined" =>"none",
145 "English" =>"English-US",
146 "Basque" => "Basque",
147 "Bulgarian" => "Bulgarian",
148 "Catalan" => "Catalan",
149 "Chinese (Traditonal/Big5)" => "Chinese-Big5",
150 "Chinese (Simplified/GB2312)" => "Chinese-GB2312",
152 "Danish" => "Danish",
154 "Estonian" => "Estonian",
155 "Finnish" =>"Finnish",
157 "Galician" => "Galician",
160 "Holo (Taiwanese)" => "Holo-Big5",
161 "Hungarian" =>"Hungarian",
162 "Icelandic" => "Icelandic",
163 "Italian" => "Italian",
164 "Japanese(SHIFT JIS)" => "Japanese",
165 "Japanese(EUC-JP)" => "Japanese-eucjp",
166 "Japanese(UTF-8)" => "Japanese-utf8",
168 "Norwegian" => "Norwegian",
169 "Polish" => "Polish",
170 "Portuguese" =>"Portuguese",
171 "Portuguese/Brazil" => "Portuguese_BR",
172 "Romanian" => "Romanian",
173 "Russian" => "Russian",
174 "Spanish" =>"Spanish",
175 "Swedish" =>"Swedish",
176 "Turkish" =>"Turkish",
178 // add new languages here! (don't forget to add a comma at the end of
182 // If the user sets "Browser-defined" as their language setting, then
183 // use the $HTTP_ACCEPT_LANGUAGE settings to determine the language.
184 // The array below translates browser language abbreviations into
185 // our available language files.
186 // NOTE: These should all be lowercase on the left side even though
187 // the proper listing is like "en-US"!
188 // Not sure what the abbreviation is? Check out the following URL:
189 // http://www.geocities.com/click2speak/languages.html
190 $browser_languages = array (
194 "zh" => "Chinese-GB2312", // Simplified Chinese
195 "zh-cn" => "Chinese-GB2312",
196 "zh-tw" => "Chinese-Big5", // Traditional Chinese
198 "en" => "English-US",
199 "en-us" => "English-US",
200 "en-gb" => "English-US",
206 "fr-ch" =>"French", // French/Swiss
207 "fr-ca" =>"French", // French/Canada
210 "de-at" =>"German", // German/Austria
211 "de-ch" =>"German", // German/Switzerland
212 "de-de" =>"German", // German/German
213 "el" =>"Greek", // German/German
215 "zh-min-nan-tw" => "Holo-Big5",
218 "it-ch" => "Italian", // Italian/Switzerland
224 "pt-br" => "Portuguese_BR", // Portuguese/Brazil
233 // The following comments will be picked up by update_translation.pl so
234 // translators will be aware that they also need to translate language names.
236 // translate("English")
237 // translate("Basque")
238 // translate("Bulgarian")
239 // translate("Catalan")
240 // translate("Chinese (Traditonal/Big5)")
241 // translate("Chinese (Simplified/GB2312)")
242 // translate("Czech")
243 // translate("Danish")
244 // translate("Dutch")
245 // translate("Estonian")
246 // translate("Finnish")
247 // translate("French")
248 // translate("Galician")
249 // translate("German")
250 // translate("Greek")
251 // translate("Holo (Taiwanese)")
252 // translate("Hungarian")
253 // translate("Icelandic")
254 // translate("Italian")
255 // translate("Japanese")
256 // translate("Korean")
257 // translate("Norwegian")
258 // translate("Polish")
259 // translate("Portuguese")
260 // translate("Portuguese/Brazil")
261 // translate("Romanian")
262 // translate("Russian")
263 // translate("Spanish")
264 // translate("Swedish")
265 // translate("Turkish")
266 // translate("Welsh")
268 if ( $single_user != "Y" )
269 $single_user_login = "";
271 // Make sure magic quotes is enabled, since this app requires it.
272 if ( get_magic_quotes_gpc () == 0 ) {
275 $val = ob_get_contents ();
278 if ( preg_match ( "/>([^<>]*php.ini)</", $val, $matches ) ) {
279 $loc = "Please edit the following file and restart your server:" .
281 "<blockquote>\n<tt>" . $matches[1] . "</tt>\n</blockquote>\n";
283 die_miserable_death ( "You must reconfigure your <tt>php.ini</tt> file to " .
284 "have <span style=\"font-weight:bold;\">magic_quotes_gpc</span> set " .
285 " to <span style=\"font-weight:bold;\">ON</span>.<br /><br />\n" .