Example #1
0
function friends_function_generate_menu(&$arg)
{
    global $auth, $cache, $config, $db, $user, $template, $phpbb_root_path;
    global $user_id, $blog_template, $blog_images_path;
    $limit = 4;
    $template->assign_vars(array('ZEBRA_LIST_LIMIT' => $limit, 'IMG_PORTAL_MEMBER' => $blog_images_path . 'icon_friend.gif', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left'));
    if ($user_id == ANONYMOUS || $user->data['is_bot']) {
        return;
    }
    // Output listing of friends online
    $menu_friends_online = $menu_friends_offline = $user_friends = 0;
    $update_time = time() - intval($config['load_online_time']) * 60;
    // lets use the cache...as this query is quite intensive
    $cache_data = false;
    //$cache->get("_zebra{$user_id}");
    if ($cache_data === false) {
        $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . intval($user_id) . '
				AND z.friend = 1
				AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
        $result = $db->sql_query($sql);
        $rowset = $db->sql_fetchrowset($result);
        $db->sql_freeresult($result);
        //$cache->put("_zebra{$user_id}", $rowset, 60); // cache for 1 minute
        $cache_data = $rowset;
    }
    foreach ($cache_data as $row) {
        $which = $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'menu_friends_online' : 'menu_friends_offline';
        ${$which}++;
        $template->assign_block_vars("{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_BLOG' => blog_url($row['user_id']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'HIDE' => true));
    }
    $template->assign_vars(array('S_SHOW_NEXT_ONLINE' => $menu_friends_online > $limit ? true : false, 'S_SHOW_NEXT_OFFLINE' => $menu_friends_offline > $limit ? true : false, 'S_MENU_ZEBRA_ENABLED' => $menu_friends_online || $menu_friends_offline ? true : false));
    $arg['user_menu_extra'] .= blog_plugins::parse_template('blog/plugins/friends/friends_body.html');
}
Example #2
0
function archive_function_generate_menu(&$arg)
{
    global $auth, $db, $user, $template, $phpbb_root_path, $blog_images_path;
    if (!$arg['user_id']) {
        return;
    }
    $last_mon = 0;
    $archive_rows = array();
    $sql = 'SELECT blog_id, blog_time, blog_subject FROM ' . BLOGS_TABLE . '
		WHERE user_id = ' . intval($arg['user_id']) . ($auth->acl_get('m_blogapprove') ? '' : ' AND blog_approved = 1') . (!$auth->acl_gets('m_blogdelete', 'a_blogdelete') ? ' AND (blog_deleted = 0 OR blog_deleted = ' . $user->data['user_id'] . ')' : '') . build_permission_sql($user->data['user_id']) . '
			ORDER BY blog_time DESC';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $date = getdate($row['blog_time']);
        // If we are starting a new month
        if ($date['mon'] != $last_mon) {
            $archive_row = array('MONTH' => $user->lang['datetime'][$date['month']], 'YEAR' => $date['year'], 'monthrow' => array());
            $archive_rows[] = $archive_row;
        }
        $archive_row_month = array('TITLE' => censor_text($row['blog_subject']), 'U_VIEW' => blog_url($arg['user_id'], $row['blog_id'], false, array(), array('blog_subject' => $row['blog_subject'])), 'DATE' => $user->format_date($row['blog_time']));
        $archive_rows[sizeof($archive_rows) - 1]['monthrow'][] = $archive_row_month;
        // set the last month variable as the current month
        $last_mon = $date['mon'];
    }
    $db->sql_freeresult($result);
    foreach ($archive_rows as $row) {
        $template->assign_block_vars('archiverow', $row);
    }
    $template->assign_vars(array('S_ARCHIVES' => sizeof($archive_rows) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'IMG_PLUS' => $blog_images_path . 'plus.gif', 'IMG_MINUS' => $blog_images_path . 'minus.gif'));
    $arg['user_menu_extra'] .= blog_plugins::parse_template('blog/plugins/archive/archive_body.html');
    unset($template->_tpldata['archiverow']);
}
Example #3
0
function userlist_function_generate_menu(&$args)
{
    global $user;
    if (!$args['user_id']) {
        $args['links'][] = array('URL' => blog_url(false, false, false, array('page' => 'userlist')), 'NAME' => $user->lang['USERLIST'], 'IMG' => 'icon_mini_register.gif', 'CLASS' => 'icon-register');
    }
}
Example #4
0
        $last_blogs[$row['blog_id']] = $row;
    }
    $db->sql_freeresult($result);
}
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_blog_pagination($blog_urls['start_zero'], $total, $limit, $start, false);
generate_blog_breadcrumbs($user->lang['USERLIST']);
// Generate the left menu
generate_menu();
page_header($user->lang['BLOG'] . ' ' . $user->lang['USERLIST']);
// Output some data
$template->assign_vars(array('FOLDER_IMG' => $user->img('forum_read', ''), 'FORUM_FOLDER_IMG_SRC' => $user->img('forum_read', '', false, '', 'src'), 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total, $limit, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $total), 'S_SORT' => true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
unset($pagination);
$i = -1;
foreach ($users as $row) {
    $i++;
    if ($i < $start) {
        continue;
    } else {
        if ($i >= $start + $limit) {
            break;
        }
    }
    $user_id = $row['user_id'];
    $last_blog = $last_blogs[$row['blog_id']];
    $blog_text = trim_text($last_blog['blog_text'], $last_blog['bbcode_uid'], $config['user_blog_text_limit'], $last_blog['bbcode_bitfield'], $last_blog['enable_bbcode']);
    $bbcode_options = ($last_blog['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($last_blog['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($last_blog['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
    $blog_text = generate_text_for_display($blog_text, $last_blog['bbcode_uid'], $last_blog['bbcode_bitfield'], $bbcode_options);
    $template->assign_block_vars('userrow', array('BLOG_COUNT' => $row['blog_count'], 'BLOG_TITLE' => $row['title'] ? censor_text($row['title']) : sprintf($user->lang['USERNAMES_BLOGS'], $row['username']), 'USERNAME' => get_username_string('full', $user_id, $row['username'], $row['user_colour']), 'LAST_BLOG' => $blog_text, 'LAST_BLOG_SUBJECT' => censor_text($last_blog['blog_subject']), 'LAST_BLOG_TIME' => $user->format_date($last_blog['blog_time']), 'U_VIEW_BLOG' => blog_url($user_id), 'U_VIEW_LAST_BLOG' => blog_url($user_id, $last_blog['blog_id'])));
}
$template->set_filenames(array('body' => 'blog/userlist.html'));
Example #5
0
			</div>
		</div>
		<div class="clear"></div>
		<?php 
    }
    ?>
		
		<div class="view_archives">
			<?php 
    if (!empty($pagination)) {
        echo $pagination;
        ?>
  &nbsp;<?php 
    }
    ?>
			Looking for older posts? <a href="<?php 
    echo blog_url('archives');
    ?>
">View our Archives</a>
		</div>
		
	<?php 
} else {
    ?>
	<div class="no_posts">
		<p>There are no posts available.</p>
	</div>
	<?php 
}
?>
</div>
Example #6
0
        }
        $blog_data->get_user_data(false, true);
        update_edit_delete();
        foreach ($ids as $id) {
            if (isset($id['reply_id'])) {
                if (!$author || $uid == blog_data::$reply[$id['reply_id']]['user_id']) {
                    $template->assign_block_vars('searchrow', $blog_data->handle_reply_data($id['reply_id']) + $blog_data->handle_user_data(blog_data::$reply[$id['reply_id']]['user_id']));
                } else {
                    // they are selecting from a specific author and this is from a different author
                    $matches--;
                }
            } else {
                if (isset(blog_data::$blog[$id['blog_id']]) && (!$author || $uid == blog_data::$blog[$id['blog_id']]['user_id'])) {
                    $template->assign_block_vars('searchrow', $blog_data->handle_blog_data($id['blog_id']) + $blog_data->handle_user_data(blog_data::$blog[$id['blog_id']]['user_id']));
                } else {
                    // they don't have permission to view this blog, or they are selecting from a specific author and this is from a different author
                    $matches--;
                }
            }
        }
    } else {
        $matches = 0;
    }
    $pagination = generate_blog_pagination(blog_url(false, false, false, array('page' => 'search', 'author' => $author, 'keywords' => $keywords, 'terms' => $terms, 'sf' => $sf, 'start' => '*start*', 'limit' => $limit), array(), true), $matches, $limit, $start, false);
    $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($matches, $limit, $start), 'TOTAL_POSTS' => $matches == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $matches), 'SEARCH_MATCHES' => $matches == 1 ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $matches) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $matches), 'U_SEARCH_WORDS' => $search_url, 'SEARCH_WORDS' => $author . ' &bull; ' . $keywords));
    $template->set_filenames(array('body' => 'blog/search_results.html'));
} else {
    $template->assign_vars(array('U_BLOG_SEARCH' => blog_url(false, false, false, array('page' => 'search'), array(), true)));
    $template->set_filenames(array('body' => 'blog/search_body.html'));
}
blog_plugins::plugin_do('search_end');
Example #7
0
function _oauth(&$vars)
{
    // top stream, re-connect to subtwitter-db
    extract($vars);
    global $prefix;
    $Blog =& $db->model('Blog');
    if (empty($db->prefix)) {
        if (isset($_REQUEST['oauth_token'])) {
            $tabresult = $db->get_result("SHOW tables");
            $tables = array();
            $tablist = array();
            for ($i = 0; $tables[$i] = mysql_fetch_assoc($tabresult); $i++) {
                foreach ($tables[$i] as $k => $v) {
                    $tablist[] = $v;
                }
            }
            while ($b = $Blog->MoveNext()) {
                if (!empty($b->prefix) && in_array($b->prefix . "_db_sessions", $tablist)) {
                    $sql = "SELECT data FROM " . $b->prefix . "_db_sessions WHERE data LIKE '%" . $db->escape_string($_REQUEST['oauth_token']) . "%'";
                    $result = $db->get_result($sql);
                    if ($db->num_rows($result) == 1) {
                        // XXX subdomain upgrade
                        $redir = blog_url($b->nickname, true);
                        $redir .= 'oauth_login';
                        $redir .= "&oauth_token=" . $_REQUEST['oauth_token'];
                        $content = '<script type="text/javascript">' . "\n";
                        $content .= '  // <![CDATA[' . "\n";
                        $content .= "  location.replace('" . $redir . "');" . "\n";
                        $content .= '  // ]]>' . "\n";
                        $content .= '</script>' . "\n";
                        return vars(array(&$content), get_defined_vars());
                    }
                }
            }
        }
    }
    // http://abrah.am
    lib_include('twitteroauth');
    /* Sessions are used to keep track of tokens while user authenticates with twitter */
    /* Consumer key from twitter */
    $consumer_key = environment('twitterKey');
    /* Consumer Secret from twitter */
    $consumer_secret = environment('twitterSecret');
    /* Set up placeholder */
    $content = NULL;
    /* Set state if previous session */
    $state = $_SESSION['oauth_state'];
    /* Checks if oauth_token is set from returning from twitter */
    $session_token = $_SESSION['oauth_request_token'];
    /* Checks if oauth_token is set from returning from twitter */
    $oauth_token = $_REQUEST['oauth_token'];
    /* Set section var */
    $section = $_REQUEST['section'];
    /* If oauth_token is missing get it */
    if ($_REQUEST['oauth_token'] != NULL && $_SESSION['oauth_state'] === 'start') {
        /*{{{*/
        $_SESSION['oauth_state'] = $state = 'returned';
    }
    /*}}}*/
    /*
     * 'default': Get a request token from twitter for new user
     * 'returned': The user has authorize the app on twitter
     */
    switch ($state) {
        /*{{{*/
        default:
            /* Create TwitterOAuth object with app key/secret */
            $to = new TwitterOAuth($consumer_key, $consumer_secret);
            /* Request tokens from twitter */
            $tok = $to->getRequestToken();
            /* Save tokens for later */
            $Blog =& $db->model('Blog');
            if (!empty($db->prefix) && isset($_REQUEST['oauth_token'])) {
                $tabresult = $db->get_result("SHOW tables");
                $tables = array();
                $tablist = array();
                for ($i = 0; $tables[$i] = mysql_fetch_assoc($tabresult); $i++) {
                    foreach ($tables[$i] as $k => $v) {
                        $tablist[] = $v;
                    }
                }
                while ($b = $Blog->MoveNext()) {
                    if (!empty($b->prefix) && in_array($b->prefix . "_db_sessions", $tablist)) {
                        $sql = "SELECT id FROM " . $b->prefix . "_db_sessions WHERE data LIKE '%" . $db->escape_string($_REQUEST['oauth_token']) . "%'";
                        $result = $db->get_result($sql);
                        if ($db->num_rows($result) == 1) {
                            $sess = $db->result_value($result, 0, "id");
                            $del = $db->get_result("DELETE FROM " . $b->prefix . "_db_sessions WHERE id = '{$sess}'");
                        }
                    }
                }
            }
            $_SESSION['oauth_request_token'] = $token = $tok['oauth_token'];
            $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
            $_SESSION['oauth_state'] = "start";
            if (isset($_GET['forward']) && !empty($_SERVER['HTTP_REFERER'])) {
                $_SESSION['oauth_twitter'] = $_SERVER['HTTP_REFERER'];
            } else {
                $_SESSION['oauth_twitter'] = $request->base;
            }
            /* Build the authorization URL */
            $auth_url = $to->getAuthorizeURL($token);
            if (empty($auth_url)) {
                $content = 'Request token not found, <a href="' . $request->url_for('oauth_login') . '">click here to try again...</a>';
            } else {
                $content = '<script type="text/javascript">' . "\n";
                $content .= '  // <![CDATA[' . "\n";
                $content .= "  location.replace('" . $auth_url . "');" . "\n";
                $content .= '  // ]]>' . "\n";
                $content .= '</script>' . "\n";
            }
            break;
        case 'returned':
            if (isset($_SESSION['oauth_twitter'])) {
                $redirect_to = $_SESSION['oauth_twitter'];
            } else {
                $redirect_to = $request->base;
            }
            /* If the access tokens are already set skip to the API call */
            if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) {
                /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */
                $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']);
                /* Request access tokens from twitter */
                $tok = $to->getAccessToken();
                /* Save the access tokens. Normally these would be saved in a database for future use. */
                $_SESSION['oauth_access_token'] = $tok['oauth_token'];
                $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret'];
                if (!($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL)) {
                    unset($_SESSION['oauth_request_token']);
                    unset($_SESSION['oauth_request_token_secret']);
                }
            }
            $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
            $session_oauth_token = $_SESSION['oauth_access_token'];
            $session_oauth_secret = $_SESSION['oauth_access_token_secret'];
            $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET');
            if (!class_exists('Services_JSON')) {
                lib_include('json');
            }
            $json = new Services_JSON();
            $user = $json->decode($content);
            if (empty($user)) {
                trigger_error('The server said: ' . $content, E_USER_ERROR);
            }
            if (empty($prefix) && in_array('invites', $db->tables)) {
                $Invite =& $db->model('Invite');
                $result = $Invite->find_by('nickname', $user->screen_name);
                if (!$result) {
                    trigger_error('Sorry, you have not been invited yet ' . environment('email_from'), E_USER_ERROR);
                }
            }
            $Identity =& $db->model('Identity');
            $Person =& $db->model('Person');
            $TwitterUser =& $db->model('TwitterUser');
            $twuser = $TwitterUser->find_by('twitter_id', $user->id);
            // a) twitter user exists, does not have a profile_id
            // b) twitter user exists, HAS a profile_id
            // c) twitter user does not exist
            if ($twuser) {
                if (!$twuser->profile_id) {
                    // a
                    $i = make_identity(array($user->screen_name, $user->profile_image_url, $user->name, $user->description, $user->url, $user->location));
                    if (!$i) {
                        trigger_error('sorry I was unable to create an identity', E_USER_ERROR);
                    }
                    $twuser->set_value('profile_id', $i->id);
                    $twuser->set_value('oauth_key', $session_oauth_token);
                    $twuser->set_value('oauth_secret', $session_oauth_secret);
                    $twuser->save_changes();
                    if (!$twuser) {
                        trigger_error('sorry I was unable to create a twitter user', E_USER_ERROR);
                    }
                } else {
                    // b
                    $i = $Identity->find($twuser->profile_id);
                    if (!$i) {
                        trigger_error('sorry I was unable to find the identity', E_USER_ERROR);
                    }
                    if ($session_oauth_token != $twuser->oauth_key) {
                        $twuser->set_value('oauth_key', $session_oauth_token);
                        $twuser->set_value('oauth_secret', $session_oauth_secret);
                        $twuser->save_changes();
                    }
                }
            } else {
                // c
                $i = make_identity(array($user->screen_name, $user->profile_image_url, $user->name, $user->description, $user->url, $user->location));
                if (!$i) {
                    trigger_error('sorry I was unable to create an identity', E_USER_ERROR);
                }
                $twuser = make_twuser($user, $i->id, $session_oauth_token, $session_oauth_secret);
                if (!$twuser) {
                    trigger_error('sorry I was unable to create a twitter user', E_USER_ERROR);
                }
            }
            $_SESSION['oauth_person_id'] = $i->person_id;
            if (empty($redirect_to)) {
                $content = "<p>there was an error in the oauth routine, sorry</p>";
            } else {
                $content = '<script type="text/javascript">' . "\n";
                $content .= '  // <![CDATA[' . "\n";
                $content .= "  location.replace('" . $redirect_to . "');" . "\n";
                $content .= '  // ]]>' . "\n";
                $content .= '</script>' . "\n";
            }
            break;
    }
    /*}}}*/
    return vars(array(&$content), get_defined_vars());
}
Example #8
0
$total_replies = $blog_data->get_reply_data('reply_count', $blog_id, array('sort_days' => $sort_days));
// Get the reply data if we need to
if ($total_replies > 0) {
    $reply_ids = $blog_data->get_reply_data('blog', $blog_id, array('start' => $start, 'limit' => $limit, 'order_dir' => $order_dir, 'sort_days' => $sort_days));
    $blog_data->get_user_data(false, true);
    update_edit_delete('reply');
} else {
    $reply_ids = false;
}
// Get the Poll Data
$blog_data->get_polls($blog_id);
// Get the Attachment Data
get_attachment_data($blog_id, $reply_ids);
blog_plugins::plugin_do('view_blog_start');
// Output some data
$template->assign_vars(array('META' => '<link rel="canonical" href="' . blog_url($user_id, $blog_id, false, $start > 0 ? array('start' => $start) : array()) . '" />', 'BLOG_CSS' => isset($user_settings[$user_id]['blog_css']) ? $user_settings[$user_id]['blog_css'] : '', 'U_PRINT_TOPIC' => !$user->data['is_bot'] ? $blog_urls['self_print'] : '', 'U_VIEW' => $blog_urls['self'], 'S_CATEGORY_MODE' => $category_id ? true : false, 'S_SINGLE' => true, 'U_QUICK_REPLY' => blog_url($user_id, $blog_id, false, array('page' => 'reply', 'mode' => 'add')), 'S_QUICK_REPLY' => $user->data['is_registered'] && $config['user_blog_quick_reply'] ? true : false));
// Quick Reply
add_form_key('postform');
// Parse the blog data and output it to the template
$template->assign_block_vars('blogrow', array_merge($blog_data->handle_blog_data($blog_id), $blog_data->handle_user_data($user_id)));
blog_plugins::plugin_do('view_blog_after_blogrow');
// to update the read count, we are only doing this if the user is not the owner, and the user doesn't view the shortened version, and we are not viewing the deleted blogs page
if ($user->data['user_id'] != $user_id) {
    $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_read_count = blog_read_count + 1 WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
}
if ($total_replies > 0 || $sort_days != 0) {
    // for sorting and pagination
    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_blog_pagination($blog_urls['start_zero'], $total_replies, $limit, $start, false);
    $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_replies, $limit, $start), 'TOTAL_POSTS' => $total_replies == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $total_replies), 'S_REPLIES' => true, 'S_SORT_REPLY' => true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
Example #9
0
/**
 * Displays the url of the current post.
 *
 *
 * @since 0.1
 */
function post_url()
{
    if (is_post()) {
        echo blog_url(false) . 'archiv/' . basename($_SERVER['REQUEST_URI']) . '/';
    }
}
Example #10
0
function antispam_reply_edit_after_sql($reply_id)
{
    global $config, $user;
    if (!class_exists('antispam')) {
        return;
    }
    if ($user->data['user_flagged']) {
        global $blog_id;
        antispam::add_log('LOG_EDITED_BLOG_REPLY', blog_url($user->data['user_id'], $blog_id, $reply_id), 'flag');
    }
}
/**
* Handle the categories
*
* @param int $parent_id If this is set to something other than 0 it will only list categories under the category_id given
* @param string $block Set the name of the block to output it to.
* @param bool $ignore_subcats True to ignore subcategories, false to display them.
* @param array $category_list If you want to send the already gotten category list...
*/
function handle_categories($parent_id = 0, $block = 'category_row', $ignore_subcats = false, $category_list = false)
{
    global $config, $template, $user;
    if (!is_array($category_list)) {
        $category_list = get_blog_categories('left_id');
    }
    blog_plugins::plugin_do('function_handle_categories');
    foreach ($category_list as $left_id => $row) {
        if ($parent_id == $row['category_id'] && !$ignore_subcats) {
            $template->assign_vars(array('U_CURRENT_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'CURRENT_CATEGORY' => $row['category_name'], 'CATEGORY_RULES' => generate_text_for_display($row['rules'], $row['rules_uid'], $row['rules_bitfield'], $row['rules_options'])));
        }
        if ($parent_id == $row['parent_id']) {
            $template->assign_block_vars($block, array('CATEGORY_NAME' => $row['category_name'], 'CATEGORY_DESCRIPTION' => generate_text_for_display($row['category_description'], $row['category_description_uid'], $row['category_description_bitfield'], $row['category_description_options']), 'BLOGS' => $row['blog_count'], 'U_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'S_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats, 'L_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 3 ? $user->lang['SUBCATEGORIES'] : $user->lang['SUBCATEGORY']));
            // If not, then there are subcategories
            if ($row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats) {
                handle_categories($row['category_id'], 'category_row.subcategory', true, $category_list);
            }
        }
    }
}
Example #12
0
        // Get the random blog(s) and the recent blogs
        $random_blog_ids = $blog_data->get_blog_data('random', 0, array('limit' => 1, 'category_id' => $category_id));
        $recent_blog_ids = $blog_data->get_blog_data('recent', 0, array('limit' => $limit, 'category_id' => $category_id));
        $recent_reply_ids = $blog_data->get_reply_data('recent', 0, array('limit' => $limit, 'category_id' => $category_id));
        $blog_data->get_user_data(false, true);
        update_edit_delete();
        // Output the random blog(s)
        if ($random_blog_ids !== false) {
            $template->assign_vars(array('S_RANDOM_BLOG' => true));
            // I've decided to use a foreach to display the random blogs so it is easier to change the limit if the board owner would like...
            foreach ($random_blog_ids as $id) {
                $template->assign_block_vars('random', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_user_text_limit'])));
            }
        }
        // Output the recent blogs
        $template->assign_block_vars('column', array('SECTION_WIDTH' => '50', 'U_FEED' => $config['user_blog_enable_feeds'] ? blog_url(false, false, false, array('mode' => 'recent_blogs', 'feed' => 'explain')) : '', 'U_VIEW' => blog_url(false, false, false, array('mode' => 'recent_blogs')), 'TITLE' => $user->lang['RECENT_BLOGS'], 'L_NO_MSG' => $user->lang['NO_BLOGS']));
        if ($recent_blog_ids !== false) {
            foreach ($recent_blog_ids as $id) {
                $template->assign_block_vars('column.row', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_text_limit'])));
            }
        }
        // Output the recent comments
        $template->assign_block_vars('column', array('SECTION_WIDTH' => '50', 'U_FEED' => $config['user_blog_enable_feeds'] ? blog_url(false, false, false, array('mode' => 'recent_comments', 'feed' => 'explain')) : '', 'U_VIEW' => blog_url(false, false, false, array('mode' => 'recent_comments')), 'TITLE' => $user->lang['RECENT_COMMENTS'], 'L_NO_MSG' => $user->lang['NO_REPLIES']));
        if ($recent_reply_ids !== false) {
            foreach ($recent_reply_ids as $id) {
                $template->assign_block_vars('column.row', array_merge($blog_data->handle_user_data(blog_data::$reply[$id]['user_id']), $blog_data->handle_reply_data($id, $config['user_blog_text_limit'])));
            }
        }
        $template->set_filenames(array('body' => 'blog/view_blog_main.html'));
}
blog_plugins::plugin_do('view_main_end');
Example #13
0
update_edit_delete('blog');
generate_blog_breadcrumbs();
if (!$feed) {
    // Generate the left menu
    generate_menu($user_id);
    if ($mode == 'deleted') {
        page_header(sprintf($user->lang['USERNAMES_DELETED_BLOGS'], blog_data::$user[$user_id]['username']));
    } else {
        if ($user->data['username'] == blog_data::$user[$user_id]['username']) {
            page_header($user->lang['MY_BLOG']);
        } else {
            page_header(sprintf($user->lang['USERNAMES_BLOGS'], blog_data::$user[$user_id]['username']));
        }
    }
    // Output some data
    $template->assign_vars(array('META' => '<link rel="canonical" href="' . blog_url($user_id, false, false, $start > 0 ? array('start' => $start) : array()) . '" />', 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_blogs, $limit, $start), 'TOTAL_POSTS' => $total_blogs == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $total_blogs), 'U_BLOG_FEED' => $config['user_blog_enable_feeds'] ? blog_url($user_id, false, false, array('feed' => 'explain')) : '', 'U_PRINT_TOPIC' => !$user->data['is_bot'] ? $blog_urls['self_print'] : '', 'U_VIEW' => $blog_urls['self'], 'S_SORT' => true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_VIEW_REPLY_COUNT' => true, 'L_NO_DELETED_BLOGS' => $sort_days == 0 ? $user->lang['NO_DELETED_BLOGS'] : sprintf($user->lang['NO_DELETED_BLOGS_SORT_DAYS'], $limit_days[$sort_days]), 'L_NO_BLOGS_USER' => $sort_days == 0 ? $user->lang['NO_BLOGS_USER'] : sprintf($user->lang['NO_BLOGS_USER_SORT_DAYS'], $limit_days[$sort_days]), 'BLOG_CSS' => isset($user_settings[$user_id]['blog_css']) ? $user_settings[$user_id]['blog_css'] : ''));
    unset($pagination);
    // parse and output the blogs
    if ($blog_ids !== false) {
        // Get the Attachment Data
        get_attachment_data($blog_ids, false);
        // read blogs, for updating the read count
        $read_blogs = array();
        foreach ($blog_ids as $id) {
            $blogrow = array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_user_text_limit']));
            $template->assign_block_vars('blogrow', $blogrow);
            if (!$blogrow['S_SHORTENED']) {
                // for updating the read count later
                array_push($read_blogs, $id);
            }
        }
Example #14
0
 /**
  * Handle reply data
  *
  * To handle the raw data gotten from the database
  *
  * @param int $id The id of the reply we want to handle
  * @param int|bool $trim_text If we want to trim the text or not(if true we will trim with the setting in $config['user_blog_user_text_limit'], else if it is an integer we will trim the text to that length)
  */
 public function handle_reply_data($id, $trim_text = false)
 {
     global $user, $phpbb_root_path, $config, $phpEx, $auth, $highlight_match;
     global $blog_attachment, $category_id;
     if (!isset(self::$reply[$id])) {
         return array();
     }
     $reply =& self::$reply[$id];
     $blog_id = $reply['blog_id'];
     $user_id = $reply['user_id'];
     blog_plugins::plugin_do('reply_handle_data_start');
     if ($trim_text !== false) {
         $reply_text = trim_text_length(false, $id, $trim_text === true ? $config['user_blog_user_text_limit'] : intval($trim_text));
         $shortened = $reply_text === false ? false : true;
         $reply_text = $reply_text === false ? $reply['reply_text'] : $reply_text;
     } else {
         $reply_text = $reply['reply_text'];
         $shortened = false;
     }
     // censor the text of the subject
     $reply_subject = censor_text($reply['reply_subject']);
     // Parse BBCode and prepare the message for viewing
     $bbcode_options = ($reply['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($reply['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($reply['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
     $reply_text = generate_text_for_display($reply_text, $reply['bbcode_uid'], $reply['bbcode_bitfield'], $bbcode_options);
     // For Highlighting
     if ($highlight_match) {
         $reply_subject = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $reply_subject);
         $reply_text = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $reply_text);
     }
     // Attachments
     $update_count = $attachments = array();
     parse_attachments_for_view($reply_text, $reply['attachment_data'], $update_count);
     foreach ($reply['attachment_data'] as $i => $attachment) {
         $attachments[]['DISPLAY_ATTACHMENT'] = $attachment;
     }
     $replyrow = array('ID' => $id, 'TITLE' => $reply_subject, 'DATE' => $user->format_date($reply['reply_time']), 'MESSAGE' => $reply_text, 'EDITED_MESSAGE' => $reply['edited_message'], 'EDIT_REASON' => $reply['edit_reason'], 'DELETED_MESSAGE' => $reply['deleted_message'], 'EXTRA' => '', 'U_VIEW' => blog_url($user_id, $blog_id, $id), 'U_VIEW_PERMANENT' => blog_url($user_id, $blog_id, $id, array(), array(), true), 'U_APPROVE' => $reply['reply_approved'] == 0 ? blog_url($user_id, $blog_id, $id, array('page' => 'reply', 'mode' => 'approve')) : '', 'U_DELETE' => check_blog_permissions('reply', 'delete', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'delete')) : '', 'U_EDIT' => check_blog_permissions('reply', 'edit', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'edit')) : '', 'U_QUOTE' => check_blog_permissions('reply', 'quote', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'quote')) : '', 'U_REPLY' => check_blog_permissions('reply', 'add', true, $blog_id) ? blog_url(false, $blog_id, false, array('page' => 'reply', 'mode' => 'add')) : '', 'U_REPORT' => check_blog_permissions('reply', 'report', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'report')) : '', 'U_WARN' => $auth->acl_get('m_warn') && $reply['user_id'] != $user->data['user_id'] && $reply['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=warn&amp;mode=warn_user&amp;u={$user_id}") : '', 'S_DELETED' => $reply['reply_deleted'] != 0 ? true : false, 'S_UNAPPROVED' => $reply['reply_approved'] == 0 ? true : false, 'S_REPORTED' => $reply['reply_reported'] && $auth->acl_get('m_blogreplyreport') ? true : false, 'S_DISPLAY_NOTICE' => !$auth->acl_get('u_download') && $reply['reply_attachment'] && sizeof($reply['attachment_data']) ? true : false, 'S_HAS_ATTACHMENTS' => $reply['reply_attachment'] ? true : false, 'attachment' => $attachments);
     blog_plugins::plugin_do_ref('reply_handle_data_end', $replyrow);
     return $replyrow;
 }
function bjaq_post()
{
    $result = handle_bjaq_post();
    if ($result == "success") {
        redirect(blog_url("?bjaq_action=bjaq_success"));
    }
    redirect_error($result);
}
/**
* handles sending subscription notices for blogs or replies
*
* Sends a PM or Email to each user in the subscription list, depending on what they want
*
* @param string $mode The mode (new_blog, or new_reply)
* @param string $post_subject The subject of the post made
* @param int|bool $uid The user_id of the user who made the new blog (if there is one).  If this is left as 0 it will grab the global value of $user_id.
* @param int|bool $bid The blog_id of the blog.  If this is left as 0 it will grab the global value of $blog_id.
* @param int|bool $rid The reply_id of the new reply (if there is one).  If this is left as 0 it will grab the global value of $reply_id.
*/
function handle_subscription($mode, $post_subject, $uid = 0, $bid = 0, $rid = 0)
{
    global $db, $user, $phpbb_root_path, $phpEx, $config;
    global $user_id, $blog_id, $reply_id;
    global $blog_data, $blog_urls;
    // if $uid, $bid, or $rid are not set, use the globals
    $uid = $uid != 0 ? $uid : $user_id;
    $bid = $bid != 0 ? $bid : $blog_id;
    $rid = $rid != 0 ? $rid : $reply_id;
    // make sure that subscriptions are enabled and that a blog_id is sent
    if (!$config['user_blog_subscription_enabled'] || $bid == 0) {
        return;
    }
    if (!isset($user->lang['BLOG_SUBSCRIPTION_NOTICE'])) {
        $user->add_lang('mods/blog/posting');
    }
    // This will hold all the send info, all ones that will be sent via PM would be $send[1], or Email would be $send[2], next would be $send[4], etc.
    $send = array();
    $subscribe_modes = get_blog_subscription_types();
    $temp = compact('mode', 'post_subject', 'uid', 'bid', 'rid', 'send');
    blog_plugins::plugin_do_ref('function_handle_subscription', $temp);
    extract($temp);
    // Fix the URLs...
    if (isset($config['user_blog_seo']) && $config['user_blog_seo']) {
        $view_url = $rid ? blog_url($uid, $bid, $rid) : blog_url($uid, $bid);
        $unsubscribe_url = $rid ? blog_url($uid, $bid, false, array('page' => 'unsubscribe')) : blog_url($uid, false, false, array('page' => 'unsubscribe'));
    } else {
        $view_url = redirect($rid ? blog_url($uid, $bid, $rid) : blog_url($uid, $bid), true);
        $unsubscribe_url = redirect($rid ? blog_url($uid, $bid, false, array('page' => 'unsubscribe')) : blog_url($uid, false, false, array('page' => 'unsubscribe')), true);
    }
    if ($mode == 'new_reply' && $rid != 0) {
        $sql = 'SELECT * FROM ' . BLOGS_SUBSCRIPTION_TABLE . '
			WHERE blog_id = ' . intval($bid) . '
			AND sub_user_id != ' . $user->data['user_id'];
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if (!array_key_exists($row['sub_type'], $send)) {
                $send[$row['sub_type']] = array($row['sub_user_id']);
            } else {
                $send[$row['sub_type']][] = $row['sub_user_id'];
            }
        }
        $db->sql_freeresult($result);
        $message = sprintf($user->lang['BLOG_SUBSCRIPTION_NOTICE'], $view_url, $user->data['username'], $unsubscribe_url);
    } else {
        if ($mode == 'new_blog' && $uid != 0) {
            $sql = 'SELECT * FROM ' . BLOGS_SUBSCRIPTION_TABLE . '
			WHERE user_id = ' . intval($uid) . '
			AND sub_user_id != ' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                if (!array_key_exists($row['sub_type'], $send)) {
                    $send[$row['sub_type']] = array($row['sub_user_id']);
                } else {
                    $send[$row['sub_type']][] = $row['sub_user_id'];
                }
            }
            $db->sql_freeresult($result);
            $message = sprintf($user->lang['USER_SUBSCRIPTION_NOTICE'], $user->data['username'], $view_url, $unsubscribe_url);
        }
    }
    $blog_data->get_user_data($config['user_blog_message_from']);
    // Send the PM
    if (isset($send[1]) && sizeof($send[1])) {
        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);
        // setup out to address list
        $address_list = array();
        foreach ($send[1] as $id) {
            $address_list[$id] = 'to';
        }
        $pm_data = array('from_user_id' => $config['user_blog_message_from'], 'from_username' => blog_data::$user[$config['user_blog_message_from']]['username'], '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' => true, 'message' => $message_parser->message, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid);
        submit_pm('post', $user->lang['SUBSCRIPTION_NOTICE'], $pm_data, false);
        unset($message_parser, $address_list, $pm_data);
    }
    // Send the email
    if (isset($send[2]) && sizeof($send[2]) && $config['email_enable']) {
        if (!class_exists('messenger')) {
            include "{$phpbb_root_path}includes/functions_messenger.{$phpEx}";
        }
        $messenger = new messenger(false);
        $blog_data->get_user_data($send[2]);
        $reply_url_var = $rid ? "r={$rid}#r{$rid}" : '';
        foreach ($send[2] as $uid) {
            $messenger->template('blog_notify', $config['default_lang']);
            $messenger->replyto($config['board_contact']);
            $messenger->to(blog_data::$user[$uid]['user_email'], blog_data::$user[$uid]['username']);
            $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
            $messenger->headers('X-AntiAbuse: User_id - ' . blog_data::$user[$config['user_blog_message_from']]['user_id']);
            $messenger->headers('X-AntiAbuse: Username - ' . blog_data::$user[$config['user_blog_message_from']]['username']);
            $messenger->headers('X-AntiAbuse: User IP - ' . blog_data::$user[$config['user_blog_message_from']]['user_ip']);
            $messenger->assign_vars(array('BOARD_CONTACT' => $config['board_contact'], 'SUBJECT' => $user->lang['SUBSCRIPTION_NOTICE'], 'TO_USERNAME' => blog_data::$user[$uid]['username'], 'TYPE' => $rid ? $user->lang['REPLY'] : $user->lang['BLOG'], 'NAME' => $post_subject, 'BY_USERNAME' => $user->data['username'], 'U_VIEW' => $view_url, 'U_UNSUBSCRIBE' => $unsubscribe_url));
            $messenger->send(NOTIFY_EMAIL);
        }
        // save the queue if we must
        $messenger->save_queue();
        unset($messenger);
    }
    blog_plugins::plugin_do('function_handle_subscription_end');
}
Example #17
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');
 }
Example #18
0
<span class="current">Projekte</span><?php 
} else {
    ?>
<a href="<?php 
    blog_url();
    ?>
projekte/" title="">Projekte</a><?php 
}
?>
</li>
          <li><?php 
if (is_page(7)) {
    ?>
<span class="current">Logs</span><?php 
} else {
    ?>
<a href="<?php 
    blog_url();
    ?>
logs/" title="">Logs</a><?php 
}
?>
</li>
          <!--li>< ?php if (is_page(8)) { ?><span class="current">To-dos</span>< ?php } else { ?><a href="< ?php blog_url(); ?>to-dos/" title="">To-dos</a>< ?php } ?></li-->
        </ul></li>
        <li><span class="version">0.1</span></li>
      </ul>
    </nav>
  </div>

  <div class="flex-item">
Example #19
0
/**
* generates the basic URL's used by this mod
*
* It is setup this way to allow easy changing of the url of some common pages
*/
function generate_blog_urls()
{
    global $config, $user, $blog_urls;
    global $blog_id, $reply_id, $user_id;
    $self_data = $_GET;
    $blog_urls = array('add_blog' => blog_url(false, false, false, array('page' => 'blog', 'mode' => 'add')), 'add_reply' => $blog_id ? blog_url($user_id, $blog_id, false, array('page' => 'reply', 'mode' => 'add')) : false, 'main' => blog_url(false, false, false, array('c' => '*skip*')), 'self' => blog_url(false, false, false, $self_data), 'self_minus_print' => blog_url(false, false, false, array_merge($self_data, array('view' => '*skip*'))), 'self_minus_start' => blog_url(false, false, false, array_merge($self_data, array('start' => '*skip*'))), 'self_print' => blog_url(false, false, false, array_merge($self_data, array('view' => 'print'))), 'start_zero' => blog_url(false, false, false, array_merge($self_data, array('start' => '*start*'))), 'subscribe' => ($blog_id != 0 || $user_id != 0) && $user->data['user_id'] != ANONYMOUS && $config['user_blog_subscription_enabled'] ? blog_url($user_id, $blog_id, false, array('page' => 'subscribe')) : '', 'unsubscribe' => ($blog_id != 0 || $user_id != 0) && $user->data['user_id'] != ANONYMOUS && $config['user_blog_subscription_enabled'] ? blog_url($user_id, $blog_id, false, array('page' => 'unsubscribe')) : '', 'view_blog' => $blog_id ? blog_url($user_id, $blog_id) : false, 'viewpoll' => $blog_id ? blog_url($user_id, $blog_id, false, array('view' => 'viewpoll')) : false, 'view_reply' => $reply_id ? blog_url($user_id, $blog_id, $reply_id) : false, 'view_user' => $user_id ? blog_url($user_id) : false, 'view_user_deleted' => $user_id ? blog_url($user_id, false, false, array('mode' => 'deleted')) : false, 'view_user_self' => blog_url($user->data['user_id']), 'vote' => $blog_id ? blog_url($user_id, $blog_id, false, array('page' => 'vote')) : false);
    blog_plugins::plugin_do('function_generate_blog_urls');
}
/**
* General attachment parsing
*
* @param string &$message The post/private message
* @param array &$attachments The attachments to parse for (inline) display. The attachments array will hold templated data after parsing.
* @param array &$update_count The attachment counts to be updated - will be filled
* @param bool $preview If set to true the attachments are parsed for preview. Within preview mode the comments are fetched from the given $attachments array and not fetched from the database.
*/
function parse_attachments_for_view(&$message, &$attachments, &$update_count, $preview = false)
{
    global $template, $user, $config, $phpbb_root_path, $auth;
    if (!$config['user_blog_enable_attachments'] || !sizeof($attachments) || !$auth->acl_get('u_download')) {
        return;
    }
    $compiled_attachments = array();
    $temp = compact('message', 'attachments', 'update_count', 'preview', 'compiled_attachments');
    blog_plugins::plugin_do_ref('function_parse_attachments_for_view', $temp);
    extract($temp);
    if (!isset($template->filename['attachment_tpl'])) {
        $template->set_filenames(array('attachment_tpl' => 'attachment.html'));
    }
    $extensions = obtain_blog_attach_extensions();
    // Look for missing attachment information...
    $attach_ids = array();
    foreach ($attachments as $pos => $attachment) {
        // If is_orphan is set, we need to retrieve the attachments again...
        if (!isset($attachment['extension']) && !isset($attachment['physical_filename'])) {
            $attach_ids[(int) $attachment['attach_id']] = $pos;
        }
    }
    // Grab attachments (security precaution)
    if (sizeof($attach_ids)) {
        global $db;
        $new_attachment_data = array();
        $sql = 'SELECT *
			FROM ' . BLOGS_ATTACHMENT_TABLE . '
			WHERE ' . $db->sql_in_set('attach_id', array_unique(array_map('intval', array_keys($attach_ids))));
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if (!isset($attach_ids[$row['attach_id']])) {
                continue;
            }
            // If we preview attachments we will set some retrieved values here
            if ($preview) {
                $row['attach_comment'] = $attachments[$attach_ids[$row['attach_id']]]['attach_comment'];
            }
            $new_attachment_data[$attach_ids[$row['attach_id']]] = $row;
        }
        $db->sql_freeresult($result);
        $attachments = $new_attachment_data;
        unset($new_attachment_data);
    }
    ksort($attachments);
    foreach ($attachments as $attachment) {
        if (!sizeof($attachment)) {
            continue;
        }
        // We need to reset/empty the _file block var, because this function might be called more than once
        $template->destroy_block_vars('_file');
        $block_array = array();
        // Some basics...
        $attachment['extension'] = strtolower(trim($attachment['extension']));
        $filename = $phpbb_root_path . $config['upload_path'] . '/blog_mod/' . basename($attachment['physical_filename']);
        $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/blog_mod/thumb_' . basename($attachment['physical_filename']);
        $upload_icon = '';
        if (isset($extensions[$attachment['extension']])) {
            if ($user->img('icon_topic_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) {
                $upload_icon = $user->img('icon_topic_attach', '');
            } else {
                if ($extensions[$attachment['extension']]['upload_icon']) {
                    $upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />';
                }
            }
        }
        $filesize = $attachment['filesize'];
        $size_lang = $filesize >= 1048576 ? $user->lang['MB'] : ($filesize >= 1024 ? $user->lang['KB'] : $user->lang['BYTES']);
        $filesize = $filesize >= 1048576 ? round(round($filesize / 1048576 * 100) / 100, 2) : ($filesize >= 1024 ? round(round($filesize / 1024 * 100) / 100, 2) : $filesize);
        $comment = str_replace("\n", '<br />', censor_text($attachment['attach_comment']));
        $block_array += array('UPLOAD_ICON' => $upload_icon, 'FILESIZE' => $filesize, 'SIZE_LANG' => $size_lang, 'DOWNLOAD_NAME' => basename($attachment['real_filename']), 'COMMENT' => $comment);
        $denied = false;
        if (!isset($extensions['_allowed_'][$attachment['extension']])) {
            $denied = true;
            $block_array += array('S_DENIED' => true, 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
        }
        if (!$denied) {
            $l_downloaded_viewed = $download_link = '';
            $display_cat = $extensions[$attachment['extension']]['display_cat'];
            if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
                if ($attachment['thumbnail']) {
                    $display_cat = ATTACHMENT_CATEGORY_THUMB;
                } else {
                    if ($config['img_display_inlined']) {
                        if ($config['img_link_width'] || $config['img_link_height']) {
                            $dimension = @getimagesize($filename);
                            // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                            if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                                $display_cat = ATTACHMENT_CATEGORY_NONE;
                            } else {
                                $display_cat = $dimension[0] <= $config['img_link_width'] && $dimension[1] <= $config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                            }
                        }
                    } else {
                        $display_cat = ATTACHMENT_CATEGORY_NONE;
                    }
                }
            }
            // Make some descisions based on user options being set.
            if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) {
                $display_cat = ATTACHMENT_CATEGORY_NONE;
            }
            if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash')) {
                $display_cat = ATTACHMENT_CATEGORY_NONE;
            }
            $download_link = blog_url(false, false, false, array('page' => 'download', 'mode' => 'download', 'id' => $attachment['attach_id']));
            switch ($display_cat) {
                // Images
                case ATTACHMENT_CATEGORY_IMAGE:
                    $l_downloaded_viewed = 'VIEWED_COUNT';
                    $inline_link = blog_url(false, false, false, array('page' => 'download', 'mode' => 'download', 'id' => $attachment['attach_id']));
                    $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => $inline_link);
                    $update_count[] = $attachment['attach_id'];
                    break;
                    // Images, but display Thumbnail
                // Images, but display Thumbnail
                case ATTACHMENT_CATEGORY_THUMB:
                    $l_downloaded_viewed = 'VIEWED_COUNT';
                    $thumbnail_link = blog_url(false, false, false, array('page' => 'download', 'mode' => 'thumbnail', 'id' => $attachment['attach_id']));
                    $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => $thumbnail_link);
                    break;
                    // Windows Media Streams
                // Windows Media Streams
                case ATTACHMENT_CATEGORY_WM:
                    $l_downloaded_viewed = 'VIEWED_COUNT';
                    // Giving the filename directly because within the wm object all variables are in local context making it impossible
                    // to validate against a valid session (all params can differ)
                    // $download_link = $filename;
                    $block_array += array('U_FORUM' => generate_board_url(), 'ATTACH_ID' => $attachment['attach_id'], 'S_WM_FILE' => true);
                    // Viewed/Heared File ... update the download count
                    $update_count[] = $attachment['attach_id'];
                    break;
                    // Real Media Streams
                // Real Media Streams
                case ATTACHMENT_CATEGORY_RM:
                case ATTACHMENT_CATEGORY_QUICKTIME:
                    $l_downloaded_viewed = 'VIEWED_COUNT';
                    $block_array += array('S_RM_FILE' => $display_cat == ATTACHMENT_CATEGORY_RM ? true : false, 'S_QUICKTIME_FILE' => $display_cat == ATTACHMENT_CATEGORY_QUICKTIME ? true : false, 'U_FORUM' => generate_board_url(), 'ATTACH_ID' => $attachment['attach_id']);
                    // Viewed/Heared File ... update the download count
                    $update_count[] = $attachment['attach_id'];
                    break;
                    // Macromedia Flash Files
                // Macromedia Flash Files
                case ATTACHMENT_CATEGORY_FLASH:
                    list($width, $height) = @getimagesize($filename);
                    $l_downloaded_viewed = 'VIEWED_COUNT';
                    $block_array += array('S_FLASH_FILE' => true, 'WIDTH' => $width, 'HEIGHT' => $height);
                    // Viewed/Heared File ... update the download count
                    $update_count[] = $attachment['attach_id'];
                    break;
                default:
                    $l_downloaded_viewed = 'DOWNLOAD_COUNT';
                    $block_array += array('S_FILE' => true);
                    break;
            }
            $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? $user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf($user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count']));
            $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count);
        }
        $template->assign_block_vars('_file', $block_array);
        $compiled_attachments[] = $template->assign_display('attachment_tpl');
    }
    $attachments = $compiled_attachments;
    unset($compiled_attachments);
    $tpl_size = sizeof($attachments);
    $unset_tpl = array();
    preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER);
    $replace = array();
    foreach ($matches[0] as $num => $capture) {
        // Flip index if we are displaying the reverse way
        $index = $config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num];
        $replace['from'][] = $matches[0][$num];
        $replace['to'][] = isset($attachments[$index]) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);
        $unset_tpl[] = $index;
    }
    if (isset($replace['from'])) {
        $message = str_replace($replace['from'], $replace['to'], $message);
    }
    $unset_tpl = array_unique($unset_tpl);
    // Needed to let not display the inlined attachments at the end of the post again
    foreach ($unset_tpl as $index) {
        unset($attachments[$index]);
    }
}
Example #21
0
function style_blog_end()
{
    global $blog_urls, $template, $user_id;
    $template->assign_vars(array('SHARE_URL' => urlencode($blog_urls['self']), 'USER_BLOG_URL' => blog_url($user_id)));
}