Esempio n. 1
0
 /**
  * Returns an array of URLs that pingbacked the given URL
  *
  * @since 1.0
  * @link http://www.aquarionics.com/misc/archives/blogite/0198.html
  * @return array The array of URLs that pingbacked the given topic
  * @param array $args Arguments passed by the XML-RPC call
  * @param string $args[0] The full URI of the post where the pingback is being sent from
  * @param string $args[1] The full URI of the post where the pingback is being sent to
  *
  * XML-RPC request to get all pingbacks on a topic
  * <methodCall>
  *     <methodName>pingback.ping</methodName>
  *     <params>
  *         <param><value><string>http://example.com/2008/08/post-tobe-queried/</string></value></param>
  *     </params>
  * </methodCall>
  */
 function pingback_extensions_getPingbacks($args)
 {
     do_action('bb_xmlrpc_call', 'pingback.extensions.getPingbacks');
     $this->escape($args);
     // Don't accept arrays of arguments
     if (is_array($args)) {
         $this->error = new IXR_Error(404, __('The requested method only accepts one parameter.'));
         return $this->error;
     } else {
         $url = (string) $args;
     }
     // Tidy up ampersands in the URI
     $url = str_replace('&amp;', '&', $url);
     $url = str_replace('&', '&amp;', $url);
     // Check if the URI is in our site
     if (!bb_match_domains($url, bb_get_uri())) {
         // These are not the droids you are looking for
         $this->error = new IXR_Error(0, __('The specified target URL is not on this domain.'));
         return $this->error;
     }
     // Make sure the specified URI is in fact associated with a topic
     if (!($topic = bb_get_topic_from_uri($url))) {
         $this->error = new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'));
         return $this->error;
     }
     // Grab the posts from the topic
     $query = new BB_Query('post', array('topic_id' => $topic_to->topic_id, 'append_meta' => true), 'get_thread');
     $posts_to = $query->results;
     unset($query);
     // Check for pingbacks in the post meta data
     $pingbacks = array();
     foreach ($posts_to as $post) {
         if (isset($post->pingback_uri)) {
             $pingbacks[] = $post->pingback_uri;
         }
     }
     unset($post);
     // This will return an empty array on failure
     return $pingbacks;
 }
Esempio n. 2
0
 }
 bb_check_ajax_referer("delete-post_{$id}");
 $status = (int) $_POST['status'];
 if (!($bb_post = bb_get_post($id))) {
     die('0');
 }
 if ($status == $bb_post->post_status) {
     die('1');
 }
 // We're already there
 if (bb_delete_post($id, $status)) {
     $topic = get_topic($bb_post->topic_id);
     if (0 == $topic->topic_posts) {
         // If we deleted the only post, send back a nxt_Ajax_Response object with a URL to redirect to
         if ($ref = nxt_get_referer()) {
             $ref_topic = bb_get_topic_from_uri($ref);
             if ($ref_topic && $ref_topic->topic_id == $topic->topic_id) {
                 $ref = add_query_arg('view', 'all', $ref);
             }
             if (false === strpos($ref, '#')) {
                 $ref .= "#post-{$bb_post->post_id}";
             }
         } else {
             $ref = add_query_arg('view', 'all', get_post_link($topic->topic_id));
         }
         $x = new nxt_Ajax_Response(array('what' => 'post', 'id' => $bb_post->post_id, 'data' => $ref));
         $x->send();
     }
     die('1');
 }
 break;
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
    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;