mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
Various updates, forum links, "improve" forum management, cleanups, blah blah, note the schema changes, note also that forum management may misbehave ... reports on wrong doings are welcome ... seem to be having problems with some mcp functions under apache/win32
git-svn-id: file:///svn/phpbb/trunk@3961 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -116,13 +116,13 @@ function generate_forum_nav(&$forum_data)
|
||||
{
|
||||
$template->assign_block_vars('navlinks', array(
|
||||
'FORUM_NAME' => $parent_name,
|
||||
'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id)
|
||||
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$parent_forum_id")
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_block_vars('navlinks', array(
|
||||
'FORUM_NAME' => $forum_data['forum_name'],
|
||||
'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_data['forum_id'])
|
||||
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_data['forum_id'])
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
@@ -224,7 +224,7 @@ function gen_forum_rules($mode, &$forum_id)
|
||||
return;
|
||||
}
|
||||
|
||||
function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir)
|
||||
function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param)
|
||||
{
|
||||
global $user;
|
||||
|
||||
@@ -254,6 +254,8 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key,
|
||||
}
|
||||
$s_sort_dir .= '</select>';
|
||||
|
||||
$u_sort_param = "st=$sort_days&sk=$sort_key&sd=$sort_dir";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,7 +264,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false)
|
||||
global $auth, $template, $user, $db, $nav_links, $phpEx, $SID;
|
||||
|
||||
$boxstring = '';
|
||||
$sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id
|
||||
$sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
ORDER BY left_id ASC';
|
||||
$result = $db->sql_query($sql, 600);
|
||||
@@ -271,7 +273,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false)
|
||||
$padding = $forum_list = $holding = '';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id']))
|
||||
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
||||
{
|
||||
// Non-postable forum with no subforums, don't display
|
||||
continue;
|
||||
@@ -447,10 +449,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">')
|
||||
);
|
||||
|
||||
meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start");
|
||||
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
@@ -481,10 +480,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">')
|
||||
);
|
||||
|
||||
meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start");
|
||||
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
@@ -512,14 +508,14 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
|
||||
|
||||
if ($can_watch)
|
||||
{
|
||||
$s_watching = ($is_watching) ? '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&unwatch=$mode&start=$start" . '">' . $user->lang['STOP_WATCHING_' . strtoupper($mode)] . '</a>' : '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&watch=$mode&start=$start" . '">' . $user->lang['START_WATCHING_' . strtoupper($mode)] . '</a>';
|
||||
$s_watching = ($is_watching) ? "<a href=\"view$mode.$phpEx$SID&$u_url=$match_id&unwatch=$mode&start=$start\">" . $user->lang['STOP_WATCHING_' . strtoupper($mode)] . '</a>' : "<a href=\"view$mode.$phpEx$SID&$u_url=$match_id&watch=$mode&start=$start\">" . $user->lang['START_WATCHING_' . strtoupper($mode)] . '</a>';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Marks a topic or form as read
|
||||
function markread($mode, $forum_id = 0, $topic_id = 0, $post_id = 0)
|
||||
function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
@@ -530,7 +526,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $post_id = 0)
|
||||
|
||||
// Default tracking type
|
||||
$type = TRACK_NORMAL;
|
||||
$current_time = time();
|
||||
$current_time = ($marktime) ? $marktime : time();
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
@@ -857,7 +853,7 @@ function generate_board_url()
|
||||
// Redirects the user to another page then exits the script nicely
|
||||
function redirect($url)
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
global $db, $cache, $config, $user;
|
||||
|
||||
if (isset($db))
|
||||
{
|
||||
@@ -869,13 +865,14 @@ function redirect($url)
|
||||
$cache->unload();
|
||||
}
|
||||
|
||||
$url = generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url));
|
||||
// Local redirect? If not, prepend the boards url
|
||||
$url = (!strstr($url, '://')) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url;
|
||||
|
||||
// Redirect via an HTML form for PITA webservers
|
||||
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
|
||||
{
|
||||
header('Refresh: 0; URL=' . $url);
|
||||
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $url . '"><title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click <a href="' . $url . '">HERE</a> to be redirected</div></body></html>';
|
||||
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $url . '"><title>Redirect</title></head><body><div align="center">' . sprintf($user->lang['URL_REDIRECT'], '<a href="' . $url . '">', '</a>') . '</div></body></html>';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -1045,5 +1042,339 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
//
|
||||
function page_header($page_title = '')
|
||||
{
|
||||
global $db, $config, $template, $user, $auth, $cache;
|
||||
|
||||
define('HEADER_INC', TRUE);
|
||||
|
||||
// gzip_compression
|
||||
if ($config['gzip_compress'])
|
||||
{
|
||||
if (extension_loaded('zlib') && !headers_sent())
|
||||
{
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate logged in/logged out status
|
||||
if ($user->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
$u_login_logout = 'ucp.'.$phpEx. $SID . '&mode=logout';
|
||||
$l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$u_login_logout = 'ucp.'.$phpEx . $SID . '&mode=login';
|
||||
$l_login_logout = $user->lang['LOGIN'];
|
||||
}
|
||||
|
||||
// Last visit date/time
|
||||
$s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : '';
|
||||
|
||||
// Get users online list ... if required
|
||||
$l_online_users = $online_userlist = $l_online_record = '';
|
||||
if (!empty($config['load_online']) && !empty($config['load_online_time']))
|
||||
{
|
||||
$userlist_ary = $userlist_visible = array();
|
||||
$logged_visible_online = $logged_hidden_online = $guests_online = 0;
|
||||
|
||||
$prev_user_id = 0;
|
||||
$prev_user_ip = $reading_sql = '';
|
||||
if (!empty($_REQUEST['f']))
|
||||
{
|
||||
$reading_sql = "AND s.session_page LIKE '%f=" . intval($_REQUEST['f']) . "%'";
|
||||
}
|
||||
|
||||
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_allow_viewonline
|
||||
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s
|
||||
WHERE s.session_time >= " . (time() - (intval($config['load_online_time']) * 60)) . "
|
||||
$reading_sql
|
||||
AND u.user_id = s.session_user_id
|
||||
ORDER BY u.username ASC, s.session_ip ASC";
|
||||
$result = $db->sql_query($sql, false);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
// User is logged in and therefor not a guest
|
||||
if ($row['user_id'] != ANONYMOUS)
|
||||
{
|
||||
// Skip multiple sessions for one user
|
||||
if ($row['user_id'] != $prev_user_id)
|
||||
{
|
||||
if ($row['user_colour'])
|
||||
{
|
||||
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||
}
|
||||
|
||||
if ($row['user_allow_viewonline'] && $row['session_allow_viewonline'])
|
||||
{
|
||||
$user_online_link = $row['username'];
|
||||
$logged_visible_online++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_online_link = '<i>' . $row['username'] . '</i>';
|
||||
$logged_hidden_online++;
|
||||
}
|
||||
|
||||
if ($row['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
$user_online_link = '<a href="' . "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] . '">' . $user_online_link . '</a>';
|
||||
$online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link;
|
||||
}
|
||||
}
|
||||
|
||||
$prev_user_id = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip multiple sessions for one user
|
||||
if ($row['session_ip'] != $prev_session_ip)
|
||||
{
|
||||
$guests_online++;
|
||||
}
|
||||
}
|
||||
|
||||
$prev_session_ip = $row['session_ip'];
|
||||
}
|
||||
|
||||
if ($online_userlist == '')
|
||||
{
|
||||
$online_userlist = $user->lang['NONE'];
|
||||
}
|
||||
|
||||
if (empty($_REQUEST['f']))
|
||||
{
|
||||
$online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_online = ($guests_online == 1) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests'];
|
||||
$online_userlist = sprintf($l_online, $online_userlist, $guests_online);
|
||||
}
|
||||
|
||||
$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
|
||||
|
||||
if ($total_online_users > $config['record_online_users'])
|
||||
{
|
||||
set_config('record_online_users', $total_online_users, TRUE);
|
||||
set_config('record_online_date', time(), TRUE);
|
||||
}
|
||||
|
||||
// Build online listing
|
||||
$vars_online = array(
|
||||
'ONLINE'=> array('total_online_users', 'l_t_user_s'),
|
||||
'REG' => array('logged_visible_online', 'l_r_user_s'),
|
||||
'HIDDEN'=> array('logged_hidden_online', 'l_h_user_s'),
|
||||
'GUEST' => array('guests_online', 'l_g_user_s')
|
||||
);
|
||||
|
||||
foreach ($vars_online as $l_prefix => $var_ary)
|
||||
{
|
||||
switch ($$var_ary[0])
|
||||
{
|
||||
case 0:
|
||||
$$var_ary[1] = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL'];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$$var_ary[1] = $user->lang[$l_prefix . '_USER_TOTAL'];
|
||||
break;
|
||||
|
||||
default:
|
||||
$$var_ary[1] = $user->lang[$l_prefix . '_USERS_TOTAL'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($vars_online);
|
||||
|
||||
$l_online_users = sprintf($l_t_user_s, $total_online_users);
|
||||
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
|
||||
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
|
||||
$l_online_users .= sprintf($l_g_user_s, $guests_online);
|
||||
$l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date']));
|
||||
$l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES';
|
||||
$l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']);
|
||||
}
|
||||
|
||||
// Obtain number of new private messages if user is logged in
|
||||
if ($user->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
if ($user->data['user_new_privmsg'])
|
||||
{
|
||||
$l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['New_pm'] : $user->lang['New_pms'];
|
||||
$l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
|
||||
|
||||
if ($user->data['user_last_privmsg'] > $user->data['session_last_visit'])
|
||||
{
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_last_privmsg = " . $user->data['session_last_visit'] . "
|
||||
WHERE user_id = " . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$s_privmsg_new = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_privmsg_new = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_privmsgs_text = $user->lang['No_new_pm'];
|
||||
$s_privmsg_new = 0;
|
||||
}
|
||||
|
||||
if ($user->data['user_unread_privmsg'])
|
||||
{
|
||||
$l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['Unread_pm'] : $user->lang['Unread_pms'];
|
||||
$l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_privmsgs_text_unread = $user->lang['No_unread_pm'];
|
||||
}
|
||||
}
|
||||
|
||||
// Generate HTML required for Mozilla Navigation bar
|
||||
$nav_links_html = '';
|
||||
*
|
||||
$nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n";
|
||||
foreach ($nav_links as $nav_item => $nav_array)
|
||||
{
|
||||
if (!empty($nav_array['url']))
|
||||
{
|
||||
$nav_links_html .= sprintf($nav_link_proto, $nav_item, $nav_array['url'], $nav_array['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
|
||||
foreach ($nav_array as $key => $nested_array)
|
||||
{
|
||||
$nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
*
|
||||
|
||||
// Which timezone?
|
||||
$tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone']));
|
||||
|
||||
// The following assigns all _common_ variables that may be used at any point
|
||||
// in a template.
|
||||
$template->assign_vars(array(
|
||||
'SITENAME' => $config['sitename'],
|
||||
'SITE_DESCRIPTION' => $config['site_desc'],
|
||||
'PAGE_TITLE' => $page_title,
|
||||
'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit),
|
||||
'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time())),
|
||||
'TOTAL_USERS_ONLINE' => $l_online_users,
|
||||
'LOGGED_IN_USER_LIST' => $online_userlist,
|
||||
'RECORD_USERS' => $l_online_record,
|
||||
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
|
||||
'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,
|
||||
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
|
||||
|
||||
'L_LOGIN_LOGOUT' => $l_login_logout,
|
||||
'L_INDEX' => $user->lang['FORUM_INDEX'],
|
||||
'L_ONLINE_EXPLAIN' => $l_online_time,
|
||||
|
||||
'U_PRIVATEMSGS' => 'ucp.'.$phpEx.$SID.'&mode=pm&folder=inbox',
|
||||
'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_VIEWONLINE' => 'viewonline.'.$phpEx.$SID,
|
||||
'U_MEMBERSLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID,
|
||||
'U_LOGIN_LOGOUT'=> $u_login_logout,
|
||||
'U_INDEX' => 'index.'.$phpEx.$SID,
|
||||
'U_SEARCH' => 'search.'.$phpEx.$SID,
|
||||
'U_REGISTER' => 'ucp.'.$phpEx.$SID.'&mode=register',
|
||||
'U_PROFILE' => 'ucp.'.$phpEx.$SID.'&mode=editprofile',
|
||||
'U_MODCP' => 'mcp.'.$phpEx.$SID,
|
||||
'U_FAQ' => 'faq.'.$phpEx.$SID,
|
||||
'U_SEARCH_SELF' => 'search.'.$phpEx.$SID.'&search_id=egosearch',
|
||||
'U_SEARCH_NEW' => 'search.'.$phpEx.$SID.'&search_id=newposts',
|
||||
'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered',
|
||||
|
||||
'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
|
||||
'S_USER_PM_POPUP' => (!empty($user->data['user_popup_pm'])) ? true : false,
|
||||
'S_USER_BROWSER' => $user->data['session_browser'],
|
||||
'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
|
||||
'S_CONTENT_ENCODING' => $user->lang['ENCODING'],
|
||||
'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'],
|
||||
'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'],
|
||||
'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], ''),
|
||||
'S_DISPLAY_ONLINE_LIST' => (!empty($config['load_online'])) ? 1 : 0,
|
||||
'S_DISPLAY_SEARCH' => (!empty($config['load_search'])) ? 1 : 0,
|
||||
'S_DISPLAY_PM' => (empty($config['privmsg_disable'])) ? 1 : 0,
|
||||
'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0,
|
||||
|
||||
'T_STYLESHEET_DATA' => $user->theme['css_data'],
|
||||
'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'],
|
||||
|
||||
'NAV_LINKS' => $nav_links_html)
|
||||
);
|
||||
|
||||
if ($config['send_encoding'])
|
||||
{
|
||||
header ('Content-type: text/html; charset: ' . $user->lang['ENCODING']);
|
||||
}
|
||||
header ('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
|
||||
header ('Expires: 0');
|
||||
header ('Pragma: no-cache');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
function page_footer()
|
||||
{
|
||||
global $db, $config, $template, $user, $auth, $cache, $starttime;
|
||||
|
||||
// Close our DB connection.
|
||||
$db->sql_close();
|
||||
|
||||
// Unload cache
|
||||
if (!empty($cache))
|
||||
{
|
||||
$cache->unload();
|
||||
}
|
||||
|
||||
// Output page creation time
|
||||
if (defined('DEBUG'))
|
||||
{
|
||||
$mtime = explode(' ', microtime());
|
||||
$totaltime = $mtime[0] + $mtime[1] - $starttime;
|
||||
|
||||
if (!empty($_REQUEST['explain']) && $auth->acl_get('a_'))
|
||||
{
|
||||
echo $db->sql_report;
|
||||
echo "<pre><b>Page generated in $totaltime seconds with " . $db->num_queries . " queries,\nspending " . $db->sql_time . ' doing SQL queries and ' . ($totaltime - $db->sql_time) . ' doing PHP things.</b></pre>';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime);
|
||||
|
||||
if ($auth->acl_get('a_'))
|
||||
{
|
||||
$debug_output .= ' | <a href="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '&explain=1">Explain</a>';
|
||||
}
|
||||
$debug_output .= ' ]';
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PHPBB_VERSION' => $config['version'],
|
||||
'ADMIN_LINK' => ($auth->acl_get('a_')) ? sprintf($user->lang['ACP'], '<a href="' . "adm/index.$phpEx?sid=" . $user->data['session_id'] . '">', '</a>') . '<br /><br />' : '',
|
||||
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '')
|
||||
);
|
||||
|
||||
$template->display('body');
|
||||
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
@@ -20,21 +20,20 @@
|
||||
***************************************************************************/
|
||||
|
||||
// Simple version of jumpbox, just lists authed forums
|
||||
// This needs altering to allow for ignoring acl checks ... they aren't needed
|
||||
// everywhere ...
|
||||
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false)
|
||||
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$right = $cat_right = 0;
|
||||
$forum_list = $padding = $holding = '';
|
||||
|
||||
$acl = ($ignore_acl) ? '' : 'f_list';
|
||||
$rowset = get_forum_list($acl, FALSE, FALSE, TRUE);
|
||||
$acl = ($ignore_acl) ? '' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel');
|
||||
$rowset = get_forum_list($acl, false, $ignore_nonpost, true);
|
||||
|
||||
foreach ($rowset as $row)
|
||||
{
|
||||
if ($row['forum_id'] == $ignore_id)
|
||||
if ((is_array($ignore_id) && in_array($row['forum_id'], $ignore_id)) ||
|
||||
$row['forum_id'] == $ignore_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -57,15 +56,16 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
|
||||
$holding = '';
|
||||
}
|
||||
|
||||
if ($row['right_id'] - $row['left_id'] > 1)
|
||||
if ($row['right_id'] - $row['left_id'] > 1 && $ignore_emptycat)
|
||||
{
|
||||
$cat_right = max($cat_right, $row['right_id']);
|
||||
|
||||
$holding .= '<option class="sep" value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '+ ' . $row['forum_name'] . '</option>';
|
||||
$holding .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '+ ' . $row['forum_name'] . '</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_list .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '- ' . $row['forum_name'] . '</option>';
|
||||
$sep = ($row['right_id'] - $row['left_id'] > 1) ? '+ ' : '- ';
|
||||
$forum_list .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $sep . $row['forum_name'] . '</option>';
|
||||
$holding = '';
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only =
|
||||
{
|
||||
// This query is identical to the jumpbox one
|
||||
$expire_time = ($no_cache) ? 0 : 120;
|
||||
$sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id
|
||||
$sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
ORDER BY left_id ASC';
|
||||
$result = $db->sql_query($sql, $expire_time);
|
||||
@@ -102,7 +102,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only =
|
||||
$rowset = array();
|
||||
foreach ($forum_rows as $row)
|
||||
{
|
||||
if ($postable_only && !$row['forum_postable'])
|
||||
if ($postable_only && $row['forum_type'] == FORUM_CAT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -122,49 +122,45 @@ function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
|
||||
global $db;
|
||||
|
||||
$forum_ids = array($forum_id);
|
||||
$where_sql = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids;
|
||||
$sql_where = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids;
|
||||
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . "
|
||||
WHERE topic_moved_id $sql_where
|
||||
AND forum_id = " . $forum_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_MOD_TABLE);
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET forum_id = $forum_id
|
||||
WHERE topic_id " . $sql_where;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
unset($table_ary);
|
||||
|
||||
if ($auto_sync)
|
||||
{
|
||||
$sql = 'SELECT DISTINCT forum_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE topic_id ' . $where_sql;
|
||||
WHERE topic_id ' . $sql_where;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . "
|
||||
WHERE topic_moved_id $where_sql
|
||||
AND forum_id = " . $forum_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET forum_id = $forum_id
|
||||
WHERE topic_id " . $where_sql;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . "
|
||||
SET forum_id = $forum_id
|
||||
WHERE topic_id " . $where_sql;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . LOG_MOD_TABLE . "
|
||||
SET forum_id = $forum_id
|
||||
WHERE topic_id " . $where_sql;
|
||||
$db->sql_query($sql);
|
||||
|
||||
if ($auto_sync)
|
||||
{
|
||||
sync('forum', 'forum_id', $forum_ids, TRUE);
|
||||
unset($forum_ids);
|
||||
}
|
||||
}
|
||||
|
||||
function move_posts($post_ids, $topic_id, $auto_sync = TRUE)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!is_array($post_ids))
|
||||
{
|
||||
$post_ids = array($post_ids);
|
||||
@@ -179,19 +175,25 @@ function move_posts($post_ids, $topic_id, $auto_sync = TRUE)
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
$topic_ids[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id;
|
||||
$sql = 'SELECT *
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
if (!$row = $db->sql_fetchrow($result))
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
trigger_error('Topic_post_not_exist');
|
||||
trigger_error('NO_TOPIC');
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET forum_id = ' . $row['forum_id'] . ", topic_id = $topic_id
|
||||
@@ -217,6 +219,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
|
||||
{
|
||||
$where_ids = array_unique($where_ids);
|
||||
}
|
||||
|
||||
if (!count($where_ids))
|
||||
{
|
||||
return array('topics' => 0, 'posts' => '0');
|
||||
@@ -226,13 +229,13 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
|
||||
'posts' => delete_posts($where_type, $where_ids, FALSE)
|
||||
);
|
||||
|
||||
$where_sql = "WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')');
|
||||
//???? $where_sql = "WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')');
|
||||
|
||||
$sql = 'SELECT topic_id, forum_id
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')');
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
@@ -247,17 +250,25 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
|
||||
return $return;
|
||||
}
|
||||
|
||||
// TODO: clean up topics cache if any, last read marking, probably some other stuff too
|
||||
// TODO: probably some other stuff too
|
||||
|
||||
$where_sql = ' IN (' . implode(', ', $topic_ids) . ')';
|
||||
$sql_where = ' IN (' . implode(', ', $topic_ids) . ')';
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
$db->sql_query('DELETE FROM ' . LASTREAD_TABLE . ' WHERE topic_id' . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id' . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id' . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id' . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id' . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_id' . $where_sql);
|
||||
|
||||
$table_ary = array(TOPICS_TRACK_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
$sql = "DELETE FROM $table
|
||||
WHERE topic_id $sql_where";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
unset($table_ary);
|
||||
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE topic_moved_id' . $sql_where;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
if ($auto_sync)
|
||||
@@ -266,6 +277,23 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
|
||||
sync('topic_reported', $where_type, $where_ids);
|
||||
}
|
||||
|
||||
// Optimize/vacuum tables
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
$table_ary = array(TOPICS_TRACK_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
|
||||
$sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary);
|
||||
$db->sql_query($sql);
|
||||
unset($table_ary);
|
||||
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
$db->sql_query('VACUUM');
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -301,13 +329,19 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE)
|
||||
return false;
|
||||
}
|
||||
|
||||
$where_sql = ' WHERE post_id IN (' . implode(', ', $post_ids) . ')';
|
||||
$sql_where = implode(', ', $post_ids);
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
$db->sql_query('DELETE FROM ' . POSTS_TABLE . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . RATINGS_TABLE . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . REPORTS_TABLE . $where_sql);
|
||||
$db->sql_query('DELETE FROM ' . SEARCH_MATCH_TABLE . $where_sql);
|
||||
|
||||
$table_ary = array(POSTS_TABLE, RATINGS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE);
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
$sql = "DELETE FROM $table
|
||||
WHERE post_id IN ($sql_where)";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
unset($table_ary);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
delete_attachment($post_ids);
|
||||
@@ -319,18 +353,35 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE)
|
||||
sync('forum', 'forum_id', $forum_ids, TRUE);
|
||||
}
|
||||
|
||||
// Optimize/vacuum tables
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
$table_ary = array(POSTS_TABLE, RATINGS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE);
|
||||
$sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary);
|
||||
$db->sql_query($sql);
|
||||
unset($table_ary);
|
||||
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
$db->sql_query('VACUUM');
|
||||
break;
|
||||
}
|
||||
|
||||
return count($post_ids);
|
||||
}
|
||||
|
||||
// All-encompasing sync function
|
||||
//
|
||||
// Usage:
|
||||
// sync('topic', 'topic_id', 123); <= resynch topic #123
|
||||
// sync('topic', 'forum_id', array(2, 3)); <= resynch topics from forum #2 and #3
|
||||
// sync('topic'); <= resynch all topics
|
||||
//
|
||||
function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, $sync_extra = FALSE)
|
||||
{
|
||||
global $db, $dbms;
|
||||
global $db;
|
||||
|
||||
if (is_array($where_ids))
|
||||
{
|
||||
@@ -351,13 +402,13 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
else
|
||||
{
|
||||
$where_sql = 'WHERE ' . $mode{0} . ".$where_type IN (" . implode(', ', $where_ids) . ')';
|
||||
$where_sql_and = $where_sql . "\n\tAND";
|
||||
$where_sql_and = $where_sql . ' AND';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql = "WHERE t.$where_type IN (" . implode(', ', $where_ids) . ')';
|
||||
$where_sql_and = $where_sql . "\n\tAND";
|
||||
$where_sql_and = $where_sql . ' AND';
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
@@ -370,7 +421,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$topic_ids = $approved_unapproved_ids = array();
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$approved_unapproved_ids[] = $row['topic_id'];
|
||||
@@ -386,29 +436,34 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
SET topic_approved = 1 - topic_approved
|
||||
WHERE topic_id IN (' . implode(', ', $approved_unapproved_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'post_attachment':
|
||||
$post_ids = array();
|
||||
|
||||
switch ($dbms)
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'oracle':
|
||||
//TODO
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = 'SELECT t.post_id, t.post_attachment, COUNT(a.attachment_id) AS attachments
|
||||
FROM ' . POSTS_TABLE . ' t
|
||||
LEFT JOIN ' . ATTACHMENTS_TABLE . " a ON t.post_id = a.post_id
|
||||
$where_sql
|
||||
GROUP BY t.post_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (($row['post_attachment'] && !$row['attachments']) || ($row['attachments'] && !$row['post_attachment']))
|
||||
{
|
||||
$post_ids[] = $row['post_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (($row['post_attachment'] && !$row['attachments']) || ($row['attachments'] && !$row['post_attachment']))
|
||||
{
|
||||
$post_ids[] = $row['post_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!count($post_ids))
|
||||
{
|
||||
@@ -419,32 +474,37 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
SET post_attachment = 1 - post_attachment
|
||||
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'topic_attachment':
|
||||
$topic_ids = array();
|
||||
|
||||
switch ($dbms)
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'oracle':
|
||||
//TODO
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = 'SELECT t.topic_id, t.topic_attachment, COUNT(a.attachment_id) AS attachments
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
||||
LEFT JOIN ' . ATTACHMENTS_TABLE . " a ON p.post_id = a.post_id
|
||||
$where_sql_and t.topic_id = p.topic_id
|
||||
AND ((t.topic_attachment = 1 AND attachments = 0)
|
||||
OR (t.topic_attachment = 0 AND attachments > 0))
|
||||
OR (t.topic_attachment = 0 AND attachments > 0))
|
||||
GROUP BY t.topic_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (($row['topic_attachment'] && !$row['attachments'])
|
||||
|| ($row['attachments'] && !$row['topic_attachment']))
|
||||
{
|
||||
$topic_ids[] = $row['topic_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$topic_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (($row['topic_attachment'] && !$row['attachments'])
|
||||
|| ($row['attachments'] && !$row['topic_attachment']))
|
||||
{
|
||||
$topic_ids[] = $row['topic_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($topic_ids))
|
||||
{
|
||||
@@ -455,98 +515,122 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
SET topic_attachment = 1 - topic_attachment
|
||||
WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'reported':
|
||||
$topic_data = $topic_ids = $post_ids = array();
|
||||
|
||||
if ($sync_extra)
|
||||
{
|
||||
// NOTE: untested
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' t
|
||||
LEFT JOIN ' . REPORTS_TABLE . " r ON r.post_id = t.post_id
|
||||
$where_sql
|
||||
AND ((t.post_reported = 1 AND r.post_id IS NULL)
|
||||
OR (t.post_reported = 0 AND r.post_id > 0))
|
||||
GROUP p.post_id";
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
$post_ids[] = $row['post_id'];
|
||||
}
|
||||
$db->sql_freeresult();
|
||||
case 'oracle':
|
||||
//TODO
|
||||
break;
|
||||
|
||||
if (count($post_ids))
|
||||
default:
|
||||
// NOTE: untested
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' t
|
||||
LEFT JOIN ' . REPORTS_TABLE . " r ON r.post_id = t.post_id
|
||||
$where_sql
|
||||
AND ((t.post_reported = 1 AND r.post_id IS NULL)
|
||||
OR (t.post_reported = 0 AND r.post_id > 0))
|
||||
GROUP p.post_id";
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
do
|
||||
{
|
||||
$post_ids[] = $row['post_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET post_reported = 1 - post_reported
|
||||
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
unset($post_ids);
|
||||
}
|
||||
$db->sql_freeresult();
|
||||
}
|
||||
|
||||
// NOTE: untested
|
||||
$sql = 'SELECT t.topic_id, t.topic_reported, p.post_reported
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
LEFT JOIN ' . POSTS_TABLE . " p ON p.topic_id = t.topic_id
|
||||
$where_sql
|
||||
GROUP BY p.topic_id, p.post_reported";
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'oracle':
|
||||
//TODO
|
||||
break;
|
||||
|
||||
default:
|
||||
// NOTE: untested
|
||||
$sql = 'SELECT t.topic_id, t.topic_reported, p.post_reported
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
LEFT JOIN ' . POSTS_TABLE . " p ON p.topic_id = t.topic_id
|
||||
$where_sql
|
||||
GROUP BY p.topic_id, p.post_reported";
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!isset($topic_data[$row['topic_id']]))
|
||||
do
|
||||
{
|
||||
$topic_data[$row['topic_id']] = array(
|
||||
'topic_reported' => $row['topic_reported'],
|
||||
'post_reported' => $row['post_reported']
|
||||
);
|
||||
if (!isset($topic_data[$row['topic_id']]))
|
||||
{
|
||||
$topic_data[$row['topic_id']] = array(
|
||||
'topic_reported' => $row['topic_reported'],
|
||||
'post_reported' => $row['post_reported']
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_data[$row['topic_id']]['post_reported'] |= $row['post_reported'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_data[$row['topic_id']]['post_reported'] |= $row['post_reported'];
|
||||
}
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
foreach ($topic_data as $topic_id => $row)
|
||||
{
|
||||
if ($row['post_reported'] != $row['topic_reported'])
|
||||
foreach ($topic_data as $topic_id => $row)
|
||||
{
|
||||
$topic_ids[] = $topic_id;
|
||||
if ($row['post_reported'] != $row['topic_reported'])
|
||||
{
|
||||
$topic_ids[] = $topic_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($topic_ids))
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_reported = 1 - topic_reported
|
||||
WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
unset($topic_ids);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return;
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'forum':
|
||||
if ($resync_parents)
|
||||
{
|
||||
$forum_ids = array();
|
||||
|
||||
$sql = 'SELECT f2.forum_id
|
||||
FROM ' . FORUMS_TABLE . ' f, ' . FORUMS_TABLE . " f2
|
||||
$where_sql_and f.left_id BETWEEN f2.left_id AND f2.right_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
|
||||
if (count($forum_ids))
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids = array();
|
||||
do
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
sync('forum', 'forum_id', $forum_ids, FALSE);
|
||||
unset($forum_ids);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -555,12 +639,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
$sql = 'SELECT f.*, f2.forum_id AS id
|
||||
FROM ' . FORUMS_TABLE . ' f, ' . FORUMS_TABLE . " f2
|
||||
$where_sql_and f2.left_id BETWEEN f.left_id AND f.right_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$forum_data = $forum_ids = $post_ids = $subforum_list = $post_count = $last_post_id = $post_info = $topic_count = $topic_count_real = array();
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['forum_type'] == FORUM_LINK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$forum_ids[$row['id']] = $row['id'];
|
||||
if (!isset($subforum_list[$row['forum_id']]))
|
||||
{
|
||||
@@ -596,6 +684,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
{
|
||||
$topic_count_real[$row['forum_id']] += $row['forum_topics'];
|
||||
}
|
||||
|
||||
if ($row['topic_approved'])
|
||||
{
|
||||
$topic_count[$row['forum_id']] = $row['forum_topics'];
|
||||
@@ -624,6 +713,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
$forum_data[$forum_id]['topics'] += $topic_count[$subforum_id];
|
||||
$forum_data[$forum_id]['topics_real'] += $topic_count_real[$subforum_id];
|
||||
}
|
||||
|
||||
if (isset($post_count[$subforum_id]))
|
||||
{
|
||||
$forum_data[$forum_id]['posts'] += $post_count[$subforum_id];
|
||||
@@ -640,6 +730,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
$post_ids[] = $data['last_post_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($post_ids))
|
||||
{
|
||||
$sql = 'SELECT p.post_id, p.poster_id, u.username, p.post_time
|
||||
@@ -682,35 +773,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
{
|
||||
if (preg_match('#name$#', $fieldname))
|
||||
{
|
||||
if (isset($row[$fieldname]))
|
||||
{
|
||||
$sql['forum_' . $fieldname] = (string) $row[$fieldname];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql['forum_' . $fieldname] = '';
|
||||
}
|
||||
$sql['forum_' . $fieldname] = (isset($row[$fieldname])) ? (string) $row[$fieldname] : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($row[$fieldname]))
|
||||
{
|
||||
$sql['forum_' . $fieldname] = (int) $row[$fieldname];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql['forum_' . $fieldname] = 0;
|
||||
}
|
||||
$sql['forum_' . $fieldname] = (isset($row[$fieldname])) ? (int) $row[$fieldname] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql) . '
|
||||
WHERE forum_id = ' . $forum_id;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'topic':
|
||||
$topic_data = $topic_ids = $post_ids = $approved_unapproved_ids = $resync_forums = array();
|
||||
@@ -719,8 +796,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
|
||||
$where_sql_and p.topic_id = t.topic_id
|
||||
GROUP BY p.topic_id, p.post_approved";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$row['total_posts'] = intval($row['total_posts']);
|
||||
@@ -766,7 +843,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
if (!count($topic_ids))
|
||||
{
|
||||
// If we get there, topic ids were invalid or topics did not contain any posts
|
||||
|
||||
delete_topics($where_type, $where_ids);
|
||||
return;
|
||||
}
|
||||
@@ -830,10 +906,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||
WHERE p.post_id IN (' . implode(', ', $post_ids) . ')
|
||||
AND u.user_id = p.poster_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$post_ids = array();
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['post_id'] == $topic_data[$row['topic_id']]['first_post_id'])
|
||||
@@ -874,33 +949,35 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
{
|
||||
// This routine assumes that post_reported values are correct
|
||||
// if they are not, use sync('reported') instead
|
||||
$fieldnames[] = 'reported';
|
||||
$sql = 'SELECT t.topic_id, p.post_id
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
|
||||
$where_sql_and p.topic_id = t.topic_id
|
||||
AND p.post_reported = 1
|
||||
GROUP t.topic_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$fieldnames[] = 'reported';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_data[$row['topic_id']]['reported'] = 1;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// This routine assumes that post_attachment values are correct
|
||||
// if they are not, use sync('post_attachment') instead
|
||||
$fieldnames[] = 'attachment';
|
||||
$sql = 'SELECT t.topic_id, p.post_id
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
|
||||
$where_sql_and p.topic_id = t.topic_id
|
||||
AND p.post_attachment = 1
|
||||
GROUP t.topic_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$fieldnames[] = 'attachment';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_data[$row['topic_id']]['attachment'] = 1;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
foreach ($topic_data as $topic_id => $row)
|
||||
@@ -929,8 +1006,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
|
||||
// NOTE: should shadow topics be updated as well?
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql) . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql) . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$resync_forums[] = $row['forum_id'];
|
||||
@@ -948,17 +1025,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE,
|
||||
GROUP BY f.forum_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$forum_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
if (count($forum_ids))
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_ids = array();
|
||||
do
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
sync('forum', 'forum_id', $forum_ids, FALSE);
|
||||
unset($forum_ids);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,8 +1084,7 @@ function prune($forum_id, $prune_date = '', $auto_sync = TRUE)
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$p_result = delete_topics('topic_id', $topic_list, $auto_sync);
|
||||
return $p_result;
|
||||
return delete_topics('topic_id', $topic_list, $auto_sync);
|
||||
}
|
||||
|
||||
// Function auto_prune(), this function now relies on passed vars
|
||||
@@ -1036,7 +1116,7 @@ function remove_comments(&$output)
|
||||
$in_comment = false;
|
||||
for($i = 0; $i < $linecount; $i++)
|
||||
{
|
||||
if (preg_match('/^\/\*/', preg_quote($lines[$i])))
|
||||
if (preg_match('#^\/\*#', preg_quote($lines[$i])))
|
||||
{
|
||||
$in_comment = true;
|
||||
}
|
||||
@@ -1046,7 +1126,7 @@ function remove_comments(&$output)
|
||||
$output .= $lines[$i] . "\n";
|
||||
}
|
||||
|
||||
if (preg_match('/\*\/$/', preg_quote($lines[$i])))
|
||||
if (preg_match('#\*\/$#', preg_quote($lines[$i])))
|
||||
{
|
||||
$in_comment = false;
|
||||
}
|
||||
@@ -1103,10 +1183,10 @@ function split_sql_file($sql, $delimiter)
|
||||
if ($i != $token_count - 1 || strlen($tokens[$i] > 0))
|
||||
{
|
||||
// This is the total number of single quotes in the token.
|
||||
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
|
||||
$total_quotes = preg_match_all("#'#", $tokens[$i], $matches);
|
||||
// Counts single quotes that are preceded by an odd number of backslashes,
|
||||
// which means they're escaped quotes.
|
||||
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
|
||||
$escaped_quotes = preg_match_all("#(?<!\\\\)(\\\\\\\\)*\\\\'#", $tokens[$i], $matches);
|
||||
|
||||
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
||||
|
||||
@@ -1132,10 +1212,10 @@ function split_sql_file($sql, $delimiter)
|
||||
for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++)
|
||||
{
|
||||
// This is the total number of single quotes in the token.
|
||||
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
|
||||
$total_quotes = preg_match_all("#'#", $tokens[$j], $matches);
|
||||
// Counts single quotes that are preceded by an odd number of backslashes,
|
||||
// which means they're escaped quotes.
|
||||
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
|
||||
$escaped_quotes = preg_match_all("#(?<!\\\\)(\\\\\\\\)*\\\\'#", $tokens[$j], $matches);
|
||||
|
||||
$unescaped_quotes = $total_quotes - $escaped_quotes;
|
||||
|
||||
@@ -1170,10 +1250,8 @@ function split_sql_file($sql, $delimiter)
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Cache moderators, called whenever permissions are
|
||||
// changed via admin_permissions. Changes of username
|
||||
// and group names must be carried through for the
|
||||
// moderators table
|
||||
// Cache moderators, called whenever permissions are changed via admin_permissions. Changes of username
|
||||
// and group names must be carried through for the moderators table
|
||||
function cache_moderators()
|
||||
{
|
||||
global $db;
|
||||
|
@@ -81,7 +81,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
unset($right_id);
|
||||
}
|
||||
|
||||
if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id']))
|
||||
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
||||
{
|
||||
// Non-postable forum with no subforums: don't display
|
||||
continue;
|
||||
@@ -103,7 +103,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
$forum_rows[$forum_id] = $row;
|
||||
$forum_ids[] = $forum_id;
|
||||
|
||||
if (!$row['forum_postable'] && $row['parent_id'] == $root_data['forum_id'])
|
||||
if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
|
||||
{
|
||||
$branch_root_id = $forum_id;
|
||||
}
|
||||
@@ -122,11 +122,30 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
$forum_rows[$forum_id]['forum_id_last_post'] = $row['forum_id'];
|
||||
}
|
||||
}
|
||||
elseif ($row['forum_postable'])
|
||||
elseif ($row['forum_type'] != FORUM_CAT)
|
||||
{
|
||||
$subforums[$parent_id]['display'] = ($row['display_on_index']) ? true : false;;
|
||||
$subforums[$parent_id]['name'][$forum_id] = $row['forum_name'];
|
||||
|
||||
// Include subforum topic/post counts in parent counts
|
||||
$forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
|
||||
$forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
|
||||
|
||||
// Show most recent last post info on parent if we're a subforum
|
||||
if (isset($forum_rows[$parent_id]) && $row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
|
||||
{
|
||||
$forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
|
||||
$forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
|
||||
$forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
|
||||
$forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
|
||||
$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_rows[$forum_id]['forum_id_last_post'] = $row['forum_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (!empty($forum_unread[$forum_id]))
|
||||
{
|
||||
@@ -186,7 +205,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
{
|
||||
if ($row['parent_id'] == $root_id)
|
||||
{
|
||||
if (!$row['forum_postable'])
|
||||
if ($row['forum_type'] == FORUM_CAT)
|
||||
{
|
||||
$hold = $row;
|
||||
continue;
|
||||
@@ -243,7 +262,16 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
}
|
||||
else
|
||||
{
|
||||
$folder_image = ($forum_unread[$forum_id]) ? 'forum_new' : 'forum';
|
||||
switch ($row['forum_type'])
|
||||
{
|
||||
case FORUM_POST:
|
||||
$folder_image = ($forum_unread[$forum_id]) ? 'forum_new' : 'forum';
|
||||
break;
|
||||
|
||||
case FORUM_LINK:
|
||||
$folder_image = 'forum_link';
|
||||
break;
|
||||
}
|
||||
|
||||
$subforums_list = '';
|
||||
$l_subforums = '';
|
||||
@@ -286,8 +314,12 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
$moderators_list = implode(', ', $forum_moderators[$forum_id]);
|
||||
}
|
||||
|
||||
$l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
|
||||
$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_link_track']) ? $row['forum_posts'] : '';
|
||||
|
||||
$template->assign_block_vars('forumrow', array(
|
||||
'S_IS_CAT' => FALSE,
|
||||
'S_IS_CAT' => false,
|
||||
'S_IS_LINK' => ($row['forum_type'] != FORUM_LINK) ? false : true,
|
||||
|
||||
'FORUM_IMG' => $row['forum_image'],
|
||||
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
||||
@@ -295,7 +327,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
|
||||
'FORUM_NAME' => $row['forum_name'],
|
||||
'FORUM_DESC' => $row['forum_desc'],
|
||||
'POSTS' => $row['forum_posts'],
|
||||
$l_post_click_count => $post_click_count,
|
||||
'TOPICS' => $row['forum_topics'],
|
||||
'LAST_POST_TIME' => $last_post_time,
|
||||
'LAST_POSTER' => $last_poster,
|
||||
@@ -305,15 +337,15 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||
'L_SUBFORUM_STR' => $l_subforums,
|
||||
'L_MODERATOR_STR' => $l_moderator,
|
||||
'L_FORUM_FOLDER_ALT'=> $folder_alt,
|
||||
|
||||
|
||||
'U_LAST_POSTER' => $last_poster_url,
|
||||
'U_LAST_POST' => $last_post_url,
|
||||
'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'])
|
||||
'U_VIEWFORUM' => ($row['forum_type'] != FORUM_LINK || $row['forum_link_track']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : $row['forum_link'])
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_HAS_SUBFORUM' => ($visible_forums) ? TRUE : FALSE,
|
||||
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
|
||||
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'])
|
||||
);
|
||||
}
|
||||
|
@@ -438,8 +438,12 @@ class userdata extends user
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
// Clean up username ... convert any entities into normal
|
||||
// text, remove excess spaces, then escape it
|
||||
$username = strtr(trim($username), array_flip(get_html_translation_table(HTML_ENTITIES)));
|
||||
$username = preg_replace('#[\s]{2,}#', '', $username);
|
||||
$username = $db->sql_escape($username);
|
||||
|
||||
|
||||
$sql = "SELECT username
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE LOWER(username) = '" . strtolower($username) . "'";
|
||||
@@ -500,7 +504,7 @@ class userdata extends user
|
||||
|
||||
if ($email != '')
|
||||
{
|
||||
if (preg_match('/^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $email))
|
||||
if (preg_match('#^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$#is', $email))
|
||||
{
|
||||
$sql = "SELECT ban_email
|
||||
FROM " . BANLIST_TABLE;
|
||||
|
@@ -794,7 +794,8 @@ class fulltext_search
|
||||
}
|
||||
}
|
||||
|
||||
preg_match_all('/\b([\w]+)\b/', $text, $split_entries);
|
||||
preg_match_all('#\b([\w]+)\b#', $text, $split_entries);
|
||||
|
||||
return array_unique($split_entries[1]);
|
||||
}
|
||||
|
||||
@@ -824,6 +825,7 @@ class fulltext_search
|
||||
WHERE m.post_id = " . intval($post_id) . "
|
||||
AND w.word_id = m.word_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$cur_words = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
@@ -908,25 +910,33 @@ class fulltext_search
|
||||
{
|
||||
$title_match = ($word_in == 'title') ? 1 : 0;
|
||||
|
||||
$sql = '';
|
||||
if (sizeof($word_ary))
|
||||
{
|
||||
$sql_in = array();
|
||||
foreach ($word_ary as $word)
|
||||
{
|
||||
$sql .= (($sql != '') ? ', ' : '') . $cur_words[$word_in][$word];
|
||||
$sql_in[] = $cur_words[$word_in][$word];
|
||||
}
|
||||
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " WHERE word_id IN ($sql) AND post_id = " . intval($post_id) . " AND title_match = $title_match";
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . '
|
||||
WHERE word_id IN (' . implode(', ', $sql_in) . ')
|
||||
AND post_id = ' . intval($post_id) . "
|
||||
AND title_match = $title_match";
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($words['add'] as $word_in => $word_ary)
|
||||
{
|
||||
$title_match = ( $word_in == 'title' ) ? 1 : 0;
|
||||
$title_match = ($word_in == 'title') ? 1 : 0;
|
||||
|
||||
if (sizeof($word_ary))
|
||||
{
|
||||
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) SELECT $post_id, word_id, $title_match FROM " . SEARCH_WORD_TABLE . " WHERE word_text IN (" . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $word_ary)) . ")";
|
||||
$sql = 'INSERT INTO ' . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)
|
||||
SELECT $post_id, word_id, $title_match
|
||||
FROM " . SEARCH_WORD_TABLE . '
|
||||
WHERE word_text IN (' . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $word_ary)) . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -957,58 +967,66 @@ class fulltext_search
|
||||
}
|
||||
|
||||
// Remove common (> 60% of posts ) words
|
||||
$result = $db->sql_query("SELECT SUM(forum_posts) AS total_posts FROM " . FORUMS_TABLE);
|
||||
$sql = "SELECT SUM(forum_posts) AS total_posts
|
||||
FROM " . FORUMS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row['total_posts'] >= 100)
|
||||
{
|
||||
$sql = "SELECT word_id
|
||||
FROM " . SEARCH_MATCH_TABLE . "
|
||||
$sql = 'SELECT word_id
|
||||
FROM ' . SEARCH_MATCH_TABLE . '
|
||||
GROUP BY word_id
|
||||
HAVING COUNT(word_id) > " . floor($row['total_posts'] * 0.6);
|
||||
HAVING COUNT(word_id) > ' . floor($row['total_posts'] * 0.6);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$in_sql = '';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$in_sql .= (( $in_sql != '') ? ', ' : '') . $row['word_id'];
|
||||
$sql_in = array();
|
||||
do
|
||||
{
|
||||
$sql_in[] = $row['word_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
$sql_in = implode(', ', $sql_in);
|
||||
|
||||
$sql = 'UPDATE ' . SEARCH_WORD_TABLE . "
|
||||
SET word_common = 1
|
||||
WHERE word_id IN ($sql_in)";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . "
|
||||
WHERE word_id IN ($sql_in)";
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($in_sql)
|
||||
{
|
||||
$sql = "UPDATE " . SEARCH_WORD_TABLE . "
|
||||
SET word_common = " . TRUE . "
|
||||
WHERE word_id IN ($in_sql)";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
||||
WHERE word_id IN ($in_sql)";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove words with no matches ... this is a potentially nasty query
|
||||
$sql = "SELECT w.word_id
|
||||
FROM ( " . SEARCH_WORD_TABLE . " w
|
||||
LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON w.word_id = m.word_id
|
||||
$sql = 'SELECT w.word_id
|
||||
FROM ( ' . SEARCH_WORD_TABLE . ' w
|
||||
LEFT JOIN ' . SEARCH_MATCH_TABLE . ' m ON w.word_id = m.word_id
|
||||
AND m.word_id IS NULL
|
||||
GROUP BY m.word_id";
|
||||
GROUP BY m.word_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$in_sql = '';
|
||||
$sql_in = array();
|
||||
do
|
||||
{
|
||||
$in_sql .= ', ' . $row['word_id'];
|
||||
$sql_in[] = $row['word_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_WORD_TABLE . '
|
||||
WHERE word_id IN (' . substr($in_sql, 2) . ')';
|
||||
WHERE word_id IN (' . implode(', ', $sql_in) . ')';
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
@@ -37,11 +37,6 @@
|
||||
to this source
|
||||
*/
|
||||
|
||||
// Changes for 2.2:
|
||||
//
|
||||
// * Allow use of Smarty plug-ins?
|
||||
// * Reduce number of methods and variables
|
||||
|
||||
class Template
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user