Exemple #1
0
function bb_quote_link($link_text = 'Quote')
{
    global $bb, $page, $topic, $forum, $bb_post;
    $add = topic_pages_add();
    if (!topic_is_open($bb_post->topic_id) || !bb_is_user_logged_in()) {
        return;
    }
    $post_id = get_post_id();
    $last_page = get_page_number($topic->topic_posts + $add);
    echo '<a href="' . get_topic_link(0, $last_page) . '&quote=' . $post_id . '#postform" id="quote_' . $post_id . '">' . __($link_text) . '</a>';
}
function for_buddypress_prepare_topic($_topic, $topic)
{
    // Cast to an array
    $_topic = (array) $topic;
    // Set the URI
    $_topic['topic_uri'] = get_topic_link($_topic['topic_id']);
    // Set readable times
    $_topic['topic_start_time_since'] = bb_since($_topic['topic_start_time']);
    $_topic['topic_time_since'] = bb_since($_topic['topic_time']);
    // Set the display names
    $_topic['topic_poster_display_name'] = get_user_display_name($_topic['topic_poster']);
    $_topic['topic_last_poster_display_name'] = get_user_display_name($_topic['topic_last_poster']);
    return $_topic;
}
Exemple #3
0
/**
 * Alerts user's friends when they write a new forum topic
 *
 * @Param: the id of the topic
 *
 * @author: Joe Hoyle
 * @version 1.0
 **/
function nm_alert_user_wrote_forum_topic($topicID)
{
    $userInfo = wp_get_current_user();
    $friendList = new userFriends();
    $friends = $friendList->get_friends($userInfo->ID);
    if (is_array($friends)) {
        $friends = nm_array_invert($friends);
        $alert = array();
        $alert['content'] = '<a href="' . getProfileLink($userInfo->ID) . '" title="View ' . nm_user_public_name($userInfo->ID) . 's profile">' . nm_user_public_name($userInfo->ID) . '</a> has written a new forum topic: <a href="' . get_topic_link($topicID) . '" title="View ' . get_topic_title($topicID) . '">' . get_topic_title($topicID) . '</a>.';
        $alert['type'] = 'forum';
        nm_add_alert($friends, $alert);
    }
    return $topicID;
}
Exemple #4
0
/**
 * Plugin Name: Post Notification
 * Plugin Description: Sends an Notification email if there's a new post to an favorite topic. (Modified Version 1.4 with Post Content included in E-Mail)
 * Author: Thomas Klaiber
 * Author URI: http://thomasklaiber.com/
 * Plugin URI: http://thomasklaiber.com/bbpress/post-notification/
 * Version: 1.4
 */
function notification_new_post($post_id = 0)
{
    global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user;
    $all_users = notification_select_all_users();
    foreach ($all_users as $userdata) {
        if (notification_is_activated($userdata->ID)) {
            if (is_user_favorite($userdata->ID, $topic_id)) {
                //$topic = get_topic($topic_id);
                $message = __("Hello,\n\nA new post on \"%1\$s\" has been added by %2\$s at DHAnswers. \n\nMessage:\n\n%3\$s \n\n%4\$s ");
                mail($userdata->user_email, '[DHAnswers] New Post for Favorite Question', sprintf($message, get_topic_title($topic_id), get_user_name($bb_current_user->ID), strip_tags(get_post_text($post_id)), get_topic_link($topic_id)), 'From: ' . bb_get_option('name') . ' <' . bb_get_option('from_email') . '>');
            }
        }
    }
}
function mod_notification_new_post()
{
    global $bbdb, $topic_id, $bb_current_user;
    $all_moderators = notification_select_all_mods();
    $topic = get_topic($topic_id);
    $header = 'From: ' . bb_get_option('name') . ' <' . bb_get_option('from_email') . '>';
    $header .= 'MIME-Version: 1.0' . "\n";
    $header .= 'Content-Type: text/plain; charset="' . BBDB_CHARSET . '"' . "\n";
    $header .= 'Content-Transfer-Encoding: 7bit' . "\n";
    $subject = '[DHAnswers] New Post';
    foreach ($all_moderators as $userdata) {
        if (mod_notification_is_activated($userdata->ID)) {
            $msg = "Hello,\n\nA new post has been added to \"" . $topic->topic_title . "\" at DHAnswers. \n\n" . get_topic_link($topic_id);
            mail($userdata->user_email, $subject, $msg, $header);
        }
    }
}
function tweet_new_topic($topic_id, $topic_title)
{
    global $bb_post;
    if ($bb_post) {
        // post already exists
    } else {
        $t_title = get_topic_title($topic_id);
        $t_link = get_topic_link($topic_id);
        //shorten URL
        exec("curl http://is.gd/api.php?longurl=" . $t_link, $shorturl);
        $message = "New ? at DHAnswers: " . $t_title . " ({$shorturl['0']})";
        if (strlen($message) > 140) {
            $message = substr($message, 0, 139) . '…';
        }
        // New Tweet using Twitter OAuth
        // TODO: check return status
        bb_post_tweet($message);
    }
    return $topic_title;
}
Exemple #7
0
function topic_icons_label($label)
{
    global $topic;
    if (bb_is_front() || bb_is_forum() || bb_is_view() || bb_is_tag()) {
        $icon_set_name = topic_icons_get_active_icon_set();
        $icon_set_url = ICON_SET_URL_BASE . $icon_set_name;
        $status = get_active_status_interpreter()->getStatus(bb_get_location(), $topic);
        $renderer = get_active_status_renderer();
        $image = $renderer->renderStatus($status);
        $tooltip = $renderer->renderStatusTooltip($status);
        $exists = file_exists(dirname(__FILE__) . '/icon-sets/' . $icon_set_name . '/' . $image);
        if (!$exists) {
            return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), ICON_SET_URL_BASE . '/empty.png', ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
        } else {
            if (strlen($tooltip) > 0) {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"><span>%s</span></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $tooltip, $label);
            } else {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
            }
        }
    }
    return $label;
}
Exemple #8
0
function bb_attachments($post_id = 0)
{
    global $bb_attachments_on_page;
    if (isset($bb_attachments_on_page)) {
        return;
    } else {
        $bb_attachments_on_page = true;
    }
    // only insert once per page -> pre 0.9.0.2
    if ($post_id == 0) {
        if (isset($_GET['bb_attachments'])) {
            $post_id = intval($_GET['bb_attachments']);
        } else {
            global $bb_post;
            $post_id = $bb_post->post_id;
        }
    }
    if ($post_id) {
        $bb_post = bb_get_post($post_id);
        if (bb_attachments_location() != 'edit.php') {
            echo "<h3 class='bbcrumb'><a href='" . bb_get_option('uri') . "'>" . bb_get_option('name') . "</a> &raquo; <a href='" . get_topic_link() . "'>" . get_topic_title($bb_post->topic_id) . "</a> &raquo; <a href='" . get_post_link($bb_post->post_id) . "'>" . __('Post') . " {$bb_post->post_position}</a> &raquo;  " . __('Attachments') . "</h3>";
        }
        echo "<div class='indent'>";
        if (isset($_FILES['bb_attachments'])) {
            bb_attachments_process_post(intval($_GET['bb_attachments']), 1);
            echo "<br />";
        }
        echo bb_attachments_post_attachments($post_id);
        echo "<br />";
        bb_attachments_upload_form($post_id);
        echo "<br />";
        echo "</div>";
    }
}
Exemple #9
0
<?php

require './bb-load.php';
bb_auth('logged_in');
if (!bb_is_user_logged_in()) {
    bb_die(__('You need to be logged in to add a tag.'));
}
$topic_id = (int) @$_POST['id'];
$page = (int) @$_POST['page'];
$tag = @$_POST['tag'];
$tag = stripslashes($tag);
bb_check_admin_referer('add-tag_' . $topic_id);
$topic = get_topic($topic_id);
if (!$topic) {
    bb_die(__('Topic not found.'));
}
if (bb_add_topic_tags($topic_id, $tag)) {
    wp_redirect(get_topic_link($topic_id, $page));
} else {
    bb_die(__('The tag was not added.  Either the tag name was invalid or the topic is closed.'));
}
exit;
Exemple #10
0
function bb_ksd_submit($submit, $type = false)
{
    global $bb_ksd_api_host;
    global $bb_ksd_api_port;
    switch ($type) {
        case 'ham':
        case 'spam':
            $path = '/1.1/submit-' . $type;
            $bb_post = bb_get_post($submit);
            if (!$bb_post) {
                return;
            }
            $user = bb_get_user($bb_post->poster_id);
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => $bb_post->poster_ip, 'permalink' => get_topic_link($bb_post->topic_id), 'comment_type' => 'forum', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $bb_post->post_text, 'comment_date_gmt' => $bb_post->post_time);
            break;
        case 'hammer':
        case 'spammer':
            $path = '/1.1/submit-' . substr($type, 0, -3);
            $user = bb_get_user($submit);
            if (!$user) {
                return;
            }
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'permalink' => get_user_profile_link($user->ID), 'comment_type' => 'profile', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $user->occ . ' ' . $user->interests, 'comment_date_gmt' => $user->user_registered);
            break;
        default:
            if (bb_is_trusted_user(bb_get_current_user())) {
                return;
            }
            $path = '/1.1/comment-check';
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => isset($_POST['topic_id']) ? 'forum' : 'profile', 'comment_author' => bb_get_current_user_info('name'), 'comment_author_email' => bb_get_current_user_info('email'), 'comment_author_url' => bb_get_current_user_info('url'), 'comment_content' => $submit);
            if (isset($_POST['topic_id'])) {
                $_submit['permalink'] = get_topic_link($_POST['topic_id']);
                // First page
            }
            break;
    }
    $query_string = '';
    foreach ($_submit as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    return bb_ksd_http_post($query_string, $bb_ksd_api_host, $path, $bb_ksd_api_port);
}
Exemple #11
0
 /**
  * Prepares topic data for return in an XML-RPC object
  *
  * @since 1.0
  * @return array The prepared topic data
  * @param array|object The unprepared topic data
  **/
 function prepare_topic($topic)
 {
     // Cast to an array
     $_topic = (array) $topic;
     // Set the URI
     $_topic['topic_uri'] = get_topic_link($_topic['topic_id']);
     // Set readable times
     $_topic['topic_start_time_since'] = bb_since($_topic['topic_start_time']);
     $_topic['topic_time_since'] = bb_since($_topic['topic_time']);
     // Set the display names
     $_topic['topic_poster_display_name'] = get_user_display_name($_topic['topic_poster']);
     $_topic['topic_last_poster_display_name'] = get_user_display_name($_topic['topic_last_poster']);
     // Remove some sensitive user ids
     unset($_topic['topic_poster'], $_topic['topic_last_poster']);
     // Allow plugins to modify the data
     return apply_filters('bb_xmlrpc_prepare_topic', $_topic, (array) $topic);
 }
Exemple #12
0
            } else {
                printf(__('<a href="%1$s">Post</a> on <a href="%2$s">%3$s</a> by %4$s'), esc_attr(add_query_arg('view', 'all', get_post_link())), get_topic_link($bb_post->topic_id), get_topic_title($bb_post->topic_id), get_post_author());
            }
            ?>
			</li>
			<?php 
        } elseif ('topic' == $object['type']) {
            global $topic;
            $topic = $object['data'];
            ?>
			<li>
			<?php 
            if ($topic->topic_poster) {
                printf(__('Topic titled <a href="%1$s">%2$s</a> started by <a href="%3$s">%4$s</a>'), esc_attr(add_query_arg('view', 'all', get_topic_link())), get_topic_title($topic->topic_id), get_user_profile_link($topic->topic_poster), get_topic_author($topic->topic_id));
            } else {
                printf(__('Topic titled <a href="%1$s">%2$s</a> started by %3$s'), esc_attr(add_query_arg('view', 'all', get_topic_link())), get_topic_title($topic->topic_id), get_topic_author($topic->topic_id));
            }
            ?>
			</li>
			<?php 
        }
    }
    remove_filter('get_topic_where', 'bb_no_where');
    ?>
		</ul>
		<?php 
} else {
    ?>
		<p>
			<?php 
    _e('No moderated posts or topics&#8230; you must have very well behaved members.');
        function widget($args, $instance)
        {
            if (RWLogger::IsOn()) {
                $params = func_get_args();
                RWLogger::LogEnterence("RatingWidgetPlugin_TopRatedWidget.widget", $params, true);
            }
            if (!defined("WP_RW__SITE_PUBLIC_KEY") || false === WP_RW__SITE_PUBLIC_KEY) {
                return;
            }
            if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) {
                return;
            }
            extract($args, EXTR_SKIP);
            $bpInstalled = ratingwidget()->IsBuddyPressInstalled();
            $bbInstalled = ratingwidget()->IsBBPressInstalled();
            $types = $this->GetTypesInfo();
            $show_any = false;
            foreach ($types as $type => $data) {
                if (false !== $instance["show_{$type}"]) {
                    $show_any = true;
                    break;
                }
            }
            if (RWLogger::IsOn()) {
                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget', 'show_any = ' . ($show_any ? 'TRUE' : 'FALSE'));
            }
            if (false === $show_any) {
                // Nothing to show.
                return;
            }
            $details = array("uid" => WP_RW__SITE_PUBLIC_KEY);
            $queries = array();
            foreach ($types as $type => $type_data) {
                if (isset($instance["show_{$type}"]) && $instance["show_{$type}"] && $instance["{$type}_count"] > 0) {
                    $options = ratingwidget()->GetOption($type_data["options"]);
                    $queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star");
                    $since_created = isset($instance["{$type}_since_created"]) ? (int) $instance["{$type}_since_created"] : WP_RW__TIME_ALL_TIME;
                    // since_created should be at least 24 hours (86400 seconds), skip otherwise.
                    if ($since_created >= WP_RW__TIME_24_HOURS_IN_SEC) {
                        $time = current_time('timestamp', true) - $since_created;
                        // c: ISO 8601 full date/time, e.g.: 2004-02-12T15:19:21+00:00
                        $queries[$type]['since_created'] = date('c', $time);
                    }
                }
            }
            $details["queries"] = urlencode(json_encode($queries));
            $rw_ret_obj = ratingwidget()->RemoteCall("action/query/ratings.php", $details, WP_RW__CACHE_TIMEOUT_TOP_RATED);
            if (false === $rw_ret_obj) {
                return;
            }
            $rw_ret_obj = json_decode($rw_ret_obj);
            if (null === $rw_ret_obj || true !== $rw_ret_obj->success) {
                return;
            }
            $title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']);
            $titleMaxLength = isset($instance['title_max_length']) && is_numeric($instance['title_max_length']) ? (int) $instance['title_max_length'] : 30;
            $empty = true;
            $toprated_data = new stdClass();
            $toprated_data->id = rand(1, 100);
            $toprated_data->title = array('label' => $title, 'show' => true, 'before' => $this->EncodeHtml($before_title), 'after' => $this->EncodeHtml($after_title));
            $toprated_data->options = array('align' => 'vertical', 'direction' => 'ltr', 'html' => array('before' => $this->EncodeHtml($before_widget), 'after' => $this->EncodeHtml($after_widget)));
            $toprated_data->site = array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST'], 'type' => 'WordPress');
            $toprated_data->itemGroups = array();
            if (count($rw_ret_obj->data) > 0) {
                foreach ($rw_ret_obj->data as $type => $ratings) {
                    if (is_array($ratings) && count($ratings) > 0) {
                        $item_group = new stdClass();
                        $item_group->type = $type;
                        $item_group->title = $instance["{$type}_title"];
                        $item_group->showTitle = 1 === $instance["show_{$type}_title"] && '' !== trim($item_group->title);
                        if (is_numeric($instance["{$type}_style"])) {
                            switch ($instance["{$type}_style"]) {
                                case 0:
                                    $instance["{$type}_style"] = 'legacy';
                                    break;
                                case 1:
                                default:
                                    $instance["{$type}_style"] = 'thumbs';
                                    break;
                            }
                        }
                        $item_group->style = $instance["{$type}_style"];
                        $item_group->options = array('title' => array('maxLen' => $titleMaxLength));
                        $item_group->items = array();
                        $has_thumb = strtolower($instance["{$type}_style"]) !== 'legacy';
                        $thumb_width = 160;
                        $thumb_height = 100;
                        if ($has_thumb) {
                            switch ($instance["{$type}_style"]) {
                                case '2':
                                case 'compact_thumbs':
                                    $thumb_width = 50;
                                    $thumb_height = 40;
                                    break;
                                case '1':
                                case 'thumbs':
                                default:
                                    $thumb_width = 160;
                                    $thumb_height = 100;
                                    break;
                            }
                            $item_group->options['thumb'] = array('width' => $thumb_width, 'height' => $thumb_height);
                        }
                        $cell = 0;
                        foreach ($ratings as $rating) {
                            $urid = $rating->urid;
                            $rclass = $types[$type]["rclass"];
                            $rclasses[$rclass] = true;
                            $extension_type = false;
                            if (RWLogger::IsOn()) {
                                RWLogger::Log('HANDLED_ITEM', 'Urid = ' . $urid . '; Class = ' . $rclass . ';');
                            }
                            if ('posts' === $type || 'pages' === $type) {
                                $post = null;
                                $id = RatingWidgetPlugin::Urid2PostId($urid);
                                $status = @get_post_status($id);
                                if (false === $status) {
                                    if (RWLogger::IsOn()) {
                                        RWLogger::Log('POST_NOT_EXIST', $id);
                                    }
                                    // Post not exist.
                                    continue;
                                } else {
                                    if ('publish' !== $status && 'private' !== $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('POST_NOT_VISIBLE', 'status = ' . $status);
                                        }
                                        // Post not yet published.
                                        continue;
                                    } else {
                                        if ('private' === $status && !is_user_logged_in()) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget::widget', 'POST_PRIVATE && USER_LOGGED_OUT');
                                            }
                                            // Private post but user is not logged in.
                                            continue;
                                        }
                                    }
                                }
                                $post = @get_post($id);
                                $title = trim(strip_tags($post->post_title));
                                $permalink = get_permalink($post->ID);
                            } else {
                                if ('comments' === $type) {
                                    $comment = null;
                                    $id = RatingWidgetPlugin::Urid2CommentId($urid);
                                    $status = @wp_get_comment_status($id);
                                    if (false === $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('COMMENT_NOT_EXIST', $id);
                                        }
                                        // Comment not exist.
                                        continue;
                                    } else {
                                        if ('approved' !== $status) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('COMMENT_NOT_VISIBLE', 'status = ' . $status);
                                            }
                                            // Comment not approved.
                                            continue;
                                        }
                                    }
                                    $comment = @get_comment($id);
                                    $title = trim(strip_tags($comment->comment_content));
                                    $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                                } else {
                                    if ('activity_updates' === $type || 'activity_comments' === $type) {
                                        $id = RatingWidgetPlugin::Urid2ActivityId($urid);
                                        $activity = new bp_activity_activity($id);
                                        if (!is_object($activity)) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('BP_ACTIVITY_NOT_EXIST', $id);
                                            }
                                            // Activity not exist.
                                            continue;
                                        } else {
                                            if (!empty($activity->is_spam)) {
                                                if (RWLogger::IsOn()) {
                                                    RWLogger::Log('BP_ACTIVITY_NOT_VISIBLE (SPAM or TRASH)');
                                                }
                                                // Activity marked as SPAM or TRASH.
                                                continue;
                                            } else {
                                                if (!empty($activity->hide_sitewide)) {
                                                    if (RWLogger::IsOn()) {
                                                        RWLogger::Log('BP_ACTIVITY_HIDE_SITEWIDE');
                                                    }
                                                    // Activity marked as hidden in site.
                                                    continue;
                                                }
                                            }
                                        }
                                        $title = trim(strip_tags($activity->content));
                                        $permalink = bp_activity_get_permalink($id);
                                    } else {
                                        if ('users' === $type) {
                                            $id = RatingWidgetPlugin::Urid2UserId($urid);
                                            if ($bpInstalled) {
                                                $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                                $permalink = bp_core_get_user_domain($id);
                                            } else {
                                                if ($bbInstalled) {
                                                    $title = trim(strip_tags(bbp_get_user_display_name($id)));
                                                    $permalink = bbp_get_user_profile_url($id);
                                                } else {
                                                    continue;
                                                }
                                            }
                                        } else {
                                            if ('forum_posts' === $type || 'forum_replies' === $type) {
                                                $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                                if (function_exists('bp_forums_get_post')) {
                                                    $forum_post = @bp_forums_get_post($id);
                                                    if (!is_object($forum_post)) {
                                                        continue;
                                                    }
                                                    $title = trim(strip_tags($forum_post->post_text));
                                                    $page = bb_get_page_number($forum_post->post_position);
                                                    $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                                } else {
                                                    if (function_exists('bbp_get_reply_id')) {
                                                        $forum_item = bbp_get_topic();
                                                        if (is_object($forum_item)) {
                                                            $is_topic = true;
                                                        } else {
                                                            $is_topic = false;
                                                            $forum_item = bbp_get_reply($id);
                                                            if (!is_object($forum_item)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
                                                                }
                                                                // Invalid id (no topic nor reply).
                                                                continue;
                                                            }
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
                                                            }
                                                        }
                                                        // Visible statueses: Public or Closed.
                                                        $visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
                                                        if (!in_array($forum_item->post_status, $visible_statuses)) {
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
                                                            }
                                                            // Item is not public nor closed.
                                                            continue;
                                                        }
                                                        $is_reply = !$is_topic;
                                                        if ($is_reply) {
                                                            // Get parent topic.
                                                            $forum_topic = bbp_get_topic($forum_post->post_parent);
                                                            if (!in_array($forum_topic->post_status, $visible_statuses)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE');
                                                                }
                                                                // Parent topic is not public nor closed.
                                                                continue;
                                                            }
                                                        }
                                                        $title = trim(strip_tags($forum_post->post_title));
                                                        $permalink = get_permalink($forum_post->ID);
                                                    } else {
                                                        continue;
                                                    }
                                                }
                                                $types[$type]['handler']->GetElementInfoByRating();
                                            } else {
                                                $found_handler = false;
                                                $extensions = ratingwidget()->GetExtensions();
                                                foreach ($extensions as $ext) {
                                                    $result = $ext->GetElementInfoByRating($type, $rating);
                                                    if (false !== $result) {
                                                        $found_handler = true;
                                                        break;
                                                    }
                                                }
                                                if ($found_handler) {
                                                    $id = $result['id'];
                                                    $title = $result['title'];
                                                    $permalink = $result['permalink'];
                                                    $img = rw_get_thumb_url($result['img'], $thumb_width, $thumb_height, $result['permalink']);
                                                    $extension_type = true;
                                                } else {
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            $queued = ratingwidget()->QueueRatingData($urid, "", "", $rclass);
                            // Override rating class in case the same rating has already been queued with a different rclass.
                            $rclass = $queued['rclass'];
                            $short = mb_strlen($title) > $titleMaxLength ? trim(mb_substr($title, 0, $titleMaxLength)) . "..." : $title;
                            $item = array('site' => array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST']), 'page' => array('externalID' => $id, 'url' => $permalink, 'title' => $short), 'rating' => array('localID' => $urid, 'options' => array('rclass' => $rclass)));
                            // Add thumb url.
                            if ($extension_type && is_string($img)) {
                                $item['page']['img'] = $img;
                            } else {
                                if ($has_thumb && in_array($type, array('posts', 'pages'))) {
                                    $item['page']['img'] = rw_get_post_thumb_url($post, $thumb_width, $thumb_height);
                                }
                            }
                            $item_group->items[] = $item;
                            $cell++;
                            $empty = false;
                        }
                        $toprated_data->itemGroups[] = $item_group;
                    }
                }
            }
            if (true === $empty) {
                //            echo '<p style="margin: 0;">There are no rated items for this period.</p>';
                //        echo $before_widget;
                //        echo $after_widget;
            } else {
                // Set a flag that the widget is loaded.
                ratingwidget()->TopRatedWidgetLoaded();
                ?>
					<b class="rw-ui-recommendations" data-id="<?php 
                echo $toprated_data->id;
                ?>
"></b>
					<script type="text/javascript">
						var _rwq = _rwq || [];
						_rwq.push(['_setRecommendations', <?php 
                echo json_encode($toprated_data);
                ?>
]);
					</script>
				<?php 
            }
        }
    default:
        switch ($status) {
            case 0:
                $message = 'unspammed-normal';
                break;
            case 1:
                $message = 'unspammed-deleted';
                break;
            default:
                break;
        }
        break;
}
$topic = get_topic($bb_post->topic_id);
if ($sendto = wp_get_referer()) {
    $sendto = remove_query_arg('message', $sendto);
    $sendto = add_query_arg('message', $message, $sendto);
    $send_to_topic = bb_get_topic_from_uri($sendto);
    if ($send_to_topic && $topic->topic_id == $send_to_topic->topic_id) {
        $sendto = add_query_arg('view', 'all', $sendto);
    }
} else {
    if ($topic->topic_posts == 0) {
        $sendto = get_forum_link($topic->forum_id);
    } else {
        $the_page = bb_get_page_number($bb_post->post_position);
        $sendto = get_topic_link($bb_post->topic_id, $the_page);
    }
}
bb_safe_redirect($sendto);
exit;
        function widget($args, $instance)
        {
            if (RWLogger::IsOn()) {
                $params = func_get_args();
                RWLogger::LogEnterence("RWTopRated.widget", $params, true);
            }
            if (!defined("WP_RW__USER_KEY") || false === WP_RW__USER_KEY) {
                return;
            }
            if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) {
                return;
            }
            extract($args, EXTR_SKIP);
            $types = array("posts" => array("rclass" => "blog-post", "classes" => "front-post,blog-post,new-blog-post,user-post", "options" => WP_RW__BLOG_POSTS_OPTIONS), "pages" => array("rclass" => "page", "classes" => "page,user-page", "options" => WP_RW__PAGES_OPTIONS), "comments" => array("rclass" => "comment", "classes" => "comment,new-blog-comment,user-comment", "options" => WP_RW__COMMENTS_OPTIONS), "activity_updates" => array("rclass" => "activity-update", "classes" => "activity-update,user-activity-update", "options" => WP_RW__ACTIVITY_UPDATES_OPTIONS), "activity_comments" => array("rclass" => "activity-comment", "classes" => "activity-comment,user-activity-comment", "options" => WP_RW__ACTIVITY_COMMENTS_OPTIONS), "forum_posts" => array("rclass" => "forum-post", "classes" => "forum-post,new-forum-post,user-forum-post", "options" => WP_RW__FORUM_POSTS_OPTIONS), "users" => array("rclass" => "user", "classes" => "user", "options" => WP_RW__FORUM_POSTS_OPTIONS));
            $show_any = false;
            foreach ($types as $type => $data) {
                if (false !== $instance["show_{$type}"]) {
                    $show_any = true;
                    break;
                }
            }
            if (false === $show_any) {
                // Nothing to show.
                return;
            }
            $details = array("uid" => WP_RW__USER_KEY);
            $queries = array();
            foreach ($types as $type => $type_data) {
                if ($instance["show_{$type}"] && $instance["{$type}_count"] > 0) {
                    $options = json_decode(RatingWidgetPlugin::_getOption($type_data["options"]));
                    $queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star");
                }
            }
            $details["queries"] = urlencode(json_encode($queries));
            $rw_ret_obj = RatingWidgetPlugin::RemoteCall("action/query/ratings.php", $details);
            if (false === $rw_ret_obj) {
                return;
            }
            $rw_ret_obj = json_decode($rw_ret_obj);
            if (null === $rw_ret_obj || true !== $rw_ret_obj->success) {
                return;
            }
            echo $before_widget;
            $title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']);
            echo $before_title . $title . $after_title;
            $empty = true;
            if (count($rw_ret_obj->data) > 0) {
                foreach ($rw_ret_obj->data as $type => $ratings) {
                    if (is_array($ratings) && count($ratings) > 0) {
                        echo '<div id="rw_top_rated_' . $type . '">';
                        if ($instance["show_{$type}_title"]) {
                            /* (1.3.3) - Conditional title display */
                            $instance["{$type}_title"] = empty($instance["{$type}_title"]) ? ucwords($type) : $instance["{$type}_title"];
                            echo '<p style="margin: 0;">' . $instance["{$type}_title"] . '</p>';
                        }
                        echo '<ul class="rw-top-rated-list">';
                        foreach ($ratings as $rating) {
                            $urid = $rating->urid;
                            $rclass = $types[$type]["rclass"];
                            RatingWidgetPlugin::QueueRatingData($urid, "", "", $rclass);
                            switch ($type) {
                                case "posts":
                                case "pages":
                                    $id = RatingWidgetPlugin::Urid2PostId($urid);
                                    $post = get_post($id);
                                    $title = trim(strip_tags($post->post_title));
                                    $permalink = get_permalink($post->ID);
                                    break;
                                case "comments":
                                    $id = RatingWidgetPlugin::Urid2CommentId($urid);
                                    $comment = get_comment($id);
                                    $title = trim(strip_tags($comment->comment_content));
                                    $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                                    break;
                                case "activity_updates":
                                case "activity_comments":
                                    $id = RatingWidgetPlugin::Urid2ActivityId($urid);
                                    $activity = new bp_activity_activity($id);
                                    $title = trim(strip_tags($activity->content));
                                    $permalink = bp_activity_get_permalink($id);
                                    break;
                                case "users":
                                    $id = RatingWidgetPlugin::Urid2UserId($urid);
                                    $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                    $permalink = bp_core_get_user_domain($id);
                                    break;
                                case "forum_posts":
                                    $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                    $forum_post = bp_forums_get_post($id);
                                    $title = trim(strip_tags($forum_post->post_text));
                                    $page = bb_get_page_number($forum_post->post_position);
                                    $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                    break;
                            }
                            $short = mb_strlen($title) > 30 ? trim(mb_substr($title, 0, 30)) . "..." : $title;
                            echo '<li>' . '<a href="' . $permalink . '" title="' . $title . '">' . $short . '</a>' . '<br />' . '<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . '"></div>' . '</li>';
                        }
                        echo "</ul>";
                        echo "</div>";
                        $empty = false;
                    }
                }
            }
            if (true === $empty) {
                echo '<p style="margin: 0;">There are no rated items for this period.</p>';
            } else {
                // Set a flag that the widget is loaded.
                RatingWidgetPlugin::TopRatedWidgetLoaded();
                ?>
<script type="text/javascript">
    // Hook render widget.
    if (typeof(RW_HOOK_READY) === "undefined"){ RW_HOOK_READY = []; }
    RW_HOOK_READY.push(function(){
        RW._foreach(RW._getByClassName("rw-top-rated-list", "ul"), function(list){
            RW._foreach(RW._getByClassName("rw-ui-container", "div", list), function(rating){
                // Deactivate rating.
                RW._Class.remove(rating, "rw-active");
                var i = (RW._getByClassName("rw-report-link", "a", rating))[0];
                if (RW._is(i)){ i.parentNode.removeChild(i); }
                
                // Update size to small.
                if (!RW._Class.has(rating, "rw-size-small"))
                {
                    RW._Class.add(rating, "rw-size-small");
                    RW._Class.remove(rating, "rw-size-medium");
                    RW._Class.remove(rating, "rw-size-large");
                }
                
                if (RW._Class.has(rating, "rw-ui-star"))
                {
                    RW._foreach(RW._getByTagName("li", rating), function(star){
                        // Clear star event handlers.
                        star.onmouseover =
                        star.onmouseout =
                        star.onclick = "";
                    });
                }
                else
                {
                    RW._foreach(RW._getByTagName("i", rating), function(thumb){
                        // Clear star event handlers.
                        thumb.onmouseover =
                        thumb.onmouseout =
                        thumb.onclick = "";
                    });

                    var like_label = RW._getByClassName("rw-ui-like-label", "span", rating);
                    if (like_label.length == 1)
                    {
                        like_label = like_label[0];
                        like_label.style.fontSize = like_label.style.lineHeight = "";
                    }
                    
                    var dislike_label = RW._getByClassName("rw-ui-dislike-label", "span", rating);
                    if (dislike_label.length == 1)
                    {
                        dislike_label = dislike_label[0];
                        dislike_label.style.fontSize = dislike_label.style.lineHeight = "";
                    }
                }
                
                var label = (RW._getByClassName("rw-ui-info", "span", rating))[0];
                label.style.fontSize = label.style.lineHeight = "";
            });
        });
    });
</script>
<?php 
            }
            echo $after_widget;
        }
Exemple #16
0
    }
    $fav = (int) $_GET['fav'];
    $topic_id = (int) $_GET['topic_id'];
    bb_check_admin_referer('toggle-favorite_' . $topic_id);
    $topic = get_topic($topic_id);
    if (!$topic || 0 != $topic->topic_status) {
        exit;
    }
    if ($fav) {
        bb_add_user_favorite($user_id, $topic_id);
    } else {
        bb_remove_user_favorite($user_id, $topic_id);
    }
    $ref = wp_get_referer();
    if (false !== strpos($ref, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))) {
        bb_safe_redirect($ref);
    } else {
        wp_redirect(get_topic_link($topic_id));
    }
    exit;
}
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($user->ID, 'favorites');
    wp_redirect($sendto);
    exit;
}
if ($topics = get_user_favorites($user->ID, true)) {
    bb_cache_last_posts($topics);
}
$favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
bb_load_template('favorites.php', array('favorites_total', 'self'));
Exemple #17
0
<?php

require 'admin-action.php';
$topic_id = (int) $_GET['id'];
$topic = get_topic($topic_id);
$super = isset($_GET['super']) && 1 == (int) $_GET['super'] ? 1 : 0;
if (!$topic) {
    bb_die(__('There is a problem with that topic, pardner.'));
}
if (!bb_current_user_can('stick_topic', $topic_id)) {
    wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    exit;
}
bb_check_admin_referer('stick-topic_' . $topic_id);
if (topic_is_sticky($topic_id)) {
    bb_unstick_topic($topic_id);
} else {
    bb_stick_topic($topic_id, $super);
}
if (!($redirect = wp_get_referer())) {
    $redirect = get_topic_link($topic_id);
}
bb_safe_redirect($redirect);
exit;
Exemple #18
0
        public function GetTopRated()
        {
            $rw_ret_obj = $this->GetTopRatedData(array('posts', 'pages'));
            if (false === $rw_ret_obj || count($rw_ret_obj->data) == 0) {
                return '';
            }
            $html = '<div id="rw_top_rated_page">';
            foreach ($rw_ret_obj->data as $type => $ratings) {
                if (is_array($ratings) && count($ratings) > 0) {
                    $html .= '<div id="rw_top_rated_page_' . $type . '" class="rw-wp-ui-top-rated-list-container">';
                    if ($instance["show_{$type}_title"]) {
                        $instance["{$type}_title"] = empty($instance["{$type}_title"]) ? ucwords($type) : $instance["{$type}_title"];
                        $html .= '<p style="margin: 0;">' . $instance["{$type}_title"] . '</p>';
                    }
                    $html .= '<ul class="rw-wp-ui-top-rated-list">';
                    $count = 1;
                    foreach ($ratings as $rating) {
                        $urid = $rating->urid;
                        $rclass = $types[$type]["rclass"];
                        $thumbnail = '';
                        ratingwidget()->QueueRatingData($urid, "", "", $rclass);
                        switch ($type) {
                            case "posts":
                            case "pages":
                                $id = RatingWidgetPlugin::Urid2PostId($urid);
                                $post = get_post($id);
                                $title = trim(strip_tags($post->post_title));
                                $excerpt = $this->GetPostExcerpt($post, 15);
                                $permalink = get_permalink($post->ID);
                                $thumbnail = $this->GetPostFeaturedImage($post->ID);
                                break;
                            case "comments":
                                $id = RatingWidgetPlugin::Urid2CommentId($urid);
                                $comment = get_comment($id);
                                $title = trim(strip_tags($comment->comment_content));
                                $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                                break;
                            case "activity_updates":
                            case "activity_comments":
                                $id = RatingWidgetPlugin::Urid2ActivityId($urid);
                                $activity = new bp_activity_activity($id);
                                $title = trim(strip_tags($activity->content));
                                $permalink = bp_activity_get_permalink($id);
                                break;
                            case "users":
                                $id = RatingWidgetPlugin::Urid2UserId($urid);
                                $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                $permalink = bp_core_get_user_domain($id);
                                break;
                            case "forum_posts":
                                $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                $forum_post = bp_forums_get_post($id);
                                $title = trim(strip_tags($forum_post->post_text));
                                $page = bb_get_page_number($forum_post->post_position);
                                $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                break;
                        }
                        $short = mb_strlen($title) > 30 ? trim(mb_substr($title, 0, 30)) . "..." : $title;
                        $html .= '
<li class="rw-wp-ui-top-rated-list-item">
    <div>
        <b class="rw-wp-ui-top-rated-list-count">' . $count . '</b>
        <img class="rw-wp-ui-top-rated-list-item-thumbnail" src="' . $thumbnail . '" alt="" />
        <div class="rw-wp-ui-top-rated-list-item-data">
            <div>
                <a class="rw-wp-ui-top-rated-list-item-title" href="' . $permalink . '" title="' . $title . '">' . $short . '</a>
                <div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . ' rw-size-small rw-prop-readOnly-true"></div>
            </div>
            <p class="rw-wp-ui-top-rated-list-item-excerpt">' . $excerpt . '</p>
        </div>
    </div>
</li>';
                        $count++;
                    }
                    $html .= "</ul>";
                    $html .= "</div>";
                }
            }
            // Set a flag that the widget is loaded.
            RatingWidgetPlugin::TopRatedWidgetLoaded();
            ob_start();
            ?>
<script type="text/javascript">
    // Hook render widget.
    if (typeof(RW_HOOK_READY) === "undefined"){ RW_HOOK_READY = []; }
    RW_HOOK_READY.push(function(){
        RW._foreach(RW._getByClassName("rw-wp-ui-top-rated-list", "ul"), function(list){
            RW._foreach(RW._getByClassName("rw-ui-container", "div", list), function(rating){
                // Deactivate rating.
                RW._Class.remove(rating, "rw-active");
                var i = (RW._getByClassName("rw-report-link", "a", rating))[0];
                if (RW._is(i)){ i.parentNode.removeChild(i); }
            });
        });
    });
</script>
<?php 
            $html .= ob_get_clean();
            $html .= '</div>';
            return $html;
        }
Exemple #19
0
     foreach ($topics as $topic) {
         $posts[] = bb_get_first_post($topic->topic_id);
     }
     $title = esc_html(sprintf(__('%1$s &raquo; View: %2$s'), bb_get_option('name'), $bb_views[$feed_id]['title']));
     $link = get_view_link($feed_id);
     $link_self = bb_get_view_rss_link($feed_id);
     break;
 case 'topic':
     if (!($topic = get_topic($feed_id))) {
         die;
     }
     if (!($posts = get_thread($feed_id, 0, 1))) {
         die;
     }
     $title = esc_html(sprintf(__('%1$s &raquo; Topic: %2$s'), bb_get_option('name'), get_topic_title()));
     $link = get_topic_link($feed_id);
     $link_self = get_topic_rss_link($feed_id);
     break;
 case 'profile':
     if (bb_get_option('mod_rewrite') === 'slugs') {
         $user = bb_get_user_by_nicename($feed_id);
     } else {
         $user = bb_get_user($feed_id);
     }
     if (!$user) {
         die;
     }
     if (!($posts = get_user_favorites($user->ID))) {
         die;
     }
     $title = esc_html(sprintf(__('%1$s &raquo; User Favorites: %2$s'), bb_get_option('name'), $user->user_login));
Exemple #20
0
function best_answer_post_link($link, $post_id)
{
    // this needs to be rewritten for better performance somehow
    global $best_answer;
    static $posts_per_page;
    $post = bb_get_post($post_id);
    if (empty($posts_per_page)) {
        $posts_per_page = bb_get_option('page_topics');
    }
    // speedup
    if ($post->post_position > $posts_per_page) {
        // is it beyond page 1 typically?
        $topic = get_topic($post->topic_id);
        if (!empty($topic->best_answer)) {
            if (!empty($best_answer['forums']) && !isset($best_answer['forums'][$topic->forum_id])) {
                return $link;
            }
            if (!is_array($topic->best_answer)) {
                (array) ($topic->best_answer = explode(',', $topic->best_answer));
                $topic->best_answer = array_flip($topic->best_answer);
            }
            if (isset($topic->best_answer[$post_id])) {
                $link = get_topic_link($post->topic_id, 1) . "#post-{$post_id}";
            }
            // change link to page 1 for best answers
        }
    }
    return $link;
}
function get_post_position_link($topic_id = 0, $position = 1)
{
    $position = (int) $position;
    $bb_topic = get_topic(get_topic_id($topic_id));
    if ($bb_topic->topic_posts < $position) {
        return;
    }
    $page = bb_get_page_number($position);
    return apply_filters('get_post_position_link', get_topic_link($bb_post->topic_id, $page) . "#position-{$position}", $bb_topic->topic_id, $position);
}
<?php

if (!isset($_GET['doit']) || 'bb-subscribe' != $_GET['doit']) {
    // sanity check
    bb_die(__('What are you trying to do, exactly?'));
}
if (!bb_is_subscriptions_active()) {
    bb_die(__('You can not subscribe to topics.'));
}
if (!isset($_GET['topic_id'])) {
    bb_die(__('Missing topic ID!'));
}
bb_auth('logged_in');
$topic_id = (int) $_GET['topic_id'];
$topic = get_topic($topic_id);
if (!$topic) {
    bb_die(__('Topic not found! What are you subscribing to?'));
}
bb_check_admin_referer('toggle-subscribe_' . $topic_id);
// Okay, we should be covered now
if (in_array($_GET['and'], array('add', 'remove'))) {
    bb_subscription_management($topic->topic_id, $_GET['and']);
}
nxt_redirect(get_topic_link($topic_id, 1));
exit;
Exemple #23
0
function get_socialit()
{
    global $socialit_plugopts, $bbdb, $public_tags, $socialit_is_mobile, $socialit_is_bot;
    $dont_get_si = false;
    $topic = get_topic(get_topic_id());
    if (class_exists('Support_Forum') && $topic) {
        //compatibility with Support Forum plugin for bbPress
        $support_forum = new Support_Forum();
        if ($support_forum->isActive() && in_array($topic->forum_id, $support_forum->enabled)) {
            if ($socialit_plugopts['sfpnonres'] == "no" && $support_forum->getTopicStatus() == "no" || $socialit_plugopts['sfpres'] == "no" && $support_forum->getTopicStatus() == "yes" || $socialit_plugopts['sfpnonsup'] == "no" && $support_forum->getTopicStatus() == "mu") {
                $dont_get_si = true;
            }
        }
    }
    if ($socialit_plugopts['mobile-hide'] == 'yes' && ($socialit_is_mobile || $socialit_is_bot)) {
        $dont_get_si = true;
    }
    if (bb_is_topic() && bb_get_topicmeta($topic->topic_id, 'hide_socialit') == true) {
        $dont_get_si = true;
    }
    if (!$dont_get_si) {
        if (bb_is_topic()) {
            $perms = urlencode(get_topic_link());
            $title = get_topic_title();
            $feedperms = strtolower($perms);
            // Grab post tags for Twittley tags. If there aren't any, use default tags set in plugin options page
            $get_tags = bb_get_topic_tags(get_topic_id());
            if ($get_tags) {
                foreach ($get_tags as $tag) {
                    $keywords = $keywords . $tag->name . ',';
                }
            }
            $topic_id_ft = get_topic_id();
            //topic id for getting text
            $first_post = (int) $bbdb->get_var("SELECT post_id FROM {$bbdb->posts} WHERE topic_id = {$topic_id_ft} ORDER BY post_id ASC LIMIT 1");
            $socialit_content = get_post_text($first_post);
        } else {
            $perms = socialit_get_current_url();
            $title = bb_get_title();
            $feedperms = strtolower($perms);
            $socialit_content = bb_get_option('description');
        }
        if (strlen($title) >= 80) {
            $short_title = urlencode(substr($title, 0, 80) . "[..]");
        } else {
            $short_title = urlencode($title);
        }
        $title = urlencode($title);
        $site_name = bb_get_option('name');
        $socialit_content = urlencode(substr(strip_tags(strip_shortcodes($socialit_content)), 0, 300));
        $socialit_content = socialit_change_plus_apos($socialit_content);
        $mail_subject = socialit_change_plus_apos($title);
        $post_summary = stripslashes($socialit_content);
        if (!empty($keywords)) {
            $d_tags = $keywords;
        } else {
            $d_tags = $socialit_plugopts['defaulttags'];
        }
        $site_name = bb_get_option('name');
        $y_cat = $socialit_plugopts['ybuzzcat'];
        $y_med = $socialit_plugopts['ybuzzmed'];
        $t_cat = $socialit_plugopts['twittcat'];
        $short_url = socialit_get_fetch_url();
        $current_rss_link = socialit_get_current_rss_link();
        // Temporary fix for bug that breaks layout when using NextGen Gallery plugin
        if (strpos($post_summary, '[') || strpos($post_summary, ']')) {
            $post_summary = "";
        }
        if (strpos($socialit_content, '[') || strpos($socialit_content, ']')) {
            $socialit_content = "";
        }
        // select the background
        if (!isset($socialit_plugopts['bgimg-yes'])) {
            $bgchosen = '';
        } elseif ($socialit_plugopts['bgimg'] == 'sexy') {
            $bgchosen = ' social-it-bg-sexy';
        } elseif ($socialit_plugopts['bgimg'] == 'caring') {
            $bgchosen = ' social-it-bg-caring';
        } elseif ($socialit_plugopts['bgimg'] == 'care-old') {
            $bgchosen = ' social-it-bg-caring-old';
        } elseif ($socialit_plugopts['bgimg'] == 'love') {
            $bgchosen = ' social-it-bg-love';
        } elseif ($socialit_plugopts['bgimg'] == 'wealth') {
            $bgchosen = ' social-it-bg-wealth';
        } elseif ($socialit_plugopts['bgimg'] == 'enjoy') {
            $bgchosen = ' social-it-bg-enjoy';
        }
        $style = $socialit_plugopts['autocenter'] ? '' : ' style="' . __($socialit_plugopts['xtrastyle']) . '"';
        $isfeed = bb_is_feed();
        if ($isfeed) {
            $style = '';
        }
        // do not add inline styles to the feed.
        $expand = $socialit_plugopts['expand'] ? ' social-it-expand' : '';
        if ($socialit_plugopts['autocenter'] == 1) {
            $autocenter = ' social-it-center';
        } elseif ($socialit_plugopts['autocenter'] == 2) {
            $autocenter = ' social-it-spaced';
        } else {
            $autocenter = '';
        }
        //write the menu
        $socials = "\n\n" . '<!-- Start Of Code Generated By Social It Plugin By www.gaut.am -->' . "\n" . '<div class="social-it' . $expand . $autocenter . $bgchosen . '"' . $style . '><ul class="socials">';
        foreach ($socialit_plugopts['bookmark'] as $name) {
            if ($name == 'socialit-twitter') {
                $socials .= bookmark_list_item($name, array('post_by' => !empty($socialit_plugopts['twittid']) ? "(via+@" . $socialit_plugopts['twittid'] . ")" : '', 'short_title' => $short_title, 'fetch_url' => $short_url));
            } elseif ($name == 'socialit-mail') {
                $socials .= bookmark_list_item($name, array('title' => $mail_subject, 'post_summary' => $post_summary, 'permalink' => $perms));
            } elseif ($name == 'socialit-diigo') {
                $socials .= bookmark_list_item($name, array('socialit_teaser' => $socialit_content, 'permalink' => $perms, 'title' => $title));
            } elseif ($name == 'socialit-linkedin') {
                $socials .= bookmark_list_item($name, array('post_summary' => $post_summary, 'site_name' => $site_name, 'permalink' => $perms, 'title' => $title));
            } elseif ($name == 'socialit-comfeed') {
                $socials .= bookmark_list_item($name, array('permalink' => $current_rss_link));
            } elseif ($name == 'socialit-yahoobuzz') {
                $socials .= bookmark_list_item($name, array('permalink' => $perms, 'title' => $title, 'yahooteaser' => $socialit_content, 'yahoocategory' => $y_cat, 'yahoomediatype' => $y_med));
            } elseif ($name == 'socialit-twittley') {
                $socials .= bookmark_list_item($name, array('permalink' => urlencode($perms), 'title' => $title, 'post_summary' => $post_summary, 'twitt_cat' => $t_cat, 'default_tags' => $d_tags));
            } else {
                $socials .= bookmark_list_item($name, array('post_summary' => $post_summary, 'permalink' => $perms, 'title' => $title));
            }
        }
        $socials .= '</ul><div style="clear:both;"></div></div><!-- End Of Code Generated By Social It Plugin By www.gaut.am -->' . "\n\n";
        return $socials;
    }
}
Exemple #24
0
            global $bb_post;
            $bb_post = $object['data'];
            ?>
			<li>
<?php 
            printf(__('<a href="%1$s">Post</a> on <a href="%2$s">%3$s</a> by <a href="%4$s">%5$s</a>'), esc_attr(add_query_arg('view', 'all', get_post_link())), get_topic_link($bb_post->topic_id), get_topic_title($bb_post->topic_id), get_user_profile_link($bb_post->poster_id), get_post_author());
            ?>
			</li>
			<?php 
        } elseif ('topic' == $object['type']) {
            global $topic;
            $topic = $object['data'];
            ?>
			<li>
<?php 
            printf(__('Topic titled <a href="%1$s">%2$s</a> started by <a href="%3$s">%4$s</a>'), esc_attr(add_query_arg('view', 'all', get_topic_link())), get_topic_title(), get_user_profile_link($topic->topic_poster), get_topic_author());
            ?>
			</li>
			<?php 
        }
    }
    remove_filter('get_topic_where', 'bb_no_where');
    ?>
		</ul>
		<?php 
} else {
    ?>
		<p>
			<?php 
    _e('No moderated posts or topics&#8230; you must have very well behaved members.');
    ?>
function bb_repermalink()
{
    global $page;
    $location = bb_get_location();
    $uri = $_SERVER['REQUEST_URI'];
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    } else {
        $id = bb_get_path();
    }
    $_original_id = $id;
    do_action('pre_permalink', $id);
    $id = apply_filters('bb_repermalink', $id);
    switch ($location) {
        case 'front-page':
            $path = null;
            $querystring = null;
            if ($page > 1) {
                if (bb_get_option('mod_rewrite')) {
                    $path = 'page/' . $page;
                } else {
                    $querystring = array('page' => $page);
                }
            }
            $permalink = bb_get_uri($path, $querystring, BB_URI_CONTEXT_HEADER);
            $issue_404 = true;
            break;
        case 'forum-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $forum_id, $forum;
            $forum = bb_get_forum($id);
            $forum_id = $forum->forum_id;
            $permalink = get_forum_link($forum->forum_id, $page);
            break;
        case 'topic-edit-page':
        case 'topic-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $topic_id, $topic;
            $topic = get_topic($id);
            $topic_id = $topic->topic_id;
            $permalink = get_topic_link($topic->topic_id, $page);
            break;
        case 'profile-page':
            // This handles the admin side of the profile as well.
            global $user_id, $user, $profile_hooks, $self;
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
            } elseif (isset($_GET['username'])) {
                $id = $_GET['username'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            if (!$id) {
                $user = bb_get_current_user();
                // Attempt to go to the current users profile
            } else {
                if (bb_get_option('mod_rewrite') === 'slugs') {
                    if (!($user = bb_get_user_by_nicename($id))) {
                        $user = bb_get_user($id);
                    }
                } else {
                    if (!($user = bb_get_user($id))) {
                        $user = bb_get_user_by_nicename($id);
                    }
                }
            }
            if (!$user || 1 == $user->user_status && !bb_current_user_can('moderate')) {
                bb_die(__('User not found.'), '', 404);
            }
            $user_id = $user->ID;
            bb_global_profile_menu_structure();
            $valid = false;
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                foreach ($profile_hooks as $valid_tab => $valid_file) {
                    if ($tab == $valid_tab) {
                        $valid = true;
                        $self = $valid_file;
                    }
                }
            }
            if ($valid) {
                $permalink = get_profile_tab_link($user->ID, $tab, $page);
            } else {
                $permalink = get_user_profile_link($user->ID, $page);
                unset($self, $tab);
            }
            break;
        case 'favorites-page':
            $permalink = get_favorites_link();
            break;
        case 'tag-page':
            // It's not an integer and tags.php pulls double duty.
            $id = isset($_GET['tag']) ? $_GET['tag'] : false;
            if (!$id || !bb_get_tag((string) $id)) {
                $permalink = bb_get_tag_page_link();
            } else {
                global $tag, $tag_name;
                $tag_name = $id;
                $tag = bb_get_tag((string) $id);
                $permalink = bb_get_tag_link(0, $page);
                // 0 => grabs $tag from global.
            }
            break;
        case 'view-page':
            // Not an integer
            if (isset($_GET['view'])) {
                $id = $_GET['view'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            global $view;
            $view = $id;
            $permalink = get_view_link($view, $page);
            break;
        default:
            return;
            break;
    }
    nxt_parse_str($_SERVER['QUERY_STRING'], $args);
    $args = urlencode_deep($args);
    if ($args) {
        $permalink = add_query_arg($args, $permalink);
        if (bb_get_option('mod_rewrite')) {
            $pretty_args = array('id', 'page', 'tag', 'tab', 'username');
            // these are already specified in the path
            if ($location == 'view-page') {
                $pretty_args[] = 'view';
            }
            foreach ($pretty_args as $pretty_arg) {
                $permalink = remove_query_arg($pretty_arg, $permalink);
            }
        }
    }
    $permalink = apply_filters('bb_repermalink_result', $permalink, $location);
    $domain = bb_get_option('domain');
    $domain = preg_replace('/^https?/', '', $domain);
    $check = preg_replace('|^.*' . trim($domain, ' /') . '|', '', $permalink, 1);
    $uri = rtrim($uri, " \t\n\r\v?");
    $uri = str_replace('/index.php', '/', $uri);
    global $bb_log;
    $bb_log->debug($uri, 'bb_repermalink() ' . __('REQUEST_URI'));
    $bb_log->debug($check, 'bb_repermalink() ' . __('should be'));
    $bb_log->debug($permalink, 'bb_repermalink() ' . __('full permalink'));
    $bb_log->debug(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null, 'bb_repermalink() ' . __('PATH_INFO'));
    if ($check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri)) {
        if ($issue_404 && rtrim($check, " \t\n\r\v/") !== rtrim($uri, " \t\n\r\v/")) {
            status_header(404);
            bb_load_template('404.php');
        } else {
            nxt_redirect($permalink);
        }
        exit;
    }
    do_action('post_permalink', $permalink);
}
 /**
  * Sends a single pingback if a link is found
  *
  * @return integer The number of pingbacks sent
  */
 function send_pingback($topic_id, $post_text)
 {
     if (!$topic_id || !$post_text) {
         return 0;
     }
     // Get all links in the text and add them to an array
     if (!preg_match_all('@<a ([^>]+)>@im', make_clickable($post_text), $post_links)) {
         return 0;
     }
     $_links = array();
     foreach ($post_links[1] as $post_link_attributes) {
         $post_link_attributes = preg_split('@\\s+@im', $post_link_attributes, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($post_link_attributes as $post_link_attribute) {
             if (strpos($post_link_attribute, '=', 1) !== false) {
                 list($_key, $_value) = explode('=', $post_link_attribute, 2);
                 if (strtolower($_key) === 'href') {
                     $_links[] = trim($_value, "'\"");
                 }
             }
         }
     }
     // Get pingbacks which have already been performed from this topic
     $past_pingbacks = bb_get_topicmeta($topic_id, 'pingback_performed');
     $new_pingbacks = array();
     foreach ($_links as $_link) {
         // If it's already been pingbacked, then skip it
         if ($past_pingbacks && in_array($_link, $past_pingbacks)) {
             continue;
         }
         // If it's trying to ping itself, then skip it
         if ($topic = bb_get_topic_from_uri($_link)) {
             if ($topic->topic_id === $topic_id) {
                 continue;
             }
         }
         // Make sure it's a page on a site and not the root
         if (!($_url = parse_url($_link))) {
             continue;
         }
         if (!isset($_url['query'])) {
             if ($_url['path'] == '' || $_url['path'] == '/') {
                 continue;
             }
         }
         // Add the URL to the array of those to be pingbacked
         $new_pingbacks[] = $_link;
     }
     include_once BACKPRESS_PATH . '/class.ixr.php';
     $count = 0;
     foreach ($new_pingbacks as $pingback_to_url) {
         if (!($pingback_endpoint_uri = BB_Pingbacks::get_endpoint_uri($pingback_to_url))) {
             continue;
         }
         // Stop this nonsense after 60 seconds
         @set_time_limit(60);
         // Get the URL to pingback from
         $pingback_from_url = get_topic_link($topic_id);
         // Using a timeout of 3 seconds should be enough to cover slow servers
         $client = new IXR_Client($pingback_endpoint_uri);
         $client->timeout = 3;
         $client->useragent .= ' -- bbPress/' . bb_get_option('version');
         // When set to true, this outputs debug messages by itself
         $client->debug = false;
         // If successful or the ping already exists then add to the pingbacked list
         if ($client->query('pingback.ping', $pingback_from_url, $pingback_to_url) || isset($client->error->code) && 48 == $client->error->code) {
             $count++;
             $past_pingbacks[] = $pingback_to_url;
         }
     }
     bb_update_topicmeta($topic_id, 'pingback_performed', $past_pingbacks);
     return $count;
 }
<?php

require 'admin-action.php';
$topic_id = (int) $_GET['id'];
$topic = get_topic($topic_id);
if (!$topic) {
    bb_die(__('There is a problem with that topic, pardner.'));
}
if (!bb_current_user_can('close_topic', $topic_id)) {
    nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    exit;
}
bb_check_admin_referer('close-topic_' . $topic_id);
if (topic_is_open($topic_id)) {
    bb_close_topic($topic_id);
    $message = 'closed';
} else {
    bb_open_topic($topic_id);
    $message = 'opened';
}
if ($sendto = nxt_get_referer()) {
    $sendto = remove_query_arg('message', $sendto);
    $sendto = add_query_arg('message', $message, $sendto);
} else {
    $sendto = get_topic_link($topic_id);
}
bb_safe_redirect($sendto);
exit;
Exemple #28
0
function mass_edit_list_posts()
{
    global $bb_posts, $bb_post;
    if ($bb_posts) {
        foreach ($bb_posts as $bb_post) {
            ?>
	<li<?php 
            alt_class('post');
            ?>
>
		<div class="threadauthor">
			<p><strong><?php 
            poster_id_link();
            ?>
</strong><br />
				<small><?php 
            poster_id_type();
            ?>
</small></p>
		</div>
		<div class="threadpost">
			<div class="post"><?php 
            post_text();
            ?>
</div>
			<div class="poststuff">
				<?php 
            printf(__('Posted: %1$s in <a href="%2$s">%3$s</a>'), bb_get_post_time(), get_topic_link($bb_post->topic_id), get_topic_title($bb_post->topic_id));
            ?>
 IP: <?php 
            post_ip_link();
            ?>
 <?php 
            post_edit_link();
            ?>
 <?php 
            post_delete_link();
            ?>
</div>
			</div>
	</li><?php 
        }
    }
}