Assembla home | Assembla project page
 

Changeset 247

Show
Ignore:
Timestamp:
04/15/08 02:22:51 (7 months ago)
Author:
Slynderdale
Message:

Added some cleaning of the channel setting in Autojoin
Added a hostip command to DNS (Thanks to kodekrash)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Autojoin.php

    r243 r247  
    8383                $channels = $this->getPluginIni('channels'); 
    8484                if (!empty($channels)) { 
    85                     $spec = explode(' ', $channels);  
     85                    $spec = split('/\s+/', preg_replace('/,\s+/', ',', trim($channels)), 2); 
    8686                    if (count($spec) > 1) { 
    8787                        $this->doJoin($spec[0], $spec[1]); 
  • trunk/Phergie/Plugin/Dns.php

    r217 r247  
    1616    protected function processRequest($arg) 
    1717    { 
     18        $source = $this->event->getSource(); 
    1819        $target = $this->event->getNick(); 
     20 
    1921        if (preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $arg)) { 
    2022            $resolved = gethostbyaddr(long2ip(ip2long($arg))); 
     
    2325        } 
    2426 
    25         $source = $this->event->getSource(); 
    2627        if (!isset($resolved)) { 
    2728            $this->doPrivmsg($source, $target . ': ' . $arg . ' cannot be resolved.'); 
     
    5253        $this->processRequest($ip); 
    5354    } 
     55 
     56    /** 
     57     * Intercepts, processes, and responds with the result of prototype lookup 
     58     * requests. 
     59     * 
     60     * @param string $function Name of the function to look up 
     61     * @return void 
     62     */ 
     63    public function onDoHostIp($host) 
     64    { 
     65        $target = $this->event->getNick(); 
     66 
     67        $tmp = file_get_contents('http://api.hostip.info/get_html.php?position=true&ip=' . urlencode(trim($host))); 
     68        if (!empty($tmp) && stripos($tmp, 'Private Address') === false) { 
     69            $contents = $host . ' -> ' . preg_replace(array('/\s+/', '/[\r\n]+/'), array(' ', ' - '), trim($tmp)); 
     70            $this->doPrivmsg($this->event->getSource(), $target . ': ' . $contents); 
     71        } 
     72        unset($host, $tmp, $contents); 
     73    } 
     74 
    5475}