コード例 #1
0
 public function beforeSendRepost($param)
 {
     //检测话题的存在性
     $topic = get_topic($param['content']);
     if (isset($topic) && !is_null($topic)) {
         foreach ($topic as $e) {
             $tik = D('Weibo/Topic')->where(array('name' => $e))->find();
             //没有这个话题的时候创建这个话题
             if (!$tik) {
                 D('Weibo/Topic')->add(array('name' => $e));
             }
         }
     }
 }
コード例 #2
0
 public function addTopic(&$content)
 {
     //检测话题的存在性
     $topic = get_topic($content);
     if (isset($topic) && !is_null($topic)) {
         foreach ($topic as $e) {
             $tik = $this->where(array('name' => $e))->find();
             //没有这个话题的时候创建这个话题
             if (!$tik) {
                 $this->add(array('name' => $e));
             }
         }
     }
 }
コード例 #3
0
ファイル: parse.php プロジェクト: xiaolw/wacms
function parse_topic($content)
{
    //找出话题
    $topic = get_topic($content);
    //将##替换成链接
    foreach ($topic as $e) {
        $tik = D('Weibo/Topic')->where(array('name' => $e))->find();
        //没有这个话题的时候创建这个话题
        if ($tik) {
            //D('Weibo/Topic')->add(array('name'=> $e));
            $space_url = U('Weibo/Topic/index', array('topk' => urlencode($e)));
            $content = str_replace("#{$e}#", "<a  href=\"{$space_url}\" target=\"_blank\">#{$e}# </a>", $content);
        }
    }
    //返回替换的文本
    return $content;
}
コード例 #4
0
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);
        }
    }
}
コード例 #5
0
ファイル: tag-add.php プロジェクト: nxtclass/NXTClass
<?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);
if (!($topic = get_topic($topic_id))) {
    bb_die(__('Topic not found.'));
}
if (bb_add_topic_tags($topic_id, $tag)) {
    nxt_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;
コード例 #6
0
/**
 * When a new forum topic or post is posted in bbPress, either:
 * 	1) Send emails to all group subscribers
 *	2) Prepares to record it for digest purposes - see {@link ass_group_forum_record_digest()}.
 *
 * Hooks into the bbPress action - 'bb_new_post' - to easily identify new forum posts vs edits.
 */
function ass_group_notification_forum_posts($post_id)
{
    global $bp, $wpdb;
    $post = bb_get_post($post_id);
    // Check to see if user has been registered long enough
    if (!ass_registered_long_enough($post->poster_id)) {
        return;
    }
    $topic = get_topic($post->topic_id);
    $group = groups_get_current_group();
    // if the current group isn't available, grab it
    if (empty($group)) {
        // get the group ID by looking up the forum ID in the groupmeta table
        $group_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT group_id\n\t\t\t\tFROM {$bp->groups->table_name_groupmeta}\n\t\t\t\tWHERE meta_key = %s\n\t\t\t\tAND meta_value = %d\n\t\t\t", 'forum_id', $topic->forum_id));
        // now get the group
        $group = groups_get_group(array('group_id' => $group_id));
    }
    $primary_link = trailingslashit(bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug);
    $blogname = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . ']';
    $is_topic = false;
    // initialize faux activity object for backpat filter reasons
    //
    // due to r-a-y being an idiot here:
    // https://github.com/boonebgorges/buddypress-group-email-subscription/commit/526b80c617fe9058a859ac4eb4cfb1d42d333aa0
    //
    // because we moved the email recording process to 'bb_new_post' from the BP activity save hook,
    // we need to ensure that 3rd-party code will continue to work as-is
    //
    // we can't add the 'id' because we're firing the filters before the activity item is created :(
    $activity = new stdClass();
    $activity->user_id = $post->poster_id;
    $activity->component = 'groups';
    $activity->item_id = $group->id;
    $activity->content = $post->post_text;
    // this is a new topic
    if ($post->post_position == 1) {
        $is_topic = true;
        // more faux activity items!
        $activity->type = 'new_forum_topic';
        $activity->secondary_item_id = $topic->topic_id;
        $activity->primary_link = $primary_link;
        $action = $activity->action = sprintf(__('%s started the forum topic "%s" in the group "%s"', 'bp-ass'), bp_core_get_user_displayname($post->poster_id), $topic->topic_title, $group->name);
        $subject = apply_filters('bp_ass_new_topic_subject', $action . ' ' . $blogname, $action, $blogname);
        $the_content = apply_filters('bp_ass_new_topic_content', $post->post_text, $activity, $topic, $group);
    } else {
        // more faux activity items!
        $activity->type = 'new_forum_post';
        $activity->secondary_item_id = $post_id;
        $action = $activity->action = sprintf(__('%s replied to the forum topic "%s" in the group "%s"', 'bp-ass'), bp_core_get_user_displayname($post->poster_id), $topic->topic_title, $group->name);
        // calculate the topic page for pagination purposes
        $pag_num = apply_filters('bp_ass_topic_pag_num', 15);
        $page = ceil($topic->topic_posts / $pag_num);
        if ($page > 1) {
            $primary_link .= '?topic_page=' . $page;
        }
        $primary_link .= "#post-" . $post_id;
        $activity->primary_link = $primary_link;
        $subject = apply_filters('bp_ass_forum_reply_subject', $action . ' ' . $blogname, $action, $blogname);
        $the_content = apply_filters('bp_ass_forum_reply_content', $post->post_text, $activity, $topic, $group);
    }
    // Convert entities and do other cleanup
    $the_content = ass_clean_content($the_content);
    // if group is not public, change primary link to login URL to verify
    // authentication and for easier redirection after logging in
    if ($group->status != 'public') {
        $primary_link = ass_get_login_redirect_url($primary_link, 'legacy_forums_view');
        $text_before_primary = __('To view or reply to this topic, go to:', 'bp-ass');
        // if public, show standard text
    } else {
        $text_before_primary = __('To view or reply to this topic, log in and go to:', 'bp-ass');
    }
    // setup the email meessage
    $message = sprintf(__('%s

"%s"

%s
%s

---------------------
', 'bp-ass'), $action . ':', $the_content, $text_before_primary, $primary_link);
    // get subscribed users
    $subscribed_users = groups_get_groupmeta($group->id, 'ass_subscribed_users');
    // do this for forum replies only
    if (!$is_topic) {
        // pre-load these arrays to reduce db calls in the loop
        $ass_replies_to_my_topic = ass_user_settings_array('ass_replies_to_my_topic');
        $ass_replies_after_me_topic = ass_user_settings_array('ass_replies_after_me_topic');
        $previous_posters = ass_get_previous_posters($post->topic_id);
        // make sure manually-subscribed topic users and regular group subscribed users are combined
        $user_topic_status = groups_get_groupmeta($group->id, 'ass_user_topic_status_' . $topic->topic_id);
        if (!empty($subscribed_users) && !empty($user_topic_status)) {
            $subscribed_users = $subscribed_users + $user_topic_status;
        }
        // consolidate the arrays to speed up processing
        foreach (array_keys($previous_posters) as $previous_poster) {
            if (empty($subscribed_users[$previous_poster])) {
                $subscribed_users[$previous_poster] = 'prev-post';
            }
        }
    }
    // setup our temporary GES object
    $bp->ges = new stdClass();
    $bp->ges->items = array();
    // digest key iterator
    $d = 0;
    // now let's either send the email or record it for digest purposes
    foreach ((array) $subscribed_users as $user_id => $group_status) {
        $self_notify = '';
        // Does the author want updates of their own forum posts?
        if ($user_id == $post->poster_id) {
            $self_notify = ass_self_post_notification($user_id);
            // Author does not want notifications of their own posts
            if (!$self_notify) {
                continue;
            }
        }
        $send_it = $notice = false;
        // default settings link
        $settings_link = ass_get_login_redirect_url(trailingslashit(bp_get_group_permalink($group) . 'notifications'), 'legacy_forums_settings');
        // Self-notification emails
        if ($self_notify === true) {
            $send_it = true;
            $group_status = 'self_notify';
            // notification settings link
            $settings_link = trailingslashit(bp_core_get_user_domain($user_id) . bp_get_settings_slug()) . 'notifications/';
            // set notice
            $notice = __('You are currently receiving notifications for your own posts.', 'bp-ass');
            $notice .= "\n\n" . sprintf(__('To disable these notifications please log in and go to: %s', 'bp-ass'), $settings_link);
            $notice .= "\n" . __('Once you are logged in, uncheck "Receive notifications of your own posts?".', 'bp-ass');
            // do the following for new topics
        } elseif ($is_topic) {
            if ($group_status == 'sub' || $group_status == 'supersub') {
                $send_it = true;
                $notice .= "\n" . __('Your email setting for this group is: ', 'bp-ass') . ass_subscribe_translate($group_status);
                // until we get a real follow link, this will have to do
                if ($group_status == 'sub') {
                    $notice .= __(", therefore you won't receive replies to this topic. To get them, click the link to view this topic on the web then click the 'Follow this topic' button.", 'bp-ass');
                } elseif ($group_status == 'supersub') {
                    $notice .= "\n" . sprintf(__('To change your email setting for this group, please log in and go to: %s', 'bp-ass'), $settings_link);
                }
                $notice .= "\n\n" . ass_group_unsubscribe_links($user_id);
            }
            // do the following for forum replies
        } else {
            $topic_status = isset($user_topic_status[$user_id]) ? $user_topic_status[$user_id] : '';
            // the topic mute button will override the subscription options below
            if ($topic_status == 'mute') {
                continue;
            }
            // skip if user set to weekly summary and they're not following this topic
            // maybe not neccesary, but good to be cautious
            if ($group_status == 'sum' && $topic_status != 'sub') {
                continue;
            }
            // User's group setting is "All Mail", so we should send this
            if ($group_status == 'supersub') {
                $send_it = true;
                $notice = __('Your email setting for this group is: ', 'bp-ass') . ass_subscribe_translate($group_status);
                $notice .= "\n" . sprintf(__('To change your email setting for this group, please log in and go to: %s', 'bp-ass'), $settings_link);
                $notice .= "\n\n" . ass_group_unsubscribe_links($user_id);
            } elseif ($topic_status == 'sub') {
                $send_it = true;
                $group_status = 'manual_topic';
                // change settings link to the forum thread
                // get rid of any query args and anchors from the thread permalink
                $settings_link = trailingslashit(strtok($primary_link, '?'));
                // let's change the notice to accurately reflect that the user is following this topic
                $notice = sprintf(__('To disable these notifications please log in and go to: %s', 'bp-ass'), $settings_link);
                $notice .= "\n" . __('Once you are logged in, click on the "Mute this topic" button to unsubscribe from the forum thread.', 'bp-ass');
            } elseif ($topic->topic_poster == $user_id && isset($ass_replies_to_my_topic[$user_id]) && $ass_replies_to_my_topic[$user_id] != 'no') {
                $send_it = true;
                $group_status = 'replies_to_my_topic';
                // override settings link to user's notifications
                $settings_link = trailingslashit(bp_core_get_user_domain($user_id) . bp_get_settings_slug()) . 'notifications/';
                // let's change the notice to accurately reflect that the user is receiving replies based on their settings
                $notice = __('You are currently receiving notifications to topics that you have started.', 'bp-ass');
                $notice .= "\n\n" . sprintf(__('To disable these notifications please log in and go to: %s', 'bp-ass'), $settings_link);
                $notice .= "\n" . __('Once you are logged in, uncheck "A member replies in a forum topic you\'ve started".', 'bp-ass');
            } elseif (isset($previous_posters[$user_id]) && isset($ass_replies_after_me_topic[$user_id]) && $ass_replies_after_me_topic[$user_id] != 'no') {
                $send_it = true;
                $group_status = 'replies_after_me_topic';
                // override settings link to user's notifications
                $settings_link = trailingslashit(bp_core_get_user_domain($user_id) . bp_get_settings_slug()) . 'notifications/';
                // let's change the notice to accurately reflect that the user is receiving replies based on their settings
                $notice = __('You are currently receiving notifications to topics that you have replied in.', 'bp-ass');
                $notice .= "\n\n" . sprintf(__('To disable these notifications please log in and go to: %s', 'bp-ass'), $settings_link);
                $notice .= "\n" . __('Once you are logged in, uncheck "A member replies after you in a forum topic".', 'bp-ass');
            }
        }
        // if we're good to send, send the email!
        if ($send_it) {
            // One last chance to filter the message content
            $user_message = apply_filters('bp_ass_forum_notification_message', $message . $notice, array('message' => $message, 'notice' => $notice, 'user_id' => $user_id, 'subscription_type' => $group_status, 'content' => $the_content, 'view_link' => $primary_link, 'settings_link' => $settings_link));
            // Get the details for the user
            $user = bp_core_get_core_userdata($user_id);
            // Send the email
            if ($user->user_email) {
                wp_mail($user->user_email, $subject, $user_message);
            }
        }
        // otherwise if digest or summary, record it!
        // temporarily save some variables to pass to groups_record_activity()
        // actual digest recording occurs in ass_group_forum_record_digest()
        if ($group_status == 'dig' || $is_topic && $group_status == 'sum') {
            $bp->ges->items[$d] = new stdClass();
            $bp->ges->items[$d]->user_id = $user_id;
            $bp->ges->items[$d]->group_id = $group->id;
            $bp->ges->items[$d]->group_status = $group_status;
            // iterate our key value
            ++$d;
        }
        unset($notice);
    }
}
コード例 #7
0
ファイル: profile.php プロジェクト: laiello/cartonbank
<h3 id="useractivity"><?php 
_e('User Activity');
?>
</h3>

<div id="user-replies" class="user-recent"><h4><?php 
_e('Recent Replies');
?>
</h4>
<?php 
if ($posts) {
    ?>
<ol>
<?php 
    foreach ($posts as $bb_post) {
        $topic = get_topic($bb_post->topic_id);
        ?>
<li<?php 
        alt_class('replies');
        ?>
>
	<a href="<?php 
        topic_link();
        ?>
"><?php 
        topic_title();
        ?>
</a> -
	<?php 
        if ($user->ID == bb_get_current_user_info('id')) {
            printf(__('You last replied: %s ago'), bb_get_post_time());
コード例 #8
0
<?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;
コード例 #9
0
ファイル: akismet.php プロジェクト: laiello/cartonbank
function bb_ksd_new_post($post_id)
{
    global $bb_ksd_pre_post_status;
    if ('2' != $bb_ksd_pre_post_status) {
        return;
    }
    $bb_post = bb_get_post($post_id);
    $topic = get_topic($bb_post->topic_id);
    if (0 == $topic->topic_posts) {
        bb_delete_topic($topic->topic_id, 2);
    }
}
コード例 #10
0
ファイル: function.php プロジェクト: ccccy/wuanlife
function parse_topic($content)
{
    //找出话题
    $topic = get_topic($content);
    //将##替换成链接
    foreach ($topic as $e) {
        $tik = D('Weibo/Topic')->where(array('name' => $e))->find();
        //没有这个话题的时候创建这个话题
        if ($tik) {
            //D('Weibo/Topic')->add(array('name'=> $e));
            $space_url = U('Weibo/Topic/index', array('topk' => urlencode($e)));
            if (modC('HIGH_LIGHT_TOPIC', 1, 'Weibo')) {
                $content = str_replace("#{$e}#", " <a class='label label-badge label-info'  href=\"{$space_url}\" target=\"_blank\">#{$e}# </a> ", $content);
            } else {
                $content = str_replace("#{$e}#", " <a href=\"{$space_url}\" target=\"_blank\">#{$e}# </a> ", $content);
            }
        }
    }
    //返回替换的文本
    return $content;
}
コード例 #11
0
/**
 * bb_get_topic_tags() - Returns all of the bb_topic_tags associated with the specified topic.
 *
 * @param int $topic_id
 * @param mixed $args
 * @return array|false Term objects (back-compat), false on failure
 */
function bb_get_topic_tags($topic_id = 0, $args = null)
{
    global $wp_taxonomy_object;
    if (!($topic = get_topic(get_topic_id($topic_id)))) {
        return false;
    }
    $topic_id = (int) $topic->topic_id;
    $cache_id = $topic_id . serialize($args);
    $terms = wp_cache_get($cache_id, 'bb_topic_tag_terms');
    if (false === $terms) {
        $terms = $wp_taxonomy_object->get_object_terms((int) $topic->topic_id, 'bb_topic_tag', $args);
        wp_cache_set($cache_id, $terms, 'bb_topic_tag_terms');
    }
    if (is_wp_error($terms)) {
        return false;
    }
    for ($i = 0; isset($terms[$i]); $i++) {
        _bb_make_tag_compat($terms[$i]);
    }
    return $terms;
}
コード例 #12
0
function bb_add_user_favorite($user_id, $topic_id)
{
    global $bbdb;
    $user_id = (int) $user_id;
    $topic_id = (int) $topic_id;
    $user = bb_get_user($user_id);
    $topic = get_topic($topic_id);
    if (!$user || !$topic) {
        return false;
    }
    $favorites_key = $bbdb->prefix . 'favorites';
    $fav = $user->{$favorites_key} ? explode(',', $user->{$favorites_key}) : array();
    if (!in_array($topic_id, $fav)) {
        $fav[] = $topic_id;
        $fav = implode(',', $fav);
        bb_update_usermeta($user->ID, $favorites_key, $fav);
    }
    do_action('bb_add_user_favorite', $user_id, $topic_id);
    return true;
}
コード例 #13
0
ファイル: phpfunction.php プロジェクト: ronak2ram/fnji
        $page_no_var = $var;
        //get the current Page from URL
    }
}
//--increment views of poem--//
$update_poem = view_increment($database, $poem_id);
//--get poem information--//
$get_poem = get_poem($database, $poem_id);
//--get topic information--//
if ($get_poem['topic_id']) {
    $poem_topics_array = array();
    //get topic ids as array
    $poem_topics = unserialize($get_poem['topic_id']);
    foreach ($poem_topics as $poem_topic_id) {
        if (!array_key_exists($poem_topic_id, $poem_topics_array)) {
            $poem_topic_array[$poem_topic_id] = get_topic($database, $poem_topic_id);
        }
    }
    $get_poem['topic_id'] = $poem_topic_array;
}
//--get author information--//
// $author_id = $get_poem['author_id'];
// if($get_poem['author_id']){
//     $get_poem['author_id'] = get_author($database, $get_poem['author_id']);
//     $tpl->author_info = $get_poem['author_id'];
//     //get_user_info
//       //  submitter_id
// }
$submitter_id = $get_poem['submitter_id'];
if ($get_poem['submitter_id']) {
    $data = get_user_info($database, $get_poem['submitter_id']);
コード例 #14
0
ファイル: export.php プロジェクト: nxtclass/NXTClass-Plugin
function bb_export_topic_posts($r, $topic_id)
{
    if (!get_topic($topic_id)) {
        return;
    }
    $r .= "\n";
    $page = 1;
    while ($posts = get_thread($topic_id, array('post_status' => 'all', 'page' => $page++))) {
        foreach ($posts as $post) {
            $r .= bb_export_post($post->post_id);
        }
    }
    return $r;
}
コード例 #15
0
ファイル: blocklist.php プロジェクト: achorg/DH-Answers
function blocklist_check($post_id = 0, $wall = false)
{
    if (bb_current_user_can('moderate') || bb_current_user_can('throttle')) {
        return;
    }
    if ($wall) {
        $bb_post = user_wall_get_post($post_id);
    } else {
        $bb_post = bb_get_post($post_id);
    }
    if (empty($post_id) || empty($bb_post) || !empty($bb_post->post_status)) {
        return;
    }
    global $blocklist, $bbdb;
    blocklist_initialize();
    if (empty($blocklist['data'])) {
        return;
    }
    (array) ($data = explode("\r\n", $blocklist['data']));
    $user = bb_get_user($bb_post->poster_id);
    foreach ($data as $item) {
        if (empty($item) || strlen($item) < 4 || ord($item) == 35) {
            continue;
        }
        if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $item)) {
            // is IP
            if (strpos($bb_post->poster_ip, $item) === 0) {
                $found = "IP address";
                $bad = $item;
                break;
            }
        } else {
            // is word
            $qitem = preg_quote($item);
            if (preg_match('/\\b' . $qitem . '/simU', $user->user_email)) {
                $found = "email";
                $bad = $item;
                break;
            }
            if (preg_match('/\\b' . $qitem . '/simU', $user->user_login)) {
                $found = "username";
                $bad = $item;
                break;
            }
            if (preg_match('/\\b' . $qitem . '/simU', $bb_post->post_text)) {
                $found = "post text";
                $bad = $item;
                break;
            } elseif (!$wall && $bb_post->post_position == 1) {
                if (empty($topic)) {
                    $topic = get_topic($bb_post->topic_id);
                }
                if (!empty($topic->topic_title) && preg_match('/\\b' . $qitem . '/simU', $topic->topic_title)) {
                    $found = "topic title";
                    $bad = $item;
                    break;
                }
            }
        }
        if (!empty($bad)) {
            break;
        }
    }
    if (!empty($bad)) {
        if ($wall) {
            user_wall_delete_post($post_id, 2);
            $uri = bb_get_option('uri') . "bb-admin/admin-base.php?post_status=2&plugin=user_wall_admin&user-wall-recent=1";
        } else {
            bb_delete_post($post_id, 2);
            if (empty($topic)) {
                $topic = get_topic($bb_post->topic_id);
            }
            if (empty($topic->topic_posts)) {
                bb_delete_topic($topic->topic_id, 2);
            }
            // if no posts in topic, also set topic to spam
            $uri = bb_get_option('uri') . 'bb-admin/' . (defined('BACKPRESS_PATH') ? '' : 'content-') . 'posts.php?post_status=2';
        }
        if (empty($blocklist['email'])) {
            return;
        }
        (array) ($email = explode("\r\n", $blocklist['email']));
        $message = "The blocklist has been triggered... \r\n\r\n";
        $message .= "Matching entry " . '"' . $bad . '"' . " found in {$found}.\r\n";
        $message .= "{$uri}\r\n\r\n";
        $message .= sprintf(__('Username: %s'), stripslashes($user->user_login)) . "\r\n";
        $message .= sprintf(__('Profile: %s'), get_user_profile_link($user->ID)) . "\r\n";
        $message .= sprintf(__('Email: %s'), stripslashes($user->user_email)) . "\r\n";
        $message .= sprintf(__('IP address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n";
        $message .= sprintf(__('Agent: %s'), substr(stripslashes($_SERVER["HTTP_USER_AGENT"]), 0, 255)) . "\r\n\r\n";
        foreach ($email as $to) {
            if (empty($to) || strlen($to) < 8) {
                continue;
            }
            @bb_mail($to, "[" . bb_get_option('name') . "] blocklist triggered", $message);
        }
    }
}
コード例 #16
0
/**
 * Updates user's subscription status in database.
 *
 * Gets user's new subscription status for topic and
 * adds new status to database.
 *
 * @since 1.1
 *
 * @param int $topic_id ID of topic for subscription
 * @param string $new_status New subscription status
 * @param int $user_id Optional. ID of user for subscription
 */
function bb_subscription_management($topic_id, $new_status, $user_id = '')
{
    global $bbdb, $nxt_taxonomy_object;
    $topic = get_topic($topic_id);
    if (!$user_id) {
        $user_id = bb_get_current_user_info('id');
    }
    do_action('bb_subscripton_management', $topic_id, $new_status, $user_id);
    switch ($new_status) {
        case 'add':
            $tt_ids = $nxt_taxonomy_object->set_object_terms($user_id, 'topic-' . $topic->topic_id, 'bb_subscribe', array('append' => true, 'user_id' => $user_id));
            break;
        case 'remove':
            // I hate this with the passion of a thousand suns
            $term_id = $bbdb->get_var("SELECT term_id FROM {$bbdb->terms} WHERE slug = 'topic-{$topic->topic_id}'");
            $term_taxonomy_id = $bbdb->get_var("SELECT term_taxonomy_id FROM {$bbdb->term_taxonomy} WHERE term_id = {$term_id} AND taxonomy = 'bb_subscribe'");
            $bbdb->query("DELETE FROM {$bbdb->term_relationships} WHERE object_id = {$user_id} AND term_taxonomy_id = {$term_taxonomy_id}");
            $bbdb->query("DELETE FROM {$bbdb->term_taxonomy} WHERE term_id = {$term_id} AND taxonomy = 'bb_subscribe'");
            break;
    }
}
コード例 #17
0
/**
 * @since 1.0.3
 * it is not used any more because qwe are linking to threaded view
 * Remove notification for group forum posts/new topic
 */
function ac_notifier_remove_notification_for_topic()
{
    global $bp;
    //is group & group forum active ?
    if (!(bp_is_active("groups") && bp_is_active("forums"))) {
        return;
    }
    //if either group or forum is not actuive do not do anything
    //check if we are on single topic screen, right?
    if (bp_is_group_forum_topic() && is_user_logged_in()) {
        $topic_id = bp_forums_get_topic_id_from_slug($bp->action_variables[1]);
        //get id from slug
        $topic = get_topic($topic_id);
        $group_id = $bp->groups->current_group->id;
        //find activity id for this topic
        $activity_id = bp_activity_get_activity_id(array('user_id' => $topic->poster_id, 'component' => $bp->groups->id, 'type' => "new_forum_topic", "item_id" => $group_id, 'secondary_item_id' => $topic_id));
        //remove notification for new topic comments: easy
        if (!empty($activity_id)) {
            bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $activity_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id);
        }
        $posts = ac_notifier_get_forum_post_ids($topic_id);
        if (!empty($posts)) {
            //find all activities for the post
            $activities = ac_notifier_get_activity_ids(array("item_id" => $group_id, "secondary_ids" => $posts, "component" => $bp->groups->id, "type" => "new_forum_post"));
            //pass the array
            foreach ((array) $activities as $ac_id) {
                bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $ac_id, $bp->ac_notifier->id, 'new_activity_comment_' . $ac_id);
            }
        }
    }
}
コード例 #18
0
function bb_get_tag_remove_link($args = null)
{
    if (is_scalar($args) || is_object($args)) {
        $args = array('tag' => $args);
    }
    $defaults = array('tag' => 0, 'topic' => 0, 'list_id' => 'tags-list');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if (is_object($tag) && isset($tag->tag_id)) {
    } elseif (!($tag = bb_get_tag(bb_get_tag_id($tag)))) {
        return false;
    }
    if (!($topic = get_topic(get_topic_id($topic)))) {
        return false;
    }
    if (!bb_current_user_can('edit_tag_by_on', $tag->user_id, $topic->topic_id)) {
        return false;
    }
    $url = bb_get_uri('tag-remove.php', array('tag' => $tag->tag_id, 'user' => $tag->user_id, 'topic' => $topic->topic_id));
    $url = esc_url(bb_nonce_url($url, 'remove-tag_' . $tag->tag_id . '|' . $topic->topic_id));
    $title = esc_attr__('Remove this tag');
    $list_id = esc_attr($list_id);
    return "[<a href='{$url}' class='delete:{$list_id}:tag-{$tag->tag_id}_{$tag->user_id}' title='{$title}'>&times;</a>]";
}
コード例 #19
0
 function get_topic($topic_id, $use_cache = true)
 {
     bb_log_deprecated('class::function', __CLASS__ . '::' . __FUNCTION__, 'get_topic');
     return get_topic($topic_id, $use_cache);
 }
コード例 #20
0
ファイル: find_aiml.php プロジェクト: ramdesh/Program-O
/**
 * function find_aiml_matches()
 * This function builds the sql to use to get a match from the tbl
 * @param array $convoArr - conversation array
 * @return array $convoArr
 **/
function find_aiml_matches($convoArr)
{
    global $dbConn, $dbn, $error_response, $use_parent_bot;
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Finding the aiml matches from the DB", 4);
    $i = 0;
    //TODO convert to get_it
    $bot_id = $convoArr['conversation']['bot_id'];
    $bot_parent_id = $convoArr['conversation']['bot_parent_id'];
    $default_aiml_pattern = $convoArr['conversation']['default_aiml_pattern'];
    #$lookingfor = get_convo_var($convoArr,"aiml","lookingfor");
    $convoArr['aiml']['lookingfor'] = str_replace('  ', ' ', $convoArr['aiml']['lookingfor']);
    $lookingfor = trim(strtoupper($convoArr['aiml']['lookingfor']));
    //get the first and last words of the cleaned user input
    $lastInputWord = get_last_word($lookingfor);
    $firstInputWord = get_first_word($lookingfor);
    //get the stored topic
    $storedtopic = get_topic($convoArr);
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Stored topic = '{$storedtopic}'", 4);
    //get the cleaned user input
    $lastthat = isset($convoArr['that'][1][1]) ? $convoArr['that'][1][1] : '';
    //build like patterns
    if ($lastthat != '') {
        $thatPatternSQL = " OR " . make_like_pattern($lastthat, 'thatpattern');
        $thatPatternSQL = rtrim($thatPatternSQL, ' OR');
    } else {
        $thatPattern = '';
        $thatPatternSQL = '';
    }
    //get the word count
    $word_count = wordsCount_inSentence($lookingfor);
    if ($bot_parent_id != 0 and $bot_parent_id != $bot_id) {
        $sql_bot_select = " (bot_id = '{$bot_id}' OR bot_id = '{$bot_parent_id}') ";
    } else {
        $sql_bot_select = " bot_id = '{$bot_id}' ";
    }
    if (!empty($storedtopic)) {
        $topic_select = "AND (`topic`='' OR `topic`='{$storedtopic}')";
    } else {
        $topic_select = '';
    }
    if ($word_count == 1) {
        //if there is one word do this
        $sql = "SELECT `id`, `pattern`, `thatpattern`, `topic` FROM `{$dbn}`.`aiml` WHERE\n  {$sql_bot_select} AND (\n  `pattern` = '_' OR\n  `pattern` = '*' OR\n  `pattern` = '{$lookingfor}' OR\n  `pattern` = '{$default_aiml_pattern}'\n  {$thatPatternSQL}\n  ) {$topic_select} order by `topic` desc, `pattern` asc, `thatpattern` asc,`id` asc;";
    } else {
        //otherwise do this
        $sql_add = make_like_pattern($lookingfor, 'pattern');
        $sql = "SELECT `id`, `bot_id`, `pattern`, `thatpattern`, `topic` FROM `{$dbn}`.`aiml` WHERE\n  {$sql_bot_select} AND (\n  `pattern` = '_' OR\n  `pattern` = '*' OR\n  `pattern` = '{$lookingfor}' OR {$sql_add} OR\n  `pattern` = '{$default_aiml_pattern}'\n  {$thatPatternSQL}\n  ) {$topic_select}\n  order by `topic` desc, `pattern` asc, `thatpattern` asc,`id` asc;";
    }
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Core Match AIML sql: {$sql}", 3);
    $result = db_fetchAll($sql, null, __FILE__, __FUNCTION__, __LINE__);
    $num_rows = count($result);
    if ($result && $num_rows > 0) {
        $tmp_rows = number_format($num_rows);
        runDebug(__FILE__, __FUNCTION__, __LINE__, "FOUND: ({$num_rows}) potential AIML matches", 2);
        $tmp_content = date('H:i:s') . ": SQL:\n{$sql}\nRows = {$tmp_rows}\n\n";
        //loop through results
        foreach ($result as $row) {
            $row['aiml_id'] = $row['id'];
            $row['bot_id'] = $bot_id;
            $row['score'] = 0;
            $row['track_score'] = '';
            $allrows[] = $row;
            $mu = memory_get_usage(true);
            if ($mu >= MEM_TRIGGER) {
                runDebug(__FILE__, __FUNCTION__, __LINE__, 'Current operation exceeds memory threshold. Aborting data retrieval.', 0);
                break;
            }
        }
    } else {
        runDebug(__FILE__, __FUNCTION__, __LINE__, "Error: FOUND NO AIML matches in DB", 1);
        $allrows[$i]['aiml_id'] = "-1";
        $allrows[$i]['bot_id'] = $bot_id;
        $allrows[$i]['pattern'] = "no results";
        $allrows[$i]['thatpattern'] = '';
        $allrows[$i]['topic'] = '';
    }
    return $allrows;
}
コード例 #21
0
ファイル: xmlrpc.php プロジェクト: nxtclass/NXTClass-Plugin
 /**
  * Removes the specified tags from the specified topic
  *
  * @since 1.0
  * @return integer|object 1 when successfully executed or an IXR_Error object on failure
  * @param array $args Arguments passed by the XML-RPC call
  * @param string $args[0] The username for authentication
  * @param string $args[1] The password for authentication
  * @param string|integer $args[2] The topic id or slug
  * @param string|array $args[3] The tags to remove from the topic
  *
  * XML-RPC request to remove the tag "banana" to the topic with id 219
  * <methodCall>
  *     <methodName>bb.removeTopicTags</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><int>219</int></value></param>
  *         <param><value><string>banana</string></value></param>
  *     </params>
  * </methodCall>
  *
  * XML-RPC request to remove the tags "banana" and "man" to the topic with id 219
  * <methodCall>
  *     <methodName>bb.removeTopicTags</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><int>219</int></value></param>
  *         <param><value><string>banana, man</string></value></param>
  *     </params>
  * </methodCall>
  *
  * XML-RPC request to remove the tags "banana" and "man" to the topic with id 219 using an array
  * <methodCall>
  *     <methodName>bb.removeTopicTags</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><int>219</int></value></param>
  *         <param><value><array>
  *             <data><value><string>banana</string></value></data>
  *             <data><value><string>man</string></value></data>
  *         </array></value></param>
  *     </params>
  * </methodCall>
  */
 function bb_removeTopicTags($args)
 {
     do_action('bb_xmlrpc_call', 'bb.removeTopicTags');
     // Escape args
     $this->escape($args);
     // Get the login credentials
     $username = $args[0];
     $password = (string) $args[1];
     // Check the user is valid
     $user = $this->authenticate($username, $password, 'edit_tags', __('You do not have permission to edit tags.'));
     do_action('bb_xmlrpc_call_authenticated', 'bb.removeTopicTags');
     // If an error was raised by authentication or by an action then return it
     if ($this->error) {
         return $this->error;
     }
     // Can be numeric id or slug
     $topic_id = isset($args[2]) ? $args[2] : false;
     // Check for bad data
     if (!$topic_id || !is_string($topic_id) && !is_integer($topic_id)) {
         $this->error = new IXR_Error(400, __('The topic id is invalid.'));
         return $this->error;
     }
     // Check the requested topic exists
     if (!($topic = get_topic($topic_id))) {
         $this->error = new IXR_Error(400, __('No topic found.'));
         return $this->error;
     }
     // The topic id may have been a slug, so make sure it's an integer here
     $topic_id = (int) $topic->topic_id;
     // Make sure they are allowed to add tags to this topic
     if (!bb_current_user_can('add_tag_to', $topic_id)) {
         $this->error = new IXR_Error(403, __('You do not have permission to remove tags from this topic.'));
         return $this->error;
     }
     $tags = isset($args[3]) ? $args[3] : false;
     // Check for bad data
     if (!$tags || !is_string($tags) && !is_array($tags)) {
         $this->error = new IXR_Error(400, __('The tag data is invalid.'));
         return $this->error;
     }
     // Add the tags
     if (!bb_remove_topic_tags($topic_id, $tags)) {
         $this->error = new IXR_Error(500, __('The tags could not be removed.'));
         return $this->error;
     }
     $result = 1;
     do_action('bb_xmlrpc_call_return', 'bb.removeTopicTags');
     // Return the result
     return $result;
 }
コード例 #22
0
ファイル: bozo.php プロジェクト: laiello/cartonbank
function bb_fermion($user_id, $topic_id = 0)
{
    global $bbdb;
    $user_id = (int) $user_id;
    $topic_id = (int) $topic_id;
    if (!$topic_id) {
        bb_delete_usermeta($user_id, 'is_bozo');
    } else {
        $topic = get_topic($topic_id);
        $user = bb_get_user($user_id);
        if (--$topic->bozos[$user_id] < 1) {
            unset($topic->bozos[$user_id]);
        }
        bb_update_topicmeta($topic_id, 'bozos', $topic->bozos);
        if (--$user->bozo_topics[$topic_id] < 1) {
            unset($user->bozo_topics[$topic_id]);
        }
        bb_update_usermeta($user_id, $bbdb->prefix . 'bozo_topics', $user->bozo_topics);
    }
}
コード例 #23
0
ファイル: functions.php プロジェクト: achorg/DH-Answers
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;
    }
}
コード例 #24
0
function bb_get_topicmeta($topic_id, $meta_key)
{
    if (!($topic = get_topic($topic_id))) {
        return;
    }
    $meta_key = bb_sanitize_meta_key($meta_key);
    if (!isset($topic->{$meta_key})) {
        return;
    }
    return $topic->{$meta_key};
}
コード例 #25
0
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);
}
コード例 #26
0
/**
 * Map meta capabilities to primitive capabilities.
 *
 * This does not actually compare whether the user ID has the actual capability,
 * just what the capability or capabilities are. Meta capability list value can
 * be 'delete_user', 'edit_user', 'delete_post', 'delete_page', 'edit_post',
 * 'edit_page', 'read_post', or 'read_page'.
 *
 * @since 0.7.2
 *
 * @param array $caps Previously existing capabilities
 * @param string $cap Capability name.
 * @param int $user_id User ID.
 * @return array Actual capabilities for meta capability.
 */
function bb_map_meta_cap($caps, $cap, $user_id, $args)
{
    // Unset the meta cap
    if (false !== ($cap_pos = array_search($cap, $caps))) {
        unset($caps[$cap_pos]);
    }
    switch ($cap) {
        case 'write_post':
            $caps[] = 'write_posts';
            break;
        case 'edit_post':
            // edit_posts, edit_others_posts, edit_deleted, edit_closed, ignore_edit_lock
            if (!($bb_post = bb_get_post($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if ($user_id == $bb_post->poster_id) {
                $caps[] = 'edit_posts';
            } else {
                $caps[] = 'edit_others_posts';
            }
            if ($bb_post->post_status == '1') {
                $caps[] = 'edit_deleted';
            }
            if (!topic_is_open($bb_post->topic_id)) {
                $caps[] = 'edit_closed';
            }
            $post_time = bb_gmtstrtotime($bb_post->post_time);
            $curr_time = time() + 1;
            $edit_lock = bb_get_option('edit_lock');
            if ($edit_lock >= 0 && $curr_time - $post_time > $edit_lock * 60) {
                $caps[] = 'ignore_edit_lock';
            }
            break;
        case 'delete_post':
            // edit_deleted, delete_posts
            if (!($bb_post = bb_get_post($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (0 != $bb_post->post_status) {
                $caps[] = 'edit_deleted';
            }
            // NO BREAK
        // NO BREAK
        case 'manage_posts':
            // back compat
            $caps[] = 'delete_posts';
            break;
        case 'write_topic':
            $caps[] = 'write_topics';
            break;
        case 'edit_topic':
            // edit_closed, edit_deleted, edit_topics, edit_others_topics
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($args[0])) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            if ($user_id == $topic->topic_poster) {
                $caps[] = 'edit_topics';
            } else {
                $caps[] = 'edit_others_topics';
            }
            break;
        case 'move_topic':
            $caps[] = 'move_topics';
            break;
        case 'stick_topic':
            $caps[] = 'stick_topics';
            break;
        case 'close_topic':
            $caps[] = 'close_topics';
            break;
        case 'delete_topic':
            $caps[] = 'delete_topics';
            add_filter('get_topic_where', 'bb_no_where', 9999);
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (0 != $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            remove_filter('get_topic_where', 'bb_no_where', 9999);
            break;
        case 'manage_topics':
            // back compat
            $caps[] = 'move_topics';
            $caps[] = 'stick_topics';
            $caps[] = 'close_topics';
            $caps[] = 'delete_topics';
            break;
        case 'add_tag_to':
            // edit_closed, edit_deleted, edit_tags;
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($topic->topic_id)) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            $caps[] = 'edit_tags';
            break;
        case 'edit_tag_by_on':
            // edit_closed, edit_deleted, edit_tags, edit_others_tags
            if (!($topic = get_topic($args[1]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($topic->topic_id)) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            if ($user_id == $args[0]) {
                $caps[] = 'edit_tags';
            } else {
                $caps[] = 'edit_others_tags';
            }
            break;
        case 'edit_user':
            // edit_profile, edit_users;
            if ($user_id == $args[0]) {
                $caps[] = 'edit_profile';
            } else {
                $caps[] = 'edit_users';
            }
            break;
        case 'edit_favorites_of':
            // edit_favorites, edit_others_favorites;
            if ($user_id == $args[0]) {
                $caps[] = 'edit_favorites';
            } else {
                $caps[] = 'edit_others_favorites';
            }
            break;
        case 'delete_forum':
            $caps[] = 'delete_forums';
            break;
        case 'change_user_password':
            // change_password, edit_users
            $caps[] = 'change_password';
            if ($user_id != $args[0]) {
                $caps[] = 'edit_users';
            }
            break;
        default:
            // If no meta caps match, return the original cap.
            $caps[] = $cap;
    }
    return $caps;
}
コード例 #27
0
function topic_is_sticky($topic_id = 0)
{
    $topic = get_topic(get_topic_id($topic_id));
    return '0' !== $topic->topic_sticky;
}
コード例 #28
0
ファイル: rss.php プロジェクト: abc2mit/abc2mit.github.io
         die;
     }
     $topics = $topics_object->results;
     if (!$topics || !is_array($topics)) {
         die;
     }
     $posts = array();
     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);
     }
コード例 #29
0
ファイル: bb-post.php プロジェクト: nxtclass/NXTClass
    $topic_id = (int) $_POST['topic_id'];
    bb_check_admin_referer('create-post_' . $topic_id);
}
if (bb_is_login_required() && !bb_current_user_can('write_post', $topic_id)) {
    bb_die(__('You are not allowed to post.  Are you logged in?'));
}
if (!topic_is_open($topic_id)) {
    bb_die(__('This topic has been closed'));
}
$post_data = array('post_text' => stripslashes($_POST['post_content']), 'topic_id' => $topic_id);
foreach (array('post_author', 'post_email', 'post_url') as $field) {
    if (!empty(${$field})) {
        $post_data[$field] = ${$field};
    }
}
$post_id = bb_insert_post($post_data);
$tags = trim($_POST['tags']);
bb_add_topic_tags($topic_id, $tags);
$topic = get_topic($topic_id, false);
$link = get_post_link($post_id);
if ($topic->topic_posts) {
    $link = add_query_arg('replies', $topic->topic_posts, $link);
}
// This action used to be bb_post.php, changed to avoid conflict in bb_load_template()
do_action('bb-post.php', $post_id);
if ($post_id) {
    nxt_redirect($link);
} else {
    nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
}
exit;
コード例 #30
0
ファイル: best-answer.php プロジェクト: achorg/DH-Answers
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;
}