Assembla home | Assembla project page
 

Changeset 223

Show
Ignore:
Timestamp:
04/13/08 00:21:06 (7 months ago)
Author:
Slynderdale
Message:

Various bug fixes and enhancements:

Notable Changes:

  • Bot.php: The auto loader now strips out the "Phergie_" prefix from class names while getting the path to the class file to include for those who don't have the bot in a directory called Phergie. Both the Phergie directory and the parent directory were added to the include path. Also added a check to see if they have a timezone is set in PHP.ini, if not, set the timezone to the default timezone to prevent strict errors while using date.
  • Streams.php: Added support for invite requests and also fixed a small bug where an empty command gets ent to call_user_func due to a packet getting cut off.
  • Base.php: Added onInvite and changed fromAdmin so the first argunent needs to be set to true for hostmask admin checking.
  • Lart.php: Improved lart a bit and fixed bugs where you couldn't remove certain terms due to spacing/character casing issues
  • Seen.php: Added a quote command to get a random quote by a specified user
  • Users.php: Renamed Users to ServerInfo to prepare it for future changes to make it store more information about users, channels and the server. Also fixed a bug where halfops and voiced users were considered an OP.
Files:

Legend:

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

    r216 r223  
    1313    trigger_error('Fatal error: PHP 5.1.2+ is required, current version: ' . PHP_VERSION, E_USER_ERROR); 
    1414 
    15     /** 
    16      * Backwards compatibility check to see if the PHP version is lower than 5.2 
    17      */ 
     15/** 
     16 * Backwards compatibility check to see if the PHP version is lower than 5.2 
     17 */ 
    1818} elseif (version_compare('5.2', PHP_VERSION, '>')) { 
    1919    trigger_error('Warning: PHP 5.2+ is recommended, current version: ' . PHP_VERSION, E_USER_WARNING); 
     
    4040 * @const string 
    4141 */ 
     42define('PHERGIE_BASE_DIR', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); 
     43 
     44/** 
     45 * Path to the directory containing the actual Phergie files 
     46 * 
     47 * @const string 
     48 */ 
    4249define('PHERGIE_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); 
    4350 
     
    5259 * Add the Phergie directory to the include path 
    5360 */ 
    54 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(PHERGIE_DIR)); 
     61set_include_path(get_include_path() . PATH_SEPARATOR . PHERGIE_DIR . PATH_SEPARATOR. PHERGIE_BASE_DIR); 
    5562 
    5663/** 
     
    6067    trigger_error('Phergie requires the CLI SAPI in order to run', E_USER_ERROR); 
    6168} 
     69 
     70/** 
     71 * Check to see if date.timezone is empty in the PHP.ini, if so, set the 
     72 * default timezone to prevent strict errors. 
     73 */ 
     74 $timezone = ini_get('date.timezone'); 
     75if (empty($timezone)) { 
     76    trigger_error('The default timezone wasn\'t set, defaulting to "' . date_default_timezone_get() . '."', E_USER_NOTICE); 
     77    date_default_timezone_set(date_default_timezone_get()); 
     78} 
     79unset($timezone); 
    6280 
    6381/** 
     
    106124function phergieAutoLoader($class) 
    107125{ 
    108     $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; 
     126    $file = $class; 
     127    if (strtolower(substr($file, 0, 8)) == 'phergie_') { 
     128        $file = substr($file, 8); 
     129    } 
     130    $file = str_replace('_', DIRECTORY_SEPARATOR, $file) . '.php'; 
    109131    require_once ($file); 
    110132    if (class_exists($class)) { 
  • trunk/Phergie/Driver/Streams.php

    r215 r223  
    256256                case 'part': 
    257257                case 'kill': 
     258                case 'invite': 
    258259                    $args = preg_split('/ :?/', $args, 2); 
    259260                break; 
     
    324325                    $plugin->onResponse(); 
    325326                // Skip events from ignored users 
    326                 } elseif (!preg_match($ignore, $event->getHostmask())) { 
    327                     call_user_func(array($plugin, 'on' . ucfirst($event->getType()))); 
     327                } elseif (!preg_match($ignore, $event->getHostmask()) && !empty($cmd)) { 
     328                    call_user_func(array($plugin, 'on' . ucfirst($cmd))); 
    328329                } 
    329330            } 
  • trunk/Phergie/Plugin/Abstract/Base.php

    r216 r223  
    219219    public function tinyUrl($url) 
    220220    { 
     221        $tiny = $url; 
    221222        if (strlen($url) > 30) { 
    222223            $opts = array( 
     
    235236                $tiny = $url; 
    236237            } 
    237         } else { 
    238             $tiny = $url; 
    239238        } 
    240239 
     
    293292            // 2 bytes, 11 bits 
    294293            case ($code&0x7FF): 
    295                 return chr(0xC0|(($code>>6) &0x1F)) . chr(0x80|($code&0x3F)); 
     294                return chr(0xC0|(($code>>6) &0x1F)) . 
     295                       chr(0x80|($code&0x3F)); 
    296296 
    297297            // 3 bytes, 16 bits 
    298298            case ($code&0xFFFF): 
    299                 return chr(0xE0|(($code>>12) &0x0F)) . chr(0x80|(($code>>6) &0x3F)) . chr(0x80|($code&0x3F)); 
     299                return chr(0xE0|(($code>>12) &0x0F)) . 
     300                       chr(0x80|(($code>>6) &0x3F)) . 
     301                       chr(0x80|($code&0x3F)); 
    300302 
    301303            // 4 bytes, 21 bits 
    302304            case ($code&0x1FFFFF): 
    303                 return chr(0xF0|($code>>18)) . chr(0x80|(($code>>12) &0x3F)) . chr(0x80|(($code>>6) &0x3F)) . chr(0x80|($code&0x3F)); 
     305                return chr(0xF0|($code>>18)) . 
     306                       chr(0x80|(($code>>12) &0x3F)) . 
     307                       chr(0x80|(($code>>6) &0x3F)) . 
     308                       chr(0x80|($code&0x3F)); 
    304309        } 
    305310    } 
     
    491496     * op. 
    492497     * 
    493      * @param bool $includeOps Include ops in the admin check 
     498     * @param bool $hostmaskAdminOnly Whether or not to allow just hostmask 
     499     *                                admins or not 
    494500     * @return bool TRUE if the message originated from an authorized 
    495501     *              individual, FALSE otherwise 
    496502     */ 
    497     public function fromAdmin($includeOps = true) 
     503    public function fromAdmin($hostmaskAdminOnly = false) 
    498504    { 
    499505        $class = $this->getName(); 
     
    514520 
    515521        // Try to match mask against admin masks 
    516         if (isset($this->adminList[$class]) && 
     522        if (!empty($this->adminList[$class]) && 
    517523            preg_match($this->adminList[$class], $this->event->getHostmask())) { 
    518524            return true; 
     
    520526 
    521527        // Check if is op and ops are admins 
    522         if ($includeOps && isset($this->opList[$class]) && $this->pluginLoaded('Users')) { 
     528        if (!$hostmaskAdminOnly && !empty($this->opList[$class]) && $this->pluginLoaded('ServerInfo')) { 
    523529            $nick = $this->event->getNick(); 
    524530            $source = $this->event->getSource(); 
    525             if (Phergie_Plugin_Users::isOp($nick, $source)) { 
     531            if (Phergie_Plugin_ServerInfo::isOp($nick, $source)) { 
    526532                return true; 
    527533            } 
     
    742748 
    743749    /** 
     750     * Handler for when a user sends an invite request 
     751     * 
     752     * @return void 
     753     */ 
     754    public function onInvite() { } 
     755 
     756    /** 
    744757     * Handler for when PHP throws an error 
    745758     * 
  • trunk/Phergie/Plugin/Abstract/Command.php

    r218 r223  
    6161        $bot = $this->getIni('nick'); 
    6262        // The Botprefix regex expression 
    63         $exp = '(?:' . preg_quote($bot) . '\s*:?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : ''); 
     63        $exp = '(?:' . preg_quote($bot) . '\s*[:,>]?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : ''); 
    6464 
    6565        if (preg_match('/^' . $exp . '(\S+)(?:[\s' . chr(240) . ']+(.*))?$/', $message, $match)) { 
  • trunk/Phergie/Plugin/Acronym.php

    r218 r223  
    8282        } while ($target[0] != '#' && $randomUser); 
    8383        if ($randomUser) { 
    84             if ($this->pluginLoaded('Users')) { 
     84            if ($this->pluginLoaded('ServerInfo')) { 
    8585                $nick = $this->getIni('nick'); 
    8686                do { 
    87                     $user = Phergie_Plugin_Users::getRandomUser($target); 
     87                    $user = Phergie_Plugin_ServerInfo::getRandomUser($target); 
    8888                } while ($user == $nick); 
    8989            } else { 
  • trunk/Phergie/Plugin/ChuckNorris.php

    r217 r223  
    266266        // Check to see if the message includes the word Chuck Norris. If so, check to see if 
    267267        // it was a bot request by checking for Fact: at the begiining and also do a floodpro check 
    268         if (preg_match('{^('.preg_quote($this->getIni('nick')).'\s*:?\s+)?\s*(chuck\s+norris)}ix', $message, $m) && 
     268        if (preg_match('{^('.preg_quote($this->getIni('nick')).'\s*[:,>]?\s+)?\s*(chuck\s+norris)}ix', $message, $m) && 
    269269            strtolower(substr($message, 0, 5)) != 'fact:' && ($source[0] != '#' || 
    270270            (!empty($m[1]) || $this->chance <= 0 || $this->chance >= 100 || mt_rand(1, 100) < $this->chance) && 
    271             ($this->floodCheck <= 0 || ($this->floodCache[$source] < (time() - $this->floodCheck))))) { 
     271            ($this->floodCheck <= 0 || !isset($this->floodCache[$source]) || 
     272            ($this->floodCache[$source] < (time() - $this->floodCheck))))) { 
    272273            $fact = $this->praiseChuckNorris(); 
    273274            if (!empty($fact)) { 
  • trunk/Phergie/Plugin/Daddy.php

    r217 r223  
    1818        $text = $this->event->getArgument(1); 
    1919        $target = $this->event->getNick(); 
    20         if (preg_match('/' . preg_quote($bot) . '\s*:?\s+?who\'?s y(?:our|a) ([^?]+)\??/iAD', $text, $m)) { 
     20        if (preg_match('/' . preg_quote($bot) . '\s*[:,>]?\s+?who\'?s y(?:our|a) ([^?]+)\??/iAD', $text, $m)) { 
    2121            if ($this->getIni('curses') && mt_rand(0, 5) === 5) { 
    2222                $this->doPrivmsg($this->event->getSource(), $target . ': I am your ' . $m[1] . ', bitch!'); 
  • trunk/Phergie/Plugin/Eval.php

    r217 r223  
    2424 
    2525        // Check to see if the admin is a hostmask admin only and not an op 
    26         if ($this->fromAdmin(false)) { 
     26        if ($this->fromAdmin(true)) { 
    2727            $code = trim($code); 
    2828            if (empty($code)) { 
     
    7676 
    7777        // Check to see if the admin is a hostmask admin only and not an op 
    78         if ($this->fromAdmin(false)) { 
     78        if ($this->fromAdmin(true)) { 
    7979            $code = trim($code); 
    8080            if (empty($code)) { 
  • trunk/Phergie/Plugin/JoinPart.php

    r217 r223  
    1919     * @var bool 
    2020     */ 
    21     protected $usersEnabled = null; 
     21    protected $serverInfoEnabled = null; 
    2222 
    2323    /** 
     
    2929    { 
    3030        if (!empty($channel)) { 
    31             $this->doJoin(trim($channel)); 
     31            $channel = preg_replace('/,\s+/', ',', trim($channel)); 
     32            $this->doJoin($channel); 
    3233        } 
    3334    } 
     
    5051        // Check whether a channel or multiple channels were given as well as a reason 
    5152        } else if (preg_match('/^([#&][^\s,]+ (?:\s*,+\s* [#&][^\s,]+)* | all | \#)?(?:[\s,]+)?(.*)?$/xis', $channel, $match)) { 
    52             $channels = preg_replace(array('{\s}', '{,+}'), array('', ','), strtolower($match[1])); 
     53            $channels = preg_replace(array('{\s}', '{,+}'), array('', ','), $match[1]); 
    5354            if (!empty($channels) || $source[0] == '#') { 
    5455                if (empty($channels) || $channels == '#') { 
     
    5758                } else if ($channels == 'all') { 
    5859                    //Check to see if the Users plugin is enabled  to retrieve a list of channels 
    59                     if (!isset($this->usersEnabled)) { 
    60                         $this->usersEnabled = $this->pluginLoaded('Users'); 
     60                    if (!isset($this->serverInfoEnabled)) { 
     61                        $this->serverInfoEnabled = $this->pluginLoaded('ServerInfo'); 
    6162                    } 
    62                     if (!$this->usersEnabled) { 
     63                    if (!$this->serverInfoEnabled) { 
    6364                        // A fallback, most IRC servers cause the user to part all channels if they try to join 0 
    6465                        $this->doJoin('0'); 
    6566                    } else { 
    66                         $channels = implode(',', Phergie_Plugin_Users::getChannels()); 
     67                        $channels = implode(',', Phergie_Plugin_ServerInfo::getChannels()); 
    6768                    } 
    6869                } 
  • trunk/Phergie/Plugin/Karma.php

    r218 r223  
    232232        $prefix = preg_quote(trim($this->getIni('command_prefix'))); 
    233233        $bot = preg_quote($this->getIni('nick')); 
    234         $exp = '(?:(?:' . $bot . '\s*:?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 
     234        $exp = '(?:(?:' . $bot . '\s*[:,>]?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 
    235235 
    236236        // Karma status request 
     
    297297 
    298298            // Force a decrementation if someone tries to update his own karma 
    299             if ($word == strtolower($target) && $sign != '--' && !$this->fromAdmin(false)) { 
     299            if ($word == strtolower($target) && $sign != '--' && !$this->fromAdmin(true)) { 
    300300                $this->doNotice($target, 'Bad ' . $target . '! You can not modify your own Karma. Shame on you!'); 
    301301                $sign = '--'; 
  • trunk/Phergie/Plugin/Lart.php

    r217 r223  
    6666 
    6767    /** 
    68      * An array used to store recursive aliases for the getAliases function 
    69      * 
    70      * @var array 
    71      */ 
    72     protected $aCache; 
    73  
    74     /** 
    7568     * Creates the database if needed, connects to it, and sets up prepared 
    7669     * statements for common operations. 
     
    10598            $columns = array(); 
    10699            foreach($table as $key => $column) { 
    107                 $columns[] = $column['name']
     100                $columns[] = trim(strtolower($column['name']))
    108101            } 
    109102            unset($table); 
     
    173166    protected function getDefinition($term) 
    174167    { 
    175         if (!isset($this->cache[$term])) { 
    176             $this->defination->execute(array(':name' => $term)); 
     168        if (!isset($this->cache[trim(strtolower($term))])) { 
     169            $this->defination->execute(array(':name' => trim($term))); 
    177170            $definition = $this->defination->fetchColumn(); 
    178171            if ($definition) { 
    179                 $this->cache[$term] = $definition; 
     172                $this->cache[trim(strtolower($term))] = $definition; 
    180173            } else { 
    181174                return false; 
    182175            } 
    183176        } 
    184         return $this->cache[$term]; 
     177        return $this->cache[trim(strtolower($term))]; 
    185178    } 
    186179 
     
    194187    protected function getAlias($definition) 
    195188    { 
    196         $this->alias->execute(array(':definition' => $definition)); 
     189        $this->alias->execute(array(':definition' => trim($definition))); 
    197190        $names = $this->alias->fetchAll(); 
    198191        if ($names && count($names) > 0) { 
     
    218211 
    219212        $definition = trim($this->getDefinition($message)); 
    220         $seen = array(strtolower($message)); 
     213        $seen = array(trim(strtolower($message))); 
    221214 
    222215        if (!empty($definition)) { 
    223216            do { 
    224                 if (strtolower($message) == strtolower($definition)) { 
     217                if (trim(strtolower($message)) == trim(strtolower($definition))) { 
    225218                    break; 
    226219                } 
     
    246239            } while(!empty($redirect)); 
    247240 
    248             if (substr($definition, 0, 3) == '/me') { 
     241            if (substr(strtolower($definition), 0, 3) == '/me') { 
    249242                $definition = trim(substr($definition, 3)); 
    250243                $this->doAction($this->event->getSource(), $definition); 
     
    262255     * @return array An array of aliases for the given term 
    263256     */ 
    264     public function getAliases($term, $recursive = true, $firstRun = true) 
    265     { 
    266         if (!is_array($this->aCache) || $firstRun) { 
    267             unset($this->aCache); 
    268             $this->aCache = array(); 
    269         } 
    270  
    271         $alias = $this->getAlias(trim($term)); 
    272         if ($alias) { 
     257    public function getAliases($term, $recursive = true, $aliasCache = array()) 
     258    { 
     259        if (!isset($aliasCache) || !is_array($aliasCache)) { 
     260            $aliasCache = array(); 
     261        } 
     262 
     263        $alias = $this->getAlias($term); 
     264        if (is_array($alias)) { 
    273265            foreach($alias as $key => $value) { 
    274266                $name = $value['name']; 
    275267                if (empty($name)) continue; 
    276                 if (!in_array($name, $this->aCache)) { 
    277                     $this->aCache[] = strtolower($name)
     268                if (!in_array($name, $aliasCache)) { 
     269                    $aliasCache[] = $name
    278270                    if ($recursive) { 
    279                         $this->getAliases($name, true, false); 
    280                     } 
    281                 } 
    282             } 
    283         } 
    284         if ($firstRun) { 
    285             $cache = $this->aCache; 
    286             unset($this->aCache); 
    287             return $cache; 
    288         } 
     271                        $aliasCache = $this->getAliases($name, $recursive, $aliasCache); 
     272                    } 
     273                } 
     274            } 
     275        } 
     276        return $aliasCache; 
    289277    } 
    290278 
     
    302290            $this->debug('Removing term: ' . $name); 
    303291            $this->delete->execute(array(':name' => $name)); 
    304             unset($this->cache[$name]); 
     292            unset($this->cache[trim(strtolower($name))]); 
    305293        } else { 
    306294            $aliases = $this->getAliases($name); 
     
    311299            foreach($aliases as $key => $alias) { 
    312300                $this->delete->execute(array(':name' => $alias)); 
    313                 unset($this->cache[$alias]); 
     301                unset($this->cache[trim(strtolower($alias))]); 
    314302            } 
    315303        } 
     
    343331 
    344332        $adminOnly = $this->getPluginIni('admin_only'); 
    345         if (preg_match('/^(' . $nick . '\s*:?\s+)?lartinfo\s+(.*?)$/i', $message, $match)) { 
     333        if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?lartinfo\s+(.*?)$/i', $message, $match)) { 
    346334            if ($this->fromAdmin()) { 
    347335                list(, $address, $name) = array_pad($match, 3, null); 
    348                 $name = trim(strtolower($name)); 
     336                $name = trim($name); 
    349337                if (!empty($name)) { 
    350338                    $this->select->execute(array(':name' => $name)); 
     
    355343                        $host = (isset($info['hostmask']) ? substr($info['hostmask'], 0, strpos($info['hostmask'], '!')) : 'N/A'); 
    356344                        $time = (isset($info['tstamp']) ? $this->getCountdown(time() -$info['tstamp']) : 'N/A'); 
    357                         $aliases = $this->getAliases($name, false); 
     345                        $aliases = $this->getAliases($name); 
    358346                        $aliases = (count($aliases) > 0 ? implode(', ', $aliases) : 'N/A'); 
    359347 
     
    370358                $this->doNotice($target, 'You do not have permission to view the lart info.'); 
    371359            } 
    372         } else if (preg_match('/^(' . $nick . '\s*:?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 
     360        } else if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 
    373361            list(, $address, $name, $definition) = array_pad($match, 4, null); 
    374362            if (!empty($name) && !empty($definition) && (empty($address) xor $source[0] == '#')) { 
     
    377365                    $definition = trim($definition); 
    378366 
    379                     $this->debug('Replacing term: ' . $name . ' = ' . $definition); 
    380                     $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow)); 
    381                     $this->doNotice($target, 'Added lart "' . $name . '".'); 
    382                     $this->cache[$name] = $definition; 
     367                    if (!empty($name) && !empty($definition)) { 
     368                        $this->debug('Replacing term: ' . $name . ' = ' . $definition); 
     369                        $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow)); 
     370                        $this->cache[trim(strtolower($name))] = $definition; 
     371                        $this->doNotice($target, 'Added lart "' . $name . '".'); 
     372                    } 
    383373                } else { 
    384374                    $this->doNotice($target, 'You do not have permission to add larts.'); 
    385375                } 
    386376            } 
    387         } else if (preg_match('/^(' . $nick . '\s*:?\s+)?forget\s+(.*)$/i', $message, $match)) { 
     377        } else if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?forget\s+(.*)$/i', $message, $match)) { 
    388378            if (!$adminOnly || $this->fromAdmin()) { 
    389379                list(, $address, $name) = array_pad($match, 3, null); 
     380                $name = trim($name); 
    390381                if (!empty($name) && (empty($address) xor $source[0] == '#')) { 
    391                     $name = trim(strtolower($name)); 
    392                     $this->deleteLart($name); 
    393                     $this->doNotice($target, 'Removed lart "' . $name . '" and all its alises.'); 
     382                    $defination = $this->getDefinition($name); 
     383                    if ($defination) { 
     384                        $this->deleteLart($name); 
     385                        $this->doNotice($target, 'Removed lart "' . $name . '" and all its aliases.'); 
     386                    } else { 
     387                        $this->doNotice($target, 'Lart "' . $name . '" does not exist.'); 
     388                    } 
    394389                } 
    395390            } else { 
  • trunk/Phergie/Plugin/Logging.php

    r217 r223  
    164164    public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 
    165165    { 
    166         if (self::staticPluginLoaded('Users', $client, $plugins)) { 
     166        if (self::staticPluginLoaded('ServerInfo', $client, $plugins)) { 
    167167            return false; 
    168168        } 
     
    321321        $nick = $this->event->getNick(); 
    322322 
    323         foreach(Phergie_Plugin_Users::getChannels($nick) as $chan) { 
     323        foreach(Phergie_Plugin_ServerInfo::getChannels($nick) as $chan) { 
    324324            $this->insertEvent( 
    325325                self::QUIT, 
     
    340340        $nick = $this->event->getNick(); 
    341341 
    342         foreach(Phergie_Plugin_Users::getChannels($nick) as $chan) { 
     342        foreach(Phergie_Plugin_ServerInfo::getChannels($nick) as $chan) { 
    343343            $this->insertEvent( 
    344344                self::NICK, 
  • trunk/Phergie/Plugin/ModuleList.php

    r218 r223  
    5757        $source = $this->event->getSource(); 
    5858        $rawArgs = $this->parseArguments($rawArgs); 
    59         $target = trim(strtolower(!empty($rawArgs['strings'][0]) && $this->fromAdmin(false) ? $rawArgs['strings'][0] : $source)); 
     59        $target = trim(strtolower(!empty($rawArgs['strings'][0]) && $this->fromAdmin(true) ? $rawArgs['strings'][0] : $source)); 
    6060        $pluginData = array(); 
    6161 
  • trunk/Phergie/Plugin/Nickserv.php

    r217 r223  
    110110    { 
    111111        $user = $this->event->getNick(); 
    112         if ($this->fromAdmin(false) && $this->nick != $this->getIni('nick')) { 
    113             $password = $this->getPluginIni('password'); 
    114             if (!empty($password)) { 
    115                 $this->doPrivmsg($this->event->getSource(), $user . ': Attempting to ghost ' . $this->nick .'.'); 
    116                 $this->doPrivmsg( 
    117                     $this->botNick, 
    118                     'GHOST ' . $this->nick . ' ' . $password, 
    119                     true 
    120                 ); 
     112        if ($this->fromAdmin(true)) { 
     113            if ($this->nick != $this->getIni('nick')) { 
     114                $password = $this->getPluginIni('password'); 
     115                if (!empty($password)) { 
     116                    $this->doPrivmsg($this->event->getSource(), $user . ': Attempting to ghost ' . $this->nick .'.'); 
     117                    $this->doPrivmsg( 
     118                        $this->botNick, 
     119                        'GHOST ' . $this->nick . ' ' . $password, 
     120                        true 
     121                    ); 
     122                } 
    121123            } 
    122124        } else { 
  • trunk/Phergie/Plugin/Puppet.php

    r217 r223  
    5454    { 
    5555        $user = $this->event->getNick(); 
    56         if ($this->fromAdmin(false)) { 
     56        if ($this->fromAdmin(true)) { 
    5757            $this->doRaw($message); 
    5858        } else { 
  • trunk/Phergie/Plugin/Quit.php

    r217 r223  
    5858             */ 
    5959            $paths = array(); 
    60             if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { 
    61                 $paths = array_merge($paths, explode(';', ini_get('include_path'))); 
    62                 $paths = array_merge($paths, explode(';', ini_get('extension_dir'))); 
    63             } else { 
    64                 $paths = array_merge($paths, explode(':', ini_get('include_path'))); 
    65                 $paths = array_merge($paths, explode(':', ini_get('extension_dir'))); 
    66             } 
     60            $paths = array_merge($paths, explode(PATH_SEPARATOR, ini_get('include_path'))); 
     61            $paths = array_merge($paths, explode(PATH_SEPARATOR, ini_get('extension_dir'))); 
    6762 
    6863            if (!empty($phpPath) && 
     
    183178    { 
    184179        $user = $this->event->getNick(); 
    185         if ($this->fromAdmin(false)) { 
     180        if ($this->fromAdmin(true)) { 
    186181            $this->handleQuit($message); 
    187182        } else { 
     
    198193    { 
    199194        $user = $this->event->getNick(); 
    200         if ($this->fromAdmin(false)) { 
     195        if ($this->fromAdmin(true)) { 
    201196            $this->handleQuit($message); 
    202197        } else { 
     
    213208    { 
    214209        $user = $this->event->getNick(); 
    215         if ($this->fromAdmin(false)) { 
     210        if ($this->fromAdmin(true)) { 
    216211            $this->handleQuit($message); 
    217212        } else { 
     
    228223    { 
    229224        $user = $this->event->getNick(); 
    230         if ($this->fromAdmin(false)) { 
     225        if ($this->fromAdmin(true)) { 
    231226            $this->handleQuit($message, true); 
    232227        } else { 
     
    243238    { 
    244239        $user = $this->event->getNick(); 
    245         if ($this->fromAdmin(false)) { 
     240        if ($this->fromAdmin(true)) { 
    246241            $this->handleReboot($message); 
    247242        } else { 
     
    258253    { 
    259254        $user = $this->event->getNick(); 
    260         if ($this->fromAdmin(false)) { 
     255        if ($this->fromAdmin(true)) { 
    261256            $this->handleReboot($message); 
    262257        } else { 
  • trunk/Phergie/Plugin/Sed.php

    r217 r223  
    7878 
    7979        // The regex used to match the Sed search/replace syntax 
    80         $regex = '{^(?:([^\s:]+)\s*:?\s+)?%?s(\d*)/(.*?)(?<!\\\)/(.*?)(?:(?<!\\\)/([gimsx]*)(\d*)([gimsx]*))?$}ix'; 
     80        $regex = '{^(?:([^\s:]+)\s*[:,>]?\s+)?%?s(\d*)/(.*?)(?<!\\\)/(.*?)(?:(?<!\\\)/([gimsx]*)(\d*)([gimsx]*))?$}ix'; 
    8181        if (preg_match($regex, $message, $matches)) { 
    8282            list($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = array_pad($matches, 8, NULL); 
  • trunk/Phergie/Plugin/Seen.php

    r217 r223  
    2424 
    2525    /** 
    26      * PRepared statement for searching for one or more time ranges during 
     26     * Prepared statement for searching for the last logged message originating 
     27     * from a particular user 
     28     * 
     29     * @var PDOStatement 
     30     */ 
     31    protected $heard; 
     32 
     33    /** 
     34     * Prepared statement for searching for one or more time ranges during 
    2735     * which a particular user is most likely to be present in a particular 
    2836     * channel 
     
    3139     */ 
    3240    protected $willsee; 
     41 
     42    /** 
     43     * Prepared statement for searching for a random logged message originating 
     44     * from a particular user 
     45     * 
     46     * @var PDOStatement 
     47     */ 
     48    protected $quote; 
    3349 
    3450    /** 
     
    98114                LIMIT 1 
    99115            '); 
     116 
     117            $this->quote = Phergie_Plugin_Logging::prepare(' 
     118                SELECT tstamp, chan, message 
     119                FROM logs 
     120                WHERE type = ' . Phergie_Plugin_Logging::PRIVMSG . ' 
     121                AND LOWER(nick) = LOWER(:name) 
     122                ORDER BY RANDOM() 
     123                LIMIT 1,1 
     124            '); 
    100125        } catch (PDOException $e) { } 
    101126    } 
     
    150175            $searchAll = true; 
    151176        } 
    152         $searchAll = (!$this->fromAdmin(false) ? false : $searchAll); 
     177        $searchAll = (!$this->fromAdmin(true) ? false : $searchAll); 
    153178 
    154179        $source = $this->event->getSource(); 
     
    173198                $source, 
    174199                sprintf( 
    175                     '%s%s was seen %s: %s on %s (%s ago)', 
     200                    '%s%s was seen %s "%s" on %s (%s ago)', 
    176201                    ($source[0] == '#' ? $target . ': ' : ''), 
    177202                    $row['nick'], 
     
    230255                $source, 
    231256                sprintf( 
    232                     '%s: %s was last seen %s: %s on %s (%s ago)', 
     257                    '%s: %s was last seen %s "%s" on %s (%s ago)', 
    233258                    $target, 
    234259                    $user, 
     
    289314                $source, 
    290315                sprintf( 
    291                     '%s: %s was last seen %s: %s on %s (%s ago)', 
     316                    '%s: %s was last seen %s "%s" on %s (%s ago)', 
    292317                    $target, 
    293318                    $user, 
     
    374399        $this->doPrivmsg($source, $message); 
    375400    } 
     401 
     402    /** 
     403     * Responds to requests for a random message originating from a particular 
     404     * user. 
     405     * 
     406     * @param string $user Nick of the user to search for 
     407     * @return void 
     408     */ 
     409    public function onDoQuote($user) 
     410    { 
     411        if (!Phergie_Plugin_Logging::databaseExists()) { 
     412            return; 
     413        } 
     414 
     415        // Don't match if user has a space (obviously it's not a nick) 
     416        if (strpos($user, ' ') !== false) { 
     417            return; 
     418        } 
     419 
     420        $source = $this->event->getSource(); 
     421        $target = $this->event->getNick(); 
     422 
     423        // Handle cases where the bot is the subject 
     424        if (strtolower($user) == strtolower($this->getIni('nick'))) { 
     425            $this->doPrivmsg($source, $target . ': Everything I say is amazing, how can I choose just one?'); 
     426            return; 
     427        } 
     428 
     429        // Handle 'me' alias 
     430        if ($user == 'me') { 
     431            $user = $target; 
     432        } 
     433 
     434        // Get the last event from the specified user 
     435        $params = array( 
     436            ':name' => $user 
     437        ); 
     438 
     439        $this->quote->execute($params); 
     440        $row = $this->quote->fetch(PDO::FETCH_ASSOC); 
     441 
     442        // Send the last action if available 
     443        if ($row) { 
     444            $this->doPrivmsg( 
     445                $source, 
     446                sprintf( 
     447                    '%s: %s was quoted saying "%s" on %s (%s ago)', 
     448                    $target, 
     449                    $user, 
     450                    $row['message'], 
     451                    $row['chan'], 
     452                    $this->formatTimestamp($row['tstamp']) 
     453                ) 
     454            ); 
     455        } else { 
     456            $this->doNotice($target, 'I have no records for ' . $user); 
     457        } 
     458    } 
    376459} 
  • trunk/Phergie/Plugin/Set.php

    r222 r223  
    1919    { 
    2020        $user = $this->event->getNick(); 
    21         if ($this->fromAdmin(false)) { 
     21        if ($this->fromAdmin(true)) { 
    2222            $append = $var === '-a' || $var === 'append' || $var === '-append'; 
    2323            // Got an append parameter, so we shift value/tmp down to var/value 
     
    5555    { 
    5656        $user = $this->event->getNick(); 
    57         if ($this->fromAdmin(false)) { 
     57        if ($this->fromAdmin(true)) { 
    5858            $this->doPrivmsg($this->event->getSource(), $var . ' = ' . $this->getIni($var)); 
    5959        } else { 
  • trunk/Phergie/Plugin/Tld.php

    r217 r223  
    7373 
    7474                foreach($pragma as $key => $column) { 
    75                     $columns[] = $column['name']
     75                    $columns[] = tr