Пример #1
0
 /**
  * Process trackback request.
  */
 function _process()
 {
     // get ID
     global $ID;
     $ID = substr($_SERVER['PATH_INFO'], 1);
     $sourceUri = $_REQUEST['url'];
     if (is_null($this->tools) || !$this->tools->linkbackAllowed()) {
         $this->_printTrackbackError('Trackbacks disabled.');
         return;
     }
     // No POST request? Quit
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->_printTrackbackError('Trackback was not received via HTTP POST.');
         return;
     }
     // Given URL is not an url? Quit
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $sourceUri)) {
         $this->_printTrackbackError('Given trackback URL is not an URL.');
         return;
     }
     // Source does not exist? Quit
     $http = new DokuHTTPClient();
     $page = $http->get($sourceUri);
     if ($page === false) {
         $this->_printTrackbackError('Linked page cannot be reached');
         return;
     }
     if (!$this->tools->saveLinkback('trackback', strip_tags($_REQUEST['title']), $sourceUri, strip_tags($_REQUEST['excerpt']), $ID)) {
         $this->_printTrackbackError('Trackback already received.');
         return;
     }
     $this->_printTrackbackSuccess();
 }
Пример #2
0
 /**
  * @param $sourceUri
  * @param $targetUri
  * @return IXR_Error
  */
 function ping($sourceUri, $targetUri)
 {
     global $ID;
     $ID = substr($_SERVER['PATH_INFO'], 1);
     if (is_null($this->tools) || !$this->tools->linkbackAllowed()) {
         return new IXR_Error(PINGBACK_ERROR_TARGETURI_CANNOT_BE_USED, '');
     }
     // Given URLs are no urls? Quit
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $sourceUri)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $targetUri)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     // Source URL does not exist? Quit
     $http = new DokuHTTPClient();
     $page = $http->get($sourceUri);
     if ($page === false) {
         return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_EXIST, '');
     }
     // Target URL does not match with request? Quit
     if ($targetUri != wl($ID, '', true)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     // Retrieve data from source
     $linkback = $this->_getTrackbackData($sourceUri, $targetUri, $page);
     // Source URL does not contain link to target? Quit
     if (!$linkback) {
         return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_CONTAIN_LINK, '');
     }
     if (!$this->tools->saveLinkback('pingback', $linkback['title'], $sourceUri, $linkback['excerpt'], $ID)) {
         return new IXR_Error(PINGBACK_ERROR_PINGBACK_ALREADY_MADE, '');
     }
 }