function main($id, $mode) { global $config, $db, $user, $table_prefix, $auth, $template, $phpbb_root_path, $phpEx; define('TABLE_PREFIX', $table_prefix); require_once 'class_ulogin.php'; $uLogin = new uLogin($db); if ($config['require_activation'] == USER_ACTIVATION_DISABLE) { trigger_error('UCP_REGISTER_DISABLE'); } if (!($user_id = $uLogin->auth())) { $user_id = $uLogin->register(); } if ($user_id) { $session = $user->session_create($user_id, 0, 1); } if (!$session) { page_header($user->lang['LOGIN'], false); $template->set_filenames(array('body' => 'login_body.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); exit; } $redirect = request_var('redirect', "{$phpbb_root_path}index.{$phpEx}"); $message = $user->lang['LOGIN_REDIRECT']; $l_redirect = $redirect === "{$phpbb_root_path}index.{$phpEx}" || $redirect === "index.{$phpEx}" ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']; $redirect = reapply_sid($redirect); if (defined('IN_CHECK_BAN') && $session['user_row']['user_type'] != USER_FOUNDER) { return false; } $redirect = meta_refresh(3, $redirect); trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>')); }
public function handle() { $title = $this->display(); $this->template->assign_vars(array('L_FAQ_TITLE' => $title, 'S_IN_FAQ' => true)); make_jumpbox(append_sid("{$this->root_path}viewforum.{$this->php_ext}")); return $this->helper->render('faq_body.html', $title); }
function oauth_show_register($oauth_info, $nickname_repeat = false, $nickname_too_short = false) { global $phpEx, $template; if (session_id() == '') { session_start(); } $_SESSION['oauth_info'] = $oauth_info; $template->assign_vars(array('S_OAUTH_REG_ACTION' => './oauth.' . $phpEx . '?mode=register', 'EMAIL' => $oauth_info->email, 'USERNAME' => $oauth_info->name, 'USERNAME_EXISTS' => $nickname_repeat, 'USERNAME_TOO_SHORT' => $nickname_too_short)); page_header($user->lang['LOGIN'], false); $template->set_filenames(array('body' => 'oauth_register.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); }
/** * Generate login box or verify password */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; $err = ''; // Make sure user->setup() has been called if (empty($user->lang)) { $user->setup(); } // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) { // Not authd // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } if (isset($_POST['login'])) { // Get credential if ($admin) { $credential = request_var('credential', ''); if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) { if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } $password = request_var('password_' . $credential, '', true); } else { $password = request_var('password', '', true); } $username = request_var('username', '', true); $autologin = !empty($_POST['autologin']) ? true : false; $viewonline = !empty($_POST['viewonline']) ? 0 : 1; $admin = $admin ? 1 : 0; $viewonline = $admin ? $user->data['session_viewonline'] : $viewonline; // Check if the supplied username is equal to the one stored within the database if re-authenticating if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username'])) { // We log the attempt to use a different username... add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); } // If authentication is successful we redirect user to previous page $result = $auth->login($username, $password, $autologin, $viewonline, $admin); // If admin authentication and login, we will log if it was a success or not... // We also break the operation on the first non-success login - it could be argued that the user already knows if ($admin) { if ($result['status'] == LOGIN_SUCCESS) { add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS'); } else { // Only log the failed attempt if a real user tried to. // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } } } // The result parameter is always an array, holding the relevant information... if ($result['status'] == LOGIN_SUCCESS) { $redirect = request_var('redirect', "{$phpbb_root_path}index.{$phpEx}"); $message = $l_success ? $l_success : $user->lang['LOGIN_REDIRECT']; $l_redirect = $admin ? $user->lang['PROCEED_TO_ACP'] : ($redirect === "{$phpbb_root_path}index.{$phpEx}" || $redirect === "index.{$phpEx}" ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']); // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); // Special case... the user is effectively banned, but we allow founders to login if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) { return; } $redirect = meta_refresh(3, $redirect); trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>')); } // Something failed, determine what... if ($result['status'] == LOGIN_BREAK) { trigger_error($result['error_msg']); } // Special cases... determine switch ($result['status']) { case LOGIN_ERROR_ATTEMPTS: // Show confirm image $sql = 'DELETE FROM ' . CONFIRM_TABLE . "\n\t\t\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\t\t\tAND confirm_type = " . CONFIRM_LOGIN; $db->sql_query($sql); // Generate code $code = gen_rand_string(mt_rand(5, 8)); $confirm_id = md5(unique_id($user->ip)); $seed = hexdec(substr(unique_id(), 4, 10)); // compute $seed % 0x7fffffff $seed -= 0x7fffffff * floor($seed / 0x7fffffff); $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array('confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) CONFIRM_LOGIN, 'code' => (string) $code, 'seed' => (int) $seed)); $db->sql_query($sql); $template->assign_vars(array('S_CONFIRM_CODE' => true, 'CONFIRM_ID' => $confirm_id, 'CONFIRM_IMAGE' => '<img src="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_LOGIN) . '" alt="" title="" />', 'L_LOGIN_CONFIRM_EXPLAIN' => sprintf($user->lang['LOGIN_CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'))); $err = $user->lang[$result['error_msg']]; break; case LOGIN_ERROR_PASSWORD_CONVERT: $err = sprintf($user->lang[$result['error_msg']], $config['email_enable'] ? '<a href="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') . '">' : '', $config['email_enable'] ? '</a>' : '', $config['board_contact'] ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '', $config['board_contact'] ? '</a>' : ''); break; // Username, password, etc... // Username, password, etc... default: $err = $user->lang[$result['error_msg']]; // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { $err = !$config['board_contact'] ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); } break; } } if (!$redirect) { // We just use what the session code determined... // If we are not within the admin directory we use the page dir... $redirect = ''; if (!$admin) { $redirect .= $user->page['page_dir'] ? $user->page['page_dir'] . '/' : ''; } $redirect .= $user->page['page_name'] . ($user->page['query_string'] ? '?' . htmlspecialchars($user->page['query_string']) : ''); } // Assign credential for username/password pair $credential = $admin ? md5(unique_id()) : false; $s_hidden_fields = array('redirect' => $redirect, 'sid' => $user->session_id); if ($admin) { $s_hidden_fields['credential'] = $credential; } $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => $config['require_activation'] != USER_ACTIVATION_NONE && $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_LOGIN_ACTION' => !$admin ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') : append_sid("index.{$phpEx}", false, true, $user->session_id), 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? $user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password')); page_header($user->lang['LOGIN'], false); $template->set_filenames(array('body' => 'login_body.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); }
/** * MCP Front Panel */ function mcp_front_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $module; global $phpbb_dispatcher; // Latest 5 unapproved if ($module->loaded('queue')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))); $post_list = array(); $forum_names = array(); $forum_id = request_var('f', 0); $template->assign_var('S_SHOW_UNAPPROVED', !empty($forum_list) ? true : false); if (!empty($forum_list)) { $sql_ary = array('SELECT' => 'COUNT(post_id) AS total', 'FROM' => array(POSTS_TABLE => 'p'), 'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . ' AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE))); /** * Allow altering the query to get the number of unapproved posts * * @event core.mcp_front_queue_unapproved_total_before * @var int sql_ary Query to get the total number of unapproved posts * @var array forum_list List of forums to look for unapproved posts * @since 3.1.5-RC1 */ $vars = array('sql_ary', 'forum_list'); extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' ORDER BY post_time DESC, post_id DESC'; $result = $db->sql_query_limit($sql, 5); while ($row = $db->sql_fetchrow($result)) { $post_list[] = $row['post_id']; } $db->sql_freeresult($result); if (empty($post_list)) { $total = 0; } } /** * Alter list of posts and total as required * * @event core.mcp_front_view_queue_postid_list_after * @var int total Number of unapproved posts * @var array post_list List of unapproved posts * @var array forum_list List of forums that contain the posts * @var array forum_names Associative array with forum_id as key and it's corresponding forum_name as value * @since 3.1.0-RC3 */ $vars = array('total', 'post_list', 'forum_list', 'forum_names'); extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars))); if ($total) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' AND t.topic_id = p.topic_id AND p.poster_id = u.user_id ORDER BY p.post_time DESC, p.post_id DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('unapproved', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=forum_view&f=' . $row['forum_id']), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } $db->sql_freeresult($result); } $s_hidden_fields = build_hidden_fields(array('redirect' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main' . ($forum_id ? '&f=' . $forum_id : '')))); $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue"), 'L_UNAPPROVED_TOTAL' => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total), 'S_HAS_UNAPPROVED_POSTS' => $total != 0)); } } // Latest 5 reported if ($module->loaded('reports')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report'))); $template->assign_var('S_SHOW_REPORTS', !empty($forum_list) ? true : false); if (!empty($forum_list)) { $sql = 'SELECT COUNT(r.report_id) AS total FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p WHERE r.post_id = p.post_id AND r.pm_id = 0 AND r.report_closed = 0 AND ' . $db->sql_in_set('p.forum_id', $forum_list); /** * Alter sql query to count the number of reported posts * * @event core.mcp_front_reports_count_query_before * @var int sql The query string used to get the number of reports that exist * @var array forum_list List of forums that contain the posts * @since 3.1.5-RC1 */ $vars = array('sql', 'forum_list'); extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars))); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { $sql_ary = array('SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', TOPICS_TABLE => 't', USERS_TABLE => array('u', 'u2'), POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = p.forum_id')), 'WHERE' => 'r.post_id = p.post_id AND r.pm_id = 0 AND r.report_closed = 0 AND r.reason_id = rr.reason_id AND p.topic_id = t.topic_id AND r.user_id = u.user_id AND p.poster_id = u2.user_id AND ' . $db->sql_in_set('p.forum_id', $forum_list), 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC'); /** * Alter sql query to get latest reported posts * * @event core.mcp_front_reports_listing_query_before * @var int sql_ary Associative array with the query to be executed * @var array forum_list List of forums that contain the posts * @since 3.1.0-RC3 */ $vars = array('sql_ary', 'forum_list'); extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_listing_query_before', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 5); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('report', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . "&i={$id}&mode=forum_view"), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i={$id}&mode=topic_view"), 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } $db->sql_freeresult($result); } $template->assign_vars(array('L_REPORTS_TOTAL' => $user->lang('REPORTS_TOTAL', (int) $total), 'S_HAS_REPORTS' => $total != 0)); } } // Latest 5 reported PMs if ($module->loaded('pm_reports') && $auth->acl_get('m_pm_report')) { $template->assign_var('S_SHOW_PM_REPORTS', true); $user->add_lang(array('ucp')); $sql = 'SELECT COUNT(r.report_id) AS total FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p WHERE r.post_id = 0 AND r.pm_id = p.msg_id AND r.report_closed = 0'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; $sql_ary = array('SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', USERS_TABLE => array('u', 'u2'), PRIVMSGS_TABLE => 'p'), 'WHERE' => 'r.pm_id = p.msg_id AND r.post_id = 0 AND r.report_closed = 0 AND r.reason_id = rr.reason_id AND r.user_id = u.user_id AND p.author_id = u2.user_id', 'ORDER_BY' => 'p.message_time DESC'); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 5); $pm_by_id = $pm_list = array(); while ($row = $db->sql_fetchrow($result)) { $pm_by_id[(int) $row['msg_id']] = $row; $pm_list[] = (int) $row['msg_id']; } $db->sql_freeresult($result); $address_list = get_recipient_strings($pm_by_id); foreach ($pm_list as $message_id) { $row = $pm_by_id[$message_id]; $template->assign_block_vars('pm_report', array('U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_SUBJECT' => $row['message_subject'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'PM_TIME' => $user->format_date($row['message_time']), 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $row['message_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } } $template->assign_vars(array('L_PM_REPORTS_TOTAL' => $user->lang('PM_REPORTS_TOTAL', (int) $total), 'S_HAS_PM_REPORTS' => $total != 0)); } // Latest 5 logs if ($module->loaded('logs')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_'))); if (!empty($forum_list)) { $log_count = false; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list); foreach ($log as $row) { $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'TIME' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEW_TOPIC' => !empty($row['viewtopic']) ? $row['viewtopic'] : '', 'U_VIEWLOGS' => !empty($row['viewlogs']) ? $row['viewlogs'] : '')); } } $template->assign_vars(array('S_SHOW_LOGS' => !empty($forum_list) ? true : false, 'S_HAS_LOGS' => !empty($log) ? true : false)); } $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.{$phpEx}")); make_jumpbox(append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=forum_view'), 0, false, 'm_', true); }
} else { $topic_last_read = $userdata['user_lastvisit']; } } if (count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id])) { asort($tracking_topics); unset($tracking_topics[key($tracking_topics)]); } $tracking_topics[$topic_id] = time(); setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); } // // Load templates // $template->set_filenames(array('body' => 'viewtopic_body.tpl')); make_jumpbox('viewforum.' . $phpEx, $forum_id); // // Output page header // $page_title = $lang['View_topic'] . ' - ' . $topic_title; include $phpbb_root_path . 'includes/page_header.' . $phpEx; // // User authorisation levels output // $s_auth_can = ($is_auth['auth_post'] ? $lang['Rules_post_can'] : $lang['Rules_post_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_reply'] ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_edit'] ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_delete'] ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_vote'] ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot']) . '<br />'; $topic_mod = ''; if ($is_auth['auth_mod']) {
$sql_array = array('SELECT' => 'c.*, i.*', 'FROM' => array(GALLERY_COMMENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'c.comment_image_id = i.image_id')), 'WHERE' => $sql_where, 'ORDER_BY' => $sql_order); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($commentrow = $db->sql_fetchrow($result)) { $image_id = $commentrow['image_id']; $album_id = $commentrow['image_album_id']; $template->assign_block_vars('commentrow', array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}") . '#' . $commentrow['comment_id'], 'COMMENT_ID' => $commentrow['comment_id'], 'TIME' => $user->format_date($commentrow['comment_time']), 'TEXT' => generate_text_for_display($commentrow['comment'], $commentrow['comment_uid'], $commentrow['comment_bitfield'], 7), 'U_DELETE' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_delete', $album_id) && $commentrow['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&image_id={$image_id}&mode=comment&submode=delete&comment_id=" . $commentrow['comment_id']) : '', 'U_EDIT' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_edit', $album_id) && $commentrow['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&image_id={$image_id}&mode=comment&submode=edit&comment_id=" . $commentrow['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&ip=' . $commentrow['comment_user_ip']) : '', 'UC_THUMBNAIL' => phpbb_gallery_image::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $commentrow['image_id'], $commentrow['image_name'], $commentrow['image_album_id']), 'UC_IMAGE_NAME' => phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $commentrow['image_id'], $commentrow['image_name'], $commentrow['image_album_id']), 'IMAGE_AUTHOR' => get_username_string('full', $commentrow['image_user_id'], $commentrow['image_username'], $commentrow['image_user_colour']), 'IMAGE_TIME' => $user->format_date($commentrow['image_time']), 'POST_AUTHOR_FULL' => get_username_string('full', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'POST_AUTHOR' => get_username_string('username', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']))); } $db->sql_freeresult($result); $template->assign_vars(array('DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_COMMENT'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_COMMENT'), 'INFO_IMG' => $user->img('icon_post_info', 'IP'), 'MINI_POST_IMG' => $user->img('icon_post_target_unread', 'COMMENT'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'))); } } unset($rowset); page_header($l_search_title ? $l_search_title : $user->lang['SEARCH']); $template->set_filenames(array('body' => 'gallery/search_results.html')); make_jumpbox(phpbb_gallery_url::append_sid('phpbb', 'viewforum')); page_footer(); } $s_albums = phpbb_gallery_album::get_albumbox(false, false, false, 'i_view'); if (!$s_albums) { trigger_error('NO_SEARCH'); } // Prevent undefined variable on build_hidden_fields() $s_hidden_fields = array('e' => 0); if ($_SID) { $s_hidden_fields['sid'] = $_SID; } if (!empty($_EXTRA_URL)) { foreach ($_EXTRA_URL as $url_param) { $url_param = explode('=', $url_param, 2); $s_hidden_fields[$url_param[0]] = $url_param[1];
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; global $request, $phpbb_dispatcher, $phpbb_container; $user->add_lang(array('viewtopic', 'viewforum')); include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action $merge_select = $action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics' ? true : false; $forum_id = $forum_info['forum_id']; $start = $request->variable('start', 0); $topic_id_list = $request->variable('topic_id_list', array(0)); $post_id_list = $request->variable('post_id_list', array(0)); $source_topic_ids = array($request->variable('t', 0)); $to_topic_id = $request->variable('to_topic_id', 0); $url_extra = ''; $url_extra .= $forum_id ? "&f={$forum_id}" : ''; $url_extra .= $GLOBALS['topic_id'] ? '&t=' . $GLOBALS['topic_id'] : ''; $url_extra .= $GLOBALS['post_id'] ? '&p=' . $GLOBALS['post_id'] : ''; $url_extra .= $GLOBALS['user_id'] ? '&u=' . $GLOBALS['user_id'] : ''; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}"); // Resync Topics switch ($action) { case 'resync': $topic_ids = $request->variable('topic_id_list', array(0)); mcp_resync_topics($topic_ids); break; case 'merge_topics': $source_topic_ids = $topic_id_list; case 'merge_topic': if ($to_topic_id) { merge_topics($forum_id, $source_topic_ids, $to_topic_id); } break; } /** * Get some data in order to execute other actions. * * @event core.mcp_forum_view_before * @var string action The action * @var array forum_info Array with forum infos * @var int start Start value * @var array topic_id_list Array of topics ids * @var array post_id_list Array of posts ids * @var array source_topic_ids Array of source topics ids * @var int to_topic_id Array of destination topics ids * @since 3.1.6-RC1 */ $vars = array('action', 'forum_info', 'start', 'topic_id_list', 'post_id_list', 'source_topic_ids', 'to_topic_id'); extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars))); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $selected_ids = ''; if (sizeof($post_id_list) && $action != 'merge_topics') { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } else { if (sizeof($topic_id_list) && $action == 'merge_topics') { foreach ($topic_id_list as $num => $topic_id) { $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id; } } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $base_url = $url . "&i={$id}&action={$action}&mode={$mode}&sd={$sort_dir}&sk={$sort_key}&st={$sort_days}" . ($merge_select ? $selected_ids : ''); $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_MERGE_SELECT' => $merge_select ? true : false, 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&forum_action={$action}&mode={$mode}&start={$start}" . ($merge_select ? $selected_ids : ''), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics))); // Grab icons $icons = $cache->obtain_icons(); $topic_rows = array(); if ($config['load_db_lastread']) { $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $read_tracking_select = ', tt.mark_time'; } else { $read_tracking_join = $read_tracking_select = ''; } /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; /** * Modify SQL query before MCP forum view topic list is queried * * @event core.mcp_view_forum_modify_sql * @var string sql SQL query for forum view topic list * @var int forum_id ID of the forum * @var string limit_time_sql SQL query part for limit time * @var string sort_order_sql SQL query part for sort order * @var int topics_per_page Number of topics per page * @var int start Start value * @since 3.1.2-RC1 */ $vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars))); $result = $db->sql_query_limit($sql, $topics_per_page, $start); $topic_list = $topic_tracking_info = array(); while ($row_ary = $db->sql_fetchrow($result)) { $topic_list[] = $row_ary['topic_id']; } $db->sql_freeresult($result); $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); $result = $db->sql_query($sql); while ($row_ary = $db->sql_fetchrow($result)) { $topic_rows[$row_ary['topic_id']] = $row_ary; } $db->sql_freeresult($result); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync if (!sizeof($topic_list) && $forum_topics && $start > 0) { redirect($url . "&i={$id}&action={$action}&mode={$mode}"); } // Get topic tracking info if (sizeof($topic_list)) { if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } foreach ($topic_list as $topic_id) { $row_ary =& $topic_rows[$topic_id]; $replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1; if ($row_ary['topic_status'] == ITEM_MOVED) { $unread_topic = false; } else { $unread_topic = isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_title = censor_text($row_ary['topic_title']); $topic_unapproved = ($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $posts_unapproved = $row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : ''; $u_mcp_queue = !$u_mcp_queue && $topic_deleted ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue; $topic_row = array('ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_ICON_IMG' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'DELETED_IMG' => $topic_deleted ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1, 'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']), 'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'], 'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']), 'S_TOPIC_REPORTED' => !empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_TOPIC_DELETED' => $topic_deleted, 'S_UNREAD_TOPIC' => $unread_topic); if ($row_ary['topic_status'] == ITEM_MOVED) { $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row_ary['topic_moved_id']}"), 'U_DELETE_TOPIC' => $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&topic_id_list[]={$row_ary['topic_id']}&mode=forum_view&action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row_ary['topic_moved_id'])); } else { if ($action == 'merge_topic' || $action == 'merge_topics') { $u_select_topic = $url . "&i={$id}&mode=forum_view&action={$action}&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } else { $u_select_topic = $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row_ary['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row_ary['topic_id'], $source_topic_ids) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row_ary['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row_ary['topic_id'], $topic_id_list) ? true : false)); } $row = $row_ary; /** * Modify the topic data before it is assigned to the template in MCP * * @event core.mcp_view_forum_modify_topicrow * @var array row Array with topic data * @var array topic_row Template array with topic data * @since 3.1.0-a1 */ $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); $row_ary = $row; unset($row); $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); }
$db->sql_return_on_error(false); if ($result) { if (!($row = $db->sql_fetchrow($result))) { $sql = "INSERT INTO " . PROFILE_VIEW_TABLE . "\n\t\t\t(user_id, viewername, viewer_id, view_stamp, counter)\n\t\t\tVALUES ('" . $db->sql_escape($target_user) . "', '" . $db->sql_escape($viewer) . "', '" . $db->sql_escape($viewer_id) . "', '" . $db->sql_escape($current_time) . "', '1')"; } $db->sql_query($sql); $count = $row['counter'] + 1; $sql = "UPDATE " . PROFILE_VIEW_TABLE . "\n\t\t\t\tSET view_stamp = '{$current_time}', counter = '{$count}'\n\t\t\t\tWHERE user_id = " . $target_user . "\n\t\t\t\tAND viewer_id = " . $viewer_id; $db->sql_query($sql); } } // Mighty Gorgon - Multiple Ranks - BEGIN @(include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT); $ranks_array = $cache->obtain_ranks(false); // Mighty Gorgon - Multiple Ranks - END make_jumpbox(CMS_PAGE_VIEWFORUM); // // Calculate the number of days this user has been a member ($memberdays) // Then calculate their posts per day // $regdate = $profiledata['user_regdate']; $memberdays = max(1, round((time() - $regdate) / 86400)); $posts_per_day = $profiledata['user_posts'] / $memberdays; // Get the users percentage of total posts if ($profiledata['user_posts'] != 0) { $total_posts = $config['max_posts']; $percentage = $total_posts ? min(100, $profiledata['user_posts'] / $total_posts * 100) : 0; } else { $percentage = 0; } // Mighty Gorgon - Thanks Received - BEGIN
} else { $topic_last_read = $userdata['user_lastvisit']; } } if (count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id])) { asort($tracking_topics); unset($tracking_topics[key($tracking_topics)]); } $tracking_topics[$topic_id] = time(); setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); } // // Load templates // $template->set_filenames(array('body' => 'viewtopic_body.tpl')); make_jumpbox('viewforum.php', $forum_id); // // Output page header // $page_title = $lang['View_topic'] . ' - ' . $topic_title; include $phpbb_root_path . 'includes/page_header.php'; // // User authorisation levels output // $s_auth_can = ($is_auth['auth_post'] ? $lang['Rules_post_can'] : $lang['Rules_post_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_reply'] ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_edit'] ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_delete'] ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot']) . '<br />'; $s_auth_can .= ($is_auth['auth_vote'] ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot']) . '<br />'; $topic_mod = ''; if ($is_auth['auth_mod']) {
$posterarr = array('poster_uid' => 0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => ''); } $posticon = $eachpost->icon(); if (isset($posticon) && $posticon != '') { $post_image = '<a name="' . $eachpost->postid() . '"><img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($eachpost->icon()) . '" alt="" /></a>'; } else { $post_image = '<a name="' . $eachpost->postid() . '"><img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" /></a>'; } $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip' => $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text))); unset($eachposter); } if ($total_posts > $forumdata['posts_per_page']) { include XOOPS_ROOT_PATH . '/class/pagenav.php'; $nav = new XoopsPageNav($total_posts, $forumdata['posts_per_page'], $start, "start", 'topic_id=' . $topic_id . '&forum=' . $forum . '&viewmode=' . $viewmode . '&order=' . $order); $xoopsTpl->assign('forum_page_nav', $nav->renderNav(4)); } else { $xoopsTpl->assign('forum_page_nav', ''); } } // create jump box $xoopsTpl->assign(array('forum_jumpbox' => make_jumpbox($forum), 'lang_forum_index' => sprintf(_MD_FORUMINDEX, $xoopsConfig['sitename']), 'lang_from' => _MD_FROM, 'lang_joined' => _MD_JOINED, 'lang_posts' => _MD_POSTS, 'lang_poster' => _MD_POSTER, 'lang_thread' => _MD_THREAD, 'lang_edit' => _EDIT, 'lang_delete' => _DELETE, 'lang_reply' => _REPLY, 'lang_postedon' => _MD_POSTEDON)); // Read in cookie of 'lastread' times $topic_lastread = newbb_get_topics_viewed(); // if cookie is not set for this topic, update view count and set cookie if (empty($topic_lastread[$topic_id])) { $sql = 'UPDATE ' . $xoopsDB->prefix('bb_topics') . ' SET topic_views = topic_views + 1 WHERE topic_id =' . $topic_id; $xoopsDB->queryF($sql); } // Update cookie newbb_add_topics_viewed($topic_lastread, $topic_id, time(), $bbCookie['path'], $bbCookie['domain'], $bbCookie['secure']); include XOOPS_ROOT_PATH . '/footer.php';
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $src_root_path, $config; global $template, $db, $user, $auth, $cache, $src_container, $src_dispatcher; $url = append_sid("{$src_root_path}mcp.{$phpEx}?" . src_extra_url()); $user->add_lang('viewtopic'); $pagination = $src_container->get('pagination'); $topic_id = request_var('t', 0); $topic_info = src_get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $src_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Restore or pprove posts? if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $src_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $src_root_path . 'includes/functions_posting.' . $phpEx; include_once $src_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { mcp_queue::approve_posts($action, $post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); src_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; $src_content_visibility = $src_container->get('content.visibility'); if ($total == -1) { $total = $src_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } $start = $pagination->validate_start($start, $posts_per_page, $total); $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' AND ' . $src_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; } $db->sql_freeresult($result); $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = $has_deleted_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $has_unapproved_posts = true; } if ($row['post_visibility'] == ITEM_DELETED) { $has_deleted_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $post_row = array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_POST_DELETED' => $row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : ''); $current_row_number = $i; /** * Event to modify the template data block for topic reviews in the MCP * * @event core.mcp_topic_review_modify_row * @var int id ID of the tab we are displaying * @var string mode Mode of the MCP page we are displaying * @var int topic_id The topic ID we are currently reviewing * @var int forum_id The forum ID we are currently in * @var int start Start item of this page * @var int current_row_number Number of the post on this page * @var array post_row Template block array of the current post * @var array row Array with original post and user data * @var array topic_info Array with topic data * @var int total Total posts count * @since 3.1.4-RC1 */ $vars = array('id', 'mode', 'topic_id', 'forum_id', 'start', 'current_row_number', 'post_row', 'row', 'topic_info', 'total'); extract($src_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars))); $template->assign_block_vars('postrow', $post_row); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $src_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = src_get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $base_url = append_sid("{$src_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"); if ($posts_per_page) { $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start); } $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_RESTORE' => $has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$src_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total))); }
public function main($mode, $author_id, $give) { $this->user->add_lang(array('memberlist', 'groups', 'search')); $this->user->add_lang_ext('gfksx/ThanksForPosts', 'thanks_mod'); // Grab data $row_number = $total_users = 0; $givens = $reseved = $rowsp = $rowsu = $words = $where = array(); $sthanks = false; $ex_fid_ary = array_keys($this->auth->acl_getf('!f_read', true)); $ex_fid_ary = sizeof($ex_fid_ary) ? $ex_fid_ary : false; if (!$this->auth->acl_gets('u_viewthanks')) { if ($this->user->data['user_id'] != ANONYMOUS) { trigger_error('NO_VIEW_USERS_THANKS'); } login_box('', isset($this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]) ? $this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $this->user->lang['LOGIN_EXPLAIN_MEMBERLIST']); } $top = $this->request->variable('top', 0); $start = $this->request->variable('start', 0); $submit = isset($_POST['submit']) ? true : false; $default_key = 'a'; $sort_key = $this->request->variable('sk', $default_key); $sort_dir = $this->request->variable('sd', 'd'); $topic_id = $this->request->variable('t', 0); $return_chars = $this->request->variable('ch', $topic_id ? -1 : 300); $order_by = ''; switch ($mode) { case 'givens': $per_page = $this->config['posts_per_page']; $total_match_count = 0; $page_title = $this->user->lang['SEARCH']; $template_html = 'thanks_results.html'; switch ($give) { case 'true': $u_search = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $author_id, 'give' => 'true', 'tslash' => '')); $sql = 'SELECT COUNT(user_id) AS total_match_count FROM ' . $this->thanks_table . ' WHERE (' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0) AND user_id = ' . $author_id; $where = 'user_id'; break; case 'false': $u_search = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $author_id, 'give' => 'false', 'tslash' => '')); $sql = 'SELECT COUNT(DISTINCT post_id) as total_match_count FROM ' . $this->thanks_table . ' WHERE (' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0) AND poster_id = ' . $author_id; $where = 'poster_id'; break; } $result = $this->db->sql_query($sql); if (!($row = $this->db->sql_fetchrow($result))) { break; } else { $total_match_count = (int) $row['total_match_count']; $this->db->sql_freeresult($result); $sql_array = array('SELECT' => 'u.username, u.user_colour, p.poster_id, p.post_id, p.topic_id, p.forum_id, p.post_time, p.post_subject, p.post_text, p.post_username, p.bbcode_bitfield, p.bbcode_uid, p.post_attachment, p.enable_bbcode, p. enable_smilies, p.enable_magic_url', 'FROM' => array($this->thanks_table => 't'), 'WHERE' => '(' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) . ' OR t.forum_id = 0) AND t.' . $where . "= {$author_id}"); $sql_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 't.poster_id = u.user_id'); $sql_array['LEFT_JOIN'][] = array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => 't.post_id = p.post_id'); $sql = $this->db->sql_build_query('SELECT_DISTINCT', $sql_array); $result = $this->db->sql_query_limit($sql, $per_page, $start); if (!($row = $this->db->sql_fetchrow($result))) { break; } else { $bbcode_bitfield = $text_only_message = ''; do { // We pre-process some variables here for later usage $row['post_text'] = censor_text($row['post_text']); $text_only_message = $row['post_text']; // make list items visible as such if ($row['bbcode_uid']) { // no BBCode in text only message strip_bbcode($text_only_message, $row['bbcode_uid']); } if ($return_chars == -1 || utf8_strlen($text_only_message) < $return_chars + 3) { $row['display_text_only'] = false; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); // Does this post have an attachment? If so, add it to the list if ($row['post_attachment'] && $config['allow_attachments']) { $attach_list[$row['forum_id']][] = $row['post_id']; } } else { $row['post_text'] = $text_only_message; $row['display_text_only'] = true; } unset($text_only_message); if ($row['display_text_only']) { // limit the message length to return_chars value $row['post_text'] = get_context($row['post_text'], array(), $return_chars); $row['post_text'] = bbcode_nl2br($row['post_text']); } else { $flags = ($row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0); $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $flags); } $this->template->assign_block_vars('searchresults', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_SUBJECT' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_subject'] : (!empty($row['forum_id']) ? '' : $row['post_subject']), 'POST_DATE' => !empty($row['post_time']) ? $this->user->format_date($row['post_time']) : '', 'MESSAGE' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_text'] : (!empty($row['forum_id']) ? $this->user->lang['SORRY_AUTH_READ'] : $row['post_text']), 'FORUM_ID' => $row['forum_id'], 'TOPIC_ID' => $row['topic_id'], 'POST_ID' => $row['post_id'], 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 't=' . $row['topic_id']), 'U_VIEW_FORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']), 'U_VIEW_POST' => !empty($row['post_id']) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "t=" . $row['topic_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'] : '')); } while ($row = $this->db->sql_fetchrow($result)); $this->db->sql_freeresult($result); } } if ($total_match_count > 1000) { $total_match_count--; $l_search_matches = $this->user->lang('FOUND_MORE_SEARCH_MATCHES', $total_match_count); } else { $l_search_matches = $this->user->lang('FOUND_SEARCH_MATCHES', $total_match_count); } $this->pagination->generate_template_pagination($u_search, 'pagination', 'start', $total_match_count, $per_page, $start); $this->template->assign_vars(array('PAGE_NUMBER' => $this->pagination->on_page($total_match_count, $per_page, $start), 'TOTAL_MATCHES' => $total_match_count, 'SEARCH_MATCHES' => $l_search_matches, 'U_THANKS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('tslash' => '')))); break; default: $page_title = $this->user->lang['THANKS_USER']; $template_html = 'thankslist_body.html'; // Grab relevant data thanks $sql = 'SELECT user_id, COUNT(user_id) AS tally FROM ' . $this->thanks_table . ' WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0 GROUP BY user_id'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $givens[$row['user_id']] = $row['tally']; } $this->db->sql_freeresult($result); $sql = 'SELECT poster_id, COUNT(user_id) AS tally FROM ' . $this->thanks_table . ' WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0 GROUP BY poster_id'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $reseved[$row['poster_id']] = $row['tally']; } $this->db->sql_freeresult($result); // Sorting $sort_key_text = array('a' => $this->user->lang['SORT_USERNAME'], 'b' => $this->user->lang['SORT_LOCATION'], 'c' => $this->user->lang['SORT_JOINED'], 'd' => $this->user->lang['SORT_POST_COUNT'], 'e' => 'R_THANKS', 'f' => 'G_THANKS'); $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'e' => 'count_thanks', 'f' => 'count_thanks'); $sort_dir_text = array('a' => $this->user->lang['ASCENDING'], 'd' => $this->user->lang['DESCENDING']); if ($this->auth->acl_get('u_viewonline')) { $sort_key_text['l'] = $this->user->lang['SORT_LAST_ACTIVE']; $sort_key_sql['l'] = 'u.user_lastvisit'; } $s_sort_key = ''; foreach ($sort_key_text as $key => $value) { $selected = $sort_key == $key ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sort_dir_text as $key => $value) { $selected = $sort_dir == $key ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } // Sorting and order if (!isset($sort_key_sql[$sort_key])) { $sort_key = $default_key; } $order_by .= $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC'); // Build a relevant pagination_url $params = array(); $check_params = array('sk' => array('sk', $default_key), 'sd' => array('sd', 'a')); foreach ($check_params as $key => $call) { if (!isset($_REQUEST[$key])) { continue; } $param = call_user_func_array(array($this->request, 'variable'), $call); $param = is_string($param) ? urlencode($param) : $param; $params[$key] = $param; if ($key != 'sk' && $key != 'sd') { $sort_params[] = $param; } } $pagination_url = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array_merge($params, array('tslash' => ''))); // Grab relevant data $sql = 'SELECT DISTINCT poster_id FROM ' . $this->thanks_table; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $rowsp[] = $row['poster_id']; } $sql = 'SELECT DISTINCT user_id FROM ' . $this->thanks_table; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $rowsu[] = $row['user_id']; } if ($sort_key == 'e') { $sortparam = 'poster'; $rows = $rowsp; } else { if ($sort_key == 'f') { $sortparam = 'user'; $rows = $rowsu; } else { $sortparam = ''; $rows = array_merge($rowsp, $rowsu); } } $total_users = count(array_unique($rows)); if (empty($rows)) { break; } $sql_array = array('SELECT' => 'u.*', 'FROM' => array($this->users_table => 'u'), 'ORDER_BY' => $order_by); if ($top) { $total_users = $top; $start = 0; $page_title = $this->user->lang['REPUT_TOPLIST']; } else { $top = $this->config['topics_per_page']; } if ($sortparam) { $sql_array['FROM'] = array($this->thanks_table => 't'); $sql_array['SELECT'] .= ', count(t.' . $sortparam . '_id) as count_thanks'; $sql_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 't.' . $sortparam . '_id = u.user_id'); $sql_array['GROUP_BY'] = 't.' . $sortparam . '_id'; } $where[] = $rows[0]; for ($i = 1, $end = sizeof($rows); $i < $end; ++$i) { $where[] = $rows[$i]; } $sql_array['WHERE'] = $this->db->sql_in_set('u.user_id', $where); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $top, $start); if (!($row = $this->db->sql_fetchrow($result))) { trigger_error('NO_USER'); } else { $sql = 'SELECT session_user_id, MAX(session_time) AS session_time FROM ' . SESSIONS_TABLE . ' WHERE session_time >= ' . (time() - $this->config['session_length']) . ' AND ' . $this->db->sql_in_set('session_user_id', $where) . ' GROUP BY session_user_id'; $result_sessions = $this->db->sql_query($sql); $session_times = array(); while ($session = $this->db->sql_fetchrow($result_sessions)) { $session_times[$session['session_user_id']] = $session['session_time']; } $this->db->sql_freeresult($result_sessions); $user_list = array(); $id_cache = array(); do { $row['session_time'] = !empty($session_times[$session['user_id']]) ? $session_times[$session['user_id']] : 0; $row['last_visit'] = !empty($session['session_time']) ? $session['session_time'] : $session['user_lastvisit']; $user_list[] = (int) $row['user_id']; $id_cache[$row['user_id']] = $row; } while ($row = $this->db->sql_fetchrow($result)); $this->db->sql_freeresult($result); // Load custom profile fields if ($this->config['load_cpf_memberlist']) { $cp_row = $this->profilefields_manager->generate_profile_fields_template_headlines('field_show_on_ml'); foreach ($cp_row as $profile_field) { $this->template->assign_block_vars('custom_fields', $profile_field); } // Grab all profile fields from users in id cache for later use - similar to the poster cache $profile_fields_cache = $this->profilefields_manager->grab_profile_fields_data($user_list); // Filter the fields we don't want to show foreach ($profile_fields_cache as $user_id => $user_profile_fields) { foreach ($user_profile_fields as $field_ident => $profile_field) { if (!$profile_field['data']['field_show_on_ml']) { unset($profile_fields_cache[$user_id][$field_ident]); } } } } //do for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i) { $user_id = $user_list[$i]; $row = $id_cache[$user_id]; $last_visit = $row['user_lastvisit']; $rank_title = $rank_img = $rank_img_src = ''; include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; get_user_rank($row['user_rank'], $user_id == ANONYMOUS ? false : $row['user_posts'], $rank_title, $rank_img, $rank_img_src); $sthanks = true; // Custom Profile Fields $cp_row = array(); if ($this->config['load_cpf_memberlist']) { $cp_row = isset($profile_fields_cache[$user_id]) ? $this->profilefields_manager->generate_profile_fields_template_data($profile_fields_cache[$user_id], false) : array(); } $memberrow = array_merge(phpbb_show_profile($row), array('ROW_NUMBER' => $row_number + ($start + 1), 'RANK_TITLE' => $rank_title, 'RANK_IMG' => $rank_img, 'RANK_IMG_SRC' => $rank_img_src, 'GIVENS' => !isset($givens[$user_id]) ? 0 : $givens[$user_id], 'RECEIVED' => !isset($reseved[$user_id]) ? 0 : $reseved[$user_id], 'JOINED' => $this->user->format_date($row['user_regdate']), 'VISITED' => empty($last_visit) ? ' - ' : $this->user->format_date($last_visit), 'POSTS' => $row['user_posts'] ? $row['user_posts'] : 0, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_SEARCH_USER' => $this->auth->acl_get('u_search') ? append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", "author_id={$user_id}&sr=posts") : '', 'U_SEARCH_USER_GIVENS' => $this->auth->acl_get('u_search') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $user_id, 'give' => 'true', 'tslash' => '')) : '', 'U_SEARCH_USER_RECEIVED' => $this->auth->acl_get('u_search') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $user_id, 'give' => 'false', 'tslash' => '')) : '', 'L_VIEWING_PROFILE' => sprintf($this->user->lang['VIEWING_PROFILE'], $row['username']), 'VISITED' => empty($last_visit) ? ' - ' : $this->user->format_date($last_visit), 'S_CUSTOM_FIELDS' => isset($cp_row['row']) && sizeof($cp_row['row']) ? true : false)); if (isset($cp_row['row']) && sizeof($cp_row['row'])) { $memberrow = array_merge($memberrow, $cp_row['row']); } $this->template->assign_block_vars('memberrow', $memberrow); if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { $this->template->assign_block_vars('memberrow.custom_fields', $field_data); } } $row_number++; } $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $this->config['topics_per_page'], $start); $this->template->assign_vars(array('PAGE_NUMBER' => $this->pagination->on_page($total_users, $this->config['topics_per_page'], $start), 'U_SORT_POSTS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'd', 'sd' => $sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_USERNAME' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'a', 'sd' => $sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_FROM' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'b', 'sd' => $sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_JOINED' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'c', 'sd' => $sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_THANKS_R' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'e', 'sd' => $sort_key == 'e' && $sort_dir == 'd' ? 'a' : 'd', 'tslash' => '')), 'U_SORT_THANKS_G' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'f', 'sd' => $sort_key == 'f' && $sort_dir == 'd' ? 'a' : 'd', 'tslash' => '')), 'U_SORT_ACTIVE' => $this->auth->acl_get('u_viewonline') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'l', 'sd' => $sort_key == 'l' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')) : '')); } break; } // Output the page $this->template->assign_vars(array('TOTAL_USERS' => $this->user->lang('LIST_USERS', $total_users), 'U_THANKS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('tslash' => '')), 'S_THANKS' => $sthanks)); page_header($page_title); $this->template->set_filenames(array('body' => $template_html)); make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}")); page_footer(); return new Response($this->template->return_display('body'), 200); }
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; $user->add_lang(array('viewtopic', 'viewforum')); include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action $merge_select = $action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics' ? true : false; if ($merge_select) { // Fixes a "bug" that makes forum_view use the same ordering as topic_view unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']); } $forum_id = $forum_info['forum_id']; $start = request_var('start', 0); $topic_id_list = request_var('topic_id_list', array(0)); $post_id_list = request_var('post_id_list', array(0)); $source_topic_ids = array(request_var('t', 0)); $to_topic_id = request_var('to_topic_id', 0); $url_extra = ''; $url_extra .= $forum_id ? "&f={$forum_id}" : ''; $url_extra .= $GLOBALS['topic_id'] ? '&t=' . $GLOBALS['topic_id'] : ''; $url_extra .= $GLOBALS['post_id'] ? '&p=' . $GLOBALS['post_id'] : ''; $url_extra .= $GLOBALS['user_id'] ? '&u=' . $GLOBALS['user_id'] : ''; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}"); // Resync Topics switch ($action) { case 'resync': $topic_ids = request_var('topic_id_list', array(0)); mcp_resync_topics($topic_ids); break; case 'merge_topics': $source_topic_ids = $topic_id_list; case 'merge_topic': if ($to_topic_id) { merge_topics($forum_id, $source_topic_ids, $to_topic_id); } break; } $selected_ids = ''; if (sizeof($post_id_list) && $action != 'merge_topics') { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } else { if (sizeof($topic_id_list) && $action == 'merge_topics') { foreach ($topic_id_list as $num => $topic_id) { $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id; } } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_MERGE_SELECT' => $merge_select ? true : false, 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&forum_action={$action}&mode={$mode}&start={$start}" . ($merge_select ? $selected_ids : ''), 'PAGINATION' => generate_pagination($url . "&i={$id}&action={$action}&mode={$mode}&sd={$sort_dir}&sk={$sort_key}&st={$sort_days}" . ($merge_select ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL_TOPICS' => $forum_topics == 1 ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics))); // Grab icons $icons = $cache->obtain_icons(); $topic_rows = array(); if ($config['load_db_lastread']) { $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $read_tracking_select = ', tt.mark_time'; } else { $read_tracking_join = $read_tracking_select = ''; } $sql = "SELECT t.topic_id\n\t\tFROM " . TOPICS_TABLE . " t\n\t\tWHERE t.forum_id IN({$forum_id}, 0)\n\t\t\t" . ($auth->acl_get('m_approve', $forum_id) ? '' : 'AND t.topic_approved = 1') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); $topic_list = $topic_tracking_info = array(); while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; } $db->sql_freeresult($result); $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $topic_rows[$row['topic_id']] = $row; } $db->sql_freeresult($result); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync if (!sizeof($topic_list) && $forum_topics && $start > 0) { redirect($url . "&i={$id}&action={$action}&mode={$mode}"); } // Get topic tracking info if (sizeof($topic_list)) { if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); } else { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); } } foreach ($topic_list as $topic_id) { $topic_title = ''; $row =& $topic_rows[$topic_id]; $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED) { $unread_topic = false; } else { $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_title = censor_text($row['topic_title']); $topic_unapproved = !$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id']) ? true : false; $posts_unapproved = $row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id']) ? true : false; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; $topic_row = array('SOLVED_TOPIC' => $row['topic_solved'] && $row['topic_type'] != POST_GLOBAL ? $forum_info['forum_solve_text'] ? $forum_info['forum_solve_text'] : $user->img('icon_topic_solved_list', 'TOPIC_SOLVED') : '', 'U_SOLVED_TOPIC' => $row['topic_solved'] ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['topic_solved'] . '#p' . $row['topic_solved']) : '', 'SOLVED_STYLE' => $forum_info['forum_solve_color'] ? ' style="color: #' . $forum_info['forum_solve_color'] . '"' : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $auth->acl_get('m_approve', $row['forum_id']) ? $row['topic_replies_real'] : $row['topic_replies'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_UNREAD_TOPIC' => $unread_topic); if ($row['topic_status'] == ITEM_MOVED) { $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_moved_id']}"), 'U_DELETE_TOPIC' => $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row['topic_moved_id'])); } else { if ($action == 'merge_topic' || $action == 'merge_topics') { $u_select_topic = $url . "&i={$id}&mode=forum_view&action={$action}&to_topic_id=" . $row['topic_id'] . $selected_ids; } else { $u_select_topic = $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids; } $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row['topic_id'], $source_topic_ids) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row['topic_id'], $topic_id_list) ? true : false)); } $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); }
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache; global $phpEx, $phpbb_root_path, $config; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); if ($action == 'merge_select') { // Fixes a "bug" that makes forum_view use the same ordering as topic_view unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']); } $forum_id = $forum_info['forum_id']; $start = request_var('start', 0); $topic_id_list = request_var('topic_id_list', array(0)); $post_id_list = request_var('post_id_list', array(0)); $topic_id = request_var('t', 0); // Resync Topics if ($action == 'resync') { $topic_ids = request_var('topic_id_list', array(0)); mcp_resync_topics($topic_ids); } $selected_ids = ''; if (sizeof($post_id_list)) { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}", $forum_id . ($action == 'merge_select' ? $selected_ids : ''), false, 'm_'); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $template->assign_vars(array('FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield']), 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&action={$action}&mode={$mode}&start={$start}" . ($action == 'merge_select' ? $selected_ids : ''), 'PAGINATION' => generate_pagination($url . "&i={$id}&action={$action}&mode={$mode}" . ($action == 'merge_select' ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL' => $forum_topics)); // Grab icons $icons = array(); $cache->obtain_icons($icons); $topic_rows = array(); $sql = 'SELECT t.* FROM ' . TOPICS_TABLE . " t\n\t\tWHERE (t.forum_id = {$forum_id} OR t.forum_id = 0)\n\t\t\t" . ($auth->acl_get('m_approve', $forum_id) ? '' : 'AND t.topic_approved = 1') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); while ($row = $db->sql_fetchrow($result)) { $topic_rows[] = $row; } $db->sql_freeresult($result); foreach ($topic_rows as $row) { $topic_title = ''; if ($row['topic_status'] == ITEM_LOCKED) { $folder_img = 'folder_locked'; $folder_alt = 'VIEW_TOPIC_LOCKED'; } else { if ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) { $folder_img = 'folder_announce'; $folder_alt = 'VIEW_TOPIC_ANNOUNCEMENT'; } else { if ($row['topic_type'] == POST_STICKY) { $folder_img = 'folder_sticky'; $folder_alt = 'VIEW_TOPIC_STICKY'; } else { if ($row['topic_status'] == ITEM_MOVED) { $folder_img = 'folder_moved'; $folder_alt = 'VIEW_TOPIC_MOVED'; } else { $folder_img = 'folder'; $folder_alt = 'NO_NEW_POSTS'; } } } } if ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) { $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'] . ' '; } else { if ($row['topic_type'] == POST_STICKY) { $topic_type = $user->lang['VIEW_TOPIC_STICKY'] . ' '; } else { if ($row['topic_status'] == ITEM_MOVED) { $topic_type = $user->lang['VIEW_TOPIC_MOVED'] . ' '; } else { $topic_type = ''; } } } if (intval($row['poll_start'])) { $topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' '; } $topic_title = censor_text($row['topic_title']); $topic_unapproved = !$row['topic_approved'] && $auth->acl_gets('m_approve', $row['forum_id']) ? true : false; $posts_unapproved = $row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_gets('m_approve', $row['forum_id']) ? true : false; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; $template->assign_block_vars('topicrow', array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $action == 'merge_select' && $row['topic_id'] != $topic_id ? true : false, 'U_SELECT_TOPIC' => $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports'), 'ATTACH_ICON_IMG' => $auth->acl_gets('f_download', 'u_download', $row['forum_id']) && $row['topic_attachment'] ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $auth->acl_get('m_approve', $row['forum_id']) ? $row['topic_replies_real'] : $row['topic_replies'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'TOPIC_ID' => $row['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row['topic_id'], $topic_id_list) ? 'checked="checked" ' : '', 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && $auth->acl_gets('m_report', $row['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved)); } unset($topic_rows); }
)); } } // now I have the urge to wash my hands :( // We overwrite $_REQUEST['f'] if there is no forum specified // to be able to display the correct online list. // One downside is that the user currently viewing this topic/post is not taken into account. if (empty($_REQUEST['f'])) { $_REQUEST['f'] = $forum_id; } // We need to do the same with the topic_id. See #53025. if (empty($_REQUEST['t']) && !empty($topic_id)) { $_REQUEST['t'] = $topic_id; } // Output the page page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id); $template->set_filenames(array( 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') ); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); page_footer(); ?>
/** * Generate login box or verify password */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; global $request, $phpbb_container, $phpbb_dispatcher; $err = ''; // Make sure user->setup() has been called if (empty($user->lang)) { $user->setup(); } /** * This event allows an extension to modify the login process * * @event core.login_box_before * @var string redirect Redirect string * @var string l_explain Explain language string * @var string l_success Success language string * @var bool admin Is admin? * @var bool s_display Display full login form? * @var string err Error string * @since 3.1.9-RC1 */ $vars = array('redirect', 'l_explain', 'l_success', 'admin', 's_display', 'err'); extract($phpbb_dispatcher->trigger_event('core.login_box_before', compact($vars))); // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) { // Not authd // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } if (empty($err) && ($request->is_set_post('login') || $request->is_set('login') && $request->variable('login', '') == 'external')) { // Get credential if ($admin) { $credential = request_var('credential', ''); if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) { if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } $password = $request->untrimmed_variable('password_' . $credential, '', true); } else { $password = $request->untrimmed_variable('password', '', true); } $username = request_var('username', '', true); $autologin = $request->is_set_post('autologin'); $viewonline = (int) (!$request->is_set_post('viewonline')); $admin = $admin ? 1 : 0; $viewonline = $admin ? $user->data['session_viewonline'] : $viewonline; // Check if the supplied username is equal to the one stored within the database if re-authenticating if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username'])) { // We log the attempt to use a different username... add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); } // If authentication is successful we redirect user to previous page $result = $auth->login($username, $password, $autologin, $viewonline, $admin); // If admin authentication and login, we will log if it was a success or not... // We also break the operation on the first non-success login - it could be argued that the user already knows if ($admin) { if ($result['status'] == LOGIN_SUCCESS) { add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS'); } else { // Only log the failed attempt if a real user tried to. // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } } } // The result parameter is always an array, holding the relevant information... if ($result['status'] == LOGIN_SUCCESS) { $redirect = request_var('redirect', "{$phpbb_root_path}index.{$phpEx}"); /** * This event allows an extension to modify the redirection when a user successfully logs in * * @event core.login_box_redirect * @var string redirect Redirect string * @var bool admin Is admin? * @since 3.1.0-RC5 * @changed 3.1.9-RC1 Removed undefined return variable */ $vars = array('redirect', 'admin'); extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars))); // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); // Special case... the user is effectively banned, but we allow founders to login if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) { return; } redirect($redirect); } // Something failed, determine what... if ($result['status'] == LOGIN_BREAK) { trigger_error($result['error_msg']); } // Special cases... determine switch ($result['status']) { case LOGIN_ERROR_PASSWORD_CONVERT: $err = sprintf($user->lang[$result['error_msg']], $config['email_enable'] ? '<a href="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') . '">' : '', $config['email_enable'] ? '</a>' : '', '<a href="' . phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx) . '">', '</a>'); break; case LOGIN_ERROR_ATTEMPTS: $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); // $captcha->reset(); $template->assign_vars(array('CAPTCHA_TEMPLATE' => $captcha->get_template())); // no break; // Username, password, etc... // no break; // Username, password, etc... default: $err = $user->lang[$result['error_msg']]; // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { $err = sprintf($user->lang[$result['error_msg']], '<a href="' . append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contactadmin') . '">', '</a>'); } break; } /** * This event allows an extension to process when a user fails a login attempt * * @event core.login_box_failed * @var array result Login result data * @var string username User name used to login * @var string password Password used to login * @var string err Error message * @since 3.1.3-RC1 */ $vars = array('result', 'username', 'password', 'err'); extract($phpbb_dispatcher->trigger_event('core.login_box_failed', compact($vars))); } // Assign credential for username/password pair $credential = $admin ? md5(unique_id()) : false; $s_hidden_fields = array('sid' => $user->session_id); if ($redirect) { $s_hidden_fields['redirect'] = $redirect; } if ($admin) { $s_hidden_fields['credential'] = $credential; } $provider_collection = $phpbb_container->get('auth.provider_collection'); $auth_provider = $provider_collection->get_provider(); $auth_provider_data = $auth_provider->get_login_data(); if ($auth_provider_data) { if (isset($auth_provider_data['VARS'])) { $template->assign_vars($auth_provider_data['VARS']); } if (isset($auth_provider_data['BLOCK_VAR_NAME'])) { foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars) { $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars); } } $template->assign_vars(array('PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'])); } $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => $config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? $user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password')); page_header($user->lang['LOGIN']); $template->set_filenames(array('body' => 'login_body.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); }
if ($total == 0) { $_CLASS['core_template']->assign_array(array( 'L_REPORTS_TOTAL' => $_CLASS['core_user']->lang['REPORTS_ZERO_TOTAL'], 'S_HAS_REPORTS' => false) ); } else { $_CLASS['core_template']->assign_array(array( 'L_REPORTS_TOTAL' => ($total == 1) ? $_CLASS['core_user']->lang['REPORT_TOTAL'] : sprintf($_CLASS['core_user']->lang['REPORTS_TOTAL'], $total), 'S_HAS_REPORTS' => true) ); } } */ $forum_list_log = get_forum_list(array('m_', 'a_general')); // Add forum_id 0 for global announcements $forum_list_log[] = 0; $log_count = 0; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list_log); foreach ($log as $row) { $_CLASS['core_template']->assign_vars_array('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'TIME' => $_CLASS['core_user']->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEWTOPIC' => $row['viewtopic'], 'U_VIEWLOGS' => $row['viewlogs'])); } $_CLASS['core_template']->assign_array(array('S_SHOW_LOGS' => true, 'S_HAS_LOGS' => !empty($log))); $_CLASS['core_template']->assign('S_MCP_ACTION', generate_link($url)); make_jumpbox(generate_link($url . '&mode=forum_view'), 0, false, 'm_'); page_header(); $_CLASS['core_display']->display($_CLASS['core_user']->get_lang('MCP'), 'modules/Forums/mcp_front.html');
/** * MCP Front Panel */ function mcp_front_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $module; // Latest 5 unapproved if ($module->loaded('queue')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))); $post_list = array(); $forum_names = array(); $forum_id = request_var('f', 0); $template->assign_var('S_SHOW_UNAPPROVED', !empty($forum_list) ? true : false); if (!empty($forum_list)) { $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') AND post_approved = 0'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { $global_id = $forum_list[0]; $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') AND post_approved = 0 ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); while ($row = $db->sql_fetchrow($result)) { $post_list[] = $row['post_id']; } $db->sql_freeresult($result); if (empty($post_list)) { $total = 0; } } if ($total) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' AND t.topic_id = p.topic_id AND p.poster_id = u.user_id ORDER BY p.post_time DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $global_topic = $row['forum_id'] ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } $template->assign_block_vars('unapproved', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), 'U_MCP_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '', 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), 'FORUM_NAME' => !$global_topic ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']))); } $db->sql_freeresult($result); } $template->assign_vars(array('S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue"))); if ($total == 0) { $template->assign_vars(array('L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'], 'S_HAS_UNAPPROVED_POSTS' => false)); } else { $template->assign_vars(array('L_UNAPPROVED_TOTAL' => $total == 1 ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total), 'S_HAS_UNAPPROVED_POSTS' => true)); } } } // Latest 5 reported if ($module->loaded('reports')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report'))); $template->assign_var('S_SHOW_REPORTS', !empty($forum_list) ? true : false); if (!empty($forum_list)) { $sql = 'SELECT COUNT(r.report_id) AS total FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p WHERE r.post_id = p.post_id AND r.report_closed = 0 AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { $global_id = $forum_list[0]; $sql = $db->sql_build_query('SELECT', array('SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', TOPICS_TABLE => 't', USERS_TABLE => array('u', 'u2'), POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = p.forum_id')), 'WHERE' => 'r.post_id = p.post_id AND r.report_closed = 0 AND r.reason_id = rr.reason_id AND p.topic_id = t.topic_id AND r.user_id = u.user_id AND p.poster_id = u2.user_id AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', 'ORDER_BY' => 'p.post_time DESC')); $result = $db->sql_query_limit($sql, 5); while ($row = $db->sql_fetchrow($result)) { $global_topic = $row['forum_id'] ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } $template->assign_block_vars('report', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), 'U_MCP_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . "&i={$id}&mode=forum_view") : '', 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i={$id}&mode=topic_view"), 'U_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'FORUM_NAME' => !$global_topic ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'POST_TIME' => $user->format_date($row['post_time']))); } } if ($total == 0) { $template->assign_vars(array('L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], 'S_HAS_REPORTS' => false)); } else { $template->assign_vars(array('L_REPORTS_TOTAL' => $total == 1 ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), 'S_HAS_REPORTS' => true)); } } } // Latest 5 logs if ($module->loaded('logs')) { $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_'))); if (!empty($forum_list)) { // Add forum_id 0 for global announcements $forum_list[] = 0; $log_count = 0; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list); foreach ($log as $row) { $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'TIME' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEW_TOPIC' => !empty($row['viewtopic']) ? $row['viewtopic'] : '', 'U_VIEWLOGS' => !empty($row['viewlogs']) ? $row['viewlogs'] : '')); } } $template->assign_vars(array('S_SHOW_LOGS' => !empty($forum_list) ? true : false, 'S_HAS_LOGS' => !empty($log) ? true : false)); } $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.{$phpEx}")); make_jumpbox(append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=forum_view'), 0, false, 'm_', true); }
} if($type != 'shadow') { $template->assign_block_vars('switch_auth_move', array()); } if(($type != 'locked') && ($type != 'shadow')) { $template->assign_block_vars('switch_auth_lock', array()); } if(($type != 'unlocked' && (($type == 'locked') || ($type == 'poll') || ($type == 'sticky') || ($type == 'announce'))) || ($user->data['user_level'] == ADMIN)) { $template->assign_block_vars('switch_auth_unlock', array()); } $template->set_filenames(array('body' => 'modcp_body.tpl')); make_jumpbox('modcp.' . PHP_EXT); $sql = "SELECT t.*, u.username, u.user_id, u.user_active, u.user_color, p.post_time, p.post_id, p.post_username, p.enable_smilies, u2.username AS topic_starter, u2.user_id AS topic_starter_id, u2.user_active AS topic_starter_active, u2.user_color AS topic_starter_color, p2.post_id, p2.post_username AS topic_starter_guest FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2, " . POSTS_TABLE . " p2 WHERE t.forum_id = " . $forum_id . " AND p.poster_id = u.user_id AND t.topic_poster = u2.user_id AND p.post_id = t.topic_last_post_id AND p2.post_id = t.topic_first_post_id " . $where_type . " ORDER BY t.topic_type DESC, p.post_time DESC LIMIT " . $start . ", " . $config['topics_per_page']; $result = $db->sql_query($sql); $total_topics = 0; while($row = $db->sql_fetchrow($result)) { $topic_rowset[] = $row;
/** * Generate login box or verify password */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; if (!class_exists('phpbb_captcha_factory')) { include $phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx; } $err = ''; // Make sure user->setup() has been called if (empty($user->lang)) { $user->setup(); } // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) { // Not authd // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } if (isset($_POST['login'])) { // Get credential if ($admin) { $credential = request_var('credential', ''); if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) { if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } $password = request_var('password_' . $credential, '', true); } else { $password = request_var('password', '', true); } $username = request_var('username', '', true); $autologin = !empty($_POST['autologin']) ? true : false; $viewonline = !empty($_POST['viewonline']) ? 0 : 1; $admin = $admin ? 1 : 0; $viewonline = $admin ? $user->data['session_viewonline'] : $viewonline; // Check if the supplied username is equal to the one stored within the database if re-authenticating if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username'])) { // We log the attempt to use a different username... add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); } // If authentication is successful we redirect user to previous page $result = $auth->login($username, $password, $autologin, $viewonline, $admin); // If admin authentication and login, we will log if it was a success or not... // We also break the operation on the first non-success login - it could be argued that the user already knows if ($admin) { if ($result['status'] == LOGIN_SUCCESS) { add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS'); } else { // Only log the failed attempt if a real user tried to. // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if ($user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } } } // The result parameter is always an array, holding the relevant information... if ($result['status'] == LOGIN_SUCCESS) { $redirect = request_var('redirect', "{$phpbb_root_path}index.{$phpEx}"); $message = $l_success ? $l_success : $user->lang['LOGIN_REDIRECT']; $l_redirect = $admin ? $user->lang['PROCEED_TO_ACP'] : ($redirect === "{$phpbb_root_path}index.{$phpEx}" || $redirect === "index.{$phpEx}" ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']); // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); // Special case... the user is effectively banned, but we allow founders to login if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) { return; } $redirect = meta_refresh(3, $redirect); trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>')); } // Something failed, determine what... if ($result['status'] == LOGIN_BREAK) { trigger_error($result['error_msg']); } // Special cases... determine switch ($result['status']) { case LOGIN_ERROR_ATTEMPTS: $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); // $captcha->reset(); $template->assign_vars(array('CAPTCHA_TEMPLATE' => $captcha->get_template())); $err = $user->lang[$result['error_msg']]; break; case LOGIN_ERROR_PASSWORD_CONVERT: $err = sprintf($user->lang[$result['error_msg']], $config['email_enable'] ? '<a href="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') . '">' : '', $config['email_enable'] ? '</a>' : '', $config['board_contact'] ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '', $config['board_contact'] ? '</a>' : ''); break; // Username, password, etc... // Username, password, etc... default: $err = $user->lang[$result['error_msg']]; // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { $err = !$config['board_contact'] ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); } break; } } // Assign credential for username/password pair $credential = $admin ? md5(unique_id()) : false; $s_hidden_fields = array('sid' => $user->session_id); if ($redirect) { $s_hidden_fields['redirect'] = $redirect; } if ($admin) { $s_hidden_fields['credential'] = $credential; } $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => $config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? $user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password')); page_header($user->lang['LOGIN'], false); $template->set_filenames(array('body' => 'login_body.html')); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); }
public function handle_video() { if (!$this->auth->acl_get('u_video_view_full')) { trigger_error($this->user->lang['UNAUTHED']); } // Initial var setup $video_id = $this->request->variable('id', 0); $video_url = $this->request->variable('video_url', '', true); $video_title = $this->request->variable('video_title', '', true); $video_cat_id = $this->request->variable('cid', 0); $video_cat_ids = $this->request->variable('id', 0); $username = $this->request->variable('username', '', true); $user_id = $this->request->variable('user_id', 0); $youtube_id = $this->request->variable('youtube_id', '', true); $create_time = $this->request->variable('create_time', ''); $video_views = $this->request->variable('video_views', 0); $sql_start = $this->request->variable('start', 0); $sql_limit = $this->request->variable('limit', 10); $sql_limits = $this->request->variable('limit', $this->config['comments_per_page']); //comments // Comments $cmnt_id = $this->request->variable('cmntid', 0); $cmnt_video_id = $this->request->variable('v', 0); $cmnt_text = utf8_normalize_nfc($this->request->variable('cmnt_text', '', true)); $mode = $this->request->variable('mode', ''); $submit = isset($_POST['submit']) ? true : false; // Determine board url - we may need it later $board_url = generate_board_url() . '/'; $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $this->phpbb_root_path; if (!$this->config['google_api_key']) { if ($this->auth->acl_get('a_')) { trigger_error($this->user->lang['NO_KEY_ADMIN']); } else { trigger_error($this->user->lang['NO_KEY_USER']); } } /** * Get youtube video ID from URL * From: http://halgatewood.com/php-get-the-youtube-video-id-from-a-youtube-url/ */ function getYouTubeIdFromURL($url) { $pattern = '/(?:youtube\\.com\\/(?:[^\\/]+\\/.+\\/|(?:v|e(?:mbed)?)\\/|.*[?&]v=)|youtu\\.be\\/)([^"&?\\/ ]{11})/i'; preg_match($pattern, $url, $matches); return isset($matches[1]) ? $matches[1] : false; } $youtube_id = getYouTubeIdFromURL($video_url); $jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$youtube_id}&key={$this->config['google_api_key']}&type=video&part=snippet"); $json = json_decode($jsonURL); if (isset($json->items[0]->snippet)) { $video_title = $json->items[0]->snippet->title; } $sql_ary = array('video_id' => $video_id, 'video_url' => $video_url, 'video_title' => $video_title, 'video_cat_id' => $video_cat_id, 'username' => $username, 'user_id' => $user_id, 'youtube_id' => $youtube_id, 'create_time' => (int) time(), 'video_views' => $video_views); $error = $row = array(); $current_time = time(); $this->template->assign_vars(array('S_NEW_VIDEO' => $this->auth->acl_get('u_video_post') ? true : false, 'SCRIPT_NAME' => 'video', 'U_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller'))); $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_INDEX'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_youtubegallery_controller'))); switch ($mode) { case 'submit': // User is a bot?! if ($this->user->data['is_bot']) { redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}")); } $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')); // Is a guest?! if ($this->user->data['user_id'] == ANONYMOUS) { login_box($redirect_url); } // Can post?! if (!$this->auth->acl_get('u_video_post')) { trigger_error($this->user->lang['UNAUTHED']); } $l_title = $this->user->lang['VIDEO_SUBMIT']; $template_html = 'video_editor.html'; $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')); $s_hidden_fields = ''; $form_enctype = ''; add_form_key('postform'); // List of categories $sql = 'SELECT * FROM ' . $this->video_cat_table . ' ORDER BY video_cat_id DESC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('cat', array('VIDEO_CAT_ID' => censor_text($row['video_cat_id']), 'VIDEO_CAT_TITLE' => censor_text($row['video_cat_title']))); } // Start assigning vars for main posting page ... $this->template->assign_vars(array('S_USER_ID' => $this->user->data['user_id'], 'S_USERNAME' => $this->user->data['username'], 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : '')); $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_SUBMIT'])); add_form_key('postform'); if ($submit) { if (!check_form_key('postform')) { trigger_error('FORM_INVALID'); } } switch ($submit) { case 'add': if ($video_url == '') { $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')); $message = $this->user->lang['NEED_VIDEO_URL']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } else { $this->db->sql_query('INSERT INTO ' . $this->video_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary)); $u_action = $this->helper->route('dmzx_youtubegallery_controller'); $meta_info = $this->helper->route('dmzx_youtubegallery_controller'); $message = $this->user->lang['VIDEO_CREATED']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } break; } break; case 'comment': $l_title = $this->user->lang['VIDEO_CMNT_SUBMIT']; $template_html = '@dmzx_youtubegallery/video_cmnt_editor.html'; if (!$this->config['enable_comments']) { trigger_error($this->user->lang['COMMENTS_DISABLED']); } // User is a bot?! if ($this->user->data['is_bot']) { redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}")); } // Can post?! if (!$this->auth->acl_get('u_video_comment')) { trigger_error($this->user->lang['UNAUTHED']); } $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id)); // Is a guest?! if ($this->user->data['user_id'] == ANONYMOUS) { login_box($redirect_url); } if (!function_exists('generate_smilies')) { include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx; } if (!function_exists('display_custom_bbcodes')) { include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx; } //Settings for comments $this->user->setup('posting'); display_custom_bbcodes(); generate_smilies('inline', 0); $bbcode_status = $this->config['allow_bbcode'] ? true : false; $smilies_status = $this->config['allow_smilies'] ? true : false; $img_status = $bbcode_status ? true : false; $url_status = $this->config['allow_post_links'] ? true : false; $flash_status = $bbcode_status && $this->config['allow_post_flash'] ? true : false; $quote_status = true; $video_id = $this->request->variable('v', 0); $uid = $bitfield = $options = ''; $allow_bbcode = $allow_urls = $allow_smilies = true; $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id)); $s_hidden_fields = ''; $form_enctype = ''; add_form_key('postform'); // Start assigning vars for main posting page ... $this->template->assign_vars(array('VIDEO_ID' => (int) $video_id, 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_QUOTE' => $quote_status)); if (isset($_POST['submit'])) { if (!check_form_key('postform')) { trigger_error('FORM_INVALID'); } $video_id = $this->request->variable('v', 0); // Get video to redirect :D $message = $this->request->variable('cmnt_text', '', true); generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $data = array('cmnt_video_id' => $this->request->variable('cmnt_video_id', 0), 'cmnt_poster_id' => $this->user->data['user_id'], 'cmnt_text' => $message, 'create_time' => time(), 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options); if ($message == '') { $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id)); $message = $this->user->lang['NEED_VIDEO_MESSAGE']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } else { $this->db->sql_query('INSERT INTO ' . $this->video_cmnts_table . ' ' . $this->db->sql_build_array('INSERT', $data)); $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id)); $message = $this->user->lang['COMMENT_CREATED']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } } $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_CMNT_SUBMIT'])); break; case 'delcmnt': if (!$this->auth->acl_get('u_video_comment_delete')) { trigger_error($this->user->lang['UNAUTHED']); } $video_id = $this->request->variable('v', 0); // Get video to redirect :D if (confirm_box(true)) { $sql = 'DELETE FROM ' . $this->video_cmnts_table . ' WHERE cmnt_id = ' . (int) $cmnt_id; $this->db->sql_query($sql); $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id)); $message = $this->user->lang['COMMENT_DELETED_SUCCESS']; meta_refresh(1, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } else { $s_hidden_fields = build_hidden_fields(array('id' => $cmnt_id, 'mode' => 'delcmnt')); confirm_box(false, $this->user->lang['DELETE_COMMENT_CONFIRM'], $s_hidden_fields); $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id)); meta_refresh(1, $meta_info); } break; case 'delete': if (!$this->auth->acl_get('u_video_delete')) { trigger_error($this->user->lang['UNAUTHED']); } $l_title = $this->user->lang['DELETE_VIDEO']; if (confirm_box(true)) { $sql = 'DELETE FROM ' . $this->video_table . ' WHERE video_id = ' . $video_id; $this->db->sql_query($sql); $meta_info = $this->helper->route('dmzx_youtubegallery_controller'); $message = $this->user->lang['VIDEO_DELETED']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } else { $s_hidden_fields = build_hidden_fields(array('mode' => 'delete', 'submit' => true, 'video_id' => $video_id)); confirm_box(false, $this->user->lang['DELETE_VIDEO'], $s_hidden_fields); $meta_info = $this->helper->route('dmzx_youtubegallery_controller'); $message = $this->user->lang['RETURN_TO_VIDEO_INDEX']; meta_refresh(3, $meta_info); $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } break; case 'view': if (!$this->auth->acl_get('u_video_view')) { trigger_error($this->user->lang['VIDEO_UNAUTHED']); } // Update video view... but only for humans if (isset($this->user->data['session_page']) && !$this->user->data['is_bot']) { $sql = 'UPDATE ' . $this->video_table . ' SET video_views = video_views + 1 WHERE video_id = ' . $video_id; $this->db->sql_query($sql); } $sql_ary = array('SELECT' => 'v.*, u.*', 'FROM' => array($this->video_table => 'v', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . ' and u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $page_title = $row['video_title']; $user_id = $row['user_id']; $flash_status = $this->config['allow_post_flash'] ? true : false; $delete_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_delete')); $this->template->assign_vars(array('VIDEO_ID' => censor_text($row['video_id']), 'VIDEO_TITLE' => censor_text($row['video_title']), 'VIDEO_VIEWS' => $row['video_views'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id']), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'YOUTUBE_VIDEO' => 'http://www.youtube.com/watch?v=' . $row['youtube_id'], 'VIDEO_LINK' => generate_board_url() . $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'VIDEO_LINK_FLASH' => 'http://www.youtube.com/v/' . $row['youtube_id'], 'U_USER_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delete', 'id' => $row['video_id'])), 'DELETE_ALLOW' => $delete_allowed, 'S_BBCODE_FLASH' => $flash_status, 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'S_VIDEO_WIDTH' => $this->config['video_width'], 'S_VIDEO_HEIGHT' => $this->config['video_height'], 'U_POST_COMMENT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => $row['video_id'])), 'S_ENABLE_COMMENTS' => $this->config['enable_comments'], 'S_POST_COMMENT' => $this->auth->acl_get('u_video_comment'))); // Comments $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $video_id)); $sql_ary = array('SELECT' => 'v.*, cmnt.*, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cmnts_table => 'cmnt', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . ' AND cmnt.cmnt_video_id = v.video_id AND u.user_id = cmnt.cmnt_poster_id', 'ORDER_BY' => 'cmnt.cmnt_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $sql_limits, $sql_start); while ($row = $this->db->sql_fetchrow($result)) { $delete_cmnt_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_comment_delete')); $text = generate_text_for_display($row['cmnt_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']); $this->template->assign_block_vars('commentrow', array('COMMENT_ID' => $row['cmnt_id'], 'COMMENT_TEXT' => $text, 'COMMENT_TIME' => $this->user->format_date($row['create_time']), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_DELETE_ALLOWED' => $delete_cmnt_allowed, 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delcmnt', 'cmntid' => (int) $row['cmnt_id'], 'v' => (int) $row['cmnt_video_id'])))); } $this->db->sql_freeresult($result); // We need another query for the video count $sql = 'SELECT COUNT(*) as comment_count FROM ' . $this->video_cmnts_table . ' WHERE cmnt_video_id = ' . (int) $video_id; $result = $this->db->sql_query($sql); $videorow['comment_count'] = $this->db->sql_fetchfield('comment_count'); $this->db->sql_freeresult($result); //Start pagination $start = $this->request->variable('start', 0); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['comment_count'], $sql_limits, $sql_start); $this->template->assign_vars(array('TOTAL_COMMENTS' => $videorow['comment_count'] == 1 ? $this->user->lang['LIST_COMMENT'] : sprintf($this->user->lang['LIST_COMMENTS'], $videorow['comment_count']))); //End pagination // Count the videos user video ... $sql = 'SELECT COUNT(video_id) AS total_videos FROM ' . $this->video_table . ' WHERE user_id = ' . (int) $user_id; $result = $this->db->sql_query($sql); $total_videos = (int) $this->db->sql_fetchfield('total_videos'); $this->db->sql_freeresult($result); $this->template->assign_vars(array('TOTAL_VIDEOS' => $total_videos)); // Count the video comments ... $sql_cmnts = 'SELECT COUNT(cmnt_id) AS total_comments FROM ' . $this->video_cmnts_table . ' WHERE cmnt_video_id = ' . (int) $video_id; $result = $this->db->sql_query($sql_cmnts); $total_comments = (int) $this->db->sql_fetchfield('total_comments'); $this->db->sql_freeresult($result); $this->template->assign_vars(array('TOTAL_COMMENTS_TITLE' => $total_comments)); $l_title = $page_title; $template_html = 'video_view.html'; $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $page_title)); break; case 'cat': $sql_limit = $sql_limit > 10 ? 10 : $sql_limit; $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $video_cat_ids)); $sql_ary = array('SELECT' => 'v.*, ct.video_cat_title,ct.video_cat_id, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'v.video_cat_id = ' . $video_cat_ids . ' AND ct.video_cat_id = ' . $video_cat_ids . ' AND v.user_id = u.user_id', 'ORDER_BY' => 'v.video_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg')); } $this->db->sql_freeresult($result); // We need another query for the video count $sql = 'SELECT COUNT(*) as video_count FROM ' . $this->video_table . ' WHERE video_cat_id = ' . (int) $video_cat_ids; $result = $this->db->sql_query($sql); $videorow['video_count'] = $this->db->sql_fetchfield('video_count'); $this->db->sql_freeresult($result); $start = $this->request->variable('start', 0); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start); $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count']))); $sql = 'SELECT * FROM ' . $this->video_cat_table . ' WHERE video_cat_id = ' . (int) $video_cat_ids; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $this->template->assign_vars(array('CAT_NAME' => $row['video_cat_title'])); $l_title = $row['video_cat_title']; $template_html = 'video_cat.html'; $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $row['video_cat_title'])); break; case 'user_videos': $this->template->assign_vars(array('S_SEARCH_USER_VIDEO' => true)); $sql_limit = $sql_limit > 10 ? 10 : $sql_limit; $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $user_id)); $sql_ary = array('SELECT' => 'v.*, ct.video_cat_title,ct.video_cat_id, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = v.user_id AND ct.video_cat_id = v.video_cat_id AND u.user_id = ' . $user_id, 'ORDER_BY' => 'v.video_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg')); } $this->db->sql_freeresult($result); // We need another query for the video count $sql = 'SELECT COUNT(*) as video_count FROM ' . $this->video_table . ' WHERE user_id = ' . $user_id; $result = $this->db->sql_query($sql); $videorow['video_count'] = $this->db->sql_fetchfield('video_count'); $this->db->sql_freeresult($result); $start = $this->request->variable('start', 0); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start); $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count']))); $l_title = $this->user->lang['USER_VIDEOS']; $template_html = 'video_search.html'; break; default: //Listing categories $sql = 'SELECT * FROM ' . $this->video_cat_table . "\n\t\t\t\tORDER BY video_cat_id"; $res = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($res)) { $this->template->assign_block_vars('videocat', array('VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])))); } // Count the videos ... $sql = 'SELECT COUNT(video_id) AS total_videos FROM ' . $this->video_table; $result = $this->db->sql_query($sql); $total_videos = (int) $this->db->sql_fetchfield('total_videos'); $this->db->sql_freeresult($result); // Count the videos categories ... $sql = 'SELECT COUNT(video_cat_id) AS total_categories FROM ' . $this->video_cat_table . ''; $result = $this->db->sql_query($sql); $total_categories = (int) $this->db->sql_fetchfield('total_categories'); $this->db->sql_freeresult($result); // Count the videos views ... $sql = 'SELECT SUM(video_views) AS total_views FROM ' . $this->video_table; $result = $this->db->sql_query($sql); $total_views = (int) $this->db->sql_fetchfield('total_views'); $this->db->sql_freeresult($result); $total_videos; // Count the videos comments ... $sql = 'SELECT COUNT(cmnt_id) AS total_comments FROM ' . $this->video_cmnts_table; $result = $this->db->sql_query($sql); $total_comments = (int) $this->db->sql_fetchfield('total_comments'); $this->db->sql_freeresult($result); $l_title = $this->user->lang['VIDEO_INDEX']; $template_html = 'video_body.html'; $l_total_video_s = $total_videos == 0 ? 'TOTAL_VIDEO_ZERO' : 'TOTAL_VIDEOS_OTHER'; $l_total_category_s = $total_categories == 0 ? 'TOTAL_CATEGORY_ZERO' : 'TOTAL_CATEGORIES_OTHER'; $l_total_view_s = $total_views == 0 ? 'TOTAL_VIEW_ZERO' : 'TOTAL_VIEWS_OTHER'; $l_total_comment_s = $total_comments == 0 ? 'TOTAL_COMMENT_ZERO' : 'TOTAL_COMMENTS_OTHER'; $this->template->assign_vars(array('U_VIDEO_SUBMIT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')), 'VIDEOSUBMIT' => $this->auth->acl_get('u_video_post'), 'U_MY_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'BUTTON_VIDEO_NEW' => "{$web_path}styles/" . $this->user->lang_name . '/button_video_new.gif', 'TOTAL_VIDEOS_INDEX' => sprintf($this->user->lang[$l_total_video_s], $total_videos), 'TOTAL_CATEGORIES' => sprintf($this->user->lang[$l_total_category_s], $total_categories), 'TOTAL_VIEWS' => sprintf($this->user->lang[$l_total_view_s], $total_views), 'TOTAL_COMMENTS' => sprintf($this->user->lang[$l_total_comment_s], $total_comments))); $sql_limit = $sql_limit > 10 ? 10 : $sql_limit; $pagination_url = $this->helper->route('dmzx_youtubegallery_controller'); $sql_ary = array('SELECT' => 'v.*, ct.video_cat_title,ct.video_cat_id, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'ct.video_cat_id = v.video_cat_id AND u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id']))); } $this->db->sql_freeresult($result); // We need another query for the video count $sql = 'SELECT COUNT(*) as video_count FROM ' . $this->video_table; $result = $this->db->sql_query($sql); $videorow['video_count'] = $this->db->sql_fetchfield('video_count'); $this->db->sql_freeresult($result); $start = $this->request->variable('start', 0); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start); $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count']))); break; } if (!$row) { $this->template->assign_vars(array('NO_ENTRY' => $this->user->lang['NO_VIDEOS'])); } // Output page page_header($l_title, false); $this->template->set_filenames(array('body' => $template_html)); make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->phpEx}")); page_footer(); }
$s_characters .= '<option value="50">50</option>'; for ($i = 100; $i < 1100; $i += 100) { $selected = $i == 200 ? ' selected="selected"' : ''; $s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } // // Sorting // $s_sort_by = ""; for ($i = 0; $i < count($sort_by_types); $i++) { $s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>'; } // // Search time // $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); $previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); $s_time = ''; for ($i = 0; $i < count($previous_days); $i++) { $selected = $topic_days == $previous_days[$i] ? ' selected="selected"' : ''; $s_time .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; } // // Output the basic page // $page_title = $lang['Search']; require_once "includes/phpBB/page_header.php"; make_jumpbox('viewforum'); $template->assign_vars(array('L_GO' => $lang['Go'], 'L_SEARCH_QUERY' => $lang['Search_query'], 'L_SEARCH_OPTIONS' => $lang['Search_options'], 'L_SEARCH_KEYWORDS' => $lang['Search_keywords'], 'L_SEARCH_KEYWORDS_EXPLAIN' => $lang['Search_keywords_explain'], 'L_SEARCH_AUTHOR' => $lang['Search_author'], 'L_SEARCH_AUTHOR_EXPLAIN' => $lang['Search_author_explain'], 'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'], 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], 'L_SEARCH_MESSAGE_ONLY' => $lang['Search_msg_only'], 'L_SEARCH_MESSAGE_TITLE' => $lang['Search_title_msg'], 'L_CATEGORY' => $lang['Category'], 'L_RETURN_FIRST' => $lang['Return_first'], 'L_CHARACTERS' => $lang['characters_posts'], 'L_SORT_BY' => $lang['Sort_by'], 'L_SORT_ASCENDING' => $lang['Sort_Ascending'], 'L_SORT_DESCENDING' => $lang['Sort_Descending'], 'L_SEARCH_PREVIOUS' => $lang['Search_previous'], 'L_DISPLAY_RESULTS' => $lang['Display_results'], 'L_FORUM' => $lang['Forum'], 'L_TOPICS' => $lang['Topics'], 'L_POSTS' => $lang['Posts'], 'S_SEARCH_ACTION' => URL::index("&file=search&mode=results"), 'S_CHARACTER_OPTIONS' => $s_characters, 'S_FORUM_OPTIONS' => $s_forums, 'S_CATEGORY_OPTIONS' => $s_categories, 'S_TIME_OPTIONS' => $s_time, 'S_SORT_OPTIONS' => $s_sort_by, 'S_HIDDEN_FIELDS' => '')); $template->set_filenames(array('body' => 'forums/search_body.html')); require_once 'includes/phpBB/page_tail.php';
// Attachment entry // Not using acl_gets here, because it is using OR logic if ($_CLASS['auth']->acl_get('f_attach', $forum_id) && $_CLASS['auth']->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype) { posting_gen_attachment_entry($attachment_data, $filename_data); } else { $_CLASS['core_template']->assign('S_SHOW_ATTACH_BOX', false); } // Output page ... page_header(); // Topic review if ($mode == 'reply' || $mode == 'quote') { if (topic_review($topic_id, $forum_id)) { $_CLASS['core_template']->assign('S_DISPLAY_REVIEW', true); } } make_jumpbox(generate_link('Forums&file=viewforum')); $_CLASS['core_template']->display('modules/Forums/posting_body.html'); // --------- // FUNCTIONS // // Delete Post function delete_post($mode, $post_id, $topic_id, $forum_id, &$data) { global $config, $_CLASS; // Specify our post mode $post_mode = $data['topic_first_post_id'] == $data['topic_last_post_id'] ? 'delete_topic' : ($data['topic_first_post_id'] == $post_id ? 'delete_first_post' : ($data['topic_last_post_id'] == $post_id ? 'delete_last_post' : 'delete')); $sql_data = array(); $next_post_id = 0; $_CLASS['core_db']->transaction(); if (!delete_posts('post_id', array($post_id), false)) { // Try to delete topic, we may had an previous error causing inconsistency
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); $user->add_lang('viewtopic'); $topic_id = request_var('t', 0); $topic_info = get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Approve posts? if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { approve_post($post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; if ($total == -1) { if ($auth->acl_get('m_approve', $topic_info['forum_id'])) { $total = $topic_info['topic_replies_real'] + 1; } else { $total = $topic_info['topic_replies'] + 1; } } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } // Make sure $start is set to the last page if it exceeds the amount if ($start < 0 || $start >= $total) { $start = $start < 0 ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; } $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' ' . (!$auth->acl_get('m_approve', $topic_info['forum_id']) ? ' AND p.post_approved = 1 ' : '') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); $bbcode_bitfield = ''; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } $db->sql_freeresult($result); if ($bbcode_bitfield !== '') { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if (!$row['post_approved']) { $has_unapproved_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $template->assign_block_vars('postrow', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => !$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => !$posts_per_page ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"), $total, $posts_per_page, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total))); }
$page_title = $lang['Post_a_reply']; $hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; break; case 'editpost': $page_title = $lang['Edit_Post']; $hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />'; break; } // Generate smilies listing for page output generate_smilies('inline', PAGE_POSTING); // // Include page header // require FT_ROOT . 'includes/page_header.php'; $template->set_filenames(array('body' => 'posting_body.tpl', 'pollbody' => 'posting_poll_body.tpl', 'reviewbody' => 'posting_topic_review.tpl')); make_jumpbox('viewforum.php'); $template->assign_vars(array('FORUM_NAME' => $forum_name, 'L_POST_A' => $page_title, 'L_POST_SUBJECT' => $lang['Post_subject'], 'U_VIEW_TOPIC' => $mode != 'newtopic' ? ' ї <a href="' . append_sid("viewtopic.php?" . POST_TOPIC_URL . "={$topic_id}") . '" class="nav" style="font-weight:normal">' . $post_info['topic_title'] . '</a>' : '', 'U_VIEW_FORUM' => append_sid("viewforum.php?" . POST_FORUM_URL . "={$forum_id}"))); // // This enables the forum/topic title to be output for posting // but not for privmsg (where it makes no sense) // $template->assign_block_vars('switch_not_privmsg', array()); if ($mode == 'newtopic' || $post_data['first_post']) { $template->assign_block_vars('switch_show_subject', array()); } //upt $set_update_post_time_checkbox = FALSE; if ($mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) { $template->assign_block_vars('switch_update_post_time', array()); if ($post_data['poster_post']) { if ($post_info['post_time'] + UPD_LAST_POST_HOUR_ACTIVE > time()) {
$template->assign_block_vars('memberrow', $memberrow); if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { $template->assign_block_vars('memberrow.custom_fields', $field_data); } } unset($id_cache[$user_id]); } } // Generate page $template->assign_vars(array('PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start), 'TOTAL_USERS' => $total_users == 1 ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users), 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'U_FIND_MEMBER' => $config['load_search'] || $auth->acl_get('a_') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser' . ($start ? "&start={$start}" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', 'U_HIDE_FIND_MEMBER' => $mode == 'searchuser' ? $u_hide_find_member : '', 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . ($sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_FROM' => $sort_url . '&sk=b&sd=' . ($sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . ($sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . ($sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_EMAIL' => $sort_url . '&sk=e&sd=' . ($sort_key == 'e' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_WEBSITE' => $sort_url . '&sk=f&sd=' . ($sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_LOCATION' => $sort_url . '&sk=b&sd=' . ($sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_ICQ' => $sort_url . '&sk=g&sd=' . ($sort_key == 'g' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_AIM' => $sort_url . '&sk=h&sd=' . ($sort_key == 'h' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_MSN' => $sort_url . '&sk=i&sd=' . ($sort_key == 'i' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_YIM' => $sort_url . '&sk=j&sd=' . ($sort_key == 'j' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_ACTIVE' => $auth->acl_get('u_viewonline') ? $sort_url . '&sk=l&sd=' . ($sort_key == 'l' && $sort_dir == 'a' ? 'd' : 'a') : '', 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . ($sort_key == 'm' && $sort_dir == 'a' ? 'd' : 'a'), 'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . ($sort_key == 'l' && $sort_dir == 'a' ? 'd' : 'a'), 'S_SHOW_GROUP' => $mode == 'group' ? true : false, 'S_VIEWONLINE' => $auth->acl_get('u_viewonline'), 'S_LEADERS_SET' => $leaders_set, 'S_MODE_SELECT' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir, 'S_CHAR_OPTIONS' => $s_char_options, 'S_MODE_ACTION' => $pagination_url)); } // Output the page page_header($page_title); $template->set_filenames(array('body' => $template_html)); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}")); page_footer(); /** * Prepare profile data */ function show_profile($data) { global $config, $auth, $template, $user, $phpEx, $phpbb_root_path; $username = $data['username']; $user_id = $data['user_id']; $rank_title = $rank_img = $rank_img_src = ''; get_user_rank($data['user_rank'], $user_id == ANONYMOUS ? false : $data['user_posts'], $rank_title, $rank_img, $rank_img_src); if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_user')) { $email = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=email&u=' . $user_id) : ($config['board_hide_emails'] && !$auth->acl_get('a_user') ? '' : 'mailto:' . $data['user_email']); } else { $email = '';
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.php?" . POST_FORUM_URL . "={$forum_id}&start=" . $start . "&sid=" . $userdata['session_id'] . '">', '</a>'); } // // Mozilla navigation bar // $nav_links['up'] = array('url' => append_sid('index.php'), 'title' => sprintf($lang['Forum_Index'], $ft_cfg['sitename'])); // // Dump out the page header and load viewforum template // define('SHOW_ONLINE', true); $page_title = $forum_row['forum_name']; require FT_ROOT . 'includes/page_header.php'; $template->set_filenames(array('body' => 'viewforum_body.tpl')); //sf // make_jumpbox('viewforum.'.$phpEx); $forums_ary = make_jumpbox('viewforum.php', 0, TRUE); $template->assign_vars(array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_row['forum_name'], 'MODERATORS' => $forum_moderators, 'POST_IMG' => $forum_row['forum_status'] == FORUM_LOCKED ? $images['post_locked'] : $images['post_new'], 'FOLDER_IMG' => $images['folder'], 'FOLDER_NEW_IMG' => $images['folder_new'], 'FOLDER_HOT_IMG' => $images['folder_hot'], 'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'], 'FOLDER_LOCKED_IMG' => $images['folder_locked'], 'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'], 'FOLDER_STICKY_IMG' => $images['folder_sticky'], 'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'], 'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'], 'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'], 'L_TOPICS' => $lang['Topics'], 'L_REPLIES' => $lang['Replies'], 'L_VIEWS' => $lang['Views'], 'L_POSTS' => $lang['Posts'], 'L_LASTPOST' => $lang['Last_Post'], 'L_MODERATOR' => $l_moderators, 'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'], 'L_POST_NEW_TOPIC' => $forum_row['forum_status'] == FORUM_LOCKED ? $lang['Forum_locked'] : $lang['Post_new_topic'], 'L_NO_NEW_POSTS' => $lang['No_new_posts'], 'L_NEW_POSTS' => $lang['New_posts'], 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'], 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'], 'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'], 'L_NEW_POSTS_HOT' => $lang['New_posts_hot'], 'L_ANNOUNCEMENT' => $lang['Post_Announcement'], 'L_STICKY' => $lang['Post_Sticky'], 'L_POSTED' => $lang['Posted'], 'L_JOINED' => $lang['Joined'], 'L_AUTHOR' => $lang['Author'], 'L_DOWNLOAD' => $lang['Post_Download'], 'FOLDER_DOWNLOAD_IMG' => $images['folder_dl'], 'S_AUTH_LIST' => $s_auth_can, 'U_VIEW_FORUM' => append_sid("viewforum.php?" . POST_FORUM_URL . "={$forum_id}"), 'U_MARK_READ' => append_sid("viewforum.php?" . POST_FORUM_URL . "={$forum_id}&mark=topics"))); // // End header // // // Okay, lets dump out the page ... // //-- mod : topic display order //-- add $template->assign_vars(array('S_DISPLAY_ORDER' => $s_display_order)); //-- fin mod : topic display order //bt $topics_sql = $tor_topics_sql = $topic_tor = array(); $current_time = isset($_GET['time']) && $_GET['time'] == 'all' ? 0 : time(); $template->assign_vars(array('TORRENT_TOPICS' => FALSE));
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } $sql = "SELECT *\n\tFROM " . RANKS_TABLE . "\n\tORDER BY rank_special, rank_min"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql); } $ranksrow = array(); while ($row = $db->sql_fetchrow($result)) { $ranksrow[] = $row; } $db->sql_freeresult($result); // // Output page header and profile_view template // $template->set_filenames(array('body' => 'profile_view_body.tpl')); make_jumpbox('viewforum.' . $phpEx); // // Calculate the number of days this user has been a member ($memberdays) // Then calculate their posts per day // $regdate = $profiledata['user_regdate']; $memberdays = max(1, round((time() - $regdate) / 86400)); $posts_per_day = $profiledata['user_posts'] / $memberdays; // Get the users percentage of total posts if ($profiledata['user_posts'] != 0) { $total_posts = get_db_stat('postcount'); $percentage = $total_posts ? min(100, $profiledata['user_posts'] / $total_posts * 100) : 0; } else { $percentage = 0; } $avatar_img = '';
$id = $row['user_id']; $username = $id == ANONYMOUS ? $lang['Guest'] : $row['username']; $row_color = !($i % 2) ? $theme['td_color1'] : $theme['td_color2']; $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('userrow', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'USERNAME' => $username, 'POSTS' => $row['postings'] . ' ' . ($row['postings'] == 1 ? $lang['Post'] : $lang['Posts']), 'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username), 'U_PROFILE' => $id == ANONYMOUS ? "modcp.{$phpEx}?mode=ip&" . POST_POST_URL . "=" . $post_id . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id'] : append_sid("profile.{$phpEx}?mode=viewprofile&" . POST_USERS_URL . "={$id}"), 'U_SEARCHPOSTS' => append_sid("search.{$phpEx}?search_author=" . ($id == ANONYMOUS ? 'Anonymous' : urlencode($username)) . "&showresults=topics"))); $i++; } while ($row = $db->sql_fetchrow($result)); } $template->pparse('viewip'); break; default: $page_title = $lang['Mod_CP']; include $phpbb_root_path . 'includes/page_header.' . $phpEx; $template->assign_vars(array('FORUM_NAME' => $forum_name, 'L_MOD_CP' => $lang['Mod_CP'], 'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'], 'L_SELECT' => $lang['Select'], 'L_DELETE' => $lang['Delete'], 'L_MOVE' => $lang['Move'], 'L_LOCK' => $lang['Lock'], 'L_UNLOCK' => $lang['Unlock'], 'L_TOPICS' => $lang['Topics'], 'L_REPLIES' => $lang['Replies'], 'L_LASTPOST' => $lang['Last_Post'], 'L_SELECT' => $lang['Select'], 'U_VIEW_FORUM' => append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}"), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />', 'S_MODCP_ACTION' => append_sid("modcp.{$phpEx}"))); $template->set_filenames(array('body' => 'modcp_body.tpl')); make_jumpbox('modcp.' . $phpEx); // // Define censored word matches // $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); $sql = "SELECT t.*, u.username, u.user_id, p.post_time\n\t\t\tFROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p\n\t\t\tWHERE t.forum_id = {$forum_id}\n\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\tORDER BY t.topic_type DESC, p.post_time DESC\n\t\t\tLIMIT {$start}, " . $board_config['topics_per_page']; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { $topic_title = ''; if ($row['topic_status'] == TOPIC_LOCKED) { $folder_img = $images['folder_locked']; $folder_alt = $lang['Topic_locked'];