Skip to content
Newer
Older
100644 840 lines (746 sloc) 32.9 KB
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
1 <?php
2 ////////////////////////////////////////////////////////////////////////////////
3 // //
35e6d7d Happy new year!
mmakaay authored Jan 9, 2011
4 // Copyright (C) 2011 Phorum Development Team //
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
5 // http://www.phorum.org //
6 // //
7 // This program is free software. You can redistribute it and/or modify //
8 // it under the terms of either the current Phorum License (viewable at //
9 // phorum.org) or the Phorum License that was distributed with this file //
10 // //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY, without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
14 // //
15 // You should have received a copy of the Phorum License //
16 // along with this program. //
30964b6 # It's a dirty job, but someone got to do it (-: copyright upgraded t…
mmakaay authored Jan 21, 2008
17 // //
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
18 ////////////////////////////////////////////////////////////////////////////////
19
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
20 /**
21 * This script bootstraps the Phorum web environment. It will load the
22 * Phorum API and handle tasks that are required for initializing and
23 * handling the request.
24 */
25
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
26 // Check that this file is not loaded directly.
cc46fd0 Implemented the Template API.
mmakaay authored Jun 1, 2009
27 if (basename(__FILE__) == basename($_SERVER["PHP_SELF"])) exit();
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
28
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
29 require_once dirname(__FILE__).'/include/api.php';
8111f69 added cache-panel in the admin for all cache-related settings (is sti…
ts77 authored Sep 11, 2006
30
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
31 phorum_api_request_parse();
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
32
b3197b8 # Improved common.php, which now has an extra "parse_request" hook. A…
mmakaay authored Jan 15, 2008
33 /*
34 * [hook]
35 * common_pre
36 *
37 * [description]
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
38 * This hook can be used for overriding settings that were loaded and
39 * setup at the start of the <filename>common.php</filename> script.
40 * If you want to dynamically assign and tweak certain settings, then
41 * this is the designated hook to use for that.<sbr/>
42 * <sbr/>
43 * Because the hook was put after the request parsing phase, you can
44 * make use of the request data that is stored in the global variables
45 * <literal>$PHORUM['forum_id']</literal> and
aeb037d Some changes to improve the breadcrumbs. The code now tries to keep t…
mmakaay authored Apr 21, 2010
46 * <literal>$PHORUM['ref_thread_id']</literal> and
47 * <literal>$PHORUM['ref_message_id']</literal> and
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
48 * <literal>$PHORUM['args']</literal>.
b3197b8 # Improved common.php, which now has an extra "parse_request" hook. A…
mmakaay authored Jan 15, 2008
49 *
50 * [category]
51 * Request initialization
52 *
53 * [when]
54 * Right after loading the settings from the database and parsing the
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
55 * request, but before making descisions on user, language and template.
b3197b8 # Improved common.php, which now has an extra "parse_request" hook. A…
mmakaay authored Jan 15, 2008
56 *
57 * [input]
58 * No input.
59 *
60 * [output]
61 * No output.
62 *
63 * [example]
64 * <hookcode>
65 * function phorum_mod_foo_common_pre()
66 * {
67 * global $PHORUM;
68 *
69 * // If we are in the forum with id = 10, we set the administrator
70 * // email information to a different value than the one configured
71 * // in the general settings.
72 * if ($PHORUM["forum_id"] == 10)
73 * {
74 * $PHORUM["system_email_from_name"] = "John Doe";
75 * $PHORUM["system_email_from_address"] = "John.Doe@example.com";
76 * }
77 * }
78 * </hookcode>
79 */
80 if (isset($PHORUM["hooks"]["common_pre"])) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
81 phorum_api_hook("common_pre", "");
b3197b8 # Improved common.php, which now has an extra "parse_request" hook. A…
mmakaay authored Jan 15, 2008
82 }
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
83
84 // ----------------------------------------------------------------------
85 // Setup data for standard (not admin) pages
86 // ----------------------------------------------------------------------
87
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
88 if (!defined( "PHORUM_ADMIN" ))
89 {
c00482f # Some small bits, nothing impressive.
mmakaay authored May 21, 2009
90 $PHORUM["DATA"]["TITLE"] =
91 isset($PHORUM["title"]) ? $PHORUM["title"] : "";
aeb037d Some changes to improve the breadcrumbs. The code now tries to keep t…
mmakaay authored Apr 21, 2010
92
0e2478e # readded missing assignment (thanks to Maurice for tracing it back!)
ts77 authored Mar 7, 2010
93 $PHORUM["DATA"]["DESCRIPTION"] =
c00482f # Some small bits, nothing impressive.
mmakaay authored May 21, 2009
94 isset( $PHORUM["description"]) ? $PHORUM["description"] : "";
95
96 $PHORUM["DATA"]["HTML_TITLE"] = !empty($PHORUM["html_title"])
97 ? $PHORUM["html_title"] : $PHORUM["DATA"]["TITLE"];
98
99 $PHORUM["DATA"]["HEAD_TAGS"] = isset($PHORUM["head_tags"])
100 ? $PHORUM["head_tags"] : "";
101
102 $PHORUM["DATA"]["FORUM_ID"] = $PHORUM["forum_id"];
103
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
104 // If the Phorum is disabled, display a message.
9d35770 # In the init code from common.php, a special case was implemented for
mmakaay authored May 26, 2009
105 if (isset($PHORUM["status"]) &&
106 $PHORUM["status"] == PHORUM_MASTER_STATUS_DISABLED) {
107
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
108 if (!empty($PHORUM["disabled_url"])) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
109 phorum_api_redirect($PHORUM['disabled_url']);
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
110 } else {
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
111 echo "This Phorum is currently administratively disabled. Please " .
112 "contact the web site owner at ".
113 htmlspecialchars($PHORUM['system_email_from_address'])." " .
114 "for more information.";
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
115 exit();
116 }
117 }
118
ee97b61 # avoid returning all forums if on the index or no forum_id is set (l…
ts77 authored Apr 15, 2010
119 if(!empty($PHORUM["forum_id"])){
120
121 // Load the settings for the currently active forum.
122 $forum_settings = phorum_api_forums_get(
9d35770 # In the init code from common.php, a special case was implemented for
mmakaay authored May 26, 2009
123 $PHORUM["forum_id"],null,null,null,PHORUM_FLAG_INCLUDE_INACTIVE);
124
ee97b61 # avoid returning all forums if on the index or no forum_id is set (l…
ts77 authored Apr 15, 2010
125 if ($forum_settings === NULL)
126 {
127 /*
128 * [hook]
129 * common_no_forum
130 *
131 * [description]
132 * This hook is called in case a forum_id is requested for
133 * an unknown or inaccessible forum. It can be used for
134 * doing things like logging the bad requests or fully
135 * overriding Phorum's default behavior for these cases
136 * (which is redirecting the user back to the index page).
137 *
138 * [category]
139 * Request initialization
140 *
141 * [when]
142 * In <filename>common.php</filename>, right after detecting
143 * that a requested forum does not exist or is inaccessible
144 * and right before redirecting the user back to the Phorum
145 * index page.
146 *
147 * [input]
148 * No input.
149 *
150 * [output]
151 * No output.
152 *
153 * [example]
154 * <hookcode>
155 * function phorum_mod_foo_common_no_forum()
156 * {
157 * // Return a 404 Not found error instead of redirecting
158 * // the user back to the index.
159 * header("HTTP/1.0 404 Not Found");
160 * print "<html><head>\n";
161 * print " <title>404 - Not Found</title>\n";
162 * print "</head><body>";
163 * print " <h1>404 - Forum Not Found</h1>";
164 * print "</body></html>";
165 * exit();
166 * }
167 * </hookcode>
168 */
169 if (isset($PHORUM["hooks"]["common_no_forum"])) {
170 phorum_api_hook("common_no_forum", "");
171 }
172
173 phorum_api_redirect(PHORUM_INDEX_URL);
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
174 }
4f7af71 # reworked code to allow displaying a thread with forum_id 0. Also, m…
brian authored Jan 28, 2007
175
ee97b61 # avoid returning all forums if on the index or no forum_id is set (l…
ts77 authored Apr 15, 2010
176 $PHORUM = array_merge($PHORUM, $forum_settings);
177
178 } elseif(isset($PHORUM["forum_id"]) && $PHORUM["forum_id"]==0){
c637cb8 MFB: adding vroot-handling for TITLE and NAME variables (fixing #404)
ts77 authored Oct 11, 2006
179
ee97b61 # avoid returning all forums if on the index or no forum_id is set (l…
ts77 authored Apr 15, 2010
180 $PHORUM = array_merge( $PHORUM, $PHORUM["default_forum_options"] );
181
182 // some hard settings are needed if we are looking at forum_id 0
655f7f2 Implemented various updates to the moderation system:
mmakaay authored Jan 15, 2011
183 $PHORUM['vroot'] = 0;
184 $PHORUM['parent_id'] = 0;
185 $PHORUM['active'] = 1;
186 $PHORUM['folder_flag'] = 1;
187 $PHORUM['cache_version'] = 0;
ee97b61 # avoid returning all forums if on the index or no forum_id is set (l…
ts77 authored Apr 15, 2010
188 }
9d35770 # In the init code from common.php, a special case was implemented for
mmakaay authored May 26, 2009
189
c637cb8 MFB: adding vroot-handling for TITLE and NAME variables (fixing #404)
ts77 authored Oct 11, 2006
190 // handling vroots
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
191 if (!empty($PHORUM['vroot']))
192 {
9d84db0 Implemented an OO database layer for Phorum. This layer will make it …
mmakaay authored Jan 24, 2011
193 $vroot_folders = $PHORUM['DB']->get_forums($PHORUM['vroot']);
c637cb8 MFB: adding vroot-handling for TITLE and NAME variables (fixing #404)
ts77 authored Oct 11, 2006
194
c00a6b5 MFB: # vroot fix: not only the title for the templates, but also $PHO…
mmakaay authored Mar 13, 2007
195 $PHORUM["title"] = $vroot_folders[$PHORUM['vroot']]['name'];
196 $PHORUM["DATA"]["TITLE"] = $PHORUM["title"];
197 $PHORUM["DATA"]["HTML_TITLE"] = $PHORUM["title"];
c637cb8 MFB: adding vroot-handling for TITLE and NAME variables (fixing #404)
ts77 authored Oct 11, 2006
198
c7b2a78 # Moved custom field handling to the user API.
mmakaay authored Jun 29, 2009
199 if ($PHORUM['vroot'] == $PHORUM['forum_id']) {
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
200 // Unset the forum-name if we are in the vroot-index.
201 // Otherwise, the NAME and TITLE would be the same and still
202 // shown twice.
c637cb8 MFB: adding vroot-handling for TITLE and NAME variables (fixing #404)
ts77 authored Oct 11, 2006
203 unset($PHORUM['name']);
204 }
205 }
206
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
207 // Stick some stuff from the settings into the template DATA.
208 $PHORUM["DATA"]["NAME"] = isset($PHORUM["name"]) ? $PHORUM["name"] : "";
209 $PHORUM["DATA"]["HTML_DESCRIPTION"] = isset( $PHORUM["description"]) ? preg_replace("!\s+!", " ", $PHORUM["description"]) : "";
210 // Clean up for getting the description without html in it, so we
211 // can use it inside the HTML meta description element.
212 $PHORUM["DATA"]["DESCRIPTION"] = str_replace(
213 array('\'', '"'), array('', ''),
214 strip_tags($PHORUM["DATA"]["HTML_DESCRIPTION"])
215 );
216 $PHORUM["DATA"]["ENABLE_PM"] = isset( $PHORUM["enable_pm"]) ? $PHORUM["enable_pm"] : '';
217 if (!empty($PHORUM["DATA"]["HTML_TITLE"]) && !empty($PHORUM["DATA"]["NAME"])) {
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
218 $PHORUM["DATA"]["HTML_TITLE"] .= PHORUM_SEPARATOR;
219 }
220 $PHORUM["DATA"]["HTML_TITLE"] .= $PHORUM["DATA"]["NAME"];
4a8cb63 # DB upgrade scripts for index changes for sorting changes in [3894].…
brian authored Feb 19, 2009
221
18b5987 # New user API code + core changes to work with the user API.
mmakaay authored Jun 7, 2007
222 // Try to restore a user session.
0c9e4c9 @mysnip # restore session for css and javascript too
mysnip authored Jan 5, 2012
223 if (phorum_api_user_session_restore(PHORUM_FORUM_SESSION))
18b5987 # New user API code + core changes to work with the user API.
mmakaay authored Jun 7, 2007
224 {
5df27dc # Added API function phorum_api_forums_get_display_modes().
mmakaay authored Jan 12, 2011
225 // If the user has overridden thread settings, change them here.
226 $modes = phorum_api_forums_get_display_modes($PHORUM);
227 $PHORUM["threaded_list"] = $modes['list'];
228 $PHORUM["threaded_read"] = $modes['read'];
52c4574
ts77 authored Jun 14, 2007
229
7efa318 @mmakaay Dumped the "enable_new_pm_count" setting in favor of a live new pm co…
mmakaay authored Jul 27, 2011
230 // Provide the number of new private messages for the user in the
231 // "new_private_messages" field.
232 if (!empty($PHORUM["enable_pm"])) {
d1851b5 # Removed PM check from phorum_user_get() and moved it to common.php.
mmakaay authored Jun 11, 2007
233 $PHORUM['user']['new_private_messages'] =
7efa318 @mmakaay Dumped the "enable_new_pm_count" setting in favor of a live new pm co…
mmakaay authored Jul 26, 2011
234 $PHORUM['user']['pm_new_count'];
d1851b5 # Removed PM check from phorum_user_get() and moved it to common.php.
mmakaay authored Jun 11, 2007
235 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
236 }
237
47cb5ac # Added documentation for hook "common_post_user".
mmakaay authored Jan 15, 2008
238 /*
239 * [hook]
240 * common_post_user
241 *
242 * [description]
243 * This hook gives modules a chance to override Phorum variables
244 * and settings, after the active user has been loaded. The settings
245 * for the active forum are also loaded before this hook is called,
246 * therefore this hook can be used for overriding general settings,
247 * forum settings and user settings.
248 *
249 * [category]
250 * Request initialization
251 *
252 * [when]
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
253 * Right after loading the data for the active user in
254 * <filename>common.php</filename>, but before deciding on the
255 * language and template to use.
47cb5ac # Added documentation for hook "common_post_user".
mmakaay authored Jan 15, 2008
256 *
257 * [input]
258 * No input.
259 *
260 * [output]
261 * No output.
262 *
263 * [example]
264 * <hookcode>
265 * function phorum_mod_foo_common_post_user()
266 * {
267 * global $PHORUM;
268 *
269 * // Switch the read mode for admin users to threaded.
270 * if ($PHORUM['user']['user_id'] && $PHORUM['user']['admin']) {
271 * $PHORUM['threaded_read'] = PHORUM_THREADED_ON;
272 * }
273 *
274 * // Disable "float_to_top" for anonymous users.
275 * if (!$PHORUM['user']['user_id']) {
276 * $PHORUM['float_to_top'] = 0;
277 * }
278 * }
279 * </hookcode>
280 */
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
281 if (isset($PHORUM["hooks"]["common_post_user"])) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
282 phorum_api_hook("common_post_user", "");
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
283 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
284
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
285 // Some code that only has to be run if the forum isn't set to fixed view.
286 if (empty($PHORUM['display_fixed']))
287 {
e156614 # Improved handling of a template name that is provided in the request
mmakaay authored May 13, 2009
288 // User template override.
289 if (!empty($PHORUM['user']['user_template']) &&
290 (!isset($PHORUM["user_template"]) ||
291 !empty($PHORUM['user_template']))) {
292 $PHORUM['template'] = $PHORUM['user']['user_template'];
293 }
294
295 // Check for a template that is passed on through request parameters.
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
296 // Only use valid template names.
e156614 # Improved handling of a template name that is provided in the request
mmakaay authored May 13, 2009
297 $template = NULL;
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
298 if (!empty($PHORUM["args"]["template"])) {
299 $template = basename($PHORUM["args"]["template"]);
e156614 # Improved handling of a template name that is provided in the request
mmakaay authored May 13, 2009
300 } elseif (!empty($_POST['template'])) {
301 $template = basename($_POST['template']);
302 }
303 if ($template !== NULL && $template != '..') {
304 $PHORUM['template'] = $template;
305 $PHORUM['DATA']['GET_VARS'][] = "template=".urlencode($template);
306 $PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"template\" value=\"".htmlspecialchars($template)."\" />\n";
ebc0b12 MFB: only allow template selection through url if not set to fixed vi…
ts77 authored Feb 16, 2008
307 }
b93240a # fix for ticket #711. We already had this solved for the admin sort …
brian authored Mar 13, 2008
308
c5240c3 Implemented a new option for the User Settings section on the General…
mmakaay authored Apr 1, 2011
309 // User language override, when allowed by the general Phorum settings.
310 if (!empty($PHORUM['user_language']) &&
311 !empty($PHORUM['user']['user_language'])) {
ebc0b12 MFB: only allow template selection through url if not set to fixed vi…
ts77 authored Feb 16, 2008
312 $PHORUM['language'] = $PHORUM['user']['user_language'];
5c87d60 # Prevent the use of illegal template paths from the URL.
mmakaay authored Sep 29, 2005
313 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
314 }
b93240a # fix for ticket #711. We already had this solved for the admin sort …
brian authored Mar 13, 2008
315
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
316 // If no language is set by now or if the language file for the
317 // configured language does not exist, then fallback to the
318 // language that is configured in the default forum settings.
319 if (empty($PHORUM["language"]) ||
320 !file_exists(PHORUM_PATH."/include/lang/$PHORUM[language].php")) {
321 $PHORUM['language'] = $PHORUM['default_forum_options']['language'];
322
323 // If the language file for the default forum settings language
324 // cannot be found, then fallback to the hard-coded default.
325 if (!file_exists(PHORUM_PATH."/include/lang/$PHORUM[language].php")) {
326 $PHORUM['language'] = PHORUM_DEFAULT_LANGUAGE;
327 }
ebc0b12 MFB: only allow template selection through url if not set to fixed vi…
ts77 authored Feb 16, 2008
328 }
fb1ef8c "# some reorganization to get the variables right"
ts77 authored Apr 4, 2007
329
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
330 // If the requested template does not exist, then fallback to the
331 // template that is configured in the default forum settings.
332 if (!file_exists(PHORUM_PATH."/templates/$PHORUM[template]/info.php")) {
333 $PHORUM['template'] = $PHORUM['default_forum_options']['template'];
334
335 // If the template directory for the default forum settings template
336 // cannot be found, then fallback to the hard-coded default.
337 if (!file_exists(PHORUM_PATH."/templates/$PHORUM[template]/info.php")) {
338 $PHORUM['template'] = PHORUM_DEFAULT_TEMPLATE;
339 }
fba59ce # Some small fixes for correctly falling back to the default template.
mmakaay authored Dec 8, 2007
340 }
fb1ef8c "# some reorganization to get the variables right"
ts77 authored Apr 4, 2007
341
ec4dec8 Fix for #765: catch the output of include files (include/db/config.php,
mmakaay authored Jun 16, 2008
342 // Use output buffering so we don't get header errors if there's
343 // some additional output in the upcoming included files (e.g. UTF-8
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
344 // byte order markers or whitespace outside the php tags).
ec4dec8 Fix for #765: catch the output of include files (include/db/config.php,
mmakaay authored Jun 16, 2008
345 ob_start();
346
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
347 // User output buffering so we don't get header errors.
348 // Not loaded if we are running an external or scheduled script.
349 if (!defined('PHORUM_SCRIPT'))
350 {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
351 include phorum_api_template('settings');
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
352 $PHORUM["DATA"]["TEMPLATE"] = htmlspecialchars($PHORUM['template']);
353 $PHORUM["DATA"]["URL"]["TEMPLATE"] = htmlspecialchars("$PHORUM[template_http_path]/$PHORUM[template]");
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
354 $PHORUM["DATA"]["URL"]["CSS"] = phorum_api_url(PHORUM_CSS_URL, "css");
355 $PHORUM["DATA"]["URL"]["CSS_PRINT"] = phorum_api_url(PHORUM_CSS_URL, "css_print");
356 $PHORUM["DATA"]["URL"]["JAVASCRIPT"] = phorum_api_url(PHORUM_JAVASCRIPT_URL);
357 $PHORUM["DATA"]["URL"]["AJAX"] = phorum_api_url(PHORUM_AJAX_URL);
7e88a53 Fix for Opera javascript redirect issue and response splitting in IE …
brian authored Apr 10, 2007
358 }
359
699e443 Setup a more consistent language file naming scheme (we've talked abo…
mmakaay authored Apr 26, 2010
360 // Language names that modules might be using to reference the same
361 // language. Before Phorum 5.3, the language filename format was
362 // not standardized, so some other formats might still be in use.
363 // The included language file can fill this array with appropriate
364 // language names when needed.
365 $PHORUM['compat_languages'] = array();
366
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
367 // Load the main language file.
490a29d Fixed a local file inclusion security hole as reported by kernelnewbi…
mmakaay authored Sep 15, 2007
368 $PHORUM['language'] = basename($PHORUM['language']);
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
369 if (file_exists(PHORUM_PATH."/include/lang/$PHORUM[language].php")) {
7d1a745 Modified common.php and the API layer files to make use of absolute p…
mmakaay authored Apr 14, 2009
370 require_once PHORUM_PATH."/include/lang/$PHORUM[language].php";
06a42e7 # naming typo for the trigger_error function (thanks to Stephan Schulz)
ts77 authored Jun 28, 2010
371 } else trigger_error(
699e443 Setup a more consistent language file naming scheme (we've talked abo…
mmakaay authored Apr 26, 2010
372 "Language file include/lang/$PHORUM[language].php not found",
373 E_USER_ERROR
374 );
375
376 // Add the active language and the default language to compat_languages,
377 // so we can simply use the language array to scan for language files.
80eed7e # Added an option to configure a fallback language name for the default
mmakaay authored Oct 18, 2010
378 $PHORUM['compat_languages'][$PHORUM['language']] = $PHORUM['language'];
699e443 Setup a more consistent language file naming scheme (we've talked abo…
mmakaay authored Apr 26, 2010
379 $PHORUM['compat_languages'] = array_reverse($PHORUM['compat_languages']);
80eed7e # Added an option to configure a fallback language name for the default
mmakaay authored Oct 18, 2010
380 if (!isset($PHORUM['compat_languages'][PHORUM_DEFAULT_LANGUAGE])) {
381 $PHORUM['compat_languages'][PHORUM_DEFAULT_LANGUAGE] =
382 PHORUM_DEFAULT_LANGUAGE;
383 }
72c841b # split() -> explode(), since split() has been deprecated in PHP.
mmakaay authored Mar 27, 2011
384 foreach (explode(',', PHORUM_DEFAULT_LANGUAGE_COMPAT) as $fallback) {
80eed7e # Added an option to configure a fallback language name for the default
mmakaay authored Oct 18, 2010
385 if (!isset($PHORUM['compat_languages'][$fallback])) {
386 $PHORUM['compat_languages'][$fallback] = $fallback;
387 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
388 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
389
390 // Load language file(s) for localized modules.
7d1a745 Modified common.php and the API layer files to make use of absolute p…
mmakaay authored Apr 14, 2009
391 if (!empty($PHORUM['hooks']['lang']['mods'])) {
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
392 foreach($PHORUM['hooks']['lang']['mods'] as $mod) {
490a29d Fixed a local file inclusion security hole as reported by kernelnewbi…
mmakaay authored Sep 15, 2007
393 $mod = basename($mod);
699e443 Setup a more consistent language file naming scheme (we've talked abo…
mmakaay authored Apr 26, 2010
394 $loaded = FALSE;
395 foreach ($PHORUM['compat_languages'] as $language) {
396 $language_file = PHORUM_PATH."/mods/$mod/lang/$language.php";
397 if (file_exists($language_file)) {
398 require_once $language_file;
399 $loaded = TRUE;
400 break;
401 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
402 }
06a42e7 # naming typo for the trigger_error function (thanks to Stephan Schulz)
ts77 authored Jun 28, 2010
403 if (!$loaded) trigger_error(
699e443 Setup a more consistent language file naming scheme (we've talked abo…
mmakaay authored Apr 26, 2010
404 "No language file found for module $mod", E_USER_ERROR
405 );
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
406 }
407 }
408
ec4dec8 Fix for #765: catch the output of include files (include/db/config.php,
mmakaay authored Jun 16, 2008
409 // Clean up the output buffer.
410 ob_end_clean();
411
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
412 // Load the locale from the language file into the template vars.
413 $PHORUM["DATA"]["LOCALE"] = isset($PHORUM['locale']) ? $PHORUM['locale'] : "";
b080ff0 added newflag caching
ts77 authored Jul 12, 2006
414
aee4866 Made a large sweep through the code to add a charset to all appropriate
mmakaay authored Jul 6, 2007
415 // If there is no HCHARSET (used by the htmlspecialchars() calls), then
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
416 // use the CHARSET for it instead. The HCHARSET is implemented to work
417 // around the limitation of PHP that it does not support all charsets
418 // for the htmlspecialchars() call. For example iso-8859-9 (Turkish)
419 // is not supported, in which case the combination CHARSET=iso-8859-9
420 // with HCHARSET=iso-8859-1 can be used to prevent PHP warnings.
aee4866 Made a large sweep through the code to add a charset to all appropriate
mmakaay authored Jul 6, 2007
421 if (empty($PHORUM["DATA"]["HCHARSET"])) {
422 $PHORUM["DATA"]["HCHARSET"] = $PHORUM["DATA"]["CHARSET"];
423 }
424
1d5dc13 @mmakaay Fixed a problem with multibyte characters being split at the middle
mmakaay authored Jan 4, 2012
425 // Set the internal encoding for mbstring functions.
426 mb_internal_encoding($PHORUM['DATA']['CHARSET']);
427
cc1e271 # Fixed escaping problems for HTML_TITLE and NAME members in $PHORUM[…
mmakaay authored Oct 19, 2005
428 // HTML titles can't contain HTML code, so we strip HTML tags
429 // and HTML escape the title.
aee4866 Made a large sweep through the code to add a charset to all appropriate
mmakaay authored Jul 6, 2007
430 $PHORUM["DATA"]["HTML_TITLE"] = htmlspecialchars(strip_tags($PHORUM["DATA"]["HTML_TITLE"]), ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
cc1e271 # Fixed escaping problems for HTML_TITLE and NAME members in $PHORUM[…
mmakaay authored Oct 19, 2005
431
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
432 // For non-admin users, check if the forum is set to
433 // read-only or administrator-only mode.
434 if (empty($PHORUM["user"]["admin"]) && isset($PHORUM['status']))
435 {
436 if ($PHORUM["status"] == PHORUM_MASTER_STATUS_ADMIN_ONLY &&
437 phorum_page != 'css' &&
438 phorum_page != 'javascript' &&
439 phorum_page != 'login') {
27e2577 # Do not treat non-admin users as logged in in admin only mode.
mmakaay authored Oct 25, 2007
440
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
441 phorum_build_common_urls();
442 $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["AdminOnlyMessage"];
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
443 phorum_api_user_set_active_user(PHORUM_FORUM_SESSION, NULL);
27e2577 # Do not treat non-admin users as logged in in admin only mode.
mmakaay authored Oct 25, 2007
444
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
445 /**
446 * @todo Not compatible with portable / embedded Phorum setups.
447 */
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
448 phorum_api_output('message');
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
449 exit();
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
450
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
451 } elseif ($PHORUM['status'] == PHORUM_MASTER_STATUS_READ_ONLY) {
452 $PHORUM['DATA']['GLOBAL_ERROR'] = $PHORUM['DATA']['LANG']['ReadOnlyMessage'];
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
453 phorum_api_user_set_active_user(PHORUM_FORUM_SESSION, NULL);
5415390 Fully implemented read only mode
brian authored Apr 25, 2007
454 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
455 }
456
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
457 // If moderator notifications are on and the person is a mod,
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
458 // lets find out if anything needs attention.
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
459
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
460 $PHORUM["user"]["NOTICE"]["MESSAGES"] = FALSE;
461 $PHORUM["user"]["NOTICE"]["USERS"] = FALSE;
462 $PHORUM["user"]["NOTICE"]["GROUPS"] = FALSE;
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
463
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
464 if ($PHORUM["DATA"]["LOGGEDIN"])
465 {
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
466 // By default, only bug the user on the list, index and cc pages.
467 // The template can override this behaviour by setting a comma
468 // separated list of phorum_page names in a template define statement
469 // like this: {DEFINE show_notify_for_pages "page 1,page 2,..,page n"}
470 if (isset($PHORUM["TMP"]["show_notify_for_pages"])) {
471 $show_notify_for_pages = explode(",", $PHORUM["TMP"]["show_notify_for_pages"]);
472 } else {
473 $show_notify_for_pages = array('index','list','cc');
474 }
475
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
476 // Check for moderator notifications that have to be shown.
477 if (in_array(phorum_page, $show_notify_for_pages) &&
478 !empty($PHORUM['enable_moderator_notifications'])) {
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
479
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
480 $forummodlist = phorum_api_user_check_access(
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
481 PHORUM_USER_ALLOW_MODERATE_MESSAGES, PHORUM_ACCESS_LIST
482 );
483 if (count($forummodlist) > 0 ) {
9d84db0 Implemented an OO database layer for Phorum. This layer will make it …
mmakaay authored Jan 24, 2011
484 $PHORUM["user"]["NOTICE"]["MESSAGES"] = ($PHORUM['DB']->get_unapproved_list($forummodlist, TRUE, 0, TRUE) > 0);
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
485 $PHORUM["DATA"]["URL"]["NOTICE"]["MESSAGES"] = phorum_api_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_UNAPPROVED);
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
486 }
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
487 if (phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_USERS)) {
9d84db0 Implemented an OO database layer for Phorum. This layer will make it …
mmakaay authored Jan 24, 2011
488 $PHORUM["user"]["NOTICE"]["USERS"] = (count($PHORUM['DB']->user_get_unapproved()) > 0);
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
489 $PHORUM["DATA"]["URL"]["NOTICE"]["USERS"] = phorum_api_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_USERS);
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
490 }
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
491 $groups = phorum_api_user_check_group_access(PHORUM_USER_GROUP_MODERATOR, PHORUM_ACCESS_LIST);
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
492 if (count($groups) > 0) {
9d84db0 Implemented an OO database layer for Phorum. This layer will make it …
mmakaay authored Jan 24, 2011
493 $PHORUM["user"]["NOTICE"]["GROUPS"] = count($PHORUM['DB']->get_group_members(array_keys($groups), PHORUM_USER_GROUP_UNAPPROVED));
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
494 $PHORUM["DATA"]["URL"]["NOTICE"]["GROUPS"] = phorum_api_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_GROUP_MODERATION);
f2735f3 # Added new template settings.tpl define 'show_notify_for_pages'.
mmakaay authored Jun 21, 2006
495 }
496 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
497
498 // A quick template variable for deciding whether or not to show
499 // moderator notification.
500 $PHORUM["user"]["NOTICE"]["SHOW"] =
501 $PHORUM["user"]["NOTICE"]["MESSAGES"] ||
502 $PHORUM["user"]["NOTICE"]["USERS"] ||
503 $PHORUM["user"]["NOTICE"]["GROUPS"];
0a6aa47 MFB: sanitizing rss-url
ts77 authored Jun 23, 2006
504 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
505
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
506 /*
507 * [hook]
508 * common
509 *
510 * [description]
511 * This hook gives modules a chance to override Phorum variables
512 * and settings near the end of the <filename>common.php</filename>
513 * script. This can be used to override the Phorum (settings)
514 * variables that are setup during this script.
515 *
516 * [category]
517 * Request initialization
518 *
519 * [when]
520 * At the end of <filename>common.php</filename>.
521 *
522 * [input]
523 * No input.
524 *
525 * [output]
526 * No output.
527 *
528 * [example]
529 * <hookcode>
530 * function phorum_mod_foo_common()
531 * {
532 * global $PHORUM;
533 *
534 * // Override the admin email address.
535 * $PHORUM["system_email_from_name"] = "John Doe";
536 * $PHORUM["system_email_from_address"] = "John.Doe@example.com";
537 * }
538 * </hookcode>
539 */
540 if (isset($PHORUM["hooks"]["common"])) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
541 phorum_api_hook("common", "");
1ddc3ef # Revised common.php and added hook comments to all hooks in that file.
mmakaay authored Jan 15, 2008
542 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
543
49cd576 Implemented a hook call "page_<phorum_page>" that can be used to run a
mmakaay authored Feb 28, 2008
544 /*
545 * [hook]
fcac1d0 # Incorporated hook availability in the docbook generation tool.
mmakaay authored Feb 28, 2008
546 * page_<phorum_page>
547 *
548 * [availability]
549 * Phorum 5 >= 5.2.7
49cd576 Implemented a hook call "page_<phorum_page>" that can be used to run a
mmakaay authored Feb 28, 2008
550 *
551 * [description]
552 * This hook gives modules a chance to run hook code for a specific
553 * Phorum page near the end of the the <filename>common.php</filename>
554 * script.<sbr/>
555 * <sbr/>
556 * It gives modules a chance to override Phorum variables
557 * and settings near the end of the <filename>common.php</filename>
558 * script. This can be used to override the Phorum (settings)
559 * variables that are setup during this script.
560 * <sbr/>
561 * The <literal>phorum_page</literal> definition that is set
562 * for each script is used to construct the name of the hook that will
563 * be called. For example the <filename>index.php</filename> script
564 * uses phorum_page <literal>index</literal>, which means that the
565 * called hook will be <literal>page_index</literal>.
566 *
567 * [category]
568 * Request initialization
569 *
570 * [when]
571 * At the end of <filename>common.php</filename>, right after the
572 * <hook>common</hook> hook is called.<sbr/>
573 * <sbr/>
574 * You can look at this as if the hook is called at the start of the
575 * called script, since including <filename>common.php</filename>
576 * is about the first thing that a Phorum script does.
577 *
578 * [input]
579 * No input.
580 *
581 * [output]
582 * No output.
583 *
584 * [example]
585 * <hookcode>
586 * function phorum_mod_foo_page_list()
587 * {
588 * global $PHORUM;
589 *
590 * // Set the type of list page to use, based on a cookie.
591 * if (empty($_COOKIE['list_style'])) {
592 * $PHORUM['threaded_list'] = PHORUM_THREADED_DEFAULT;
593 * } elseif ($_COOKIE['list_style'] == 'threaded') {
594 * $PHORUM['threaded_list'] = PHORUM_THREADED_ON;
595 * } elseif ($_COOKIE['list_style'] == 'flat') {
596 * $PHORUM['threaded_list'] = PHORUM_THREADED_OFF;
597 * } elseif ($_COOKIE['list_style'] == 'hybrid') {
598 * $PHORUM['threaded_list'] = PHORUM_THREADED_HYBRID;
599 * }
600 * }
601 * </hookcode>
602 */
603 $page_hook = 'page_'.phorum_page;
604 if (isset($PHORUM["hooks"][$page_hook])) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
605 phorum_api_hook($page_hook, "");
49cd576 Implemented a hook call "page_<phorum_page>" that can be used to run a
mmakaay authored Feb 28, 2008
606 }
607
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
608 $formatted = phorum_api_format_users(array($PHORUM['user']));
2d2c1b8 Fixed #717: User data doesn't get reloaded after profile edit.
mmakaay authored Mar 10, 2008
609 $PHORUM['DATA']['USER'] = $formatted[0];
84abc50 # Added some useful variables to the template data
mmakaay authored Feb 17, 2006
610 $PHORUM['DATA']['PHORUM_PAGE'] = phorum_page;
611 $PHORUM['DATA']['USERTRACK'] = $PHORUM['track_user_activity'];
19dfc59 # Added DATA->VROOT, so code like {IF FORUM_ID VROOT} .. {/IF} can be…
mmakaay authored Oct 3, 2006
612 $PHORUM['DATA']['VROOT'] = $PHORUM['vroot'];
52c4574
ts77 authored Jun 14, 2007
613 $PHORUM['DATA']['POST_VARS'].="<input type=\"hidden\" name=\"forum_id\" value=\"{$PHORUM["forum_id"]}\" />\n";
aeb037d Some changes to improve the breadcrumbs. The code now tries to keep t…
mmakaay authored Apr 21, 2010
614 if (!empty($PHORUM['ref_thread_id'])) {
615 $PHORUM['DATA']['POST_VARS'].="<input type=\"hidden\" name=\"ref_thread_id\" value=\"{$PHORUM["ref_thread_id"]}\" />\n";
616 }
617 if (!empty($PHORUM['ref_message_id'])) {
618 $PHORUM['DATA']['POST_VARS'].="<input type=\"hidden\" name=\"ref_message_id\" value=\"{$PHORUM["ref_message_id"]}\" />\n";
619 }
c40b7c0 # removed feed url logic from phorum_get_url and put the burden on th…
brian authored Jul 10, 2007
620
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
621 if (!empty($PHORUM['use_rss'])) {
622 if($PHORUM["default_feed"] == "rss"){
c40b7c0 # removed feed url logic from phorum_get_url and put the burden on th…
brian authored Jul 10, 2007
623 $PHORUM["DATA"]["FEED"] = $PHORUM["DATA"]["LANG"]["RSS"];
624 $PHORUM["DATA"]["FEED_CONTENT_TYPE"] = "application/rss+xml";
625 } else {
626 $PHORUM["DATA"]["FEED"] = $PHORUM["DATA"]["LANG"]["ATOM"];
627 $PHORUM["DATA"]["FEED_CONTENT_TYPE"] = "application/atom+xml";
628 }
629 }
630
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
631 $PHORUM['DATA']['BREADCRUMBS'] = array();
31fde34 MFB: breadcrumbs in template are now generated from the forum-path st…
ts77 authored Dec 15, 2007
632
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
633 // Add the current forum path to the breadcrumbs.
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
634 $index_page_url_template = phorum_api_url(PHORUM_INDEX_URL, '%forum_id%');
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
635 if (!empty($PHORUM['forum_path']) && !is_array($PHORUM['forum_path'])) {
636 $PHORUM['forum_path'] = unserialize($PHORUM['forum_path']);
637 }
638 if (empty($PHORUM['forum_path']))
639 {
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
640 $id = $PHORUM['forum_id'];
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
641 $url = empty($id)
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
642 ? phorum_api_url(PHORUM_INDEX_URL)
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
643 : str_replace('%forum_id%',$id,$index_page_url_template);
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
644
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
645 $PHORUM['DATA']['BREADCRUMBS'][] = array(
9211757 made breadcrumbs urls default to index-url instead of list and added …
ts77 authored Dec 30, 2007
646 'URL' => $url,
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
647 'TEXT' => $PHORUM['DATA']['LANG']['Home'],
648 'ID' => $id,
649 'TYPE' => 'root'
650 );
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
651 }
652 else
653 {
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
654 $track = NULL;
655 foreach ($PHORUM['forum_path'] as $id => $name)
656 {
657 if ($track === NULL) {
658 $name = $PHORUM['DATA']['LANG']['Home'];
659 $type = 'root';
660 $first = FALSE;
661 } else {
662 $type = 'folder';
663 }
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
664
9211757 made breadcrumbs urls default to index-url instead of list and added …
ts77 authored Dec 30, 2007
665 if(empty($id)) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
666 $url = phorum_api_url(PHORUM_INDEX_URL);
9211757 made breadcrumbs urls default to index-url instead of list and added …
ts77 authored Dec 30, 2007
667 } else {
668 $url = str_replace('%forum_id%',$id,$index_page_url_template);
669 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
670
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
671 // Note: $id key is not required in general. Only used for
672 // fixing up the last entry's TYPE.
673 $PHORUM['DATA']['BREADCRUMBS'][$id]=array(
9211757 made breadcrumbs urls default to index-url instead of list and added …
ts77 authored Dec 30, 2007
674 'URL' => $url,
417d8dc # Some additions to the breadcrumb generation code and the root node
mmakaay authored Dec 16, 2007
675 'TEXT' => strip_tags($name),
676 'ID' => $id,
677 'TYPE' => $type
678 );
679 $track = $id;
31fde34 MFB: breadcrumbs in template are now generated from the forum-path st…
ts77 authored Dec 15, 2007
680 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
681
0cece21 # Breadcrumbs fix. The breadcrumb for the active forum was formatted …
mmakaay authored Feb 20, 2008
682 if (!$PHORUM['folder_flag']) {
683 $PHORUM['DATA']['BREADCRUMBS'][$track]['TYPE'] = 'forum';
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
684 $PHORUM['DATA']['BREADCRUMBS'][$track]['URL'] = phorum_api_url(PHORUM_LIST_URL, $track);
0cece21 # Breadcrumbs fix. The breadcrumb for the active forum was formatted …
mmakaay authored Feb 20, 2008
685 }
aeb037d Some changes to improve the breadcrumbs. The code now tries to keep t…
mmakaay authored Apr 21, 2010
686
687 if (!empty($PHORUM['ref_thread_id'])) {
688 $PHORUM['DATA']['BREADCRUMBS'][] = array(
689 'URL' => phorum_api_url(
690 PHORUM_READ_URL,
691 $PHORUM['ref_thread_id'],
692 $PHORUM['ref_message_id']
693 ),
694 'TEXT' => $PHORUM['DATA']['LANG']['Thread'],
695 'ID' => $PHORUM['ref_message_id'],
696 'TYPE' => 'message'
697 );
698
699 }
31fde34 MFB: breadcrumbs in template are now generated from the forum-path st…
ts77 authored Dec 15, 2007
700 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
701 }
702
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
703 // ----------------------------------------------------------------------
704 // Setup data for admin pages
705 // ----------------------------------------------------------------------
a7616c9 # Fixed missing LANG->AnonymousUser, used by the dblayer when deleting a
mmakaay authored Sep 12, 2007
706
707 else {
708
709 // The admin interface is not localized, but we might need language
710 // strings at some point after all, for example if we reset the
711 // author name in messages for deleted users to "anonymous".
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
712 $PHORUM["language"] = basename($PHORUM['default_forum_options']['language']);
7d1a745 Modified common.php and the API layer files to make use of absolute p…
mmakaay authored Apr 14, 2009
713 if (file_exists(PHORUM_PATH."/include/lang/$PHORUM[language].php")) {
714 require_once PHORUM_PATH."/include/lang/$PHORUM[language].php";
a7616c9 # Fixed missing LANG->AnonymousUser, used by the dblayer when deleting a
mmakaay authored Sep 12, 2007
715 }
716 }
717
9a2992c # Modified common.php for moving query parsing forward, loading settings
mmakaay authored Jan 14, 2008
718 // ----------------------------------------------------------------------
719 // Functions
720 // ----------------------------------------------------------------------
58dff47 Added shutdown function for future use and a shutdown hook
brian authored May 26, 2007
721
722 /**
52b1198 Implemented a new hook "get_template_file", which can be used to infl…
mmakaay authored Mar 10, 2009
723 * Check if the user has read permission for a forum page.
724 *
725 * If the user does not have read permission for the currently active
726 * forum, then an error message is shown. What message to show depends
727 * on the exact case. Possible cases are:
728 *
729 * - The user is logged in: final missing read permission message;
730 * - The user is not logged in, but wouldn't be allowed to read the
731 * forum, even if he were logged in: final missing read permission message;
732 * - The user is not logged in, but could be allowed to read the
733 * forum if he were logged in: please login message.
734 *
735 * @return boolean
736 * TRUE in case the user is allowed to read the forum,
737 * FALSE otherwise.
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
738 */
739 function phorum_check_read_common()
740 {
032d188 #Initial commit for ticket #698. Just did the files in the base dir i…
brian authored Mar 13, 2008
741 global $PHORUM;
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
742
743 $retval = TRUE;
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
744
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
745 if ($PHORUM["forum_id"] > 0 &&
746 !$PHORUM["folder_flag"] &&
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
747 !phorum_api_user_check_access(PHORUM_USER_ALLOW_READ)) {
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
748
749 if ( $PHORUM["DATA"]["LOGGEDIN"] ) {
750 // if they are logged in and not allowed, they don't have rights
bf5b0d2 # Additional commit for ticket #698. missed these in the earlier commit
brian authored Mar 13, 2008
751 $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["NoRead"];
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
752 } else {
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
753 // Check if they could read if logged in.
754 // If so, let them know to log in.
755 if (empty($PHORUM["DATA"]["POST"]["parentid"]) &&
756 $PHORUM["reg_perms"] & PHORUM_USER_ALLOW_READ) {
bf5b0d2 # Additional commit for ticket #698. missed these in the earlier commit
brian authored Mar 13, 2008
757 $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["PleaseLoginRead"];
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
758 } else {
bf5b0d2 # Additional commit for ticket #698. missed these in the earlier commit
brian authored Mar 13, 2008
759 $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["NoRead"];
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
760 }
761 }
762
763 phorum_build_common_urls();
764
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
765 phorum_api_output("message");
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
766
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
767 $retval = FALSE;
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
768 }
769
770 return $retval;
771 }
772
15fe7b7 Added a new function: phorum_get_template_file(), which is used for
mmakaay authored Apr 7, 2006
773 /**
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
774 * Generate the URLs that are used on most pages.
15fe7b7 Added a new function: phorum_get_template_file(), which is used for
mmakaay authored Apr 7, 2006
775 */
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
776 function phorum_build_common_urls()
777 {
bf5b0d2 # Additional commit for ticket #698. missed these in the earlier commit
brian authored Mar 13, 2008
778 global $PHORUM;
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
779
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
780 $GLOBALS["PHORUM"]["DATA"]["URL"]["BASE"] = phorum_api_url(PHORUM_BASE_URL);
2e470b7 # I remember! {URL->BASE} is not useful in embedded/portable mode, si…
mmakaay authored Nov 4, 2007
781 $GLOBALS["PHORUM"]["DATA"]["URL"]["HTTP_PATH"] = $PHORUM['http_path'];
1620d74 # beginning of template rewrite. Includes changes to core
brian authored Apr 7, 2006
782
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
783 $GLOBALS["PHORUM"]["DATA"]["URL"]["LIST"] = phorum_api_url(PHORUM_LIST_URL);
f2d66cd MFB: # Generate URL->LIST for folders too (since it's used in the hea…
mmakaay authored Sep 24, 2006
784
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
785 // These links are only needed in forums, not in folders.
786 if (isset($PHORUM['folder_flag']) && !$PHORUM['folder_flag']) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
787 $GLOBALS["PHORUM"]["DATA"]["URL"]["POST"] = phorum_api_url(PHORUM_POSTING_URL);
788 $GLOBALS["PHORUM"]["DATA"]["URL"]["SUBSCRIBE"] = phorum_api_url(PHORUM_SUBSCRIBE_URL);
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
789 }
790
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
791 $GLOBALS["PHORUM"]["DATA"]["URL"]["SEARCH"] = phorum_api_url(PHORUM_SEARCH_URL);
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
792
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
793 // Find the id for the index.
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
794 $index_id=-1;
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
795
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
796 // A folder where we usually don't show the index-link but on
797 // additional pages like search and login it is shown.
798 if ($PHORUM['folder_flag'] && phorum_page != 'index' &&
799 ($PHORUM['forum_id'] == 0 || $PHORUM['vroot'] == $PHORUM['forum_id'])) {
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
800
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
801 $index_id = $PHORUM['forum_id'];
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
802
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
803 // Either a folder where the link should be shown (not vroot or root)
804 // or an active forum where the link should be shown.
805 } elseif (($PHORUM['folder_flag'] &&
806 ($PHORUM['forum_id'] != 0 && $PHORUM['vroot'] != $PHORUM['forum_id'])) ||
807 (!$PHORUM['folder_flag'] && $PHORUM['active'])) {
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
808
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
809 // Go to root or vroot.
810 if (isset($PHORUM["index_style"]) && $PHORUM["index_style"] == PHORUM_INDEX_FLAT) {
811 // vroot is either 0 (root) or another id
812 $index_id = $PHORUM["vroot"];
813 // Go to the parent folder.
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
814 } else {
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
815 $index_id=$PHORUM["parent_id"];
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
816 }
817 }
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
818
819 if ($index_id > -1) {
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
820 // check if its the full root, avoid adding an id in this case (SE-optimized ;))
821 if (!empty($index_id))
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
822 $GLOBALS["PHORUM"]["DATA"]["URL"]["INDEX"] = phorum_api_url(PHORUM_INDEX_URL, $index_id);
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
823 else
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
824 $GLOBALS["PHORUM"]["DATA"]["URL"]["INDEX"] = phorum_api_url(PHORUM_INDEX_URL);
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
825 }
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
826
3f75d93 streamlined index/messagelist/post-url creation should fix #199
ts77 authored Dec 16, 2005
827 // these urls depend on the login-status of a user
1a44dcb First steps for an easier to use API. What you can do now, is:
mmakaay authored May 9, 2009
828 if ($GLOBALS["PHORUM"]["DATA"]["LOGGEDIN"]) {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
829 $GLOBALS["PHORUM"]["DATA"]["URL"]["LOGINOUT"] = phorum_api_url( PHORUM_LOGIN_URL, "logout=1" );
830 $GLOBALS["PHORUM"]["DATA"]["URL"]["REGISTERPROFILE"] = phorum_api_url( PHORUM_CONTROLCENTER_URL );
838e7db The template variable {URL->VIEWPROFILE} is now available for use in
mmakaay authored Oct 21, 2010
831 $GLOBALS["PHORUM"]["DATA"]["URL"]["VIEWPROFILE"] = phorum_api_url(PHORUM_PROFILE_URL, $PHORUM['user']['user_id']);
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
832 $GLOBALS["PHORUM"]["DATA"]["URL"]["PM"] = phorum_api_url( PHORUM_PM_URL );
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
833 } else {
1a7e31c # Massive refactoring for going back to pure function calls for the core
mmakaay authored Jun 11, 2009
834 $GLOBALS["PHORUM"]["DATA"]["URL"]["LOGINOUT"] = phorum_api_url( PHORUM_LOGIN_URL );
835 $GLOBALS["PHORUM"]["DATA"]["URL"]["REGISTERPROFILE"] = phorum_api_url( PHORUM_REGISTER_URL );
4775e82 # more line-ending properties
ts77 authored Aug 26, 2005
836 }
837 }
838
839 ?>
Something went wrong with that request. Please try again.