| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*======================================================================
|
|
|
4 |
Copyright Project Beehive Forum 2002
|
|
|
5 |
|
|
|
6 |
This file is part of Beehive Forum.
|
|
|
7 |
|
|
|
8 |
Beehive Forum is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
|
|
|
13 |
Beehive Forum is distributed in the hope that it will be useful,
|
|
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
16 |
GNU General Public License for more details.
|
|
|
17 |
|
|
|
18 |
You should have received a copy of the GNU General Public License
|
|
|
19 |
along with Beehive; if not, write to the Free Software
|
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
21 |
USA
|
|
|
22 |
======================================================================*/
|
|
|
23 |
|
|
|
24 |
/* $Id: forum.inc.php,v 1.1 2008/05/12 15:50:20 farell Exp $ */
|
|
|
25 |
|
|
|
26 |
// We shouldn't be accessing this file directly.
|
|
|
27 |
|
|
|
28 |
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
|
|
|
29 |
header("Request-URI: ../index.php");
|
|
|
30 |
header("Content-Location: ../index.php");
|
|
|
31 |
header("Location: ../index.php");
|
|
|
32 |
exit;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
include_once(BH_INCLUDE_PATH. "attachments.inc.php");
|
|
|
36 |
include_once(BH_INCLUDE_PATH. "constants.inc.php");
|
|
|
37 |
include_once(BH_INCLUDE_PATH. "db.inc.php");
|
|
|
38 |
include_once(BH_INCLUDE_PATH. "fixhtml.inc.php");
|
|
|
39 |
include_once(BH_INCLUDE_PATH. "folder.inc.php");
|
|
|
40 |
include_once(BH_INCLUDE_PATH. "form.inc.php");
|
|
|
41 |
include_once(BH_INCLUDE_PATH. "format.inc.php");
|
|
|
42 |
include_once(BH_INCLUDE_PATH. "header.inc.php");
|
|
|
43 |
include_once(BH_INCLUDE_PATH. "html.inc.php");
|
|
|
44 |
include_once(BH_INCLUDE_PATH. "install.inc.php");
|
|
|
45 |
include_once(BH_INCLUDE_PATH. "lang.inc.php");
|
|
|
46 |
include_once(BH_INCLUDE_PATH. "perm.inc.php");
|
|
|
47 |
include_once(BH_INCLUDE_PATH. "pm.inc.php");
|
|
|
48 |
include_once(BH_INCLUDE_PATH. "session.inc.php");
|
|
|
49 |
include_once(BH_INCLUDE_PATH. "stats.inc.php");
|
|
|
50 |
include_once(BH_INCLUDE_PATH. "text_captcha.inc.php");
|
|
|
51 |
include_once(BH_INCLUDE_PATH. "threads.inc.php");
|
|
|
52 |
include_once(BH_INCLUDE_PATH. "user.inc.php");
|
|
|
53 |
include_once(BH_INCLUDE_PATH. "word_filter.inc.php");
|
|
|
54 |
|
|
|
55 |
function get_forum_data()
|
|
|
56 |
{
|
|
|
57 |
static $forum_data = false;
|
|
|
58 |
|
|
|
59 |
if (!$db_get_forum_data = db_connect()) return false;
|
|
|
60 |
|
|
|
61 |
if (($uid = bh_session_get_value('UID')) === false) return false;
|
|
|
62 |
|
|
|
63 |
if (isset($_GET['webtag']) && strlen(trim(_stripslashes($_GET['webtag']))) > 0) {
|
|
|
64 |
$webtag = trim(_stripslashes($_GET['webtag']));
|
|
|
65 |
}elseif (isset($_POST['webtag']) && strlen(trim(_stripslashes($_POST['webtag']))) > 0) {
|
|
|
66 |
$webtag = trim(_stripslashes($_POST['webtag']));
|
|
|
67 |
}elseif (isset($_SERVER['argv'][1]) && strlen(trim(_stripslashes($_SERVER['argv'][1]))) > 0) {
|
|
|
68 |
$webtag = trim(_stripslashes($_SERVER['argv'][1]));
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
if (!is_array($forum_data) || !isset($forum_data['WEBTAG']) || !isset($forum_data['PREFIX'])) {
|
|
|
72 |
|
|
|
73 |
if (isset($webtag) && preg_match("/^[A-Z0-9_]+$/", $webtag) > 0) {
|
|
|
74 |
|
|
|
75 |
// Check #1: See if the webtag specified in GET/POST
|
|
|
76 |
// actually exists.
|
|
|
77 |
|
|
|
78 |
$webtag = db_escape_string($webtag);
|
|
|
79 |
|
|
|
80 |
$sql = "SELECT FORUMS.FID, FORUMS.WEBTAG, FORUMS.ACCESS_LEVEL, ";
|
|
|
81 |
$sql.= "CONCAT(FORUMS.DATABASE_NAME, '.', FORUMS.WEBTAG, '_') AS PREFIX ";
|
|
|
82 |
$sql.= "FROM FORUMS WHERE WEBTAG = '$webtag'";
|
|
|
83 |
|
|
|
84 |
if ($result = db_query($sql, $db_get_forum_data)) {
|
|
|
85 |
|
|
|
86 |
if (db_num_rows($result) > 0) {
|
|
|
87 |
|
|
|
88 |
$forum_data = db_fetch_array($result);
|
|
|
89 |
|
|
|
90 |
if (!isset($forum_data['ACCESS_LEVEL'])) $forum_data['ACCESS_LEVEL'] = 0;
|
|
|
91 |
if (!isset($forum_data['ALLOWED'])) $forum_data['ALLOWED'] = 0;
|
|
|
92 |
|
|
|
93 |
return $forum_data;
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
return array('WEBTAG_SEARCH' => $webtag);
|
|
|
98 |
|
|
|
99 |
}else {
|
|
|
100 |
|
|
|
101 |
// Check #2: Try and select a default webtag from
|
|
|
102 |
// the databse
|
|
|
103 |
|
|
|
104 |
$sql = "SELECT FORUMS.FID, FORUMS.WEBTAG, FORUMS.ACCESS_LEVEL, ";
|
|
|
105 |
$sql.= "CONCAT(FORUMS.DATABASE_NAME, '.', FORUMS.WEBTAG, '_') AS PREFIX ";
|
|
|
106 |
$sql.= "FROM FORUMS WHERE DEFAULT_FORUM = 1";
|
|
|
107 |
|
|
|
108 |
if ($result = db_query($sql, $db_get_forum_data)) {
|
|
|
109 |
|
|
|
110 |
if (db_num_rows($result) > 0) {
|
|
|
111 |
|
|
|
112 |
$forum_data = db_fetch_array($result);
|
|
|
113 |
|
|
|
114 |
if (!isset($forum_data['ACCESS_LEVEL'])) $forum_data['ACCESS_LEVEL'] = 0;
|
|
|
115 |
if (!isset($forum_data['ALLOWED'])) $forum_data['ALLOWED'] = 0;
|
|
|
116 |
}
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
return $forum_data;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
function get_webtag(&$webtag_search)
|
|
|
125 |
{
|
|
|
126 |
$forum_data = get_forum_data();
|
|
|
127 |
|
|
|
128 |
if (is_array($forum_data) && isset($forum_data['WEBTAG'])) {
|
|
|
129 |
return $forum_data['WEBTAG'];
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
if (is_array($forum_data) && isset($forum_data['WEBTAG_SEARCH'])) {
|
|
|
133 |
$webtag_search = $forum_data['WEBTAG_SEARCH'];
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
return false;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
function get_table_prefix()
|
|
|
140 |
{
|
|
|
141 |
$forum_data = get_forum_data();
|
|
|
142 |
|
|
|
143 |
if (is_array($forum_data) && isset($forum_data['WEBTAG'])) {
|
|
|
144 |
return $forum_data;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
return false;
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
function forum_check_access_level()
|
|
|
151 |
{
|
|
|
152 |
static $forum_data = false;
|
|
|
153 |
|
|
|
154 |
if (!$db_forum_check_access_level = db_connect()) return false;
|
|
|
155 |
|
|
|
156 |
if (($uid = bh_session_get_value('UID')) === false) return false;
|
|
|
157 |
|
|
|
158 |
if (!$table_data = get_table_prefix()) return true;
|
|
|
159 |
|
|
|
160 |
$forum_fid = $table_data['FID'];
|
|
|
161 |
|
|
|
162 |
if (!is_array($forum_data) || !isset($forum_data['ACCESS_LEVEL']) || !isset($forum_data['ALLOWED'])) {
|
|
|
163 |
|
|
|
164 |
$sql = "SELECT FORUMS.FID, FORUMS.ACCESS_LEVEL, USER_FORUM.ALLOWED FROM FORUMS ";
|
|
|
165 |
$sql.= "LEFT JOIN USER_FORUM ON (USER_FORUM.FID = FORUMS.FID ";
|
|
|
166 |
$sql.= "AND USER_FORUM.UID = '$uid') WHERE FORUMS.FID = '$forum_fid'";
|
|
|
167 |
|
|
|
168 |
if (!$result = db_query($sql, $db_forum_check_access_level)) return false;
|
|
|
169 |
|
|
|
170 |
if (db_num_rows($result) > 0) {
|
|
|
171 |
|
|
|
172 |
$forum_data = db_fetch_array($result);
|
|
|
173 |
}
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
if (isset($forum_data['ACCESS_LEVEL'])) {
|
|
|
177 |
|
|
|
178 |
if ($forum_data['ACCESS_LEVEL'] < FORUM_UNRESTRICTED) {
|
|
|
179 |
|
|
|
180 |
return forum_closed_message();
|
|
|
181 |
|
|
|
182 |
}elseif ($forum_data['ACCESS_LEVEL'] == FORUM_RESTRICTED && $forum_data['ALLOWED'] <> FORUM_USER_ALLOWED) {
|
|
|
183 |
|
|
|
184 |
return forum_restricted_message();
|
|
|
185 |
|
|
|
186 |
}elseif ($forum_data['ACCESS_LEVEL'] == FORUM_PASSWD_PROTECTED) {
|
|
|
187 |
|
|
|
188 |
return forum_check_password($forum_data['FID']);
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
return true;
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
function forum_closed_message()
|
|
|
196 |
{
|
|
|
197 |
$lang = load_language_file();
|
|
|
198 |
|
|
|
199 |
html_draw_top();
|
|
|
200 |
|
|
|
201 |
$forum_name = forum_get_setting('forum_name', false, 'A Beehive Forum');
|
|
|
202 |
|
|
|
203 |
echo "<h1>{$lang['closed']}</h1>\n";
|
|
|
204 |
|
|
|
205 |
if ($closed_message = forum_get_setting('closed_message', false)) {
|
|
|
206 |
|
|
|
207 |
html_display_error_msg(fix_html($closed_message), '600', 'center');
|
|
|
208 |
|
|
|
209 |
}else {
|
|
|
210 |
|
|
|
211 |
html_display_error_msg(sprintf($lang['forumiscurrentlyclosed'], _htmlentities($forum_name)), '600', 'center');
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
215 |
|
|
|
216 |
html_display_warning_msg($lang['adminforumclosedtip'], '600', 'center');
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
html_draw_bottom();
|
|
|
220 |
exit;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
function forum_restricted_message()
|
|
|
224 |
{
|
|
|
225 |
$lang = load_language_file();
|
|
|
226 |
|
|
|
227 |
html_draw_top();
|
|
|
228 |
|
|
|
229 |
$forum_name = forum_get_setting('forum_name', false, 'A Beehive Forum');
|
|
|
230 |
|
|
|
231 |
echo "<h1>{$lang['restricted']}</h1>\n";
|
|
|
232 |
|
|
|
233 |
if ($restricted_message = forum_get_setting('restricted_message', false)) {
|
|
|
234 |
|
|
|
235 |
html_display_error_msg(fix_html($restricted_message), '600', 'center');
|
|
|
236 |
|
|
|
237 |
}else {
|
|
|
238 |
|
|
|
239 |
html_display_error_msg(sprintf($lang['youdonothaveaccesstoforum'], _htmlentities($forum_name)), '600', 'center');
|
|
|
240 |
html_display_warning_msg($lang['toapplyforaccessplease'], '600', 'center');
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
244 |
|
|
|
245 |
html_display_warning_msg($lang['adminforumclosedtip'], '600', 'center');
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
html_draw_bottom();
|
|
|
249 |
exit;
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
function forum_get_password($forum_fid)
|
|
|
253 |
{
|
|
|
254 |
if (!$db_forum_get_password = db_connect()) return false;
|
|
|
255 |
|
|
|
256 |
if (!is_numeric($forum_fid)) return false;
|
|
|
257 |
|
|
|
258 |
$sql = "SELECT FORUM_PASSWD FROM FORUMS WHERE FID = '$forum_fid'";
|
|
|
259 |
|
|
|
260 |
if (!$result = db_query($sql, $db_forum_get_password)) return false;
|
|
|
261 |
|
|
|
262 |
if (db_num_rows($result) > 0) {
|
|
|
263 |
|
|
|
264 |
list($forum_passwd) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
265 |
return is_md5($forum_passwd) ? $forum_passwd : false;
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
return false;
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
function forum_get_saved_password(&$password, &$passhash, &$sesshash)
|
|
|
272 |
{
|
|
|
273 |
$webtag = get_webtag($webtag_search);
|
|
|
274 |
|
|
|
275 |
if (isset($_COOKIE["bh_{$webtag}_password"]) && strlen(_stripslashes($_COOKIE["bh_{$webtag}_password"])) > 0) {
|
|
|
276 |
$password = _stripslashes($_COOKIE["bh_{$webtag}_password"]);
|
|
|
277 |
}else {
|
|
|
278 |
$password = "";
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
if (isset($_COOKIE["bh_{$webtag}_passhash"]) && is_md5($_COOKIE["bh_{$webtag}_passhash"])) {
|
|
|
282 |
$passhash = trim(_stripslashes($_COOKIE["bh_{$webtag}_passhash"]));
|
|
|
283 |
}else {
|
|
|
284 |
$passhash = "";
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
if (isset($_COOKIE["bh_{$webtag}_sesshash"]) && is_md5($_COOKIE["bh_{$webtag}_sesshash"])) {
|
|
|
288 |
$sesshash = trim(_stripslashes($_COOKIE["bh_{$webtag}_sesshash"]));
|
|
|
289 |
}else {
|
|
|
290 |
$sesshash = "";
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
return true;
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
function forum_check_password($forum_fid)
|
|
|
297 |
{
|
|
|
298 |
$frame_top_target = html_get_top_frame_name();
|
|
|
299 |
|
|
|
300 |
if (!$db_forum_check_password = db_connect()) return false;
|
|
|
301 |
|
|
|
302 |
$webtag = get_webtag($webtag_search);
|
|
|
303 |
|
|
|
304 |
if (!is_numeric($forum_fid)) return false;
|
|
|
305 |
|
|
|
306 |
if ($forum_passhash = forum_get_password($forum_fid)) {
|
|
|
307 |
|
|
|
308 |
forum_get_saved_password($password, $passhash, $sesshash);
|
|
|
309 |
|
|
|
310 |
if ($sesshash == $forum_passhash) return true;
|
|
|
311 |
|
|
|
312 |
// If we got this far then the password verification failed or
|
|
|
313 |
// the user hasn't seen the password dialog before.
|
|
|
314 |
|
|
|
315 |
$lang = load_language_file();
|
|
|
316 |
|
|
|
317 |
html_draw_top();
|
|
|
318 |
|
|
|
319 |
echo "<h1>{$lang['passwdprotectedforum']}</h1>\n";
|
|
|
320 |
|
|
|
321 |
if (isset($_COOKIE["bh_{$webtag}_sesshash"]) && strlen(trim(_stripslashes($_COOKIE["bh_{$webtag}_sesshash"]))) > 0) {
|
|
|
322 |
|
|
|
323 |
bh_setcookie("bh_{$webtag}_sesshash", "", time() - YEAR_IN_SECONDS);
|
|
|
324 |
html_display_error_msg($lang['usernameorpasswdnotvalid'], '550', 'center');
|
|
|
325 |
}
|
|
|
326 |
|
|
|
327 |
echo "<br />\n";
|
|
|
328 |
echo "<div align=\"center\">\n";
|
|
|
329 |
echo " <form method=\"post\" action=\"forum_password.php\" target=\"", html_get_top_frame_name(), "\">\n";
|
|
|
330 |
echo " ", form_input_hidden('webtag', _htmlentities($webtag)), "\n";
|
|
|
331 |
echo " ", form_input_hidden('final_uri', _htmlentities(get_request_uri())), "\n";
|
|
|
332 |
echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"550\">\n";
|
|
|
333 |
|
|
|
334 |
if ($password_protected_message = forum_get_setting('password_protected_message', false)) {
|
|
|
335 |
|
|
|
336 |
echo " <tr>\n";
|
|
|
337 |
echo " <td align=\"left\">", fix_html($password_protected_message), "</td>\n";
|
|
|
338 |
echo " </tr>\n";
|
|
|
339 |
|
|
|
340 |
}else {
|
|
|
341 |
|
|
|
342 |
echo " <tr>\n";
|
|
|
343 |
echo " <td align=\"center\">{$lang['passwdprotectedwarning']}</td>\n";
|
|
|
344 |
echo " </tr>\n";
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
echo " <tr>\n";
|
|
|
348 |
echo " <td align=\"left\"> </td>\n";
|
|
|
349 |
echo " </tr>\n";
|
|
|
350 |
echo " <tr>\n";
|
|
|
351 |
echo " <td align=\"center\">\n";
|
|
|
352 |
echo " <table class=\"box\" width=\"400\">\n";
|
|
|
353 |
echo " <tr>\n";
|
|
|
354 |
echo " <td class=\"posthead\" align=\"center\">\n";
|
|
|
355 |
echo " <table class=\"posthead\" width=\"100%\">\n";
|
|
|
356 |
echo " <tr>\n";
|
|
|
357 |
echo " <td align=\"left\" class=\"subhead\" colspan=\"2\">{$lang['enterpasswd']}</td>\n";
|
|
|
358 |
echo " </tr>\n";
|
|
|
359 |
echo " </table>\n";
|
|
|
360 |
echo " <table class=\"posthead\" width=\"90%\">\n";
|
|
|
361 |
echo " <tr>\n";
|
|
|
362 |
echo " <td align=\"left\">{$lang['passwd']}:</td>\n";
|
|
|
363 |
echo " <td align=\"left\">", form_input_password('forum_password', _htmlentities($password), 40, false, "autocomplete=\"off\""), form_input_hidden("forum_passhash", _htmlentities($passhash)), "</td>\n";
|
|
|
364 |
echo " </tr>\n";
|
|
|
365 |
echo " <tr>\n";
|
|
|
366 |
echo " <td align=\"left\"> </td>\n";
|
|
|
367 |
echo " <td align=\"left\">", form_checkbox('remember_password', 'Y', $lang['rememberpassword'], (strlen($password) > 0 && strlen($passhash) > 0)), "</td>\n";
|
|
|
368 |
echo " </tr>\n";
|
|
|
369 |
echo " <tr>\n";
|
|
|
370 |
echo " <td align=\"left\" colspan=\"2\"> </td>\n";
|
|
|
371 |
echo " </tr>\n";
|
|
|
372 |
echo " </table>\n";
|
|
|
373 |
echo " </td>\n";
|
|
|
374 |
echo " </tr>\n";
|
|
|
375 |
echo " </table>\n";
|
|
|
376 |
echo " </td>\n";
|
|
|
377 |
echo " </tr>\n";
|
|
|
378 |
echo " <tr>\n";
|
|
|
379 |
echo " <td align=\"left\"> </td>\n";
|
|
|
380 |
echo " </tr>\n";
|
|
|
381 |
echo " <tr>\n";
|
|
|
382 |
echo " <td align=\"center\">", form_submit("submit", $lang['logon']), " ", form_submit("cancel", $lang['cancel']), "</td>\n";
|
|
|
383 |
echo " </tr>\n";
|
|
|
384 |
|
|
|
385 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
386 |
|
|
|
387 |
echo " <tr>\n";
|
|
|
388 |
echo " <td align=\"left\"> </td>\n";
|
|
|
389 |
echo " </tr>\n";
|
|
|
390 |
echo " <tr>\n";
|
|
|
391 |
echo " <td align=\"center\">{$lang['adminforumclosedtip']}</td>\n";
|
|
|
392 |
echo " </tr>\n";
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
echo " </table>\n";
|
|
|
396 |
echo " </form>\n";
|
|
|
397 |
echo "</div>\n";
|
|
|
398 |
|
|
|
399 |
html_draw_bottom();
|
|
|
400 |
exit;
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
return true;
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
function forum_get_settings()
|
|
|
407 |
{
|
|
|
408 |
if (!$db_forum_get_settings = db_connect()) return false;
|
|
|
409 |
|
|
|
410 |
static $forum_settings_array = false;
|
|
|
411 |
|
|
|
412 |
if (!$table_data = get_table_prefix()) return false;
|
|
|
413 |
|
|
|
414 |
$forum_fid = $table_data['FID'];
|
|
|
415 |
|
|
|
416 |
if (!is_array($forum_settings_array)) {
|
|
|
417 |
|
|
|
418 |
$forum_settings_array = array('fid' => $forum_fid);
|
|
|
419 |
|
|
|
420 |
// Get the named settings from FORUM_SETTINGS table.
|
|
|
421 |
|
|
|
422 |
$sql = "SELECT SNAME, SVALUE FROM FORUM_SETTINGS WHERE FID = '$forum_fid'";
|
|
|
423 |
|
|
|
424 |
if (!$result = db_query($sql, $db_forum_get_settings)) return false;
|
|
|
425 |
|
|
|
426 |
if (db_num_rows($result) > 0) {
|
|
|
427 |
|
|
|
428 |
if (!is_array($forum_settings_array)) $forum_settings_array = array();
|
|
|
429 |
|
|
|
430 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
431 |
|
|
|
432 |
$forum_settings_array[$forum_data['SNAME']] = $forum_data['SVALUE'];
|
|
|
433 |
}
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
// Get the forum timezone, GMT offset and DST offset.
|
|
|
437 |
|
|
|
438 |
$sql = "SELECT FORUM_SETTINGS.SVALUE, TIMEZONES.GMT_OFFSET, ";
|
|
|
439 |
$sql.= "TIMEZONES.DST_OFFSET FROM FORUM_SETTINGS FORUM_SETTINGS ";
|
|
|
440 |
$sql.= "LEFT JOIN TIMEZONES ON (TIMEZONES.TZID = FORUM_SETTINGS.SVALUE) ";
|
|
|
441 |
$sql.= "WHERE FORUM_SETTINGS.SNAME = 'forum_timezone' ";
|
|
|
442 |
$sql.= "AND FORUM_SETTINGS.FID = '$forum_fid'";
|
|
|
443 |
|
|
|
444 |
if (!$result = db_query($sql, $db_forum_get_settings)) return false;
|
|
|
445 |
|
|
|
446 |
if (db_num_rows($result) > 0) {
|
|
|
447 |
|
|
|
448 |
if (!is_array($forum_settings_array)) $forum_settings_array = array();
|
|
|
449 |
|
|
|
450 |
while ($forum_timezone_data = db_fetch_array($result)) {
|
|
|
451 |
|
|
|
452 |
$forum_settings_array['forum_timezone'] = $forum_timezone_data['SVALUE'];
|
|
|
453 |
$forum_settings_array['forum_gmt_offset'] = $forum_timezone_data['GMT_OFFSET'];
|
|
|
454 |
$forum_settings_array['forum_dst_offset'] = $forum_timezone_data['DST_OFFSET'];
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
// Get the WEBTAG and ACCESS_LEVEL
|
|
|
459 |
|
|
|
460 |
$sql = "SELECT WEBTAG, ACCESS_LEVEL FROM FORUMS WHERE FID = '$forum_fid'";
|
|
|
461 |
|
|
|
462 |
if (!$result = db_query($sql, $db_forum_get_settings)) return false;
|
|
|
463 |
|
|
|
464 |
list($webtag, $access_level) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
465 |
|
|
|
466 |
$forum_settings_array['webtag'] = $webtag;
|
|
|
467 |
$forum_settings_array['access_level'] = $access_level;
|
|
|
468 |
}
|
|
|
469 |
|
|
|
470 |
return $forum_settings_array;
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
function forum_get_global_settings()
|
|
|
474 |
{
|
|
|
475 |
if (!$db_forum_get_global_settings = db_connect()) return false;
|
|
|
476 |
|
|
|
477 |
static $forum_global_settings_array = false;
|
|
|
478 |
|
|
|
479 |
if (!is_array($forum_global_settings_array)) {
|
|
|
480 |
|
|
|
481 |
$sql = "SELECT SNAME, SVALUE FROM FORUM_SETTINGS WHERE FID = '0'";
|
|
|
482 |
|
|
|
483 |
if (!$result = db_query($sql, $db_forum_get_global_settings)) return false;
|
|
|
484 |
|
|
|
485 |
if (db_num_rows($result) > 0) {
|
|
|
486 |
|
|
|
487 |
if (!is_array($forum_global_settings_array)) $forum_global_settings_array = array();
|
|
|
488 |
|
|
|
489 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
490 |
|
|
|
491 |
$forum_global_settings_array[$forum_data['SNAME']] = $forum_data['SVALUE'];
|
|
|
492 |
}
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
$sql = "SELECT FORUM_SETTINGS.SVALUE, TIMEZONES.GMT_OFFSET, ";
|
|
|
496 |
$sql.= "TIMEZONES.DST_OFFSET FROM FORUM_SETTINGS FORUM_SETTINGS ";
|
|
|
497 |
$sql.= "LEFT JOIN TIMEZONES ON (TIMEZONES.TZID = FORUM_SETTINGS.SVALUE) ";
|
|
|
498 |
$sql.= "WHERE FORUM_SETTINGS.SNAME = 'forum_timezone' ";
|
|
|
499 |
$sql.= "AND FORUM_SETTINGS.FID = '0'";
|
|
|
500 |
|
|
|
501 |
if (!$result = db_query($sql, $db_forum_get_global_settings)) return false;
|
|
|
502 |
|
|
|
503 |
if (db_num_rows($result) > 0) {
|
|
|
504 |
|
|
|
505 |
if (!is_array($forum_global_settings_array)) $forum_global_settings_array = array();
|
|
|
506 |
|
|
|
507 |
while ($forum_timezone_data = db_fetch_array($result)) {
|
|
|
508 |
|
|
|
509 |
$forum_global_settings_array['forum_timezone'] = $forum_timezone_data['SVALUE'];
|
|
|
510 |
$forum_global_settings_array['forum_gmt_offset'] = $forum_timezone_data['GMT_OFFSET'];
|
|
|
511 |
$forum_global_settings_array['forum_dst_offset'] = $forum_timezone_data['DST_OFFSET'];
|
|
|
512 |
}
|
|
|
513 |
}
|
|
|
514 |
}
|
|
|
515 |
|
|
|
516 |
return $forum_global_settings_array;
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
function forum_get_settings_by_fid($fid, $include_global_settings = true)
|
|
|
520 |
{
|
|
|
521 |
if (!$db_forum_get_settings_by_fid = db_connect()) return false;
|
|
|
522 |
|
|
|
523 |
if (!is_numeric($fid)) return false;
|
|
|
524 |
|
|
|
525 |
$forum_settings_array = array('fid' => $fid);
|
|
|
526 |
|
|
|
527 |
$sql = "SELECT WEBTAG, ACCESS_LEVEL FROM FORUMS WHERE FID = '$fid'";
|
|
|
528 |
|
|
|
529 |
if (!$result = db_query($sql, $db_forum_get_settings_by_fid)) return false;
|
|
|
530 |
|
|
|
531 |
list($webtag, $access_level) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
532 |
|
|
|
533 |
$forum_settings_array['webtag'] = $webtag;
|
|
|
534 |
$forum_settings_array['access_level'] = $access_level;
|
|
|
535 |
|
|
|
536 |
$sql = "SELECT SNAME, SVALUE FROM FORUM_SETTINGS WHERE FID = '$fid'";
|
|
|
537 |
|
|
|
538 |
if (!$result = db_query($sql, $db_forum_get_settings_by_fid)) return false;
|
|
|
539 |
|
|
|
540 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
541 |
|
|
|
542 |
$forum_settings_array[$forum_data['SNAME']] = $forum_data['SVALUE'];
|
|
|
543 |
}
|
|
|
544 |
|
|
|
545 |
$sql = "SELECT FORUM_SETTINGS.SVALUE AS TIMEZONE, TIMEZONES.GMT_OFFSET, ";
|
|
|
546 |
$sql.= "TIMEZONES.DST_OFFSET FROM FORUM_SETTINGS FORUM_SETTINGS ";
|
|
|
547 |
$sql.= "LEFT JOIN TIMEZONES ON (TIMEZONES.TZID = FORUM_SETTINGS.SVALUE) ";
|
|
|
548 |
$sql.= "WHERE FORUM_SETTINGS.SNAME = 'forum_timezone' ";
|
|
|
549 |
$sql.= "AND FID = '$fid'";
|
|
|
550 |
|
|
|
551 |
if (!$result = db_query($sql, $db_forum_get_settings_by_fid)) return false;
|
|
|
552 |
|
|
|
553 |
list($timezone, $gmt_offset, $dst_offset) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
554 |
|
|
|
555 |
$forum_settings_array['forum_timezone'] = $timezone;
|
|
|
556 |
$forum_settings_array['forum_gmt_offset'] = $gmt_offset;
|
|
|
557 |
$forum_settings_array['forum_dst_offset'] = $dst_offset;
|
|
|
558 |
|
|
|
559 |
if ($include_global_settings === true) {
|
|
|
560 |
|
|
|
561 |
$forum_global_settings = forum_get_global_settings();
|
|
|
562 |
return array_merge($forum_global_settings, $forum_settings_array);
|
|
|
563 |
}
|
|
|
564 |
|
|
|
565 |
return $forum_settings_array;
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
function forum_save_settings($forum_settings_array)
|
|
|
569 |
{
|
|
|
570 |
if (!is_array($forum_settings_array)) return false;
|
|
|
571 |
|
|
|
572 |
if (!$db_forum_save_settings = db_connect()) return false;
|
|
|
573 |
|
|
|
574 |
if (!$table_data = get_table_prefix()) return false;
|
|
|
575 |
|
|
|
576 |
$forum_fid = $table_data['FID'];
|
|
|
577 |
|
|
|
578 |
foreach ($forum_settings_array as $sname => $svalue) {
|
|
|
579 |
|
|
|
580 |
if (forum_check_setting_name($sname)) {
|
|
|
581 |
|
|
|
582 |
$sname = db_escape_string($sname);
|
|
|
583 |
$svalue = db_escape_string($svalue);
|
|
|
584 |
|
|
|
585 |
$sql = "SELECT SVALUE FROM FORUM_SETTINGS WHERE FID = '$forum_fid' ";
|
|
|
586 |
$sql.= "AND SNAME = '$sname'";
|
|
|
587 |
|
|
|
588 |
if (!$result = db_query($sql, $db_forum_save_settings)) return false;
|
|
|
589 |
|
|
|
590 |
if (db_num_rows($result) > 0) {
|
|
|
591 |
|
|
|
592 |
$sql = "UPDATE LOW_PRIORITY FORUM_SETTINGS SET SVALUE = '$svalue' WHERE FID = '$forum_fid' ";
|
|
|
593 |
$sql.= "AND SNAME = '$sname'";
|
|
|
594 |
|
|
|
595 |
if (!$result = db_query($sql, $db_forum_save_settings)) return false;
|
|
|
596 |
|
|
|
597 |
}else {
|
|
|
598 |
|
|
|
599 |
$sql = "INSERT INTO FORUM_SETTINGS (FID, SNAME, SVALUE) ";
|
|
|
600 |
$sql.= "VALUES ($forum_fid, '$sname', '$svalue')";
|
|
|
601 |
|
|
|
602 |
if (!$result = db_query($sql, $db_forum_save_settings)) return false;
|
|
|
603 |
}
|
|
|
604 |
}
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
return true;
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
function forum_save_default_settings($forum_settings_array)
|
|
|
611 |
{
|
|
|
612 |
if (!is_array($forum_settings_array)) return false;
|
|
|
613 |
|
|
|
614 |
if (!$db_forum_save_default_settings = db_connect()) return false;
|
|
|
615 |
|
|
|
616 |
foreach ($forum_settings_array as $sname => $svalue) {
|
|
|
617 |
|
|
|
618 |
if (forum_check_global_setting_name($sname)) {
|
|
|
619 |
|
|
|
620 |
$sname = db_escape_string($sname);
|
|
|
621 |
$svalue = db_escape_string($svalue);
|
|
|
622 |
|
|
|
623 |
$sql = "SELECT SVALUE FROM FORUM_SETTINGS WHERE FID = '0' ";
|
|
|
624 |
$sql.= "AND SNAME = '$sname'";
|
|
|
625 |
|
|
|
626 |
if (!$result = db_query($sql, $db_forum_save_default_settings)) return false;
|
|
|
627 |
|
|
|
628 |
if (db_num_rows($result) > 0) {
|
|
|
629 |
|
|
|
630 |
$sql = "UPDATE LOW_PRIORITY FORUM_SETTINGS SET SVALUE = '$svalue' WHERE FID = '0' ";
|
|
|
631 |
$sql.= "AND SNAME = '$sname'";
|
|
|
632 |
|
|
|
633 |
if (!$result = db_query($sql, $db_forum_save_default_settings)) return false;
|
|
|
634 |
|
|
|
635 |
}else {
|
|
|
636 |
|
|
|
637 |
$sql = "INSERT INTO FORUM_SETTINGS (FID, SNAME, SVALUE) ";
|
|
|
638 |
$sql.= "VALUES ('0', '$sname', '$svalue')";
|
|
|
639 |
|
|
|
640 |
if (!$result = db_query($sql, $db_forum_save_default_settings)) return false;
|
|
|
641 |
}
|
|
|
642 |
}
|
|
|
643 |
}
|
|
|
644 |
|
|
|
645 |
return true;
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
function forum_check_setting_name($setting_name)
|
|
|
649 |
{
|
|
|
650 |
$valid_forum_settings = array('allow_polls', 'allow_post_editing', 'allow_search_spidering',
|
|
|
651 |
'closed_message', 'default_emoticons', 'default_language',
|
|
|
652 |
'default_style', 'enable_wiki_integration', 'enable_wiki_quick_links',
|
|
|
653 |
'force_word_filter', 'forum_desc', 'forum_dl_saving', 'forum_email',
|
|
|
654 |
'forum_keywords', 'forum_name', 'forum_timezone', 'guest_account_enabled',
|
|
|
655 |
'guest_show_recent', 'maximum_post_length', 'minimum_post_frequency',
|
|
|
656 |
'password_protected_message', 'poll_allow_guests', 'post_edit_grace_period',
|
|
|
657 |
'post_edit_time', 'require_post_approval', 'restricted_message', 'show_links',
|
|
|
658 |
'show_stats', 'wiki_integration_uri');
|
|
|
659 |
|
|
|
660 |
return in_array($setting_name, $valid_forum_settings);
|
|
|
661 |
}
|
|
|
662 |
|
|
|
663 |
function forum_check_global_setting_name($setting_name)
|
|
|
664 |
{
|
|
|
665 |
$valid_global_forum_settings = array('active_sess_cutoff', 'allow_new_registrations', 'allow_search_spidering',
|
|
|
666 |
'allow_username_changes', 'attachments_allow_embed', 'attachments_enabled',
|
|
|
667 |
'attachments_max_user_space', 'attachment_allow_guests', 'attachment_dir',
|
|
|
668 |
'attachment_use_old_method', 'forum_desc', 'forum_email',
|
|
|
669 |
'forum_keywords', 'forum_name', 'forum_noreply_email',
|
|
|
670 |
'forum_rules_enabled', 'forum_rules_message', 'guest_account_enabled',
|
|
|
671 |
'guest_show_recent', 'messages_unread_cutoff', 'messages_unread_cutoff_custom',
|
|
|
672 |
'new_user_email_notify', 'new_user_mark_as_of_int', 'new_user_pm_notify_email',
|
|
|
673 |
'pm_allow_attachments', 'pm_auto_prune', 'pm_max_user_messages',
|
|
|
674 |
'require_email_confirmation', 'require_unique_email', 'require_user_approval',
|
|
|
675 |
'search_min_frequency', 'session_cutoff', 'showpopuponnewpm', 'show_pms',
|
|
|
676 |
'text_captcha_dir', 'text_captcha_enabled', 'text_captcha_key');
|
|
|
677 |
|
|
|
678 |
return in_array($setting_name, $valid_global_forum_settings);
|
|
|
679 |
}
|
|
|
680 |
|
|
|
681 |
function forum_get_name($fid)
|
|
|
682 |
{
|
|
|
683 |
if (!$db_forum_get_name = db_connect()) return false;
|
|
|
684 |
|
|
|
685 |
if (!is_numeric($fid)) return "A Beehive Forum";
|
|
|
686 |
|
|
|
687 |
$sql = "SELECT SVALUE AS FORUM_NAME FROM FORUM_SETTINGS ";
|
|
|
688 |
$sql.= "WHERE SNAME = 'forum_name' AND FID = '$fid'";
|
|
|
689 |
|
|
|
690 |
if (!$result = db_query($sql, $db_forum_get_name)) return false;
|
|
|
691 |
|
|
|
692 |
if (db_num_rows($result) > 0) {
|
|
|
693 |
|
|
|
694 |
list($forum_name) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
695 |
return $forum_name;
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
return "A Beehive Forum";
|
|
|
699 |
}
|
|
|
700 |
|
|
|
701 |
function forum_get_webtag($fid)
|
|
|
702 |
{
|
|
|
703 |
if (!$db_forum_get_webtag = db_connect()) return false;
|
|
|
704 |
|
|
|
705 |
if (!is_numeric($fid)) return false;
|
|
|
706 |
|
|
|
707 |
$sql = "SELECT WEBTAG FROM FORUMS WHERE FID = '$fid'";
|
|
|
708 |
|
|
|
709 |
if (!$result = db_query($sql, $db_forum_get_webtag)) return false;
|
|
|
710 |
|
|
|
711 |
if (db_num_rows($result) > 0) {
|
|
|
712 |
|
|
|
713 |
list($forum_webtag) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
714 |
return $forum_webtag;
|
|
|
715 |
}
|
|
|
716 |
|
|
|
717 |
return false;
|
|
|
718 |
}
|
|
|
719 |
|
|
|
720 |
function forum_get_table_prefix($fid)
|
|
|
721 |
{
|
|
|
722 |
if (!$db_forum_get_webtag = db_connect()) return false;
|
|
|
723 |
|
|
|
724 |
if (!is_numeric($fid)) return false;
|
|
|
725 |
|
|
|
726 |
$sql = "SELECT CONCAT(FORUMS.DATABASE_NAME, '.', FORUMS.WEBTAG, '_') AS PREFIX, ";
|
|
|
727 |
$sql.= "FID, WEBTAG FROM FORUMS WHERE FID = '$fid'";
|
|
|
728 |
|
|
|
729 |
if (!$result = db_query($sql, $db_forum_get_webtag)) return false;
|
|
|
730 |
|
|
|
731 |
if (db_num_rows($result) > 0) {
|
|
|
732 |
|
|
|
733 |
$forum_data = db_fetch_array($result);
|
|
|
734 |
return $forum_data;
|
|
|
735 |
}
|
|
|
736 |
|
|
|
737 |
return false;
|
|
|
738 |
}
|
|
|
739 |
|
|
|
740 |
function forum_get_setting($setting_name, $value = false, $default = false)
|
|
|
741 |
{
|
|
|
742 |
$forum_settings = (isset($GLOBALS['forum_settings'])) ? $GLOBALS['forum_settings'] : false;
|
|
|
743 |
$forum_global_settings = (isset($GLOBALS['forum_global_settings'])) ? $GLOBALS['forum_global_settings'] : false;
|
|
|
744 |
|
|
|
745 |
if (is_array($forum_settings) && isset($forum_settings[$setting_name])) {
|
|
|
746 |
|
|
|
747 |
if ($value !== false) {
|
|
|
748 |
|
|
|
749 |
if (strtoupper($forum_settings[$setting_name]) == strtoupper($value)) {
|
|
|
750 |
|
|
|
751 |
return true;
|
|
|
752 |
}
|
|
|
753 |
|
|
|
754 |
}else {
|
|
|
755 |
|
|
|
756 |
return $forum_settings[$setting_name];
|
|
|
757 |
}
|
|
|
758 |
}
|
|
|
759 |
|
|
|
760 |
if (is_array($forum_global_settings) && isset($forum_global_settings[$setting_name])) {
|
|
|
761 |
|
|
|
762 |
if ($value !== false) {
|
|
|
763 |
|
|
|
764 |
if (strtoupper($forum_global_settings[$setting_name]) == strtoupper($value)) {
|
|
|
765 |
|
|
|
766 |
return true;
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
}else {
|
|
|
770 |
|
|
|
771 |
return $forum_global_settings[$setting_name];
|
|
|
772 |
}
|
|
|
773 |
}
|
|
|
774 |
|
|
|
775 |
return $default;
|
|
|
776 |
}
|
|
|
777 |
|
|
|
778 |
/**
|
|
|
779 |
* Get Unread Cutoff
|
|
|
780 |
*
|
|
|
781 |
* Retrieves and validates the current forum's unread cut-off value.
|
|
|
782 |
*
|
|
|
783 |
* @return mixed - False if unread messages are disabled or integer number of seconds the cut-off is set to.
|
|
|
784 |
* @param void
|
|
|
785 |
*/
|
|
|
786 |
|
|
|
787 |
function forum_get_unread_cutoff()
|
|
|
788 |
{
|
|
|
789 |
// Array of valid Unread cutoff periods.
|
|
|
790 |
|
|
|
791 |
$unread_cutoff_periods = array(THIRTY_DAYS_IN_SECONDS, SIXTY_DAYS_IN_SECONDS,
|
|
|
792 |
NINETY_DAYS_IN_SECONDS, HUNDRED_EIGHTY_DAYS_IN_SECONDS,
|
|
|
793 |
YEAR_IN_SECONDS);
|
|
|
794 |
|
|
|
795 |
// Fetch the unread cutoff value
|
|
|
796 |
|
|
|
797 |
$messages_unread_cutoff = forum_get_setting('messages_unread_cutoff');
|
|
|
798 |
|
|
|
799 |
// If unread message support is disabled we return false.
|
|
|
800 |
|
|
|
801 |
if ($messages_unread_cutoff == UNREAD_MESSAGES_DISABLED) return false;
|
|
|
802 |
|
|
|
803 |
// If unread message support isn't disabled we should check that
|
|
|
804 |
// It is a valid value and return it or return the default of one year.
|
|
|
805 |
|
|
|
806 |
return in_array($messages_unread_cutoff, $unread_cutoff_periods) ? $messages_unread_cutoff : YEAR_IN_SECONDS;
|
|
|
807 |
}
|
|
|
808 |
|
|
|
809 |
/**
|
|
|
810 |
* Process Unread Cutoff
|
|
|
811 |
*
|
|
|
812 |
* Processes and validates a forum unread cut-off value saved in a settings array.
|
|
|
813 |
* Works the same as forum_get_unread_cutoff() but is intended to be passed an
|
|
|
814 |
* array of forum settings from forum_get_settings() or other.
|
|
|
815 |
*
|
|
|
816 |
* @return mixed - False if unread messages are disabled or integer number of seconds the cut-off is set to.
|
|
|
817 |
* @param void
|
|
|
818 |
*/
|
|
|
819 |
|
|
|
820 |
function forum_process_unread_cutoff($forum_settings)
|
|
|
821 |
{
|
|
|
822 |
// Check the $forum_settings array.
|
|
|
823 |
|
|
|
824 |
if (!is_array($forum_settings)) return YEAR_IN_SECONDS;
|
|
|
825 |
|
|
|
826 |
// Array of valid Unread cutoff periods.
|
|
|
827 |
|
|
|
828 |
$unread_cutoff_periods = array(THIRTY_DAYS_IN_SECONDS, SIXTY_DAYS_IN_SECONDS,
|
|
|
829 |
NINETY_DAYS_IN_SECONDS, HUNDRED_EIGHTY_DAYS_IN_SECONDS,
|
|
|
830 |
YEAR_IN_SECONDS);
|
|
|
831 |
|
|
|
832 |
// Fetch the unread cutoff value from the settings array
|
|
|
833 |
|
|
|
834 |
if (isset($forum_settings['messages_unread_cutoff'])) {
|
|
|
835 |
$messages_unread_cutoff = $forum_settings['messages_unread_cutoff'];
|
|
|
836 |
}else {
|
|
|
837 |
$messages_unread_cutoff = YEAR_IN_SECONDS;
|
|
|
838 |
}
|
|
|
839 |
|
|
|
840 |
// If unread message support is disabled we return false.
|
|
|
841 |
|
|
|
842 |
if ($messages_unread_cutoff == UNREAD_MESSAGES_DISABLED) return false;
|
|
|
843 |
|
|
|
844 |
// If unread message support isn't disabled we should check that
|
|
|
845 |
// It is a valid value and return it or return the default of one year.
|
|
|
846 |
|
|
|
847 |
return in_array($messages_unread_cutoff, $unread_cutoff_periods) ? $messages_unread_cutoff : YEAR_IN_SECONDS;
|
|
|
848 |
}
|
|
|
849 |
|
|
|
850 |
function forum_update_unread_data($unread_cutoff_stamp)
|
|
|
851 |
{
|
|
|
852 |
if (!$db_forum_update_unread_data = db_connect()) return false;
|
|
|
853 |
|
|
|
854 |
if (!$table_data = get_table_prefix()) return false;
|
|
|
855 |
|
|
|
856 |
if (!is_numeric($unread_cutoff_stamp)) return false;
|
|
|
857 |
|
|
|
858 |
if ($unread_cutoff_stamp > 0) {
|
|
|
859 |
|
|
|
860 |
if ($forum_prefix_array = forum_get_all_prefixes()) {
|
|
|
861 |
|
|
|
862 |
foreach($forum_prefix_array as $forum_prefix) {
|
|
|
863 |
|
|
|
864 |
$sql = "INSERT INTO {$forum_prefix}THREAD_STATS (TID, UNREAD_PID, UNREAD_CREATED) ";
|
|
|
865 |
$sql.= "SELECT POST.TID, MAX(POST.PID), MAX(POST.CREATED) FROM {$forum_prefix}POST POST ";
|
|
|
866 |
$sql.= "LEFT JOIN {$forum_prefix}THREAD_STATS THREAD_STATS ON (THREAD_STATS.TID = POST.TID) ";
|
|
|
867 |
$sql.= "WHERE POST.CREATED < FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - $unread_cutoff_stamp) ";
|
|
|
868 |
$sql.= "AND (THREAD_STATS.UNREAD_PID < POST.PID OR THREAD_STATS.UNREAD_PID IS NULL) ";
|
|
|
869 |
$sql.= "GROUP BY POST.TID ON DUPLICATE KEY UPDATE UNREAD_PID = VALUES(UNREAD_PID), ";
|
|
|
870 |
$sql.= "UNREAD_CREATED = VALUES(UNREAD_CREATED)";
|
|
|
871 |
|
|
|
872 |
if (!$result = db_query($sql, $db_forum_update_unread_data)) return false;
|
|
|
873 |
|
|
|
874 |
$sql = "DELETE QUICK FROM {$forum_prefix}USER_THREAD ";
|
|
|
875 |
$sql.= "USING {$forum_prefix}USER_THREAD ";
|
|
|
876 |
$sql.= "LEFT JOIN {$forum_prefix}THREAD ";
|
|
|
877 |
$sql.= "ON ({$forum_prefix}USER_THREAD.TID = ";
|
|
|
878 |
$sql.= "{$forum_prefix}THREAD.TID) ";
|
|
|
879 |
$sql.= "WHERE {$forum_prefix}THREAD.MODIFIED IS NOT NULL ";
|
|
|
880 |
$sql.= "AND {$forum_prefix}THREAD.MODIFIED < ";
|
|
|
881 |
$sql.= "FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - $unread_cutoff_stamp) ";
|
|
|
882 |
$sql.= "AND ({$forum_prefix}USER_THREAD.INTEREST IS NULL ";
|
|
|
883 |
$sql.= "OR {$forum_prefix}USER_THREAD.INTEREST = 0) ";
|
|
|
884 |
|
|
|
885 |
if (!$result = db_query($sql, $db_forum_update_unread_data)) return false;
|
|
|
886 |
}
|
|
|
887 |
}
|
|
|
888 |
}
|
|
|
889 |
|
|
|
890 |
return true;
|
|
|
891 |
}
|
|
|
892 |
|
|
|
893 |
function forum_load_start_page()
|
|
|
894 |
{
|
|
|
895 |
$webtag = get_webtag($webtag_search);
|
|
|
896 |
|
|
|
897 |
if (@file_exists("forums/$webtag/start_main.php")) {
|
|
|
898 |
|
|
|
899 |
$filesize = filesize("forums/$webtag/start_main.php");
|
|
|
900 |
|
|
|
901 |
if ($filesize > 0 && @$fp = fopen("forums/$webtag/start_main.php", "r")) {
|
|
|
902 |
|
|
|
903 |
$content = fread($fp, $filesize);
|
|
|
904 |
fclose($fp);
|
|
|
905 |
return $content;
|
|
|
906 |
}
|
|
|
907 |
}
|
|
|
908 |
|
|
|
909 |
return false;
|
|
|
910 |
}
|
|
|
911 |
|
|
|
912 |
function forum_start_page_get_html($content)
|
|
|
913 |
{
|
|
|
914 |
ob_start();
|
|
|
915 |
|
|
|
916 |
html_draw_top();
|
|
|
917 |
echo $content;
|
|
|
918 |
html_draw_bottom();
|
|
|
919 |
|
|
|
920 |
$content = ob_get_contents();
|
|
|
921 |
|
|
|
922 |
ob_end_clean();
|
|
|
923 |
|
|
|
924 |
return word_filter_rem_ob_tags($content);
|
|
|
925 |
}
|
|
|
926 |
|
|
|
927 |
function forum_save_start_page($content)
|
|
|
928 |
{
|
|
|
929 |
$webtag = get_webtag($webtag_search);
|
|
|
930 |
|
|
|
931 |
if (@!is_dir("forums")) @mkdir("forums", 0755);
|
|
|
932 |
if (@!is_dir("forums/$webtag")) @mkdir("forums/$webtag", 0755);
|
|
|
933 |
|
|
|
934 |
$content = forum_start_page_get_html($content);
|
|
|
935 |
|
|
|
936 |
if (@$fp = fopen("forums/$webtag/start_main.php", "w")) {
|
|
|
937 |
|
|
|
938 |
fwrite($fp, $content);
|
|
|
939 |
fclose($fp);
|
|
|
940 |
|
|
|
941 |
return true;
|
|
|
942 |
}
|
|
|
943 |
|
|
|
944 |
return false;
|
|
|
945 |
}
|
|
|
946 |
|
|
|
947 |
function forum_create($webtag, $forum_name, $owner_uid, $database_name, $access, &$error_str)
|
|
|
948 |
{
|
|
|
949 |
// Load the language
|
|
|
950 |
|
|
|
951 |
$lang = load_language_file();
|
|
|
952 |
|
|
|
953 |
// Ensure the variables we've been given are valid
|
|
|
954 |
|
|
|
955 |
if (!preg_match("/^[A-Z]{1}[A-Z0-9_]+$/", $webtag)) return false;
|
|
|
956 |
if (!preg_match("/^[A-Z]{1}[A-Z0-9_]+$/i", $database_name)) return false;
|
|
|
957 |
|
|
|
958 |
if (!is_numeric($owner_uid)) $owner_uid = 0;
|
|
|
959 |
if (!is_numeric($access)) $access = 0;
|
|
|
960 |
|
|
|
961 |
// Only users with acces to the forum tools can create / delete forums.
|
|
|
962 |
|
|
|
963 |
if (bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
964 |
|
|
|
965 |
if (($uid = bh_session_get_value('UID')) === false) return false;
|
|
|
966 |
|
|
|
967 |
if (!$db_forum_create = db_connect()) return false;
|
|
|
968 |
|
|
|
969 |
// Check that the WEBTAG is unique.
|
|
|
970 |
|
|
|
971 |
$sql = "SELECT FID FROM FORUMS WHERE WEBTAG = '$webtag'";
|
|
|
972 |
|
|
|
973 |
if (!$result = @db_query($sql, $db_forum_create)) return false;
|
|
|
974 |
|
|
|
975 |
if (db_num_rows($result) > 0) {
|
|
|
976 |
|
|
|
977 |
$error_str = $lang['selectedwebtagisalreadyinuse'];
|
|
|
978 |
return false;
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
// Check for any conflicting tables.
|
|
|
982 |
|
|
|
983 |
if ($conflicting_tables_array = install_get_table_conflicts($webtag, true, false)) {
|
|
|
984 |
|
|
|
985 |
$error_str = $lang['selecteddatabasecontainsconflictingtables'];
|
|
|
986 |
$error_str.= sprintf("<p>%s</p>\n", implode(", ", $conflicting_tables_array));
|
|
|
987 |
|
|
|
988 |
return false;
|
|
|
989 |
}
|
|
|
990 |
|
|
|
991 |
// Create the tables
|
|
|
992 |
|
|
|
993 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_ADMIN_LOG (";
|
|
|
994 |
$sql.= " ID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
995 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
996 |
$sql.= " CREATED DATETIME DEFAULT NULL,";
|
|
|
997 |
$sql.= " ACTION MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
998 |
$sql.= " ENTRY TEXT,";
|
|
|
999 |
$sql.= " PRIMARY KEY (ID)";
|
|
|
1000 |
$sql.= ") TYPE=MYISAM";
|
|
|
1001 |
|
|
|
1002 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1003 |
|
|
|
1004 |
forum_delete_tables($webtag, $database_name);
|
|
|
1005 |
|
|
|
1006 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1007 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1008 |
}
|
|
|
1009 |
|
|
|
1010 |
return;
|
|
|
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_BANNED (";
|
|
|
1014 |
$sql.= " ID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1015 |
$sql.= " BANTYPE TINYINT(4) NOT NULL DEFAULT '0',";
|
|
|
1016 |
$sql.= " BANDATA VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1017 |
$sql.= " COMMENT VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1018 |
$sql.= " PRIMARY KEY (ID)";
|
|
|
1019 |
$sql.= ") TYPE=MYISAM";
|
|
|
1020 |
|
|
|
1021 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1022 |
|
|
|
1023 |
forum_delete_tables($webtag, $database_name);
|
|
|
1024 |
|
|
|
1025 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1026 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1027 |
}
|
|
|
1028 |
|
|
|
1029 |
return;
|
|
|
1030 |
}
|
|
|
1031 |
|
|
|
1032 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_FOLDER (";
|
|
|
1033 |
$sql.= " FID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1034 |
$sql.= " TITLE VARCHAR(32) DEFAULT NULL,";
|
|
|
1035 |
$sql.= " DESCRIPTION VARCHAR(255) DEFAULT NULL,";
|
|
|
1036 |
$sql.= " PREFIX VARCHAR(16) DEFAULT NULL,";
|
|
|
1037 |
$sql.= " ALLOWED_TYPES TINYINT(3) DEFAULT NULL,";
|
|
|
1038 |
$sql.= " POSITION MEDIUMINT(8) UNSIGNED DEFAULT '0',";
|
|
|
1039 |
$sql.= " PRIMARY KEY (FID)";
|
|
|
1040 |
$sql.= ") TYPE=MYISAM";
|
|
|
1041 |
|
|
|
1042 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1043 |
|
|
|
1044 |
forum_delete_tables($webtag, $database_name);
|
|
|
1045 |
|
|
|
1046 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1047 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1048 |
}
|
|
|
1049 |
|
|
|
1050 |
return;
|
|
|
1051 |
}
|
|
|
1052 |
|
|
|
1053 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_FORUM_LINKS (";
|
|
|
1054 |
$sql.= " LID SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1055 |
$sql.= " POS MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1056 |
$sql.= " URI VARCHAR(255) DEFAULT NULL,";
|
|
|
1057 |
$sql.= " TITLE VARCHAR(64) DEFAULT NULL,";
|
|
|
1058 |
$sql.= " PRIMARY KEY (LID)";
|
|
|
1059 |
$sql.= ") TYPE=MYISAM";
|
|
|
1060 |
|
|
|
1061 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1062 |
|
|
|
1063 |
forum_delete_tables($webtag, $database_name);
|
|
|
1064 |
|
|
|
1065 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1066 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
return;
|
|
|
1070 |
}
|
|
|
1071 |
|
|
|
1072 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_LINKS (";
|
|
|
1073 |
$sql.= " LID SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1074 |
$sql.= " FID SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1075 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1076 |
$sql.= " URI VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1077 |
$sql.= " TITLE VARCHAR(64) NOT NULL DEFAULT '',";
|
|
|
1078 |
$sql.= " DESCRIPTION TEXT NOT NULL,";
|
|
|
1079 |
$sql.= " CREATED DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1080 |
$sql.= " VISIBLE CHAR(1) NOT NULL DEFAULT 'N',";
|
|
|
1081 |
$sql.= " CLICKS MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1082 |
$sql.= " PRIMARY KEY (LID)";
|
|
|
1083 |
$sql.= ") TYPE=MYISAM";
|
|
|
1084 |
|
|
|
1085 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1086 |
|
|
|
1087 |
forum_delete_tables($webtag, $database_name);
|
|
|
1088 |
|
|
|
1089 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1090 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1091 |
}
|
|
|
1092 |
|
|
|
1093 |
return;
|
|
|
1094 |
}
|
|
|
1095 |
|
|
|
1096 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_LINKS_COMMENT (";
|
|
|
1097 |
$sql.= " CID SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1098 |
$sql.= " LID SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1099 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1100 |
$sql.= " CREATED DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1101 |
$sql.= " COMMENT TEXT NOT NULL,";
|
|
|
1102 |
$sql.= " PRIMARY KEY (CID)";
|
|
|
1103 |
$sql.= ") TYPE=MYISAM";
|
|
|
1104 |
|
|
|
1105 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1106 |
|
|
|
1107 |
forum_delete_tables($webtag, $database_name);
|
|
|
1108 |
|
|
|
1109 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1110 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1111 |
}
|
|
|
1112 |
|
|
|
1113 |
return;
|
|
|
1114 |
}
|
|
|
1115 |
|
|
|
1116 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_LINKS_FOLDERS (";
|
|
|
1117 |
$sql.= " FID SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1118 |
$sql.= " PARENT_FID SMALLINT(5) UNSIGNED DEFAULT NULL,";
|
|
|
1119 |
$sql.= " NAME VARCHAR(32) NOT NULL DEFAULT '',";
|
|
|
1120 |
$sql.= " VISIBLE CHAR(1) NOT NULL DEFAULT '',";
|
|
|
1121 |
$sql.= " PRIMARY KEY (FID)";
|
|
|
1122 |
$sql.= ") TYPE=MYISAM";
|
|
|
1123 |
|
|
|
1124 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1125 |
|
|
|
1126 |
forum_delete_tables($webtag, $database_name);
|
|
|
1127 |
|
|
|
1128 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1129 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1130 |
}
|
|
|
1131 |
|
|
|
1132 |
return;
|
|
|
1133 |
}
|
|
|
1134 |
|
|
|
1135 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_LINKS_VOTE (";
|
|
|
1136 |
$sql.= " LID SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1137 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1138 |
$sql.= " RATING SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1139 |
$sql.= " TSTAMP DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1140 |
$sql.= " PRIMARY KEY (LID,UID)";
|
|
|
1141 |
$sql.= ") TYPE=MYISAM";
|
|
|
1142 |
|
|
|
1143 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1144 |
|
|
|
1145 |
forum_delete_tables($webtag, $database_name);
|
|
|
1146 |
|
|
|
1147 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1148 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1149 |
}
|
|
|
1150 |
|
|
|
1151 |
return;
|
|
|
1152 |
}
|
|
|
1153 |
|
|
|
1154 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_POLL (";
|
|
|
1155 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1156 |
$sql.= " QUESTION VARCHAR(64) DEFAULT NULL,";
|
|
|
1157 |
$sql.= " CLOSES DATETIME DEFAULT NULL,";
|
|
|
1158 |
$sql.= " CHANGEVOTE TINYINT(1) NOT NULL DEFAULT '1',";
|
|
|
1159 |
$sql.= " POLLTYPE TINYINT(1) NOT NULL DEFAULT '0',";
|
|
|
1160 |
$sql.= " SHOWRESULTS TINYINT(1) NOT NULL DEFAULT '1',";
|
|
|
1161 |
$sql.= " VOTETYPE TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1162 |
$sql.= " OPTIONTYPE TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1163 |
$sql.= " ALLOWGUESTS TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1164 |
$sql.= " PRIMARY KEY (TID)";
|
|
|
1165 |
$sql.= ") TYPE=MYISAM";
|
|
|
1166 |
|
|
|
1167 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1168 |
|
|
|
1169 |
forum_delete_tables($webtag, $database_name);
|
|
|
1170 |
|
|
|
1171 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1172 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1173 |
}
|
|
|
1174 |
|
|
|
1175 |
return;
|
|
|
1176 |
}
|
|
|
1177 |
|
|
|
1178 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_POLL_VOTES (";
|
|
|
1179 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1180 |
$sql.= " OPTION_ID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1181 |
$sql.= " OPTION_NAME CHAR(255) NOT NULL DEFAULT '',";
|
|
|
1182 |
$sql.= " GROUP_ID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1183 |
$sql.= " PRIMARY KEY (TID,OPTION_ID)";
|
|
|
1184 |
$sql.= ") TYPE=MYISAM";
|
|
|
1185 |
|
|
|
1186 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1187 |
|
|
|
1188 |
forum_delete_tables($webtag, $database_name);
|
|
|
1189 |
|
|
|
1190 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1191 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1192 |
}
|
|
|
1193 |
|
|
|
1194 |
return;
|
|
|
1195 |
}
|
|
|
1196 |
|
|
|
1197 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_POST (";
|
|
|
1198 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1199 |
$sql.= " PID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1200 |
$sql.= " REPLY_TO_PID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1201 |
$sql.= " FROM_UID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1202 |
$sql.= " TO_UID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1203 |
$sql.= " VIEWED DATETIME DEFAULT NULL,";
|
|
|
1204 |
$sql.= " CREATED DATETIME DEFAULT NULL,";
|
|
|
1205 |
$sql.= " STATUS TINYINT(4) DEFAULT '0',";
|
|
|
1206 |
$sql.= " APPROVED DATETIME DEFAULT NULL,";
|
|
|
1207 |
$sql.= " APPROVED_BY MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1208 |
$sql.= " EDITED DATETIME DEFAULT NULL,";
|
|
|
1209 |
$sql.= " EDITED_BY MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1210 |
$sql.= " IPADDRESS VARCHAR(15) NOT NULL DEFAULT '',";
|
|
|
1211 |
$sql.= " MOVED_TID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1212 |
$sql.= " MOVED_PID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1213 |
$sql.= " PRIMARY KEY (TID,PID),";
|
|
|
1214 |
$sql.= " KEY TO_UID (TO_UID),";
|
|
|
1215 |
$sql.= " KEY FROM_UID (FROM_UID),";
|
|
|
1216 |
$sql.= " KEY IPADDRESS (IPADDRESS, FROM_UID),";
|
|
|
1217 |
$sql.= " KEY CREATED (CREATED),";
|
|
|
1218 |
$sql.= " KEY APPROVED (APPROVED)";
|
|
|
1219 |
$sql.= ") TYPE=MYISAM";
|
|
|
1220 |
|
|
|
1221 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1222 |
|
|
|
1223 |
forum_delete_tables($webtag, $database_name);
|
|
|
1224 |
|
|
|
1225 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1226 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1227 |
}
|
|
|
1228 |
|
|
|
1229 |
return;
|
|
|
1230 |
}
|
|
|
1231 |
|
|
|
1232 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_POST_CONTENT (";
|
|
|
1233 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1234 |
$sql.= " PID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1235 |
$sql.= " CONTENT TEXT,";
|
|
|
1236 |
$sql.= " PRIMARY KEY (TID,PID),";
|
|
|
1237 |
$sql.= " FULLTEXT KEY CONTENT (CONTENT)";
|
|
|
1238 |
$sql.= ") TYPE=MYISAM";
|
|
|
1239 |
|
|
|
1240 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1241 |
|
|
|
1242 |
forum_delete_tables($webtag, $database_name);
|
|
|
1243 |
|
|
|
1244 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1245 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1246 |
}
|
|
|
1247 |
|
|
|
1248 |
return;
|
|
|
1249 |
}
|
|
|
1250 |
|
|
|
1251 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_PROFILE_ITEM (";
|
|
|
1252 |
$sql.= " PIID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1253 |
$sql.= " PSID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1254 |
$sql.= " NAME VARCHAR(64) DEFAULT NULL,";
|
|
|
1255 |
$sql.= " TYPE TINYINT(3) UNSIGNED DEFAULT '0',";
|
|
|
1256 |
$sql.= " OPTIONS TEXT NOT NULL, ";
|
|
|
1257 |
$sql.= " POSITION MEDIUMINT(3) UNSIGNED DEFAULT '0',";
|
|
|
1258 |
$sql.= " PRIMARY KEY (PIID)";
|
|
|
1259 |
$sql.= ") TYPE=MYISAM";
|
|
|
1260 |
|
|
|
1261 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1262 |
|
|
|
1263 |
forum_delete_tables($webtag, $database_name);
|
|
|
1264 |
|
|
|
1265 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1266 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1267 |
}
|
|
|
1268 |
|
|
|
1269 |
return;
|
|
|
1270 |
}
|
|
|
1271 |
|
|
|
1272 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_ITEM ";
|
|
|
1273 |
$sql.= "(PSID, NAME, TYPE, OPTIONS, POSITION) ";
|
|
|
1274 |
$sql.= "VALUES (1, 'Location', 0, '', 1)";
|
|
|
1275 |
|
|
|
1276 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1277 |
|
|
|
1278 |
forum_delete_tables($webtag, $database_name);
|
|
|
1279 |
|
|
|
1280 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1281 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1282 |
}
|
|
|
1283 |
|
|
|
1284 |
return;
|
|
|
1285 |
}
|
|
|
1286 |
|
|
|
1287 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_ITEM ";
|
|
|
1288 |
$sql.= "(PSID, NAME, TYPE, OPTIONS, POSITION) ";
|
|
|
1289 |
$sql.= "VALUES (1, 'Age', 0, '', 2)";
|
|
|
1290 |
|
|
|
1291 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1292 |
|
|
|
1293 |
forum_delete_tables($webtag, $database_name);
|
|
|
1294 |
|
|
|
1295 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1296 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1297 |
}
|
|
|
1298 |
|
|
|
1299 |
return;
|
|
|
1300 |
}
|
|
|
1301 |
|
|
|
1302 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_ITEM ";
|
|
|
1303 |
$sql.= "(PSID, NAME, TYPE, OPTIONS, POSITION) VALUES ";
|
|
|
1304 |
$sql.= "(1, 'Gender', 5, 'Male\nFemale\nUnspecified', 3)";
|
|
|
1305 |
|
|
|
1306 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1307 |
|
|
|
1308 |
forum_delete_tables($webtag, $database_name);
|
|
|
1309 |
|
|
|
1310 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1311 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1312 |
}
|
|
|
1313 |
|
|
|
1314 |
return;
|
|
|
1315 |
}
|
|
|
1316 |
|
|
|
1317 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_ITEM ";
|
|
|
1318 |
$sql.= "(PSID, NAME, TYPE, OPTIONS, POSITION) ";
|
|
|
1319 |
$sql.= "VALUES (1, 'Quote', 0, '', 4)";
|
|
|
1320 |
|
|
|
1321 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1322 |
|
|
|
1323 |
forum_delete_tables($webtag, $database_name);
|
|
|
1324 |
|
|
|
1325 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1326 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1327 |
}
|
|
|
1328 |
|
|
|
1329 |
return;
|
|
|
1330 |
}
|
|
|
1331 |
|
|
|
1332 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_ITEM ";
|
|
|
1333 |
$sql.= "(PSID, NAME, TYPE, OPTIONS, POSITION) ";
|
|
|
1334 |
$sql.= "VALUES (1, 'Occupation', 0, '', 5)";
|
|
|
1335 |
|
|
|
1336 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1337 |
|
|
|
1338 |
forum_delete_tables($webtag, $database_name);
|
|
|
1339 |
|
|
|
1340 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1341 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1342 |
}
|
|
|
1343 |
|
|
|
1344 |
return;
|
|
|
1345 |
}
|
|
|
1346 |
|
|
|
1347 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_PROFILE_SECTION (";
|
|
|
1348 |
$sql.= " PSID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1349 |
$sql.= " NAME VARCHAR(64) DEFAULT NULL,";
|
|
|
1350 |
$sql.= " POSITION MEDIUMINT(3) UNSIGNED DEFAULT '0',";
|
|
|
1351 |
$sql.= " PRIMARY KEY (PSID)";
|
|
|
1352 |
$sql.= ") TYPE=MYISAM";
|
|
|
1353 |
|
|
|
1354 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1355 |
|
|
|
1356 |
forum_delete_tables($webtag, $database_name);
|
|
|
1357 |
|
|
|
1358 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1359 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1360 |
}
|
|
|
1361 |
|
|
|
1362 |
return;
|
|
|
1363 |
}
|
|
|
1364 |
|
|
|
1365 |
|
|
|
1366 |
$sql = "INSERT INTO {$database_name}.{$webtag}_PROFILE_SECTION ";
|
|
|
1367 |
$sql.= "(NAME, POSITION) VALUES ('Personal', 1)";
|
|
|
1368 |
|
|
|
1369 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1370 |
|
|
|
1371 |
forum_delete_tables($webtag, $database_name);
|
|
|
1372 |
|
|
|
1373 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1374 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1375 |
}
|
|
|
1376 |
|
|
|
1377 |
return;
|
|
|
1378 |
}
|
|
|
1379 |
|
|
|
1380 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_RSS_FEEDS (";
|
|
|
1381 |
$sql.= " RSSID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1382 |
$sql.= " NAME VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1383 |
$sql.= " UID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1384 |
$sql.= " FID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1385 |
$sql.= " URL VARCHAR(255) DEFAULT NULL,";
|
|
|
1386 |
$sql.= " PREFIX VARCHAR(16) DEFAULT NULL,";
|
|
|
1387 |
$sql.= " FREQUENCY MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1388 |
$sql.= " LAST_RUN DATETIME DEFAULT NULL,";
|
|
|
1389 |
$sql.= " PRIMARY KEY (RSSID)";
|
|
|
1390 |
$sql.= ") TYPE=MYISAM";
|
|
|
1391 |
|
|
|
1392 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1393 |
|
|
|
1394 |
forum_delete_tables($webtag, $database_name);
|
|
|
1395 |
|
|
|
1396 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1397 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1398 |
}
|
|
|
1399 |
|
|
|
1400 |
return;
|
|
|
1401 |
}
|
|
|
1402 |
|
|
|
1403 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_RSS_HISTORY (";
|
|
|
1404 |
$sql.= " RSSID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1405 |
$sql.= " LINK VARCHAR(255) DEFAULT NULL,";
|
|
|
1406 |
$sql.= " KEY RSSID (RSSID)";
|
|
|
1407 |
$sql.= ") TYPE=MYISAM";
|
|
|
1408 |
|
|
|
1409 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1410 |
|
|
|
1411 |
forum_delete_tables($webtag, $database_name);
|
|
|
1412 |
|
|
|
1413 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1414 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1415 |
}
|
|
|
1416 |
|
|
|
1417 |
return;
|
|
|
1418 |
}
|
|
|
1419 |
|
|
|
1420 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_STATS (";
|
|
|
1421 |
$sql.= " ID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1422 |
$sql.= " MOST_USERS_DATE DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1423 |
$sql.= " MOST_USERS_COUNT MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1424 |
$sql.= " MOST_POSTS_DATE DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1425 |
$sql.= " MOST_POSTS_COUNT MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1426 |
$sql.= " PRIMARY KEY (ID)";
|
|
|
1427 |
$sql.= ") TYPE=MYISAM";
|
|
|
1428 |
|
|
|
1429 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1430 |
|
|
|
1431 |
forum_delete_tables($webtag, $database_name);
|
|
|
1432 |
|
|
|
1433 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1434 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1435 |
}
|
|
|
1436 |
|
|
|
1437 |
return;
|
|
|
1438 |
}
|
|
|
1439 |
|
|
|
1440 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_THREAD (";
|
|
|
1441 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1442 |
$sql.= " FID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1443 |
$sql.= " BY_UID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1444 |
$sql.= " TITLE VARCHAR(64) DEFAULT NULL,";
|
|
|
1445 |
$sql.= " LENGTH MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1446 |
$sql.= " POLL_FLAG CHAR(1) DEFAULT NULL,";
|
|
|
1447 |
$sql.= " CREATED DATETIME DEFAULT NULL,";
|
|
|
1448 |
$sql.= " MODIFIED DATETIME DEFAULT NULL,";
|
|
|
1449 |
$sql.= " CLOSED DATETIME DEFAULT NULL,";
|
|
|
1450 |
$sql.= " STICKY CHAR(1) DEFAULT NULL,";
|
|
|
1451 |
$sql.= " STICKY_UNTIL DATETIME DEFAULT NULL,";
|
|
|
1452 |
$sql.= " ADMIN_LOCK DATETIME DEFAULT NULL,";
|
|
|
1453 |
$sql.= " PRIMARY KEY (TID),";
|
|
|
1454 |
$sql.= " KEY BY_UID (BY_UID),";
|
|
|
1455 |
$sql.= " KEY STICKY (STICKY, MODIFIED), ";
|
|
|
1456 |
$sql.= " KEY LENGTH (LENGTH), ";
|
|
|
1457 |
$sql.= " KEY TITLE (TITLE)";
|
|
|
1458 |
$sql.= ") TYPE=MYISAM";
|
|
|
1459 |
|
|
|
1460 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1461 |
|
|
|
1462 |
forum_delete_tables($webtag, $database_name);
|
|
|
1463 |
|
|
|
1464 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1465 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1466 |
}
|
|
|
1467 |
|
|
|
1468 |
return;
|
|
|
1469 |
}
|
|
|
1470 |
|
|
|
1471 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_THREAD_STATS (";
|
|
|
1472 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1473 |
$sql.= " VIEWCOUNT MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1474 |
$sql.= " UNREAD_PID MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1475 |
$sql.= " UNREAD_CREATED DATETIME DEFAULT NULL,";
|
|
|
1476 |
$sql.= " PRIMARY KEY (TID)";
|
|
|
1477 |
$sql.= ") TYPE=MYISAM";
|
|
|
1478 |
|
|
|
1479 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1480 |
|
|
|
1481 |
forum_delete_tables($webtag, $database_name);
|
|
|
1482 |
|
|
|
1483 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1484 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1485 |
}
|
|
|
1486 |
|
|
|
1487 |
return;
|
|
|
1488 |
}
|
|
|
1489 |
|
|
|
1490 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_THREAD_TRACK (";
|
|
|
1491 |
$sql.= " TID MEDIUMINT(8) NOT NULL DEFAULT '0',";
|
|
|
1492 |
$sql.= " NEW_TID MEDIUMINT(8) NOT NULL DEFAULT '0',";
|
|
|
1493 |
$sql.= " CREATED DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1494 |
$sql.= " TRACK_TYPE TINYINT(4) NOT NULL DEFAULT '0',";
|
|
|
1495 |
$sql.= " PRIMARY KEY (TID, NEW_TID)";
|
|
|
1496 |
$sql.= ") TYPE=MYISAM";
|
|
|
1497 |
|
|
|
1498 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1499 |
|
|
|
1500 |
forum_delete_tables($webtag, $database_name);
|
|
|
1501 |
|
|
|
1502 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1503 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1504 |
}
|
|
|
1505 |
|
|
|
1506 |
return;
|
|
|
1507 |
}
|
|
|
1508 |
|
|
|
1509 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_FOLDER (";
|
|
|
1510 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1511 |
$sql.= " FID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1512 |
$sql.= " INTEREST TINYINT(4) DEFAULT '0',";
|
|
|
1513 |
$sql.= " PRIMARY KEY (UID, FID)";
|
|
|
1514 |
$sql.= ") TYPE=MYISAM";
|
|
|
1515 |
|
|
|
1516 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1517 |
|
|
|
1518 |
forum_delete_tables($webtag, $database_name);
|
|
|
1519 |
|
|
|
1520 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1521 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1522 |
}
|
|
|
1523 |
|
|
|
1524 |
return;
|
|
|
1525 |
}
|
|
|
1526 |
|
|
|
1527 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_PEER (";
|
|
|
1528 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1529 |
$sql.= " PEER_UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1530 |
$sql.= " RELATIONSHIP TINYINT(4) DEFAULT NULL,";
|
|
|
1531 |
$sql.= " PEER_NICKNAME VARCHAR(32) DEFAULT NULL,";
|
|
|
1532 |
$sql.= " PRIMARY KEY (UID,PEER_UID)";
|
|
|
1533 |
$sql.= ") TYPE=MYISAM";
|
|
|
1534 |
|
|
|
1535 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1536 |
|
|
|
1537 |
forum_delete_tables($webtag, $database_name);
|
|
|
1538 |
|
|
|
1539 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1540 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1541 |
}
|
|
|
1542 |
|
|
|
1543 |
return;
|
|
|
1544 |
}
|
|
|
1545 |
|
|
|
1546 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_POLL_VOTES (";
|
|
|
1547 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1548 |
$sql.= " VOTE_ID MEDIUMINT(8) NOT NULL AUTO_INCREMENT,";
|
|
|
1549 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1550 |
$sql.= " OPTION_ID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1551 |
$sql.= " TSTAMP DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
|
|
1552 |
$sql.= " PRIMARY KEY (TID, VOTE_ID),";
|
|
|
1553 |
$sql.= " KEY UID (UID)";
|
|
|
1554 |
$sql.= ") TYPE=MYISAM";
|
|
|
1555 |
|
|
|
1556 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1557 |
|
|
|
1558 |
forum_delete_tables($webtag, $database_name);
|
|
|
1559 |
|
|
|
1560 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1561 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1562 |
}
|
|
|
1563 |
|
|
|
1564 |
return;
|
|
|
1565 |
}
|
|
|
1566 |
|
|
|
1567 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_PREFS (";
|
|
|
1568 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1569 |
$sql.= " HOMEPAGE_URL VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1570 |
$sql.= " PIC_URL VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1571 |
$sql.= " PIC_AID CHAR(32) NOT NULL DEFAULT '',";
|
|
|
1572 |
$sql.= " AVATAR_URL VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1573 |
$sql.= " AVATAR_AID CHAR(32) NOT NULL DEFAULT '',";
|
|
|
1574 |
$sql.= " EMAIL_NOTIFY CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1575 |
$sql.= " MARK_AS_OF_INT CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1576 |
$sql.= " POSTS_PER_PAGE VARCHAR(3) NOT NULL DEFAULT '20',";
|
|
|
1577 |
$sql.= " FONT_SIZE VARCHAR(2) NOT NULL DEFAULT '10',";
|
|
|
1578 |
$sql.= " STYLE VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1579 |
$sql.= " EMOTICONS VARCHAR(255) NOT NULL DEFAULT '',";
|
|
|
1580 |
$sql.= " VIEW_SIGS CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1581 |
$sql.= " START_PAGE VARCHAR(3) NOT NULL DEFAULT '0',";
|
|
|
1582 |
$sql.= " LANGUAGE VARCHAR(32) NOT NULL DEFAULT '',";
|
|
|
1583 |
$sql.= " DOB_DISPLAY CHAR(1) NOT NULL DEFAULT '2',";
|
|
|
1584 |
$sql.= " ANON_LOGON CHAR(1) NOT NULL DEFAULT '0',";
|
|
|
1585 |
$sql.= " SHOW_STATS CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1586 |
$sql.= " IMAGES_TO_LINKS CHAR(1) NOT NULL DEFAULT 'N',";
|
|
|
1587 |
$sql.= " USE_WORD_FILTER CHAR(1) NOT NULL DEFAULT 'N',";
|
|
|
1588 |
$sql.= " USE_ADMIN_FILTER CHAR(1) NOT NULL DEFAULT 'N',";
|
|
|
1589 |
$sql.= " ALLOW_EMAIL CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1590 |
$sql.= " ALLOW_PM CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1591 |
$sql.= " SHOW_THUMBS VARCHAR(2) NOT NULL DEFAULT '2',";
|
|
|
1592 |
$sql.= " ENABLE_WIKI_WORDS CHAR(1) NOT NULL DEFAULT 'Y',";
|
|
|
1593 |
$sql.= " USE_MOVER_SPOILER CHAR(1) DEFAULT 'N', ";
|
|
|
1594 |
$sql.= " USE_LIGHT_MODE_SPOILER CHAR(1) DEFAULT 'N', ";
|
|
|
1595 |
$sql.= " USE_OVERFLOW_RESIZE CHAR(1) DEFAULT 'Y', ";
|
|
|
1596 |
$sql.= " PRIMARY KEY (UID)";
|
|
|
1597 |
$sql.= ") TYPE=MYISAM";
|
|
|
1598 |
|
|
|
1599 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1600 |
|
|
|
1601 |
forum_delete_tables($webtag, $database_name);
|
|
|
1602 |
|
|
|
1603 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1604 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1605 |
}
|
|
|
1606 |
|
|
|
1607 |
return;
|
|
|
1608 |
}
|
|
|
1609 |
|
|
|
1610 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_PROFILE (";
|
|
|
1611 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1612 |
$sql.= " PIID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1613 |
$sql.= " ENTRY VARCHAR(255) DEFAULT NULL,";
|
|
|
1614 |
$sql.= " PRIVACY TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1615 |
$sql.= " PRIMARY KEY (UID,PIID)";
|
|
|
1616 |
$sql.= ") TYPE=MYISAM";
|
|
|
1617 |
|
|
|
1618 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1619 |
|
|
|
1620 |
forum_delete_tables($webtag, $database_name);
|
|
|
1621 |
|
|
|
1622 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1623 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1624 |
}
|
|
|
1625 |
|
|
|
1626 |
return;
|
|
|
1627 |
}
|
|
|
1628 |
|
|
|
1629 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_SIG (";
|
|
|
1630 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1631 |
$sql.= " CONTENT TEXT,";
|
|
|
1632 |
$sql.= " HTML CHAR(1) DEFAULT NULL,";
|
|
|
1633 |
$sql.= " PRIMARY KEY (UID)";
|
|
|
1634 |
$sql.= ") TYPE=MYISAM";
|
|
|
1635 |
|
|
|
1636 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1637 |
|
|
|
1638 |
forum_delete_tables($webtag, $database_name);
|
|
|
1639 |
|
|
|
1640 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1641 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1642 |
}
|
|
|
1643 |
|
|
|
1644 |
return;
|
|
|
1645 |
}
|
|
|
1646 |
|
|
|
1647 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_THREAD (";
|
|
|
1648 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1649 |
$sql.= " TID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1650 |
$sql.= " LAST_READ MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1651 |
$sql.= " LAST_READ_AT DATETIME DEFAULT NULL,";
|
|
|
1652 |
$sql.= " INTEREST TINYINT(4) DEFAULT NULL,";
|
|
|
1653 |
$sql.= " PRIMARY KEY (UID,TID),";
|
|
|
1654 |
$sql.= " KEY TID (TID),";
|
|
|
1655 |
$sql.= " KEY LAST_READ (LAST_READ)";
|
|
|
1656 |
$sql.= ") TYPE=MYISAM";
|
|
|
1657 |
|
|
|
1658 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1659 |
|
|
|
1660 |
forum_delete_tables($webtag, $database_name);
|
|
|
1661 |
|
|
|
1662 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1663 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1664 |
}
|
|
|
1665 |
|
|
|
1666 |
return;
|
|
|
1667 |
}
|
|
|
1668 |
|
|
|
1669 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_USER_TRACK (";
|
|
|
1670 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1671 |
$sql.= " DDKEY DATETIME DEFAULT NULL,";
|
|
|
1672 |
$sql.= " LAST_POST DATETIME DEFAULT NULL,";
|
|
|
1673 |
$sql.= " LAST_SEARCH DATETIME DEFAULT NULL,";
|
|
|
1674 |
$sql.= " LAST_SEARCH_KEYWORDS TEXT DEFAULT NULL,";
|
|
|
1675 |
$sql.= " POST_COUNT MEDIUMINT(8) UNSIGNED DEFAULT NULL,";
|
|
|
1676 |
$sql.= " USER_TIME_BEST DATETIME DEFAULT NULL,";
|
|
|
1677 |
$sql.= " USER_TIME_TOTAL DATETIME DEFAULT NULL,";
|
|
|
1678 |
$sql.= " USER_TIME_UPDATED DATETIME DEFAULT NULL,";
|
|
|
1679 |
$sql.= " PRIMARY KEY (UID)";
|
|
|
1680 |
$sql.= ") TYPE=MYISAM";
|
|
|
1681 |
|
|
|
1682 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1683 |
|
|
|
1684 |
forum_delete_tables($webtag, $database_name);
|
|
|
1685 |
|
|
|
1686 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1687 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1688 |
}
|
|
|
1689 |
|
|
|
1690 |
return;
|
|
|
1691 |
}
|
|
|
1692 |
|
|
|
1693 |
$sql = "CREATE TABLE {$database_name}.{$webtag}_WORD_FILTER (";
|
|
|
1694 |
$sql.= " UID MEDIUMINT(8) UNSIGNED NOT NULL,";
|
|
|
1695 |
$sql.= " FID MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,";
|
|
|
1696 |
$sql.= " FILTER_NAME VARCHAR(255) NOT NULL,";
|
|
|
1697 |
$sql.= " MATCH_TEXT TEXT NOT NULL,";
|
|
|
1698 |
$sql.= " REPLACE_TEXT TEXT NOT NULL,";
|
|
|
1699 |
$sql.= " FILTER_TYPE TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1700 |
$sql.= " FILTER_ENABLED TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',";
|
|
|
1701 |
$sql.= " PRIMARY KEY (UID, FID)";
|
|
|
1702 |
$sql.= ") TYPE = MYISAM";
|
|
|
1703 |
|
|
|
1704 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1705 |
|
|
|
1706 |
forum_delete_tables($webtag, $database_name);
|
|
|
1707 |
|
|
|
1708 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1709 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1710 |
}
|
|
|
1711 |
|
|
|
1712 |
return;
|
|
|
1713 |
}
|
|
|
1714 |
|
|
|
1715 |
// Save Webtag, Database name and Access Level.
|
|
|
1716 |
|
|
|
1717 |
$sql = "INSERT INTO FORUMS (WEBTAG, OWNER_UID, DATABASE_NAME, ACCESS_LEVEL) ";
|
|
|
1718 |
$sql.= "VALUES ('$webtag', '$owner_uid', '$database_name', $access)";
|
|
|
1719 |
|
|
|
1720 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1721 |
|
|
|
1722 |
forum_delete_tables($webtag, $database_name);
|
|
|
1723 |
|
|
|
1724 |
if (defined("BEEHIVE_INSTALL_NOWARN")) {
|
|
|
1725 |
db_trigger_error($sql, $db_forum_create);
|
|
|
1726 |
}
|
|
|
1727 |
|
|
|
1728 |
return false;
|
|
|
1729 |
}
|
|
|
1730 |
|
|
|
1731 |
// Get the new FID so we can save the settings
|
|
|
1732 |
|
|
|
1733 |
$forum_fid = db_insert_id($db_forum_create);
|
|
|
1734 |
|
|
|
1735 |
// Create General Folder
|
|
|
1736 |
|
|
|
1737 |
$sql = "INSERT INTO {$database_name}.{$webtag}_FOLDER (TITLE, DESCRIPTION, ALLOWED_TYPES, POSITION) ";
|
|
|
1738 |
$sql.= "VALUES ('General', NULL, NULL, 0)";
|
|
|
1739 |
|
|
|
1740 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1741 |
|
|
|
1742 |
forum_delete($forum_fid);
|
|
|
1743 |
return false;
|
|
|
1744 |
}
|
|
|
1745 |
|
|
|
1746 |
$folder_fid = db_insert_id($db_forum_create);
|
|
|
1747 |
|
|
|
1748 |
// Create folder permissions
|
|
|
1749 |
|
|
|
1750 |
$sql = "INSERT INTO GROUP_PERMS (GID, FORUM, FID, PERM) ";
|
|
|
1751 |
$sql.= "VALUES (0, '$forum_fid', '$folder_fid', 14588);";
|
|
|
1752 |
|
|
|
1753 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1754 |
|
|
|
1755 |
forum_delete($forum_fid);
|
|
|
1756 |
return false;
|
|
|
1757 |
}
|
|
|
1758 |
|
|
|
1759 |
// Add some default forum links
|
|
|
1760 |
|
|
|
1761 |
$sql = "INSERT INTO {$database_name}.{$webtag}_FORUM_LINKS (POS, TITLE, URI) ";
|
|
|
1762 |
$sql.= "VALUES (2, 'Project Beehive Home', 'http://www.beehiveforum.net/')";
|
|
|
1763 |
|
|
|
1764 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1765 |
|
|
|
1766 |
forum_delete($forum_fid);
|
|
|
1767 |
return false;
|
|
|
1768 |
}
|
|
|
1769 |
|
|
|
1770 |
$sql = "INSERT INTO {$database_name}.{$webtag}_FORUM_LINKS (POS, TITLE, URI) ";
|
|
|
1771 |
$sql.= "VALUES (2, 'Teh Forum', 'http://www.tehforum.co.uk/forum/')";
|
|
|
1772 |
|
|
|
1773 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1774 |
|
|
|
1775 |
forum_delete($forum_fid);
|
|
|
1776 |
return false;
|
|
|
1777 |
}
|
|
|
1778 |
|
|
|
1779 |
// Create user permissions for forum leader
|
|
|
1780 |
|
|
|
1781 |
if (!forum_apply_user_permissions($forum_fid, $owner_uid)) {
|
|
|
1782 |
|
|
|
1783 |
forum_delete($forum_fid);
|
|
|
1784 |
return false;
|
|
|
1785 |
}
|
|
|
1786 |
|
|
|
1787 |
// Create Welcome thread and post.
|
|
|
1788 |
|
|
|
1789 |
$sql = "INSERT INTO {$database_name}.{$webtag}_THREAD ";
|
|
|
1790 |
$sql.= "(FID, BY_UID, TITLE, LENGTH, POLL_FLAG, CREATED, MODIFIED, CLOSED, STICKY, STICKY_UNTIL, ADMIN_LOCK) ";
|
|
|
1791 |
$sql.= "VALUES (1, 1, 'Welcome', 1, 'N', NOW(), NOW(), NULL, 'N', NULL, NULL)";
|
|
|
1792 |
|
|
|
1793 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1794 |
|
|
|
1795 |
forum_delete($forum_fid);
|
|
|
1796 |
return false;
|
|
|
1797 |
}
|
|
|
1798 |
|
|
|
1799 |
$sql = "INSERT INTO {$database_name}.{$webtag}_POST ";
|
|
|
1800 |
$sql.= "(TID, REPLY_TO_PID, FROM_UID, TO_UID, VIEWED, CREATED, STATUS, APPROVED, ";
|
|
|
1801 |
$sql.= "APPROVED_BY, EDITED, EDITED_BY, IPADDRESS) VALUES (1, 0, 1, 0, NULL, NOW(), ";
|
|
|
1802 |
$sql.= "0, NOW(), 1, NULL, 0, '')";
|
|
|
1803 |
|
|
|
1804 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1805 |
|
|
|
1806 |
forum_delete($forum_fid);
|
|
|
1807 |
return false;;
|
|
|
1808 |
}
|
|
|
1809 |
|
|
|
1810 |
$sql = "INSERT INTO {$database_name}.{$webtag}_POST_CONTENT (TID, PID, CONTENT) ";
|
|
|
1811 |
$sql.= "VALUES (1, 1, 'Welcome to your new Beehive Forum')";
|
|
|
1812 |
|
|
|
1813 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1814 |
|
|
|
1815 |
forum_delete($forum_fid);
|
|
|
1816 |
return false;;
|
|
|
1817 |
}
|
|
|
1818 |
|
|
|
1819 |
// Create Top Level Links Folder
|
|
|
1820 |
|
|
|
1821 |
$sql = "INSERT INTO {$database_name}.{$webtag}_LINKS_FOLDERS ";
|
|
|
1822 |
$sql.= "(PARENT_FID, NAME, VISIBLE) VALUES (NULL, 'Top Level', 'Y')";
|
|
|
1823 |
|
|
|
1824 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1825 |
|
|
|
1826 |
forum_delete($forum_fid);
|
|
|
1827 |
return false;
|
|
|
1828 |
}
|
|
|
1829 |
|
|
|
1830 |
// Store Forum settings
|
|
|
1831 |
|
|
|
1832 |
$forum_settings = array('wiki_integration_uri' => 'http://en.wikipedia.org/wiki/[WikiWord]',
|
|
|
1833 |
'enable_wiki_quick_links' => 'Y',
|
|
|
1834 |
'enable_wiki_integration' => 'N',
|
|
|
1835 |
'minimum_post_frequency' => '0',
|
|
|
1836 |
'maximum_post_length' => '6226',
|
|
|
1837 |
'post_edit_time' => '0',
|
|
|
1838 |
'allow_post_editing' => 'Y',
|
|
|
1839 |
'require_post_approval' => 'N',
|
|
|
1840 |
'forum_dl_saving' => 'Y',
|
|
|
1841 |
'forum_timezone' => '27',
|
|
|
1842 |
'default_language' => 'en',
|
|
|
1843 |
'default_emoticons' => 'default',
|
|
|
1844 |
'default_style' => 'Default',
|
|
|
1845 |
'forum_keywords' => 'A Beehive Forum, Beehive Forum, Project Beehive Forum',
|
|
|
1846 |
'forum_desc' => 'A Beehive Forum',
|
|
|
1847 |
'forum_email' => 'admin@abeehiveforum.net',
|
|
|
1848 |
'forum_name' => $forum_name,
|
|
|
1849 |
'show_links' => 'Y',
|
|
|
1850 |
'allow_polls' => 'Y',
|
|
|
1851 |
'show_stats' => 'Y',
|
|
|
1852 |
'allow_search_spidering' => 'Y',
|
|
|
1853 |
'guest_account_enabled' => 'Y',
|
|
|
1854 |
'forum_links_top_link' => 'Forum Links:');
|
|
|
1855 |
|
|
|
1856 |
foreach ($forum_settings as $sname => $svalue) {
|
|
|
1857 |
|
|
|
1858 |
$sname = db_escape_string($sname);
|
|
|
1859 |
$svalue = db_escape_string($svalue);
|
|
|
1860 |
|
|
|
1861 |
$sql = "INSERT INTO FORUM_SETTINGS (FID, SNAME, SVALUE) ";
|
|
|
1862 |
$sql.= "VALUES ($forum_fid, '$sname', '$svalue')";
|
|
|
1863 |
|
|
|
1864 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1865 |
|
|
|
1866 |
forum_delete($forum_fid);
|
|
|
1867 |
return false;
|
|
|
1868 |
}
|
|
|
1869 |
}
|
|
|
1870 |
|
|
|
1871 |
// Make sure at least the current user can access the forum
|
|
|
1872 |
// even if it's not protected.
|
|
|
1873 |
|
|
|
1874 |
$sql = "INSERT INTO USER_FORUM (UID, FID, ALLOWED) VALUES('$uid', $forum_fid, 1)";
|
|
|
1875 |
|
|
|
1876 |
if (!$result = @db_query($sql, $db_forum_create)) {
|
|
|
1877 |
|
|
|
1878 |
forum_delete($forum_fid);
|
|
|
1879 |
return false;
|
|
|
1880 |
}
|
|
|
1881 |
|
|
|
1882 |
return $forum_fid;
|
|
|
1883 |
}
|
|
|
1884 |
|
|
|
1885 |
return false;
|
|
|
1886 |
}
|
|
|
1887 |
|
|
|
1888 |
function forum_update($fid, $forum_name, $owner_uid, $access_level)
|
|
|
1889 |
{
|
|
|
1890 |
if (!is_numeric($fid)) return false;
|
|
|
1891 |
if (!is_numeric($owner_uid)) return false;
|
|
|
1892 |
if (!is_numeric($access_level)) return false;
|
|
|
1893 |
|
|
|
1894 |
if (bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
1895 |
|
|
|
1896 |
if (!$db_forum_update = db_connect()) return false;
|
|
|
1897 |
|
|
|
1898 |
$forum_name = db_escape_string($forum_name);
|
|
|
1899 |
|
|
|
1900 |
$sql = "UPDATE LOW_PRIORITY FORUMS SET ACCESS_LEVEL = '$access_level', ";
|
|
|
1901 |
$sql.= "OWNER_UID = '$owner_uid' WHERE FID = '$fid'";
|
|
|
1902 |
|
|
|
1903 |
if (!$result = db_query($sql, $db_forum_update)) return false;
|
|
|
1904 |
|
|
|
1905 |
$sql = "UPDATE LOW_PRIORITY FORUM_SETTINGS SET SVALUE = '$forum_name' ";
|
|
|
1906 |
$sql.= "WHERE SNAME = 'forum_name' AND FID = '$fid'";
|
|
|
1907 |
|
|
|
1908 |
if (!$result = db_query($sql, $db_forum_update)) return false;
|
|
|
1909 |
|
|
|
1910 |
if (db_affected_rows($result) < 1) {
|
|
|
1911 |
|
|
|
1912 |
$sql = "INSERT IGNORE INTO FORUM_SETTINGS (FID, SNAME, SVALUE) ";
|
|
|
1913 |
$sql.= "VALUES ('$fid', 'forum_name', '$forum_name')";
|
|
|
1914 |
|
|
|
1915 |
if (!$result = db_query($sql, $db_forum_update)) return false;
|
|
|
1916 |
}
|
|
|
1917 |
|
|
|
1918 |
return true;
|
|
|
1919 |
}
|
|
|
1920 |
|
|
|
1921 |
return false;
|
|
|
1922 |
}
|
|
|
1923 |
|
|
|
1924 |
function forum_apply_user_permissions($forum_fid, $uid)
|
|
|
1925 |
{
|
|
|
1926 |
if (!$db_forum_apply_user_permissions = db_connect()) return false;
|
|
|
1927 |
|
|
|
1928 |
if (!is_numeric($forum_fid)) return false;
|
|
|
1929 |
if (!is_numeric($uid)) return false;
|
|
|
1930 |
|
|
|
1931 |
$forum_user_perms = USER_PERM_ADMIN_TOOLS | USER_PERM_FOLDER_MODERATE;
|
|
|
1932 |
|
|
|
1933 |
$sql = "INSERT INTO GROUPS (FORUM, GROUP_NAME, GROUP_DESC, AUTO_GROUP) ";
|
|
|
1934 |
$sql.= "VALUES ('$forum_fid', NULL, NULL, 1);";
|
|
|
1935 |
|
|
|
1936 |
if (!$result = db_query($sql, $db_forum_apply_user_permissions)) return false;
|
|
|
1937 |
|
|
|
1938 |
$new_gid = db_insert_id($db_forum_apply_user_permissions);
|
|
|
1939 |
|
|
|
1940 |
$sql = "INSERT INTO GROUP_PERMS (GID, FORUM, FID, PERM) ";
|
|
|
1941 |
$sql.= "VALUES ('$new_gid', '$forum_fid', 0, '$forum_user_perms');";
|
|
|
1942 |
|
|
|
1943 |
if (!$result = db_query($sql, $db_forum_apply_user_permissions)) return false;
|
|
|
1944 |
|
|
|
1945 |
$sql = "INSERT INTO GROUP_USERS VALUES ($new_gid, $uid);";
|
|
|
1946 |
|
|
|
1947 |
if (!$result = db_query($sql, $db_forum_apply_user_permissions)) return false;
|
|
|
1948 |
|
|
|
1949 |
return true;
|
|
|
1950 |
}
|
|
|
1951 |
|
|
|
1952 |
function forum_delete($fid)
|
|
|
1953 |
{
|
|
|
1954 |
if (bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
1955 |
|
|
|
1956 |
if (!$db_forum_delete = db_connect()) return false;
|
|
|
1957 |
|
|
|
1958 |
if (!is_numeric($fid)) return false;
|
|
|
1959 |
|
|
|
1960 |
$sql = "SELECT WEBTAG, DATABASE_NAME FROM FORUMS WHERE FID = '$fid'";
|
|
|
1961 |
|
|
|
1962 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1963 |
|
|
|
1964 |
if (db_num_rows($result) > 0) {
|
|
|
1965 |
|
|
|
1966 |
list($webtag, $database_name) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
1967 |
|
|
|
1968 |
$sql = "DELETE QUICK FROM FORUMS WHERE FID = '$fid'";
|
|
|
1969 |
|
|
|
1970 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1971 |
|
|
|
1972 |
$sql = "DELETE QUICK FROM FORUM_SETTINGS WHERE FID = '$fid'";
|
|
|
1973 |
|
|
|
1974 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1975 |
|
|
|
1976 |
$sql = "DELETE QUICK FROM GROUP_PERMS WHERE FORUM = '$fid'";
|
|
|
1977 |
|
|
|
1978 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1979 |
|
|
|
1980 |
$sql = "SELECT GID FROM GROUPS WHERE FORUM = '$fid'";
|
|
|
1981 |
|
|
|
1982 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1983 |
|
|
|
1984 |
while($user_perms = db_fetch_array($result)) {
|
|
|
1985 |
|
|
|
1986 |
$sql = "DELETE QUICK FROM GROUP_USERS WHERE GID = '{$user_perms['GID']}'";
|
|
|
1987 |
|
|
|
1988 |
if (!$result_remove = db_query($sql, $db_forum_delete)) return false;
|
|
|
1989 |
}
|
|
|
1990 |
|
|
|
1991 |
$sql = "DELETE QUICK FROM GROUPS WHERE FORUM = '$fid'";
|
|
|
1992 |
|
|
|
1993 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1994 |
|
|
|
1995 |
$sql = "DELETE QUICK FROM USER_FORUM WHERE FID = '$fid'";
|
|
|
1996 |
|
|
|
1997 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
1998 |
|
|
|
1999 |
$sql = "DELETE QUICK FROM VISITOR_LOG WHERE FORUM = '$fid'";
|
|
|
2000 |
|
|
|
2001 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
2002 |
|
|
|
2003 |
$sql = "DELETE QUICK FROM SEARCH_RESULTS WHERE FORUM = '$fid'";
|
|
|
2004 |
|
|
|
2005 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
2006 |
|
|
|
2007 |
$sql = "SELECT AID FROM POST_ATTACHMENT_IDS WHERE FID = '$fid'";
|
|
|
2008 |
|
|
|
2009 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
2010 |
|
|
|
2011 |
while ($attachment_data = db_fetch_array($result)) {
|
|
|
2012 |
delete_attachment_by_aid($attachment_data['AID']);
|
|
|
2013 |
}
|
|
|
2014 |
|
|
|
2015 |
$sql = "DELETE QUICK FROM POST_ATTACHMENT_IDS WHERE FID = '$fid'";
|
|
|
2016 |
|
|
|
2017 |
if (!$result = db_query($sql, $db_forum_delete)) return false;
|
|
|
2018 |
|
|
|
2019 |
if (forum_delete_tables($webtag, $database_name)) return true;
|
|
|
2020 |
}
|
|
|
2021 |
}
|
|
|
2022 |
|
|
|
2023 |
return false;
|
|
|
2024 |
}
|
|
|
2025 |
|
|
|
2026 |
function forum_delete_tables($webtag, $database_name)
|
|
|
2027 |
{
|
|
|
2028 |
// Ensure the variables we've been given are valid
|
|
|
2029 |
|
|
|
2030 |
if (!preg_match("/^[A-Z0-9_]+$/", $webtag)) return false;
|
|
|
2031 |
if (!preg_match("/^[A-Z0-9_]+$/i", $database_name)) return false;
|
|
|
2032 |
|
|
|
2033 |
// Only users with acces to the forum tools can create / delete forums.
|
|
|
2034 |
|
|
|
2035 |
if (bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
2036 |
|
|
|
2037 |
if (!$db_forum_delete_tables = db_connect()) return false;
|
|
|
2038 |
|
|
|
2039 |
$table_array = array('ADMIN_LOG', 'BANNED', 'FOLDER',
|
|
|
2040 |
'FORUM_LINKS', 'GROUPS', 'GROUP_PERMS',
|
|
|
2041 |
'GROUP_USERS', 'LINKS', 'LINKS_COMMENT',
|
|
|
2042 |
'LINKS_FOLDERS', 'LINKS_VOTE', 'POLL',
|
|
|
2043 |
'POLL_VOTES', 'POST', 'POST_CONTENT',
|
|
|
2044 |
'PROFILE_ITEM', 'PROFILE_SECTION', 'RSS_FEEDS',
|
|
|
2045 |
'RSS_HISTORY', 'STATS', 'THREAD',
|
|
|
2046 |
'THREAD_STATS', 'THREAD_TRACK', 'USER_TRACK',
|
|
|
2047 |
'USER_FOLDER', 'USER_PEER', 'USER_POLL_VOTES',
|
|
|
2048 |
'USER_PREFS', 'USER_PROFILE', 'USER_SIG',
|
|
|
2049 |
'USER_THREAD', 'VISITOR_LOG', 'WORD_FILTER');
|
|
|
2050 |
|
|
|
2051 |
foreach ($table_array as $table_name) {
|
|
|
2052 |
|
|
|
2053 |
$sql = "DROP TABLE IF EXISTS {$database_name}.{$webtag}_{$table_name}";
|
|
|
2054 |
|
|
|
2055 |
if (!$result = db_query($sql, $db_forum_delete_tables)) return false;
|
|
|
2056 |
}
|
|
|
2057 |
|
|
|
2058 |
return true;
|
|
|
2059 |
}
|
|
|
2060 |
|
|
|
2061 |
return false;
|
|
|
2062 |
}
|
|
|
2063 |
|
|
|
2064 |
function forum_update_access($fid, $access)
|
|
|
2065 |
{
|
|
|
2066 |
if (!is_numeric($fid)) return false;
|
|
|
2067 |
if (!is_numeric($access)) return false;
|
|
|
2068 |
|
|
|
2069 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
2070 |
|
|
|
2071 |
if (($uid = bh_session_get_value('UID')) === false) return false;
|
|
|
2072 |
|
|
|
2073 |
if (!$db_forum_update_access = db_connect()) return false;
|
|
|
2074 |
|
|
|
2075 |
$sql = "UPDATE LOW_PRIORITY FORUMS SET ACCESS_LEVEL = '$access' ";
|
|
|
2076 |
$sql.= "WHERE FID = '$fid'";
|
|
|
2077 |
|
|
|
2078 |
if (!$result = db_query($sql, $db_forum_update_access)) return false;
|
|
|
2079 |
|
|
|
2080 |
$sql = "SELECT UID FROM USER_FORUM WHERE FID = '$fid' ";
|
|
|
2081 |
$sql.= "AND UID = '$uid' LIMIT 0, 1";
|
|
|
2082 |
|
|
|
2083 |
if (!$result = db_query($sql, $db_forum_update_access)) return false;
|
|
|
2084 |
|
|
|
2085 |
if (db_num_rows($result) > 0) {
|
|
|
2086 |
|
|
|
2087 |
$sql = "UPDATE LOW_PRIORITY USER_FORUM SET ALLOWED = 1 WHERE UID = '$uid' AND FID = '$fid'";
|
|
|
2088 |
|
|
|
2089 |
if (!$result = db_query($sql, $db_forum_update_access)) return false;
|
|
|
2090 |
|
|
|
2091 |
}else {
|
|
|
2092 |
|
|
|
2093 |
$sql = "INSERT IGNORE INTO USER_FORUM (UID, FID, ALLOWED) ";
|
|
|
2094 |
$sql.= "VALUES ('$uid', '$fid', '1')";
|
|
|
2095 |
|
|
|
2096 |
if (!$result = db_query($sql, $db_forum_update_access)) return false;
|
|
|
2097 |
}
|
|
|
2098 |
|
|
|
2099 |
return true;
|
|
|
2100 |
}
|
|
|
2101 |
|
|
|
2102 |
return false;
|
|
|
2103 |
}
|
|
|
2104 |
|
|
|
2105 |
function forum_update_password($fid, $password)
|
|
|
2106 |
{
|
|
|
2107 |
if (!$db_forum_update_password = db_connect()) return false;
|
|
|
2108 |
|
|
|
2109 |
if (!is_numeric($fid)) return false;
|
|
|
2110 |
|
|
|
2111 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
2112 |
|
|
|
2113 |
$password = db_escape_string(md5($password));
|
|
|
2114 |
|
|
|
2115 |
$sql = "UPDATE LOW_PRIORITY FORUMS SET FORUM_PASSWD = '$password' ";
|
|
|
2116 |
$sql.= "WHERE FID = '$fid'";
|
|
|
2117 |
|
|
|
2118 |
if (!$result = db_query($sql, $db_forum_update_password)) return false;
|
|
|
2119 |
|
|
|
2120 |
return true;
|
|
|
2121 |
}
|
|
|
2122 |
|
|
|
2123 |
return false;
|
|
|
2124 |
}
|
|
|
2125 |
|
|
|
2126 |
function forum_get($fid)
|
|
|
2127 |
{
|
|
|
2128 |
if (!is_numeric($fid)) return false;
|
|
|
2129 |
|
|
|
2130 |
if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0)) {
|
|
|
2131 |
|
|
|
2132 |
if (!$db_forum_get = db_connect()) return false;
|
|
|
2133 |
|
|
|
2134 |
$sql = "SELECT FID, WEBTAG, OWNER_UID, DATABASE_NAME, DEFAULT_FORUM, ";
|
|
|
2135 |
$sql.= "ACCESS_LEVEL, FORUM_PASSWD FROM FORUMS WHERE FID = '$fid'";
|
|
|
2136 |
|
|
|
2137 |
if (!$result = db_query($sql, $db_forum_get)) return false;
|
|
|
2138 |
|
|
|
2139 |
if (db_num_rows($result) > 0) {
|
|
|
2140 |
|
|
|
2141 |
$forum_get_array = db_fetch_array($result);
|
|
|
2142 |
$forum_get_array['FORUM_SETTINGS'] = array();
|
|
|
2143 |
|
|
|
2144 |
if (isset($forum_get_array['OWNER_UID'])) {
|
|
|
2145 |
|
|
|
2146 |
if ($forum_leader = user_get_logon($forum_get_array['OWNER_UID'])) {
|
|
|
2147 |
|
|
|
2148 |
$forum_get_array['FORUM_SETTINGS']['forum_leader'] = $forum_leader;
|
|
|
2149 |
}
|
|
|
2150 |
}
|
|
|
2151 |
|
|
|
2152 |
$sql = "SELECT SNAME, SVALUE FROM FORUM_SETTINGS WHERE FID = '$fid'";
|
|
|
2153 |
|
|
|
2154 |
if (!$result = db_query($sql, $db_forum_get)) return false;
|
|
|
2155 |
|
|
|
2156 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
2157 |
$forum_get_array['FORUM_SETTINGS'][$forum_data['SNAME']] = $forum_data['SVALUE'];
|
|
|
2158 |
}
|
|
|
2159 |
|
|
|
2160 |
return $forum_get_array;
|
|
|
2161 |
}
|
|
|
2162 |
}
|
|
|
2163 |
|
|
|
2164 |
return false;
|
|
|
2165 |
}
|
|
|
2166 |
|
|
|
2167 |
function forum_get_permissions($fid, $offset = 0)
|
|
|
2168 |
{
|
|
|
2169 |
if (!$db_forum_get_permissions = db_connect()) return false;
|
|
|
2170 |
|
|
|
2171 |
if (!is_numeric($fid)) return false;
|
|
|
2172 |
if (!is_numeric($offset)) $offset = 0;
|
|
|
2173 |
|
|
|
2174 |
$perms_user_array = array();
|
|
|
2175 |
|
|
|
2176 |
$sql = "SELECT SQL_CALC_FOUND_ROWS USER.UID, USER.LOGON, USER.NICKNAME FROM USER USER ";
|
|
|
2177 |
$sql.= "LEFT JOIN USER_FORUM USER_FORUM ON (USER_FORUM.UID = USER.UID) ";
|
|
|
2178 |
$sql.= "WHERE USER_FORUM.FID = '$fid' AND USER_FORUM.ALLOWED = 1 ";
|
|
|
2179 |
$sql.= "LIMIT $offset, 20";
|
|
|
2180 |
|
|
|
2181 |
if (!$result = db_query($sql, $db_forum_get_permissions)) return false;
|
|
|
2182 |
|
|
|
2183 |
// Fetch the number of total results
|
|
|
2184 |
|
|
|
2185 |
$sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
|
|
|
2186 |
|
|
|
2187 |
if (!$result_count = db_query($sql, $db_forum_get_permissions)) return false;
|
|
|
2188 |
|
|
|
2189 |
list($perms_user_count) = db_fetch_array($result_count, DB_RESULT_NUM);
|
|
|
2190 |
|
|
|
2191 |
if (db_num_rows($result) > 0) {
|
|
|
2192 |
|
|
|
2193 |
while ($user_data = db_fetch_array($result)) {
|
|
|
2194 |
|
|
|
2195 |
if (isset($user_data['LOGON']) && isset($user_data['PEER_NICKNAME'])) {
|
|
|
2196 |
if (!is_null($user_data['PEER_NICKNAME']) && strlen($user_data['PEER_NICKNAME']) > 0) {
|
|
|
2197 |
$user_data['NICKNAME'] = $user_data['PEER_NICKNAME'];
|
|
|
2198 |
}
|
|
|
2199 |
}
|
|
|
2200 |
|
|
|
2201 |
if (!isset($user_data['LOGON'])) $user_data['LOGON'] = $lang['unknownuser'];
|
|
|
2202 |
if (!isset($user_data['NICKNAME'])) $user_data['NICKNAME'] = "";
|
|
|
2203 |
|
|
|
2204 |
$perms_user_array[] = $user_data;
|
|
|
2205 |
}
|
|
|
2206 |
|
|
|
2207 |
}else if ($perms_user_count > 0) {
|
|
|
2208 |
|
|
|
2209 |
$offset = floor(($group_user_count - 1) / 10) * 10;
|
|
|
2210 |
return perm_group_get_users($gid, $offset);
|
|
|
2211 |
}
|
|
|
2212 |
|
|
|
2213 |
return array('user_count' => $perms_user_count,
|
|
|
2214 |
'user_array' => $perms_user_array);
|
|
|
2215 |
}
|
|
|
2216 |
|
|
|
2217 |
function forum_update_default($fid)
|
|
|
2218 |
{
|
|
|
2219 |
if (!is_numeric($fid)) return false;
|
|
|
2220 |
|
|
|
2221 |
if (bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
|
|
|
2222 |
|
|
|
2223 |
if (!$db_forum_get_permissions = db_connect()) return false;
|
|
|
2224 |
|
|
|
2225 |
$sql = "UPDATE LOW_PRIORITY FORUMS SET DEFAULT_FORUM = 0";
|
|
|
2226 |
|
|
|
2227 |
if (!$result = db_query($sql, $db_forum_get_permissions)) return false;
|
|
|
2228 |
|
|
|
2229 |
if ($fid > 0) {
|
|
|
2230 |
|
|
|
2231 |
$sql = "UPDATE LOW_PRIORITY FORUMS SET DEFAULT_FORUM = 1 WHERE FID = '$fid'";
|
|
|
2232 |
|
|
|
2233 |
if (!$result = db_query($sql, $db_forum_get_permissions)) return false;
|
|
|
2234 |
}
|
|
|
2235 |
|
|
|
2236 |
return $result;
|
|
|
2237 |
}
|
|
|
2238 |
|
|
|
2239 |
return false;
|
|
|
2240 |
}
|
|
|
2241 |
|
|
|
2242 |
function forum_get_post_count($webtag)
|
|
|
2243 |
{
|
|
|
2244 |
if (!$db_forum_get_post_count = db_connect()) return false;
|
|
|
2245 |
|
|
|
2246 |
if (preg_match("/^[a-z0-9_]+$/i", $webtag) < 1) return 0;
|
|
|
2247 |
|
|
|
2248 |
$sql = "SELECT COUNT(PID) AS POST_COUNT FROM {$webtag}_POST POST ";
|
|
|
2249 |
|
|
|
2250 |
if (!$result_post_count = db_query($sql, $db_forum_get_post_count)) return false;
|
|
|
2251 |
|
|
|
2252 |
if (db_num_rows($result_post_count) > 0) {
|
|
|
2253 |
|
|
|
2254 |
$$forum_data = db_fetch_array($result_post_count);
|
|
|
2255 |
return $$forum_data['POST_COUNT'];
|
|
|
2256 |
}
|
|
|
2257 |
|
|
|
2258 |
return 0;
|
|
|
2259 |
}
|
|
|
2260 |
|
|
|
2261 |
function forum_search_array_clean($forum_search)
|
|
|
2262 |
{
|
|
|
2263 |
return db_escape_string(trim(str_replace("%", "", $forum_search)));
|
|
|
2264 |
}
|
|
|
2265 |
|
|
|
2266 |
function forum_search($forum_search, $offset)
|
|
|
2267 |
{
|
|
|
2268 |
if (!$db_forum_search = db_connect()) return false;
|
|
|
2269 |
|
|
|
2270 |
if (!is_numeric($offset)) return false;
|
|
|
2271 |
|
|
|
2272 |
if (($uid = bh_session_get_value('UID')) === false) return false;
|
|
|
2273 |
|
|
|
2274 |
$lang = load_language_file();
|
|
|
2275 |
|
|
|
2276 |
// Array to hold our forums in.
|
|
|
2277 |
|
|
|
2278 |
$forums_array = array();
|
|
|
2279 |
|
|
|
2280 |
if (strlen(trim($forum_search)) > 0) {
|
|
|
2281 |
|
|
|
2282 |
$forum_search_array = explode(";", $forum_search);
|
|
|
2283 |
$forum_search_array = array_map('forum_search_array_clean', $forum_search_array);
|
|
|
2284 |
|
|
|
2285 |
$forum_search_webtag = implode("%' OR FORUMS.WEBTAG LIKE '%", $forum_search_array);
|
|
|
2286 |
$forum_search_svalue = implode("%' OR FORUM_SETTINGS.SVALUE LIKE '%", $forum_search_array);
|
|
|
2287 |
|
|
|
2288 |
$sql = "SELECT SQL_CALC_FOUND_ROWS CONCAT(FORUMS.DATABASE_NAME, '.', FORUMS.WEBTAG, '_') AS PREFIX, ";
|
|
|
2289 |
$sql.= "FORUMS.FID, FORUMS.ACCESS_LEVEL, USER_FORUM.INTEREST FROM FORUM_SETTINGS ";
|
|
|
2290 |
$sql.= "LEFT JOIN USER_FORUM ON (USER_FORUM.FID = FORUM_SETTINGS.FID ";
|
|
|
2291 |
$sql.= "AND USER_FORUM.UID = '$uid') LEFT JOIN FORUMS ON (FORUMS.FID = FORUM_SETTINGS.FID) ";
|
|
|
2292 |
$sql.= "WHERE FORUMS.ACCESS_LEVEL > -1 AND (FORUMS.WEBTAG LIKE ";
|
|
|
2293 |
$sql.= "'%$forum_search_webtag%' OR FORUM_SETTINGS.SVALUE LIKE ";
|
|
|
2294 |
$sql.= "'%$forum_search_svalue%') GROUP BY FORUMS.FID ";
|
|
|
2295 |
$sql.= "LIMIT $offset, 10";
|
|
|
2296 |
|
|
|
2297 |
if (!$result_forums = db_query($sql, $db_forum_search)) return false;
|
|
|
2298 |
|
|
|
2299 |
// Fetch the number of total results
|
|
|
2300 |
|
|
|
2301 |
$sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
|
|
|
2302 |
|
|
|
2303 |
if (!$result_count = db_query($sql, $db_forum_search)) return false;
|
|
|
2304 |
|
|
|
2305 |
list($forums_count) = db_fetch_array($result_count, DB_RESULT_NUM);
|
|
|
2306 |
|
|
|
2307 |
if (db_num_rows($result_forums) > 0) {
|
|
|
2308 |
|
|
|
2309 |
while ($forum_data = db_fetch_array($result_forums)) {
|
|
|
2310 |
|
|
|
2311 |
$forum_fid = $forum_data['FID'];
|
|
|
2312 |
|
|
|
2313 |
$forum_settings = forum_get_settings_by_fid($forum_fid);
|
|
|
2314 |
|
|
|
2315 |
foreach($forum_settings as $key => $value) {
|
|
|
2316 |
|
|
|
2317 |
if (!isset($forum_data[strtoupper($key)])) {
|
|
|
2318 |
|
|
|
2319 |
$forum_data[strtoupper($key)] = $value;
|
|
|
2320 |
}
|
|
|
2321 |
}
|
|
|
2322 |
|
|
|
2323 |
// Check the forum name is set. If it isn't set it to 'A Beehive Forum'
|
|
|
2324 |
|
|
|
2325 |
if (!isset($forum_data['FORUM_NAME']) || strlen(trim($forum_data['FORUM_NAME'])) < 1) {
|
|
|
2326 |
$forum_data['FORUM_NAME'] = "A Beehive Forum";
|
|
|
2327 |
}
|
|
|
2328 |
|
|
|
2329 |
// Check the forum description variable is set.
|
|
|
2330 |
|
|
|
2331 |
if (!isset($forum_data['FORUM_DESC'])) {
|
|
|
2332 |
$forum_data['FORUM_DESC'] = "";
|
|
|
2333 |
}
|
|
|
2334 |
|
|
|
2335 |
// Unread cut-off stamp.
|
|
|
2336 |
|
|
|
2337 |
$unread_cutoff_stamp = forum_process_unread_cutoff($forum_settings);
|
|
|
2338 |
|
|
|
2339 |
// Get available folders for queries below
|
|
|
2340 |
|
|
|
2341 |
$folders = folder_get_available_by_forum($forum_fid);
|
|
|
2342 |
|
|
|
2343 |
// User relationship constants
|
|
|
2344 |
|
|
|
2345 |
$user_ignored = USER_IGNORED;
|
|
|
2346 |
$user_ignored_completely = USER_IGNORED_COMPLETELY;
|
|
|
2347 |
|
|
|
2348 |
// Get any unread messages
|
|
|
2349 |
|
|
|
2350 |
if (is_numeric($unread_cutoff_stamp) && $unread_cutoff_stamp !== false) {
|
|
|
2351 |
|
|
|
2352 |
$sql = "SELECT SUM(THREAD.LENGTH) - SUM(COALESCE(USER_THREAD.LAST_READ, 0)) ";
|
|
|
2353 |
$sql.= "AS UNREAD_MESSAGES FROM {$forum_data['PREFIX']}THREAD THREAD ";
|
|
|
2354 |
$sql.= "LEFT JOIN {$forum_data['PREFIX']}USER_THREAD USER_THREAD ";
|
|
|
2355 |
$sql.= "ON (USER_THREAD.TID = THREAD.TID AND USER_THREAD.UID = '$uid') ";
|
|
|
2356 |
$sql.= "WHERE THREAD.FID IN ($folders) ";
|
|
|
2357 |
$sql.= "AND (THREAD.MODIFIED > FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - ";
|
|
|
2358 |
$sql.= "$unread_cutoff_stamp) OR $unread_cutoff_stamp = 0) ";
|
|
|
2359 |
|
|
|
2360 |
if (!$result_unread_count = db_query($sql, $db_forum_search)) return false;
|
|
|
2361 |
|
|
|
2362 |
list($unread_messages) = db_fetch_array($result_unread_count, DB_RESULT_NUM);
|
|
|
2363 |
|
|
|
2364 |
$forum_data['UNREAD_MESSAGES'] = $unread_messages;
|
|
|
2365 |
|
|
|
2366 |
}else {
|
|
|
2367 |
|
|
|
2368 |
$forum_data['UNREAD_MESSAGES'] = 0;
|
|
|
2369 |
}
|
|
|
2370 |
|
|
|
2371 |
// Total number of messages
|
|
|
2372 |
|
|
|
2373 |
$sql = "SELECT SUM(THREAD.LENGTH) AS NUM_MESSAGES ";
|
|
|
2374 |
$sql.= "FROM {$forum_data['PREFIX']}THREAD THREAD ";
|
|
|
2375 |
$sql.= "WHERE THREAD.FID IN ($folders) ";
|
|
|
2376 |
|
|
|
2377 |
if (!$result_messages_count = db_query($sql, $db_forum_search)) return false;
|
|
|
2378 |
|
|
|
2379 |
$num_messages_data = db_fetch_array($result_messages_count);
|
|
|
2380 |
|
|
|
2381 |
if (!isset($num_messages_data['NUM_MESSAGES']) || is_null($num_messages_data['NUM_MESSAGES'])) {
|
|
|
2382 |
$forum_data['NUM_MESSAGES'] = 0;
|
|
|
2383 |
}else {
|
|
|
2384 |
$forum_data['NUM_MESSAGES'] = $num_messages_data['NUM_MESSAGES'];
|
|
|
2385 |
}
|
|
|
2386 |
|
|
|
2387 |
// Get unread to me message count
|
|
|
2388 |
|
|
|
2389 |
$sql = "SELECT COUNT(POST.PID) AS UNREAD_TO_ME ";
|
|
|
2390 |
$sql.= "FROM {$forum_data['PREFIX']}THREAD THREAD ";
|
|
|
2391 |
$sql.= "LEFT JOIN {$forum_data['PREFIX']}POST POST ";
|
|
|
2392 |
$sql.= "ON (POST.TID = THREAD.TID) WHERE THREAD.FID IN ($folders) ";
|
|
|
2393 |
$sql.= "AND POST.TO_UID = '$uid' AND POST.VIEWED IS NULL ";
|
|
|
2394 |
|
|
|
2395 |
if (!$result_unread_to_me = db_query($sql, $db_forum_search)) return false;
|
|
|
2396 |
|
|
|
2397 |
$post_count_data = db_fetch_array($result_unread_to_me);
|
|
|
2398 |
|
|
|
2399 |
if (!isset($post_count_data['UNREAD_TO_ME']) || is_null($post_count_data['UNREAD_TO_ME'])) {
|
|
|
2400 |
$forum_data['UNREAD_TO_ME'] = 0;
|
|
|
2401 |
}else {
|
|
|
2402 |
$forum_data['UNREAD_TO_ME'] = $post_count_data['UNREAD_TO_ME'];
|
|
|
2403 |
}
|
|
|
2404 |
|
|
|
2405 |
// Sometimes the USER_THREAD table might have a higher count that the thread
|
|
|
2406 |
// length due to table corruption. I've only seen this on the SF provided
|
|
|
2407 |
// webspace but none the less we do this check here anyway.
|
|
|
2408 |
|
|
|
2409 |
if ($forum_data['NUM_MESSAGES'] < 0) $forum_data['NUM_MESSAGES'] = 0;
|
|
|
2410 |
if ($forum_data['UNREAD_MESSAGES'] < 0) $forum_data['UNREAD_MESSAGES'] = 0;
|
|
|
2411 |
if ($forum_data['UNREAD_TO_ME'] < 0) $forum_data['UNREAD_TO_ME'] = 0;
|
|
|
2412 |
|
|
|
2413 |
// Get Last Visited
|
|
|
2414 |
|
|
|
2415 |
$sql = "SELECT UNIX_TIMESTAMP(LAST_VISIT) AS LAST_VISIT FROM USER_FORUM ";
|
|
|
2416 |
$sql.= "WHERE UID = '$uid' AND FID = '$forum_fid' ";
|
|
|
2417 |
$sql.= "AND LAST_VISIT IS NOT NULL AND LAST_VISIT > 0";
|
|
|
2418 |
|
|
|
2419 |
if (!$result_last_visit = db_query($sql, $db_forum_search)) return false;
|
|
|
2420 |
|
|
|
2421 |
$user_last_visit_data = db_fetch_array($result_last_visit);
|
|
|
2422 |
|
|
|
2423 |
if (!isset($user_last_visit_data['LAST_VISIT']) || is_null($user_last_visit_data['LAST_VISIT'])) {
|
|
|
2424 |
$forum_data['LAST_VISIT'] = 0;
|
|
|
2425 |
}else {
|
|
|
2426 |
$forum_data['LAST_VISIT'] = $user_last_visit_data['LAST_VISIT'];
|
|
|
2427 |
}
|
|
|
2428 |
|
|
|
2429 |
$forums_array[] = $forum_data;
|
|
|
2430 |
}
|
|
|
2431 |
|
|
|
2432 |
}else if ($forums_count > 0) {
|
|
|
2433 |
|
|
|
2434 |
$offset = floor(($forums_count - 1) / 10) * 10;
|
|
|
2435 |
return forum_search($forum_search, $offset);
|
|
|
2436 |
}
|
|
|
2437 |
}
|
|
|
2438 |
|
|
|
2439 |
return array('forums_array' => $forums_array,
|
|
|
2440 |
'forums_count' => $forums_count);
|
|
|
2441 |
}
|
|
|
2442 |
|
|
|
2443 |
function forum_get_all_prefixes()
|
|
|
2444 |
{
|
|
|
2445 |
if (!$db_forum_get_all_prefixes = db_connect()) return false;
|
|
|
2446 |
|
|
|
2447 |
$sql = "SELECT CONCAT(DATABASE_NAME, '.', WEBTAG, '_') AS PREFIX, ";
|
|
|
2448 |
$sql.= "FID FROM FORUMS ";
|
|
|
2449 |
|
|
|
2450 |
if (!$result = db_query($sql, $db_forum_get_all_prefixes)) return false;
|
|
|
2451 |
|
|
|
2452 |
if (db_num_rows($result) > 0) {
|
|
|
2453 |
|
|
|
2454 |
$prefix_array = array();
|
|
|
2455 |
|
|
|
2456 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
2457 |
$prefix_array[$forum_data['FID']] = $forum_data['PREFIX'];
|
|
|
2458 |
}
|
|
|
2459 |
|
|
|
2460 |
return $prefix_array;
|
|
|
2461 |
}
|
|
|
2462 |
|
|
|
2463 |
return false;
|
|
|
2464 |
}
|
|
|
2465 |
|
|
|
2466 |
function forum_get_all_webtags()
|
|
|
2467 |
{
|
|
|
2468 |
if (!$db_forum_get_all_webtags = db_connect()) return false;
|
|
|
2469 |
|
|
|
2470 |
$sql = "SELECT FID, WEBTAG FROM FORUMS ";
|
|
|
2471 |
|
|
|
2472 |
if (!$result = db_query($sql, $db_forum_get_all_webtags)) return false;
|
|
|
2473 |
|
|
|
2474 |
if (db_num_rows($result) > 0) {
|
|
|
2475 |
|
|
|
2476 |
$webtag_array = array();
|
|
|
2477 |
|
|
|
2478 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
2479 |
$webtag_array[$forum_data['FID']] = $forum_data['WEBTAG'];
|
|
|
2480 |
}
|
|
|
2481 |
|
|
|
2482 |
return $webtag_array;
|
|
|
2483 |
}
|
|
|
2484 |
|
|
|
2485 |
return false;
|
|
|
2486 |
}
|
|
|
2487 |
|
|
|
2488 |
function forum_get_all_fids()
|
|
|
2489 |
{
|
|
|
2490 |
if (!$db_forum_get_all_fids = db_connect()) return false;
|
|
|
2491 |
|
|
|
2492 |
$sql = "SELECT FID FROM FORUMS";
|
|
|
2493 |
|
|
|
2494 |
if (!$result = db_query($sql, $db_forum_get_all_fids)) return false;
|
|
|
2495 |
|
|
|
2496 |
if (db_num_rows($result) > 0) {
|
|
|
2497 |
|
|
|
2498 |
$fids_array = array();
|
|
|
2499 |
|
|
|
2500 |
while ($forum_data = db_fetch_array($result)) {
|
|
|
2501 |
$fids_array[] = $forum_data['FID'];
|
|
|
2502 |
}
|
|
|
2503 |
|
|
|
2504 |
return $fids_array;
|
|
|
2505 |
}
|
|
|
2506 |
|
|
|
2507 |
return false;
|
|
|
2508 |
}
|
|
|
2509 |
|
|
|
2510 |
function forum_update_last_visit($uid)
|
|
|
2511 |
{
|
|
|
2512 |
if (!$db_forum_update_last_visit = db_connect()) return false;
|
|
|
2513 |
|
|
|
2514 |
if (!is_numeric($uid)) return false;
|
|
|
2515 |
|
|
|
2516 |
if (!$table_data = get_table_prefix()) return false;
|
|
|
2517 |
|
|
|
2518 |
$forum_fid = $table_data['FID'];
|
|
|
2519 |
|
|
|
2520 |
if ($uid > 0) {
|
|
|
2521 |
|
|
|
2522 |
$sql = "SELECT LAST_VISIT FROM USER_FORUM WHERE UID = '$uid'";
|
|
|
2523 |
$sql.= "AND FID = '$forum_fid'";
|
|
|
2524 |
|
|
|
2525 |
if (!$result = db_query($sql, $db_forum_update_last_visit)) return false;
|
|
|
2526 |
|
|
|
2527 |
if (db_num_rows($result) > 0) {
|
|
|
2528 |
|
|
|
2529 |
$sql = "UPDATE LOW_PRIORITY USER_FORUM SET LAST_VISIT = NOW() ";
|
|
|
2530 |
$sql.= "WHERE UID = '$uid' AND FID = '$forum_fid'";
|
|
|
2531 |
|
|
|
2532 |
}else {
|
|
|
2533 |
|
|
|
2534 |
$sql = "INSERT INTO USER_FORUM (UID, FID, LAST_VISIT) ";
|
|
|
2535 |
$sql.= "VALUES ('$uid', '$forum_fid', NOW())";
|
|
|
2536 |
}
|
|
|
2537 |
|
|
|
2538 |
if (!$result = db_query($sql, $db_forum_update_last_visit)) return false;
|
|
|
2539 |
}
|
|
|
2540 |
|
|
|
2541 |
return true;
|
|
|
2542 |
}
|
|
|
2543 |
|
|
|
2544 |
function forums_get_available_dbs()
|
|
|
2545 |
{
|
|
|
2546 |
if (!$db_forums_get_available_dbs = db_connect()) return false;
|
|
|
2547 |
|
|
|
2548 |
$sql = "SHOW DATABASES";
|
|
|
2549 |
|
|
|
2550 |
if (!$result = db_query($sql, $db_forums_get_available_dbs)) return false;
|
|
|
2551 |
|
|
|
2552 |
if (db_num_rows($result) > 0) {
|
|
|
2553 |
|
|
|
2554 |
$database_array = array();
|
|
|
2555 |
|
|
|
2556 |
while ($database = db_fetch_array($result)) {
|
|
|
2557 |
|
|
|
2558 |
if (!stristr('information_schema', $database['Database'])) {
|
|
|
2559 |
|
|
|
2560 |
$database_array[$database['Database']] = $database['Database'];
|
|
|
2561 |
}
|
|
|
2562 |
}
|
|
|
2563 |
|
|
|
2564 |
return $database_array;
|
|
|
2565 |
}
|
|
|
2566 |
|
|
|
2567 |
return false;
|
|
|
2568 |
}
|
|
|
2569 |
|
|
|
2570 |
function forums_get_available_count()
|
|
|
2571 |
{
|
|
|
2572 |
if (!$db_forums_get_available_count = db_connect()) return false;
|
|
|
2573 |
|
|
|
2574 |
if (($uid = bh_session_get_value('UID')) === false) return 0;
|
|
|
2575 |
|
|
|
2576 |
$sql = "SELECT COUNT(FORUMS.FID) FROM FORUMS FORUMS ";
|
|
|
2577 |
$sql.= "LEFT JOIN USER_FORUM USER_FORUM ON (USER_FORUM.FID = FORUMS.FID ";
|
|
|
2578 |
$sql.= "AND USER_FORUM.UID = '$uid') WHERE FORUMS.ACCESS_LEVEL = 0 ";
|
|
|
2579 |
$sql.= "OR FORUMS.ACCESS_LEVEL = 2 OR (FORUMS.ACCESS_LEVEL = 1 ";
|
|
|
2580 |
$sql.= "AND USER_FORUM.ALLOWED = 1) ";
|
|
|
2581 |
|
|
|
2582 |
if (!$result = db_query($sql, $db_forums_get_available_count)) return false;
|
|
|
2583 |
|
|
|
2584 |
if (db_num_rows($result) > 0) {
|
|
|
2585 |
|
|
|
2586 |
list($forum_available_count) = db_fetch_array($result, DB_RESULT_NUM);
|
|
|
2587 |
return $forum_available_count;
|
|
|
2588 |
}
|
|
|
2589 |
|
|
|
2590 |
return false;
|
|
|
2591 |
}
|
|
|
2592 |
|
|
|
2593 |
// Forum self-preservation functions. Randomly picks a function to
|
|
|
2594 |
// run which helps preserve functionality of Beehive.
|
|
|
2595 |
|
|
|
2596 |
function forum_perform_self_clean()
|
|
|
2597 |
{
|
|
|
2598 |
$forum_self_clean_functions_array = array('update_stats',
|
|
|
2599 |
'pm_system_prune_folders',
|
|
|
2600 |
'bh_remove_stale_sessions',
|
|
|
2601 |
'thread_auto_prune_unread_data',
|
|
|
2602 |
'captcha_clean_up');
|
|
|
2603 |
|
|
|
2604 |
$forum_self_clean_prob = intval(forum_get_setting('forum_self_clean_prob', false, 1000));
|
|
|
2605 |
|
|
|
2606 |
if ($forum_self_clean_prob < 1) $forum_self_clean_prob = 1;
|
|
|
2607 |
if ($forum_self_clean_prob > 1000) $forum_self_clean_prob = 1000;
|
|
|
2608 |
|
|
|
2609 |
if (($mt_result = mt_rand(1, $forum_self_clean_prob)) == 1) {
|
|
|
2610 |
|
|
|
2611 |
$forum_self_clean_function = mt_rand(0, sizeof($forum_self_clean_functions_array) - 1);
|
|
|
2612 |
|
|
|
2613 |
if (isset($forum_self_clean_functions_array[$forum_self_clean_function])
|
|
|
2614 |
&& function_exists($forum_self_clean_functions_array[$forum_self_clean_function])) {
|
|
|
2615 |
|
|
|
2616 |
return $forum_self_clean_functions_array[$forum_self_clean_function]();
|
|
|
2617 |
}
|
|
|
2618 |
}
|
|
|
2619 |
|
|
|
2620 |
return false;
|
|
|
2621 |
}
|
|
|
2622 |
|
|
|
2623 |
?>
|