function blog_enable_html_edit_preview(&$arg) { global $reply_id, $blog_id; if (!function_exists('enable_html_permission')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mods/enable_html.' . $phpEx; } if ($reply_id && isset(blog_data::$reply[$reply_id])) { $user_id = blog_data::$reply[$reply_id]['user_id']; } else { if ($blog_id && isset(blog_data::$blog[$blog_id])) { $user_id = blog_data::$blog[$blog_id]['user_id']; } else { global $user; $user_id = $user->data['user_id']; } } blog_data::get_user_data($user_id); $html_auth = enable_html_permission($user_id, blog_data::$user[$user_id]); if ($html_auth) { $arg = enable_html($arg, ''); } }
function main($id, $mode) { global $auth, $db, $user, $template; global $config, $phpbb_root_path, $phpEx, $action; global $blog_data, $blog_plugins, $blog_urls; $user->add_lang(array('mods/blog/common', 'mods/blog/mcp')); // include some files include $phpbb_root_path . 'includes/functions_display.' . $phpEx; include $phpbb_root_path . 'blog/functions.' . $phpEx; // set some initial variables that we will use $blog_data = new blog_data(); blog_plugins::plugin_do('mcp_start'); $blog = strpos($mode, 'blogs') ? true : false; $start = request_var('start', 0); $limit = request_var('limit', 10); $sort_days = request_var('st', !empty($user->data['user_post_show_days']) ? $user->data['user_post_show_days'] : 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; $order_dir = $sort_dir == 'a' ? 'ASC' : 'DESC'; if ($blog) { $sort_by_text = array('t' => $user->lang['POST_TIME']); $sort_by_sql = array('t' => 'blog_time'); } else { $sort_by_text = array('t' => $user->lang['POST_TIME']); $sort_by_sql = array('t' => 'reply_time'); } generate_blog_urls(); $this->tpl_name = 'blog/mcp_blog'; $this->page_title = $user->lang['MCP_BLOG_' . strtoupper($mode)]; $template->assign_vars(array('L_TITLE' => $user->lang['MCP_BLOG_' . strtoupper($mode)], 'L_EXPLAIN' => $user->lang['MCP_BLOG_' . strtoupper($mode) . '_EXPLAIN'], 'S_BLOGS' => $blog, 'S_REPLIES' => !$blog)); $extra_data = array('start' => $start, 'limit' => $limit, 'order_by' => $sort_by_sql[$sort_key], 'order_dir' => $order_dir, 'sort_days' => $sort_days); switch ($mode) { // Need to add counts here... case 'reported_blogs': $ids = $blog_data->get_blog_data('reported', false, $extra_data); break; case 'reported_replies': $ids = $blog_data->get_reply_data('reported', false, $extra_data); break; case 'disapproved_blogs': $ids = $blog_data->get_blog_data('disapproved', false, $extra_data); break; case 'disapproved_replies': $ids = $blog_data->get_reply_data('disapproved', false, $extra_data); break; default: blog_plugins::plugin_do_arg('mcp_default', $mode); } if ($blog) { $cnt_sql = 'SELECT count(blog_id) AS total FROM ' . BLOGS_TABLE . ' WHERE blog_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0'); } else { $cnt_sql = 'SELECT count(reply_id) AS total FROM ' . BLOGS_REPLY_TABLE . ' WHERE ' . 'reply_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0'); } $result = $db->sql_query($cnt_sql); $row = $db->sql_fetchrow($result); if ($row) { $count = $row['total']; } $db->sql_freeresult($result); unset($row, $cnt_sql); if ($ids === false) { $ids = array(); } $blog_data->get_user_data(false, true); if ($blog) { $total_posts = $count == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $count); foreach ($ids as $id) { $user_id = blog_data::$blog[$id]['user_id']; $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $id), 'SUBJECT' => blog_data::$blog[$id]['blog_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$blog[$id]['blog_time']))); } } else { $total_posts = $count == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $count); foreach ($ids as $id) { $user_id = blog_data::$reply[$id]['user_id']; $blog_id = blog_data::$reply[$id]['blog_id']; $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $blog_id, $id), 'SUBJECT' => blog_data::$reply[$id]['reply_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$reply[$id]['reply_time']))); } } gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $pagination = generate_pagination($this->u_action . "&limit={$limit}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}", $count, $limit, $start, false); $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($count, $limit, $start), 'TOTAL_POSTS' => $total_posts, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days)); blog_plugins::plugin_do('mcp_end'); }
/** * Get user data * * grabs the data on the user and places it in the self::$user array * * @param int|bool $id The user_id (or multiple user_ids if given an array) of the user we want to grab the data for * @param bool $user_queue If user_queue is true then we just grab the user_ids from the user_queue, otherwise we select data from $id. */ public function get_user_data($id, $user_queue = false, $username = false) { global $user, $db, $phpbb_root_path, $phpEx, $config, $auth, $cp; // if we are using the user_queue, set $user_id as that for consistency if ($user_queue) { $id = self::$user_queue; } blog_plugins::plugin_do('user_data_start'); // this holds the user_id's we will query $users_to_query = array(); // if the $user_id isn't an array, make it one for consistency if (!is_array($id)) { $id = array(intval($id)); } if ($username) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE username_clean = \'' . $db->sql_escape(utf8_clean_string($username)) . '\''; $result = $db->sql_query($sql); $id[] = $db->sql_fetchfield('user_id', $result); $db->sql_freeresult($result); } if (!sizeof($id)) { return; } $id[] = 1; foreach ($id as $i) { if ($i && !isset(self::$user[$i]) && !in_array($i, $users_to_query)) { $users_to_query[] = (int) $i; } } if (!sizeof($users_to_query)) { return; } // Grab all profile fields from users in id cache for later use - similar to the poster cache if ($config['user_blog_custom_profile_enable']) { if (!class_exists('custom_profile')) { include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $cp = new custom_profile(); } $profile_fields_cache = $cp->generate_profile_fields_template('grab', $users_to_query); } // Grab user status information $status_data = array(); $sql = 'SELECT session_user_id, MAX(session_time) AS online_time, MIN(session_viewonline) AS viewonline FROM ' . SESSIONS_TABLE . ' WHERE ' . $db->sql_in_set('session_user_id', $users_to_query) . ' GROUP BY session_user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $status_data[$row['session_user_id']] = $row; } $db->sql_freeresult($result); $update_time = $config['load_online_time'] * 60; // Get the rest of the data on the users and parse everything we need $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $users_to_query); blog_plugins::plugin_do_ref('user_data_sql', $sql); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $user_id = $row['user_id']; blog_plugins::plugin_do_ref('user_data_while', $row); // view profile link $row['view_profile'] = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $user_id); // Full username, with colour $row['username_full'] = get_username_string('full', $user_id, $row['username'], $row['user_colour']); // format the color correctly $row['user_colour'] = get_username_string('colour', $user_id, $row['username'], $row['user_colour']); // Avatar $row['avatar'] = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']); // Rank get_user_rank($row['user_rank'], $row['user_posts'], $row['rank_title'], $row['rank_img'], $row['rank_img_src']); if ($row['user_type'] != USER_IGNORE && $row['user_id'] != ANONYMOUS) { // Online/Offline Status $row['status'] = isset($status_data[$user_id]) && time() - $update_time < $status_data[$user_id]['online_time'] && ($status_data[$user_id]['viewonline'] && $row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false; // IM Links $row['aim_url'] = $row['user_aim'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=aim&u={$user_id}") : ''; $row['icq_url'] = $row['user_icq'] ? 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'] : ''; $row['jabber_url'] = $row['user_jabber'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$user_id}") : ''; $row['msn_url'] = $row['user_msnm'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$user_id}") : ''; $row['yim_url'] = $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : ''; // PM and email links $row['email_url'] = $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_email') ? '' : 'mailto:' . $row['user_email']); $row['pm_url'] = $row['user_id'] != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&mode=compose&u={$user_id}") : ''; // get the custom profile fields if the admin wants them if ($config['user_blog_custom_profile_enable']) { $row['cp_row'] = isset($profile_fields_cache[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array(); } } else { $row = array_merge($row, array('status' => false, 'aim_url' => '', 'icq_url' => '', 'jabber_url' => '', 'msn_url' => '', 'yim_url' => '', 'email_url' => '', 'pm_url' => '')); } // now lets put everything in the user array self::$user[$user_id] = $row; } $db->sql_freeresult($result); unset($status_data, $row); // if we did use the user_queue, reset it if ($user_queue) { self::$user_queue = array(); } if ($username) { if (isset($user_id) && $user_id != ANONYMOUS) { // Grab all profile fields from users in id cache for later use - similar to the poster cache if ($config['user_blog_custom_profile_enable']) { if (!class_exists('custom_profile')) { include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $cp = new custom_profile(); } $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_id); } // Grab user status information $status_data = array(); $sql = 'SELECT session_user_id, MAX(session_time) AS online_time, MIN(session_viewonline) AS viewonline FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . intval($user_id) . ' GROUP BY session_user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $status_data[$row['session_user_id']] = $row; } $db->sql_freeresult($result); $update_time = $config['load_online_time'] * 60; self::$user[$user_id]['status'] = isset($status_data[$user_id]) && time() - $update_time < $status_data[$user_id]['online_time'] && ($status_data[$user_id]['viewonline'] && $row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false; unset($status_data); return $user_id; } else { return false; } } else { // replace any non-existing users with the anonymous user. foreach ($id as $i) { if ($i && !array_key_exists($i, self::$user)) { self::$user[$i] = self::$user[1]; } } } }
$feed = $feed && ($feed == 'explain' || $feed == 'RSS_0.91' || $feed == 'RSS_1.0' || $feed == 'RSS_2.0' || $feed == 'ATOM' || $feed == 'JAVASCRIPT') && $config['user_blog_enable_feeds'] ? $feed : false; $hilit_words = request_var('hilit', '', true); $start = request_var('start', 0); $limit = request_var('limit', $page == 'search' ? 20 : ($blog_id || $reply_id ? 10 : 5)); $sort_days = request_var('st', !empty($user->data['user_post_show_days']) ? $user->data['user_post_show_days'] : 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', $blog_id || $reply_id ? 'a' : 'd'); $order_dir = $sort_dir == 'a' ? 'ASC' : 'DESC'; // set some initial variables that we will use $s_hidden_fields = $subscribed_title = $username = ''; $default = $inc_file = $user_style = $subscribed = false; $error = $blog_urls = $zebra_list = $user_settings = array(); // include some files include $phpbb_root_path . 'includes/functions_display.' . $phpEx; include $phpbb_root_path . 'blog/functions.' . $phpEx; $blog_data = new blog_data(); // We need to use our own error handler which resets the template when trigger_error is called. set_error_handler('blog_error_handler'); // check if the User Blog Mod is installed/enabled if (!isset($config['user_blog_enable']) && $user->data['user_type'] == USER_FOUNDER) { // Now we will just redirect to the install.php file. Otherwise we have problems with some stuff trying to get data from non-existing tables. redirect(append_sid("{$phpbb_root_path}blog/database.{$phpEx}")); } else { if ((!isset($config['user_blog_enable']) || !$config['user_blog_enable']) && $user->data['user_type'] != USER_FOUNDER) { trigger_error('USER_BLOG_MOD_DISABLED'); } } blog_plugins::plugin_do('blog_start'); switch ($page) { case 'vote': // Vote in a poll