Dotclear

Changeset 1689:6a99bdc5ed01


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

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

Location:
inc/core
Files:
2 edited

Legend:

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

    r1620 r1689  
    199199     /** 
    200200     Updates comments and trackbacks counters in post table. Should be called 
    201      every time comments or trackbacks are added, removed or changed there status. 
     201     every time comments or trackbacks are added, removed or changed their status. 
    202202      
    203203     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
     
    18801880     - cat_id: (integer or array) Get comments belonging to entries of given category ID 
    18811881     - comment_id: (integer) Get comment with given ID 
     1882     - comment_site: (string) Get comments with given comment_site 
    18821883     - comment_status: (integer) Get comments with given comment_status 
    18831884     - comment_trackback: (integer) Get only comments (0) or trackbacks (1) 
     
    19691970          if (isset($params['comment_id']) && $params['comment_id'] !== '') { 
    19701971               $strReq .= 'AND comment_id = '.(integer) $params['comment_id'].' '; 
     1972          } 
     1973           
     1974          if (isset($params['comment_site'])) { 
     1975               $comment_site = $this->con->escape(str_replace('*','%',$params['comment_site'])); 
     1976               $strReq .= "AND comment_site LIKE '".$comment_site."' "; 
    19711977          } 
    19721978           
  • 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