Changeset 131

Show
Ignore:
Timestamp:
03/06/08 03:32:18 (5 years ago)
Author:
Seldaek
Message:

* Url: rebuilt antispam cache

Files:
1 modified

Legend:

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

    r127 r131  
    2121    */ 
    2222    protected $format = '%title% [ %link% ]'; 
     23 
     24        /** 
     25         * Url cache to prevent spamming, especially with multiple bots on the same channel 
     26         */ 
     27        protected $cache = array(); 
    2328 
    2429    /** 
     
    5156                // Convert url 
    5257                $tinyUrl = $this->tinyUrl($url); 
     58 
     59                                // Prevent spamfest 
     60                                if(array_search($url, $this->cache, true) !== false || array_search($tinyUrl, $this->cache, true) !== false) 
     61                                        return; 
    5362 
    5463                $opts = array('http' => 
     
    106115                ); 
    107116 
     117                // Update cache 
     118                $this->cache[] = $url; 
     119                $this->cache[] = $tinyUrl; 
     120                                if (count($this->cache) > 10) { 
     121                        array_shift($this->cache); 
     122                        array_shift($this->cache); 
     123                                } 
     124 
    108125                unset($title, $tinyUrl, $title); 
    109126            }