Changeset 65

Show
Ignore:
Timestamp:
02/17/08 19:03:21 (5 years ago)
Author:
Seldaek
Message:

* antiloop fix for Url

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Phergie/Plugin/Url.php

    r64 r65  
    2121    */ 
    2222    protected $format = '%title% [ %link% ]'; 
     23 
     24        /** 
     25         * Saves the last url parsed to avoid spamming/looping with multiple bots 
     26         * 
     27         * It's saved in an array containing (url, tinyurl) so both are checked 
     28         * 
     29         * @var array 
     30         */ 
     31        protected $lastUrl = array(); 
    2332 
    2433    /** 
     
    4756        if (preg_match('#(https?://(?:[a-z0-9_-]+\.)+[a-z]{2,6}[^\s]*)#is', $this->event->getArgument(1), $m)) { 
    4857            $url = rtrim($m[1], '), ]'); 
     58            // Spam check on base URL 
     59                        if(array_search($url, $this->lastUrl) !== false) 
     60                                return; 
    4961            // @todo if image or something, output content type 
     62            // Convert url 
    5063            $tinyUrl = $this->tinyUrl($url); 
     64                        // Spam check on tinyURL 
     65                        if(array_search($tinyUrl, $this->lastUrl) !== false) 
     66                                return; 
     67 
    5168            $titleLength = $this->getIni('title_length'); 
    5269 
     
    96113                ) 
    97114            ); 
     115 
     116                        $this->lastUrl = array($url, $tinyUrl); 
    98117        } 
    99118    }