Dotclear


Ignore:
Timestamp:
09/01/13 20:56:28 (12 years ago)
Author:
Florent Cotton <florent.cotton@…>
Branch:
default
Message:

Réception des trackbacks/pingbacks évitant autant que possible les doublons. (close #1629)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.trackback.php

    r1684 r1689  
    147147     //@} 
    148148      
     149     private function pingAlreadyDone($post_id, $from_url) 
     150     { 
     151          $params = array( 
     152               'post_id' => $post_id, 
     153               'comment_site' => $from_url, 
     154               'comment_trackback' => 1, 
     155          ); 
     156           
     157          $rs = $this->core->blog->getComments($params, true); 
     158          if ($rs && !$rs->isEmpty()) { 
     159               return ($rs->f(0)); 
     160          } 
     161           
     162          return false; 
     163     } 
     164      
    149165     private function addBacklink($post_id, $url, $blog_name, $title, $excerpt, &$comment) 
    150166     { 
     
    206222          $charset = ''; 
    207223          $comment = ''; 
    208            
     224                     
    209225          $err = false; 
    210226          $msg = ''; 
     
    238254                    $err = true; 
    239255                    $msg = 'Trackbacks are not allowed for this post or weblog.'; 
     256               } 
     257 
     258               $url = trim(html::clean($url)); 
     259               if ($this->pingAlreadyDone($post->post_id, $url)) { 
     260                    $err = true; 
     261                    $msg = 'The trackback has already been registered'; 
    240262               } 
    241263          } 
     
    270292               $blog_name = html::escapeHTML($blog_name); 
    271293               $blog_name = text::cutString($blog_name,60); 
    272                 
    273                $url = trim(html::clean($url)); 
    274294                
    275295               try 
     
    361381          } 
    362382 
     383          if ($this->pingAlreadyDone($posts->post_id, $from_url)) { 
     384               throw new Exception(__('Don\'t repeat yourself, please.'), 48); 
     385          } 
     386           
    363387          # OK. We've found our champion. Time to check the remote part. 
    364388          try { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map