예제 #1
0
} else {
    // insert array
    $sql_data = array('user_ip' => $user->data['user_id'] == $user_id ? $user->data['user_ip'] : blog_data::$blog[$blog_id]['user_ip'], 'blog_subject' => $blog_subject, 'blog_text' => $message_parser->message, 'blog_checksum' => md5($message_parser->message), 'blog_approved' => blog_data::$blog[$blog_id]['blog_approved'] == 1 || $auth->acl_get('u_blognoapprove') ? 1 : 0, 'enable_bbcode' => $post_options->enable_bbcode, 'enable_smilies' => $post_options->enable_smilies, 'enable_magic_url' => $post_options->enable_magic_url, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'blog_edit_time' => time(), 'blog_edit_reason' => utf8_normalize_nfc(request_var('edit_reason', '', true)), 'blog_edit_user' => $user->data['user_id'], 'blog_edit_count' => blog_data::$blog[$blog_id]['blog_edit_count'] + 1, 'blog_edit_locked' => $auth->acl_get('m_bloglockedit') && $user->data['user_id'] != blog_data::$blog[$blog_id]['user_id'] ? request_var('lock_post', false) : false, 'perm_guest' => request_var('perm_guest', 1), 'perm_registered' => request_var('perm_registered', 2), 'perm_foe' => request_var('perm_foe', 0), 'perm_friend' => request_var('perm_friend', 2), 'blog_attachment' => sizeof($blog_attachment->attachment_data) ? 1 : 0, 'poll_title' => !empty($poll) ? $poll_title : '', 'poll_length' => !empty($poll) && $poll_length ? time() + $poll_length * 86400 : 0, 'poll_max_options' => !empty($poll) ? max($poll_max_options, 1) : 1, 'poll_vote_change' => !empty($poll) ? $poll_vote_change : 0);
    if ($original_poll_text != $poll_option_text) {
        $sql_data['poll_start'] = empty($poll) ? 0 : time();
    }
    blog_plugins::plugin_do_ref('blog_edit_sql', $sql_data);
    $sql = 'UPDATE ' . BLOGS_TABLE . '
		SET ' . $db->sql_build_array('UPDATE', $sql_data) . '
			WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
    // Reindex the blog
    $blog_search->index('edit', $blog_id, 0, $message_parser->message, $blog_subject, $user_id);
    // Update the attachments
    $blog_attachment->update_attachment_data($blog_id, 0, blog_data::$blog[$blog_id]['user_id']);
    blog_plugins::plugin_do_arg('blog_edit_after_sql', $blog_id);
    // Submit the poll
    if ($auth->acl_get('u_blog_create_poll')) {
        submit_blog_poll($poll, $blog_id, 'edit');
    }
    // Handle the subscriptions
    add_blog_subscriptions($blog_id, 'subscription_');
    // Insert into the categories list
    if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) {
        $category_list = get_blog_categories('category_id');
        foreach ($category_ary as $i => $cat_id) {
            if (!isset($category_list[$cat_id])) {
                unset($category_ary[$i]);
            }
        }
    }
예제 #2
0
/**
* Outputs data as a Feed.
*
* @param int|array $blog_ids The id's of blogs that are going to get outputted,
* @param string $feed_type The type of feed we are outputting
*/
function feed_output($ids, $feed_type)
{
    global $template, $phpbb_root_path, $phpEx, $page, $mode, $limit, $config, $user, $blog_data, $user_id, $blog_id;
    // Feed explanation page
    if ($feed_type == 'explain') {
        $available_feeds = array('RSS 0.91' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_0.91'))), 'RSS 1.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_1.0'))), 'RSS 2.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_2.0'))), 'ATOM' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'ATOM'))), 'JAVASCRIPT' => array('url' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT'))), 'text' => htmlspecialchars('<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>'), 'demo' => '<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>'));
        blog_plugins::plugin_do_ref('available_feeds', $available_feeds);
        $message = '<strong>' . $user->lang['AVAILABLE_FEEDS'] . '</strong><br /><br />';
        foreach ($available_feeds as $feed_name => $data) {
            if (!is_array($data)) {
                $message .= '<br /><h2><a href="' . $data . '">' . $feed_name . '</a></h2><div><a href="' . $data . '">' . $data . '</a></div><br />';
            } else {
                $message .= '<br /><h2><a href="' . $data['url'] . '">' . $feed_name . '</a></h2><div><dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code style="font-size: 12px;">' . $data['text'] . '</code></dd></dl></div><br />';
                if (isset($data['demo'])) {
                    $message .= $data['demo'];
                }
            }
        }
        trigger_error($message);
    }
    $title = $feed_type == 'JAVASCRIPT' ? str_replace("'", "\\'", $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME']) : $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME'];
    $template->assign_vars(array('FEED' => $feed_type, 'SELF_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode)), 'SELF_FULL_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode, 'feed' => $feed_type, 'limit' => $limit)), 'TITLE' => $config['sitename'] . ' ' . $title . ' ' . $user->lang['FEED'], 'SITE_URL' => generate_board_url(), 'SITE_DESC' => $config['site_desc'], 'SITE_LANG' => $config['default_lang'], 'CURRENT_TIME' => $feed_type == 'ATOM' ? date3339() : date('r'), 'IMG_MIN' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/min_dark_blue.gif', 'IMG_MAX' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/max_dark_blue.gif', 'S_OUTPUT' => isset($_GET['output']) ? true : false));
    if ($ids !== false) {
        if (!is_array($ids)) {
            $ids = array(intval($ids));
        }
        // the items section is only used in RSS 1.0
        if ($feed_type == 'RSS_1.0') {
            if (strpos($mode, 'comments') === false) {
                // output the URLS for the items section
                foreach ($ids as $id) {
                    $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id)));
                }
            } else {
                // output the URLS for the items section
                foreach ($ids as $id) {
                    $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$reply[$id]['user_id'], $id)));
                }
            }
        }
        if (strpos($mode, 'comments') === false) {
            // Output the main data
            foreach ($ids as $id) {
                $blog_row = $blog_data->handle_blog_data($id, true);
                $row = array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$blog[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", '&#039;', $blog_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$blog[$id]['blog_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$blog[$id]['blog_time']) : '');
                $template->assign_block_vars('item', array_merge($blog_row, $row));
            }
        } else {
            // Output the main data
            foreach ($ids as $id) {
                $reply_row = $blog_data->handle_reply_data($id, true);
                $row = array('URL' => blog_url(blog_data::$reply[$id]['user_id'], blog_data::$reply[$id]['blog_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$reply[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", '&#039;', $reply_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$reply[$id]['reply_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$reply[$id]['reply_time']) : '');
                $template->assign_block_vars('item', array_merge($reply_row, $row));
            }
        }
        blog_plugins::plugin_do_arg('function_feed_output', compact('ids', 'feed_type', 'mode'));
    }
    // Output time
    if ($feed_type == 'JAVASCRIPT') {
        header('Content-type: text/html; charset=UTF-8');
    } else {
        header('Content-type: application/xml; charset=UTF-8');
    }
    header('Cache-Control: private, no-cache="set-cookie"');
    header('Expires: 0');
    header('Pragma: no-cache');
    $template->set_template();
    $template->set_filenames(array('body' => 'blog/blog_feed.xml'));
    $template->display('body');
    garbage_collection();
    exit_handler();
}
예제 #3
0
/**
* Syncronise Blog Data
*
* This should never need to be used unless someone manually deletes blogs or replies from the database
* It is not used by the User Blog mod anywhere, except for updates/upgrades and the resync page.
* To any potential users: Make sure you do not set this in a page where it gets ran often.  Resyncing data is a long process, especially when the number of blogs that you have is large
*
* @param string $mode can be all, reply_count, real_reply_count, delete_orphan_replies, or user_blog_count
*/
function resync_blog($mode)
{
    global $cache, $db;
    $blog_data = array();
    // Start by selecting all blog data that we will use
    $sql = 'SELECT blog_id, blog_reply_count, blog_real_reply_count FROM ' . BLOGS_TABLE . ' ORDER BY blog_id ASC';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $blog_data[$row['blog_id']] = $row;
    }
    $db->sql_freeresult($result);
    /*
     * Update & Resync the reply counts
     */
    if ($mode == 'reply_count' || $mode == 'all') {
        foreach ($blog_data as $row) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql = 'SELECT count(reply_id) AS total
				FROM ' . BLOGS_REPLY_TABLE . '
					WHERE blog_id = ' . $row['blog_id'] . '
						AND reply_deleted = 0
						AND reply_approved = 1';
            $result = $db->sql_query($sql);
            $total = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($total['total'] != $row['blog_reply_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = ' . $total['total'] . ' WHERE blog_id = ' . $row['blog_id'];
                $db->sql_query($sql);
            }
        }
    }
    /*
     * Update & Resync the real reply counts
     */
    if ($mode == 'real_reply_count' || $mode == 'all') {
        foreach ($blog_data as $row) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql = 'SELECT count(reply_id) AS total
				FROM ' . BLOGS_REPLY_TABLE . '
					WHERE blog_id = ' . $row['blog_id'];
            $result = $db->sql_query($sql);
            $total = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($total['total'] != $row['blog_real_reply_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_real_reply_count = ' . $total['total'] . ' WHERE blog_id = ' . $row['blog_id'];
                $db->sql_query($sql);
            }
        }
    }
    /*
     * Delete's all oprhaned replies (replies where the blogs they should go under have been deleted).
     */
    if ($mode == 'delete_orphan_replies' || $mode == 'all') {
        // Now get all reply data we will use
        $sql = 'SELECT reply_id, blog_id FROM ' . BLOGS_REPLY_TABLE . ' ORDER BY reply_id ASC';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            // if the blog_id it attached to is not in $blog_data
            if (!array_key_exists($row['blog_id'], $blog_data)) {
                $sql2 = 'DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE reply_id = ' . $row['reply_id'];
                $db->sql_query($sql2);
            }
        }
        $db->sql_freeresult($result);
    }
    /*
     * Updates the blog_count for each user
     */
    if ($mode == 'user_blog_count' || $mode == 'all') {
        // select the users data we will need
        $sql = 'SELECT user_id, blog_count FROM ' . USERS_TABLE;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql2 = 'SELECT count(blog_id) AS total
				FROM ' . BLOGS_TABLE . '
					WHERE user_id = \'' . $row['user_id'] . '\'
						AND blog_deleted = 0
						AND blog_approved = 1';
            $result2 = $db->sql_query($sql2);
            $total = $db->sql_fetchrow($result2);
            $db->sql_freeresult($result2);
            if ($total['total'] != $row['blog_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = ' . $total['total'] . ' WHERE user_id = ' . $row['user_id'];
                $db->sql_query($sql);
            }
        }
        $db->sql_freeresult($result);
    }
    /**
     * Updates the user permissions for each blog
     */
    if ($mode == 'user_permissions' || $mode == 'all') {
        $sql = 'SELECT * FROM ' . BLOGS_USERS_TABLE;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $sql_ary = array('perm_guest' => $row['perm_guest'], 'perm_registered' => $row['perm_registered'], 'perm_foe' => $row['perm_foe'], 'perm_friend' => $row['perm_friend']);
            $sql = 'UPDATE ' . BLOGS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'];
            $db->sql_query($sql);
        }
        $db->sql_freeresult($result);
    }
    // clear the cache
    $cache->purge();
    if (class_exists('blog_plugins')) {
        blog_plugins::plugin_do_arg('function_resync_blog', $mode);
    }
}
/**
* Informs users when a blog or reply was reported or needs approval
*
* Informs users in the $config['user_blog_inform'] variable (in the variable should be user_id's seperated by commas if there is more than one)
*
* @param string $mode The mode - blog_report, reply_report, blog_approve, reply_approve
*/
function inform_approve_report($mode, $id)
{
    global $phpbb_root_path, $phpEx, $config, $user;
    switch ($mode) {
        case 'blog_report':
            $message = sprintf($user->lang['BLOG_REPORT_PM'], $user->data['username'], blog_url($user->data['user_id'], $id));
            $subject = $user->lang['BLOG_REPORT_PM_SUBJECT'];
            break;
        case 'reply_report':
            $message = sprintf($user->lang['REPLY_REPORT_PM'], $user->data['username'], blog_url($user->data['user_id'], false, $id));
            $subject = $user->lang['REPLY_REPORT_PM_SUBJECT'];
            break;
        case 'blog_approve':
            $message = sprintf($user->lang['BLOG_APPROVE_PM'], $user->data['username'], blog_url($user->data['user_id'], $id));
            $subject = $user->lang['BLOG_APPROVE_PM_SUBJECT'];
            break;
        case 'reply_approve':
            $message = sprintf($user->lang['REPLY_APPROVE_PM'], $user->data['username'], blog_url($user->data['user_id'], false, $id));
            $subject = $user->lang['REPLY_APPROVE_PM_SUBJECT'];
            break;
        default:
            blog_plugins::plugin_do_arg('function_inform_approve_report', compact('mode', 'id'));
    }
    $to = explode(",", $config['user_blog_inform']);
    // setup out to address list
    $address_list = array();
    foreach ($to as $id) {
        $id = (int) $id;
        if ($id) {
            $address_list[$id] = 'to';
        }
    }
    if (sizeof($address_list)) {
        if (!function_exists('submit_pm')) {
            // include the private messages functions page
            include "{$phpbb_root_path}includes/functions_privmsgs.{$phpEx}";
        }
        if (!class_exists('parse_message')) {
            include "{$phpbb_root_path}includes/message_parser.{$phpEx}";
        }
        $message_parser = new parse_message();
        $message_parser->message = $message;
        $message_parser->parse(true, true, true, true, true, true, true);
        $pm_data = array('from_user_id' => $config['user_blog_message_from'], 'from_username' => $user->lang['ADMINISTRATOR'], 'address_list' => array('u' => $address_list), 'icon_id' => 10, 'from_user_ip' => '0.0.0.0', 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => false, 'message' => $message_parser->message, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid);
        submit_pm('post', $subject, $pm_data, false);
    }
}
예제 #5
0
    handle_basic_posting_data(false, 'reply');
    // Assign some variables to the template parser
    $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'MESSAGE' => $reply_text, 'SUBJECT' => $reply_subject, 'L_MESSAGE_BODY_EXPLAIN' => intval($config['max_post_chars']) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', 'L_POST_A' => $user->lang['POST_A_NEW_REPLY']));
    $template->set_filenames(array('body' => 'blog/blog_posting_layout.html'));
} else {
    // insert array, not all of these really need to be inserted, since some are what the fields are as default, but I want it this way. :P
    $sql_data = array('blog_id' => $blog_id, 'user_id' => $user->data['user_id'], 'user_ip' => $user->data['user_ip'], 'reply_time' => time(), 'reply_subject' => $reply_subject, 'reply_text' => $message_parser->message, 'reply_checksum' => md5($message_parser->message), 'reply_approved' => $auth->acl_get('u_blogreplynoapprove') ? 1 : 0, 'enable_bbcode' => $post_options->enable_bbcode, 'enable_smilies' => $post_options->enable_smilies, 'enable_magic_url' => $post_options->enable_magic_url, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'reply_edit_reason' => '', 'reply_attachment' => sizeof($blog_attachment->attachment_data) ? 1 : 0);
    blog_plugins::plugin_do_ref('reply_add_sql', $sql_data);
    $sql = 'INSERT INTO ' . BLOGS_REPLY_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data);
    $db->sql_query($sql);
    $reply_id = $db->sql_nextid();
    $blog_search->index('add', $blog_id, $reply_id, $message_parser->message, $reply_subject, $user->data['user_id']);
    // update the URLS to include the new reply_id
    generate_blog_urls();
    $blog_attachment->update_attachment_data(false, $reply_id);
    blog_plugins::plugin_do_arg('reply_add_after_sql', $reply_id);
    // Handle the subscriptions
    add_blog_subscriptions($blog_id, 'subscription_');
    handle_blog_cache('add_reply', $user_id);
    // update the reply count for the blog
    if ($sql_data['reply_approved']) {
        $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = blog_reply_count + 1, blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        set_config('num_blog_replies', ++$config['num_blog_replies'], true);
        handle_subscription('new_reply', censor_text($reply_subject), 0, $blog_id, $reply_id);
    } else {
        $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        inform_approve_report('reply_approve', $reply_id);
    }
    $message = (!$sql_data['reply_approved'] ? $user->lang['REPLY_NEED_APPROVE'] : $user->lang['REPLY_SUBMIT_SUCCESS']) . '<br /><br />';
예제 #6
0
/**
* Handles updates to the cache
*
* @param string $mode
* @param int $user_id
*/
function handle_blog_cache($mode, $user_id = 0)
{
    global $cache;
    $temp = compact('mode', 'user_id');
    blog_plugins::plugin_do_arg('function_handle_blog_cache', $temp);
    if (!$mode && $user_id) {
        //$cache->destroy("_blog_settings_{$user_id}");
        //$cache->destroy("_blog_subscription_{$user_id}");
        //$cache->destroy("_blog_rating_{$user_id}");
    }
    switch ($mode) {
        /*		Not currently used...
        		case 'new_blog' :
        		case 'edit_blog' :
        		case 'approve_blog' :
        		case 'delete_blog' :
        		case 'undelete_blog' :
        		case 'report_blog' :
        		case 'new_reply' :
        		case 'approve_reply' :
        		case 'report_reply' :
        		case 'delete_reply' :
        		case 'undelete_reply' :
        */
        case 'plugins':
            $cache->destroy('_blog_plugins');
            break;
        case 'extensions':
            $cache->destroy('_blog_extensions');
            break;
        case 'categories':
            $cache->destroy('_blog_categories');
            break;
        default:
            blog_plugins::plugin_do_arg('function_handle_blog_cache_mode', $mode);
    }
}
예제 #7
0
 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 . "&amp;limit={$limit}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;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');
 }
예제 #8
0
 }
 // Handle the subscriptions
 add_blog_subscriptions($blog_id, 'subscription_');
 // Insert into the categories list
 if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) {
     $category_list = get_blog_categories('category_id');
     foreach ($category_ary as $i => $cat_id) {
         if (!isset($category_list[$cat_id])) {
             unset($category_ary[$i]);
         }
     }
     put_blogs_in_cats($blog_id, $category_ary, $auth->acl_get('u_blognoapprove') ? true : false);
 }
 // regenerate the urls to include the blog_id
 generate_blog_urls();
 blog_plugins::plugin_do_arg('blog_add_after_sql', $blog_id);
 handle_blog_cache('new_blog', $user->data['user_id']);
 if ($sql_data['blog_approved']) {
     // Update the blog_count for the user
     $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count + 1 WHERE user_id = ' . $user->data['user_id'];
     $db->sql_query($sql);
     set_config('num_blogs', ++$config['num_blogs'], true);
     handle_subscription('new_blog', censor_text($blog_subject), $user->data['user_id'], $blog_id);
 } else {
     inform_approve_report('blog_approve', $blog_id);
 }
 $message = !$sql_data['blog_approved'] ? $user->lang['BLOG_NEED_APPROVE'] : $user->lang['BLOG_SUBMIT_SUCCESS'];
 $message .= '<br /><br /><a href="' . $blog_urls['view_blog'] . '">' . $user->lang['VIEW_BLOG'] . '</a><br />';
 $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user_self'] . '">', '</a>');
 if (!$sql_data['blog_approved']) {
     blog_meta_refresh(3, $blog_urls['view_user_self']);