Changeset 223
- Timestamp:
- 04/13/08 00:21:06 (7 months ago)
- Files:
-
- trunk/Phergie/Bot.php (modified) (5 diffs)
- trunk/Phergie/Driver/Streams.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (7 diffs)
- trunk/Phergie/Plugin/Abstract/Command.php (modified) (1 diff)
- trunk/Phergie/Plugin/Acronym.php (modified) (1 diff)
- trunk/Phergie/Plugin/ChuckNorris.php (modified) (1 diff)
- trunk/Phergie/Plugin/Daddy.php (modified) (1 diff)
- trunk/Phergie/Plugin/Eval.php (modified) (2 diffs)
- trunk/Phergie/Plugin/JoinPart.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Karma.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Lart.php (modified) (13 diffs)
- trunk/Phergie/Plugin/Logging.php (modified) (3 diffs)
- trunk/Phergie/Plugin/ModuleList.php (modified) (1 diff)
- trunk/Phergie/Plugin/Nickserv.php (modified) (1 diff)
- trunk/Phergie/Plugin/Puppet.php (modified) (1 diff)
- trunk/Phergie/Plugin/Quit.php (modified) (7 diffs)
- trunk/Phergie/Plugin/Sed.php (modified) (1 diff)
- trunk/Phergie/Plugin/Seen.php (modified) (8 diffs)
- trunk/Phergie/Plugin/ServerInfo.php (added)
- trunk/Phergie/Plugin/Set.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Tld.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Toggle.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Users.php (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Bot.php
r216 r223 13 13 trigger_error('Fatal error: PHP 5.1.2+ is required, current version: ' . PHP_VERSION, E_USER_ERROR); 14 14 15 /**16 * Backwards compatibility check to see if the PHP version is lower than 5.217 */15 /** 16 * Backwards compatibility check to see if the PHP version is lower than 5.2 17 */ 18 18 } elseif (version_compare('5.2', PHP_VERSION, '>')) { 19 19 trigger_error('Warning: PHP 5.2+ is recommended, current version: ' . PHP_VERSION, E_USER_WARNING); … … 40 40 * @const string 41 41 */ 42 define('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 */ 42 49 define('PHERGIE_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); 43 50 … … 52 59 * Add the Phergie directory to the include path 53 60 */ 54 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(PHERGIE_DIR));61 set_include_path(get_include_path() . PATH_SEPARATOR . PHERGIE_DIR . PATH_SEPARATOR. PHERGIE_BASE_DIR); 55 62 56 63 /** … … 60 67 trigger_error('Phergie requires the CLI SAPI in order to run', E_USER_ERROR); 61 68 } 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'); 75 if (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 } 79 unset($timezone); 62 80 63 81 /** … … 106 124 function phergieAutoLoader($class) 107 125 { 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'; 109 131 require_once ($file); 110 132 if (class_exists($class)) { trunk/Phergie/Driver/Streams.php
r215 r223 256 256 case 'part': 257 257 case 'kill': 258 case 'invite': 258 259 $args = preg_split('/ :?/', $args, 2); 259 260 break; … … 324 325 $plugin->onResponse(); 325 326 // 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))); 328 329 } 329 330 } trunk/Phergie/Plugin/Abstract/Base.php
r216 r223 219 219 public function tinyUrl($url) 220 220 { 221 $tiny = $url; 221 222 if (strlen($url) > 30) { 222 223 $opts = array( … … 235 236 $tiny = $url; 236 237 } 237 } else {238 $tiny = $url;239 238 } 240 239 … … 293 292 // 2 bytes, 11 bits 294 293 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)); 296 296 297 297 // 3 bytes, 16 bits 298 298 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)); 300 302 301 303 // 4 bytes, 21 bits 302 304 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)); 304 309 } 305 310 } … … 491 496 * op. 492 497 * 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 494 500 * @return bool TRUE if the message originated from an authorized 495 501 * individual, FALSE otherwise 496 502 */ 497 public function fromAdmin($ includeOps = true)503 public function fromAdmin($hostmaskAdminOnly = false) 498 504 { 499 505 $class = $this->getName(); … … 514 520 515 521 // Try to match mask against admin masks 516 if ( isset($this->adminList[$class]) &&522 if (!empty($this->adminList[$class]) && 517 523 preg_match($this->adminList[$class], $this->event->getHostmask())) { 518 524 return true; … … 520 526 521 527 // 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')) { 523 529 $nick = $this->event->getNick(); 524 530 $source = $this->event->getSource(); 525 if (Phergie_Plugin_ Users::isOp($nick, $source)) {531 if (Phergie_Plugin_ServerInfo::isOp($nick, $source)) { 526 532 return true; 527 533 } … … 742 748 743 749 /** 750 * Handler for when a user sends an invite request 751 * 752 * @return void 753 */ 754 public function onInvite() { } 755 756 /** 744 757 * Handler for when PHP throws an error 745 758 * trunk/Phergie/Plugin/Abstract/Command.php
r218 r223 61 61 $bot = $this->getIni('nick'); 62 62 // The Botprefix regex expression 63 $exp = '(?:' . preg_quote($bot) . '\s* :?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : '');63 $exp = '(?:' . preg_quote($bot) . '\s*[:,>]?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : ''); 64 64 65 65 if (preg_match('/^' . $exp . '(\S+)(?:[\s' . chr(240) . ']+(.*))?$/', $message, $match)) { trunk/Phergie/Plugin/Acronym.php
r218 r223 82 82 } while ($target[0] != '#' && $randomUser); 83 83 if ($randomUser) { 84 if ($this->pluginLoaded(' Users')) {84 if ($this->pluginLoaded('ServerInfo')) { 85 85 $nick = $this->getIni('nick'); 86 86 do { 87 $user = Phergie_Plugin_ Users::getRandomUser($target);87 $user = Phergie_Plugin_ServerInfo::getRandomUser($target); 88 88 } while ($user == $nick); 89 89 } else { trunk/Phergie/Plugin/ChuckNorris.php
r217 r223 266 266 // Check to see if the message includes the word Chuck Norris. If so, check to see if 267 267 // 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) && 269 269 strtolower(substr($message, 0, 5)) != 'fact:' && ($source[0] != '#' || 270 270 (!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))))) { 272 273 $fact = $this->praiseChuckNorris(); 273 274 if (!empty($fact)) { trunk/Phergie/Plugin/Daddy.php
r217 r223 18 18 $text = $this->event->getArgument(1); 19 19 $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)) { 21 21 if ($this->getIni('curses') && mt_rand(0, 5) === 5) { 22 22 $this->doPrivmsg($this->event->getSource(), $target . ': I am your ' . $m[1] . ', bitch!'); trunk/Phergie/Plugin/Eval.php
r217 r223 24 24 25 25 // 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)) { 27 27 $code = trim($code); 28 28 if (empty($code)) { … … 76 76 77 77 // 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)) { 79 79 $code = trim($code); 80 80 if (empty($code)) { trunk/Phergie/Plugin/JoinPart.php
r217 r223 19 19 * @var bool 20 20 */ 21 protected $ usersEnabled = null;21 protected $serverInfoEnabled = null; 22 22 23 23 /** … … 29 29 { 30 30 if (!empty($channel)) { 31 $this->doJoin(trim($channel)); 31 $channel = preg_replace('/,\s+/', ',', trim($channel)); 32 $this->doJoin($channel); 32 33 } 33 34 } … … 50 51 // Check whether a channel or multiple channels were given as well as a reason 51 52 } 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]); 53 54 if (!empty($channels) || $source[0] == '#') { 54 55 if (empty($channels) || $channels == '#') { … … 57 58 } else if ($channels == 'all') { 58 59 //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'); 61 62 } 62 if (!$this-> usersEnabled) {63 if (!$this->serverInfoEnabled) { 63 64 // A fallback, most IRC servers cause the user to part all channels if they try to join 0 64 65 $this->doJoin('0'); 65 66 } else { 66 $channels = implode(',', Phergie_Plugin_ Users::getChannels());67 $channels = implode(',', Phergie_Plugin_ServerInfo::getChannels()); 67 68 } 68 69 } trunk/Phergie/Plugin/Karma.php
r218 r223 232 232 $prefix = preg_quote(trim($this->getIni('command_prefix'))); 233 233 $bot = preg_quote($this->getIni('nick')); 234 $exp = '(?:(?:' . $bot . '\s* :?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))';234 $exp = '(?:(?:' . $bot . '\s*[:,>]?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 235 235 236 236 // Karma status request … … 297 297 298 298 // 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)) { 300 300 $this->doNotice($target, 'Bad ' . $target . '! You can not modify your own Karma. Shame on you!'); 301 301 $sign = '--'; trunk/Phergie/Plugin/Lart.php
r217 r223 66 66 67 67 /** 68 * An array used to store recursive aliases for the getAliases function69 *70 * @var array71 */72 protected $aCache;73 74 /**75 68 * Creates the database if needed, connects to it, and sets up prepared 76 69 * statements for common operations. … … 105 98 $columns = array(); 106 99 foreach($table as $key => $column) { 107 $columns[] = $column['name'];100 $columns[] = trim(strtolower($column['name'])); 108 101 } 109 102 unset($table); … … 173 166 protected function getDefinition($term) 174 167 { 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))); 177 170 $definition = $this->defination->fetchColumn(); 178 171 if ($definition) { 179 $this->cache[ $term] = $definition;172 $this->cache[trim(strtolower($term))] = $definition; 180 173 } else { 181 174 return false; 182 175 } 183 176 } 184 return $this->cache[ $term];177 return $this->cache[trim(strtolower($term))]; 185 178 } 186 179 … … 194 187 protected function getAlias($definition) 195 188 { 196 $this->alias->execute(array(':definition' => $definition));189 $this->alias->execute(array(':definition' => trim($definition))); 197 190 $names = $this->alias->fetchAll(); 198 191 if ($names && count($names) > 0) { … … 218 211 219 212 $definition = trim($this->getDefinition($message)); 220 $seen = array( strtolower($message));213 $seen = array(trim(strtolower($message))); 221 214 222 215 if (!empty($definition)) { 223 216 do { 224 if ( strtolower($message) == strtolower($definition)) {217 if (trim(strtolower($message)) == trim(strtolower($definition))) { 225 218 break; 226 219 } … … 246 239 } while(!empty($redirect)); 247 240 248 if (substr( $definition, 0, 3) == '/me') {241 if (substr(strtolower($definition), 0, 3) == '/me') { 249 242 $definition = trim(substr($definition, 3)); 250 243 $this->doAction($this->event->getSource(), $definition); … … 262 255 * @return array An array of aliases for the given term 263 256 */ 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)) { 273 265 foreach($alias as $key => $value) { 274 266 $name = $value['name']; 275 267 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; 278 270 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; 289 277 } 290 278 … … 302 290 $this->debug('Removing term: ' . $name); 303 291 $this->delete->execute(array(':name' => $name)); 304 unset($this->cache[ $name]);292 unset($this->cache[trim(strtolower($name))]); 305 293 } else { 306 294 $aliases = $this->getAliases($name); … … 311 299 foreach($aliases as $key => $alias) { 312 300 $this->delete->execute(array(':name' => $alias)); 313 unset($this->cache[ $alias]);301 unset($this->cache[trim(strtolower($alias))]); 314 302 } 315 303 } … … 343 331 344 332 $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)) { 346 334 if ($this->fromAdmin()) { 347 335 list(, $address, $name) = array_pad($match, 3, null); 348 $name = trim( strtolower($name));336 $name = trim($name); 349 337 if (!empty($name)) { 350 338 $this->select->execute(array(':name' => $name)); … … 355 343 $host = (isset($info['hostmask']) ? substr($info['hostmask'], 0, strpos($info['hostmask'], '!')) : 'N/A'); 356 344 $time = (isset($info['tstamp']) ? $this->getCountdown(time() -$info['tstamp']) : 'N/A'); 357 $aliases = $this->getAliases($name , false);345 $aliases = $this->getAliases($name); 358 346 $aliases = (count($aliases) > 0 ? implode(', ', $aliases) : 'N/A'); 359 347 … … 370 358 $this->doNotice($target, 'You do not have permission to view the lart info.'); 371 359 } 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)) { 373 361 list(, $address, $name, $definition) = array_pad($match, 4, null); 374 362 if (!empty($name) && !empty($definition) && (empty($address) xor $source[0] == '#')) { … … 377 365 $definition = trim($definition); 378 366 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 } 383 373 } else { 384 374 $this->doNotice($target, 'You do not have permission to add larts.'); 385 375 } 386 376 } 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)) { 388 378 if (!$adminOnly || $this->fromAdmin()) { 389 379 list(, $address, $name) = array_pad($match, 3, null); 380 $name = trim($name); 390 381 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 } 394 389 } 395 390 } else { trunk/Phergie/Plugin/Logging.php
r217 r223 164 164 public static function checkDependencies(Phergie_Driver_Abstract $client, array$plugins) 165 165 { 166 if (self::staticPluginLoaded(' Users', $client, $plugins)) {166 if (self::staticPluginLoaded('ServerInfo', $client, $plugins)) { 167 167 return false; 168 168 } … … 321 321 $nick = $this->event->getNick(); 322 322 323 foreach(Phergie_Plugin_ Users::getChannels($nick) as $chan) {323 foreach(Phergie_Plugin_ServerInfo::getChannels($nick) as $chan) { 324 324 $this->insertEvent( 325 325 self::QUIT, … … 340 340 $nick = $this->event->getNick(); 341 341 342 foreach(Phergie_Plugin_ Users::getChannels($nick) as $chan) {342 foreach(Phergie_Plugin_ServerInfo::getChannels($nick) as $chan) { 343 343 $this->insertEvent( 344 344 self::NICK, trunk/Phergie/Plugin/ModuleList.php
r218 r223 57 57 $source = $this->event->getSource(); 58 58 $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)); 60 60 $pluginData = array(); 61 61 trunk/Phergie/Plugin/Nickserv.php
r217 r223 110 110 { 111 111 $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 } 121 123 } 122 124 } else { trunk/Phergie/Plugin/Puppet.php
r217 r223 54 54 { 55 55 $user = $this->event->getNick(); 56 if ($this->fromAdmin( false)) {56 if ($this->fromAdmin(true)) { 57 57 $this->doRaw($message); 58 58 } else { trunk/Phergie/Plugin/Quit.php
r217 r223 58 58 */ 59 59 $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'))); 67 62 68 63 if (!empty($phpPath) && … … 183 178 { 184 179 $user = $this->event->getNick(); 185 if ($this->fromAdmin( false)) {180 if ($this->fromAdmin(true)) { 186 181 $this->handleQuit($message); 187 182 } else { … … 198 193 { 199 194 $user = $this->event->getNick(); 200 if ($this->fromAdmin( false)) {195 if ($this->fromAdmin(true)) { 201 196 $this->handleQuit($message); 202 197 } else { … … 213 208 { 214 209 $user = $this->event->getNick(); 215 if ($this->fromAdmin( false)) {210 if ($this->fromAdmin(true)) { 216 211 $this->handleQuit($message); 217 212 } else { … … 228 223 { 229 224 $user = $this->event->getNick(); 230 if ($this->fromAdmin( false)) {225 if ($this->fromAdmin(true)) { 231 226 $this->handleQuit($message, true); 232 227 } else { … … 243 238 { 244 239 $user = $this->event->getNick(); 245 if ($this->fromAdmin( false)) {240 if ($this->fromAdmin(true)) { 246 241 $this->handleReboot($message); 247 242 } else { … … 258 253 { 259 254 $user = $this->event->getNick(); 260 if ($this->fromAdmin( false)) {255 if ($this->fromAdmin(true)) { 261 256 $this->handleReboot($message); 262 257 } else { trunk/Phergie/Plugin/Sed.php
r217 r223 78 78 79 79 // 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'; 81 81 if (preg_match($regex, $message, $matches)) { 82 82 list($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = array_pad($matches, 8, NULL); trunk/Phergie/Plugin/Seen.php
r217 r223 24 24 25 25 /** 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 27 35 * which a particular user is most likely to be present in a particular 28 36 * channel … … 31 39 */ 32 40 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; 33 49 34 50 /** … … 98 114 LIMIT 1 99 115 '); 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 '); 100 125 } catch (PDOException $e) { } 101 126 } … … 150 175 $searchAll = true; 151 176 } 152 $searchAll = (!$this->fromAdmin( false) ? false : $searchAll);177 $searchAll = (!$this->fromAdmin(true) ? false : $searchAll); 153 178 154 179 $source = $this->event->getSource(); … … 173 198 $source, 174 199 sprintf( 175 '%s%s was seen %s : %son %s (%s ago)',200 '%s%s was seen %s "%s" on %s (%s ago)', 176 201 ($source[0] == '#' ? $target . ': ' : ''), 177 202 $row['nick'], … … 230 255 $source, 231 256 sprintf( 232 '%s: %s was last seen %s : %son %s (%s ago)',257 '%s: %s was last seen %s "%s" on %s (%s ago)', 233 258 $target, 234 259 $user, … … 289 314 $source, 290 315 sprintf( 291 '%s: %s was last seen %s : %son %s (%s ago)',316 '%s: %s was last seen %s "%s" on %s (%s ago)', 292 317 $target, 293 318 $user, … … 374 399 $this->doPrivmsg($source, $message); 375 400 } 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 } 376 459 } trunk/Phergie/Plugin/Set.php
r222 r223 19 19 { 20 20 $user = $this->event->getNick(); 21 if ($this->fromAdmin( false)) {21 if ($this->fromAdmin(true)) { 22 22 $append = $var === '-a' || $var === 'append' || $var === '-append'; 23 23 // Got an append parameter, so we shift value/tmp down to var/value … … 55 55 { 56 56 $user = $this->event->getNick(); 57 if ($this->fromAdmin( false)) {57 if ($this->fromAdmin(true)) { 58 58 $this->doPrivmsg($this->event->getSource(), $var . ' = ' . $this->getIni($var)); 59 59 } else { trunk/Phergie/Plugin/Tld.php
r217 r223 73 73 74 74 foreach($pragma as $key => $column) { 75 $columns[] = $column['name'];75 $columns[] = tr