public function pingAction()
 {
     // We encapsulate xmlrpc, disable everything
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     // Get the request
     $request = Pingback_Utility::getRawPostData();
     $this->_logger->log("Received pingback request: {$request}", Zend_Log::DEBUG);
     // Process the request
     $server = new Pingback_Server();
     $server->execute($request);
     if ($server->isValid()) {
         $source = $server->getSourceURL();
         $target = $server->getTargetURL();
         $this->process($source, $target);
     }
     // Log the response
     $response = $server->getResponse();
     $this->_logger->log("Response: {$response}", Zend_Log::DEBUG);
     // We turn off output buffering to avoid memory issues
     // when dumping the response
     ob_end_flush();
     print $response;
     // Die to make sure that we don't screw up the response
     die;
 }
Example #2
0
 protected function _ping($method, $parameters)
 {
     list($this->_requestSource, $this->_requestTarget) = $parameters;
     $fault = null;
     // is the source argument really an url?
     if (!$fault && !Pingback_Utility::isURL($this->_requestSource)) {
         $fault = self::RESPONSE_FAULT_SOURCE;
     }
     // is the target argument really an url?
     if (!$fault && !Pingback_Utility::isURL($this->_requestTarget)) {
         $fault = self::RESPONSE_FAULT_TARGET;
     }
     // is the target url pingback enabled?
     if (!$fault && !Pingback_Utility::isPingbackEnabled($this->_requestTarget)) {
         $fault = self::RESPONSE_FAULT_TARGET_INVALID;
     }
     // is the source backlinking to the target?
     if (!$fault && !Pingback_Utility::isBacklinking($this->_requestSource, $this->_requestTarget)) {
         $fault = self::RESPONSE_FAULT_SOURCE_LINK;
     }
     if ($fault !== null) {
         $this->setFault($fault);
         return $this->getFaultAsArray($fault);
     } else {
         $this->setSuccess();
         return $this->getSuccessAsArray();
     }
 }
Example #3
0
 private function pingback($item)
 {
     $users = new Users();
     $logger = Zend_Registry::get("logger");
     $username = $this->_application->user->username;
     $userid = $this->_application->user->id;
     $source = $users->getUrl($userid, "entry/" . $item->getSlug());
     $logger->log("Pingback source: " . $source, Zend_Log::DEBUG);
     $logger->log("Item title: " . $item->getTitle(), Zend_Log::DEBUG);
     $logger->log("Item content: " . $item->getContent(), Zend_Log::DEBUG);
     // Search for user to ping
     preg_match_all('/@([a-zA-Z0-9\\-\\.]+)/', $item->getTitle(), $mentions, PREG_SET_ORDER);
     // Ping each user
     foreach ($mentions as $mention) {
         $target = "http://" . $mention[1];
         $url = Pingback_Utility::getPingbackServerURL($target);
         if ($url) {
             $logger->log("Pingback server for " . $mention[1] . ": " . $url, Zend_Log::DEBUG);
             $response = Pingback_Utility::sendPingback($source, $target, $url);
             $logger->log("Pingback response for " . $mention[1] . ": " . $response, Zend_Log::DEBUG);
         }
     }
     // Search for link to ping
     preg_match_all('/href="(https?:\\/\\/[^\\"]*)/', $item->getContent(), $matches, PREG_SET_ORDER);
     // If a link item, add the link to the list
     $links = array();
     if ($item->getType() == SourceItem::LINK_TYPE) {
         array_push($links, $item->getLink());
     }
     // If a reply, add the reply_to_url to the list
     if ($item->isreply()) {
         array_push($links, $item->getReplyTo());
     }
     // Collect links
     foreach ($matches as $link) {
         array_push($links, $link[1]);
     }
     // Ping each link
     foreach ($links as $link) {
         $url = Pingback_Utility::getPingbackServerURL($link);
         if ($url) {
             $logger->log("Pingback server for " . $link . ": " . $url, Zend_Log::DEBUG);
             $response = Pingback_Utility::sendPingback($source, $link, $url);
             $logger->log("Pingback response for " . $link . ": " . $response, Zend_Log::DEBUG);
         }
     }
 }
 private function pingback($comment, $source)
 {
     $logger = Zend_Registry::get("logger");
     $logger->log("Pingback source: " . $source, Zend_Log::DEBUG);
     $logger->log("Comment: " . $comment, Zend_Log::DEBUG);
     // Search for user to ping
     preg_match_all('/@([a-zA-Z0-9\\-\\.]+)/', $comment, $mentions, PREG_SET_ORDER);
     // Ping each user
     foreach ($mentions as $mention) {
         $logger->log("Attemptint pingback for " . $mention[1], Zend_Log::DEBUG);
         $target = "http://" . $mention[1];
         $url = Pingback_Utility::getPingbackServerURL($target);
         if ($url) {
             $logger->log("Pingback server for " . $mention[1] . ": " . $url, Zend_Log::DEBUG);
             $response = Pingback_Utility::sendPingback($source, $target, $url);
             $logger->log("Pingback response for " . $mention[1] . ": " . $response, Zend_Log::DEBUG);
         }
     }
 }