Ejemplo n.º 1
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);
         }
     }
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }