Changeset 204
- Timestamp:
- 04/04/08 10:08:19 (8 months ago)
- Files:
-
- trunk/Phergie/Bot.php (modified) (6 diffs)
- trunk/Phergie/Driver/Abstract.php (modified) (3 diffs)
- trunk/Phergie/Driver/Streams.php (modified) (7 diffs)
- trunk/Phergie/Event/Request.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Ctcp.php (modified) (1 diff)
- trunk/Phergie/Plugin/Dice.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Drink.php (modified) (1 diff)
- trunk/Phergie/Plugin/FeedTicker.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Karma.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Lart.php (modified) (1 diff)
- trunk/Phergie/Plugin/Logging.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Math.php (modified) (8 diffs)
- trunk/Phergie/Plugin/ModuleList.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Quit.php (modified) (5 diffs)
- trunk/Phergie/Plugin/Seen.php (modified) (11 diffs)
- trunk/Phergie/Plugin/Tld.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Toggle.php (modified) (1 diff)
- trunk/Phergie/Plugin/Url.php (modified) (9 diffs)
- trunk/Phergie/Plugin/Users.php (modified) (3 diffs)
- trunk/Phergie/phergie.ini (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Bot.php
r203 r204 113 113 * @const string 114 114 */ 115 define('PHERGIE_INI', $ini);115 define('PHERGIE_INI', basename($ini)); 116 116 117 117 /** … … 120 120 * @const string 121 121 */ 122 define('PHERGIE_INI_PATH', PHERGIE_DIR . PHERGIE_INI);122 define('PHERGIE_INI_PATH', realpath($ini)); 123 123 124 124 /** … … 131 131 function phergieAutoLoader($class) { 132 132 if (strpos(strtolower($class), 'phergie_') === 0) { 133 list (, $type, $name) = explode('_', $class, 3);133 list (, $type, $name) = array_pad(explode('_', $class, 3), 3, null); 134 134 $name = str_replace('_', DIRECTORY_SEPARATOR, $name); 135 135 … … 200 200 $driver = 'Streams'; 201 201 } 202 require_once PHERGIE_DRIVER_DIR . $driver . '.php';203 202 $class = 'Phergie_Driver_' . $driver; 204 203 $client = new $class(); … … 216 215 $include = array(); 217 216 if (!empty($config['plugins']) 218 && preg_match('/(all|none)(?: except(.+))?/ADi', $config['plugins'], $match)) {219 $all = $match[1]!= 'none';220 if ( isset($match[2])) {221 $include = array_map('strtolower', preg_split('/[, ]+/', $match[2]));217 && preg_match('/(all|none)(?:\s*except\s*(.+))?/ADi', $config['plugins'], $match)) { 218 $all = trim(strtolower($match[1])) != 'none'; 219 if (!empty($match[2])) { 220 $include = array_map('strtolower', preg_split('/[, ]+/', trim($match[2]))); 222 221 } 223 222 } … … 244 243 245 244 foreach ($plugins as $plugin) { 246 require_once PHERGIE_PLUGIN_DIR . $plugin . '.php';247 245 $class = 'Phergie_Plugin_' . $plugin; 248 246 /** trunk/Phergie/Driver/Abstract.php
r203 r204 71 71 { 72 72 if (preg_match('/^([^!@]+)!([^@]+)@(.*)$/', $hostmask, $match) > 0) { 73 list (, $nick, $user, $host) = $match;73 list (, $nick, $user, $host) = array_pad($match, 4, null); 74 74 } else { 75 75 $host = $hostmask; … … 125 125 echo $message; 126 126 if ($log = $this->getIni('log') and !empty($log)) { 127 file_put_contents( $log, $message, FILE_APPEND);127 file_put_contents(realpath($log), $message, FILE_APPEND); 128 128 } 129 129 } … … 167 167 foreach ($iterator as $filename) { 168 168 if ($iterator->isFile() && pathinfo($filename, PATHINFO_EXTENSION) == 'php') { 169 $plugins[] = ($preserveExt ? (string) $filename : basename( (string)$filename, '.php'));169 $plugins[] = ($preserveExt ? (string) $filename : basename($filename, '.php')); 170 170 } 171 171 } trunk/Phergie/Driver/Streams.php
r203 r204 1 1 <?php 2 3 /**4 * @see Phergie_Driver_Abstract5 */6 require_once PHERGIE_DRIVER_DIR.'Abstract.php';7 2 8 3 /** … … 153 148 unset($server, $params); 154 149 150 if ($this->getIni('invisible')) { 151 $this->doMode($this->getIni('nick'), '+i'); 152 } 153 155 154 $ignore = $this->hostmasksToRegex($this->getIni('ignore')); 155 156 // Run the onConnect handler since we successfully connected to the server 157 foreach ($this->plugins as $plugin) { 158 $plugin->onConnect(); 159 } 156 160 157 161 while(true) { … … 159 163 $this->queueing = true; 160 164 161 $buffer = '';162 while (empty ($buffer)) {165 $buffer = null; 166 while (empty($buffer)) { 163 167 $buffer = fgets($this->socket, 512); 164 168 … … 179 183 } 180 184 } 185 if (!isset($buffer) || empty($buffer)) { 186 continue; 187 } 181 188 $buffer = rtrim($buffer); 182 189 $this->debug('<- ' . $buffer); 183 190 184 if ( $buffer[0]== ':') {185 list ($prefix, $cmd, $args) = explode(' ', substr($buffer, 1), 3);191 if (substr($buffer, 0, 1) == ':') { 192 list ($prefix, $cmd, $args) = array_pad(explode(' ', substr($buffer, 1), 3), 3, null); 186 193 $this->parseHostmask($prefix, $nick, $user, $host); 187 194 } else { 188 list ($cmd, $args) = explode(' ', $buffer, 2);195 list ($cmd, $args) = array_pad(explode(' ', $buffer, 2), 2, null); 189 196 } 190 197 … … 203 210 if(substr($temp[1], 0, 1) === chr(1) && substr($temp[1], -1) === chr(1)) { 204 211 $ctcp = trim(substr($temp[1], 1, -1)); 205 list ($cmd, $args) = explode(' ', $ctcp.' ', 2);212 list ($cmd, $args) = array_pad(explode(' ', $ctcp, 2), 2, null); 206 213 $cmd = strtolower($cmd); 207 214 … … 240 247 if(substr($temp[1], 0, 1) === chr(1) && substr($temp[1], -1) === chr(1)) { 241 248 $ctcp = trim(substr($temp[1], 1, -1)); 242 list ($cmd, $args) = explode(' ', $ctcp.' ', 2);249 list ($cmd, $args) = array_pad(explode(' ', $ctcp, 2), 2, null); 243 250 $cmd = strtolower($cmd); 244 251 … … 496 503 public function doWhois($nick) 497 504 { 498 $this->send(Phergie_Event_Requ set::TYPE_WHOIS, array($nick));505 $this->send(Phergie_Event_Request::TYPE_WHOIS, array($nick)); 499 506 } 500 507 trunk/Phergie/Event/Request.php
r194 r204 14 14 */ 15 15 const TYPE_NICK = 'nick'; 16 17 /** 18 * Whois message 19 * 20 * @const string 21 */ 22 const TYPE_WHOIS = 'whois'; 16 23 17 24 /** trunk/Phergie/Plugin/Abstract/Base.php
r203 r204 431 431 432 432 if ($time > 0 || count($return) <= 0) { 433 $return[] = $time. 's';433 $return[] = ($time > 0 ? $time : '0') . 's'; 434 434 } 435 435 … … 725 725 726 726 /** 727 * Handler for when the bot connects to the server 728 * 729 * @return void 730 */ 731 public function onConnect() { } 732 733 /** 734 * Handler for each iteration of the while loop while connected to the 735 * server 736 * 737 * @return void 738 */ 739 public function onTick() { } 740 741 /** 727 742 * Handler for when PHP throws an error 728 743 * … … 745 760 $source = null; 746 761 if (isset($arguments[0])) { 747 $source = trim( $arguments[0]);748 } 749 if ((( isset($source) && isset($this->muted[$source]) && $this->muted[$source]) ||762 $source = trim(strtolower($arguments[0])); 763 } 764 if (((!empty($source) && isset($this->muted[$source]) && $this->muted[$source]) || 750 765 (isset($this->muted['global']) && $this->muted['global'])) && 751 766 substr($method, 0, 2) === 'do') { trunk/Phergie/Plugin/Ctcp.php
r200 r204 59 59 $name = $this->getIni('nick'); 60 60 $realname = $this->getIni('realname'); 61 $username = $this->getIni('username'); 61 62 62 $finger = 'Realname: '.(!empty($realname) ? $realname: $name); 63 $finger = (!empty($realname) ? $realname: $name) . 64 ' ('.(!empty($username) ? $username: $name) . ')'; 63 65 $this->doCtcpReply($source, 'finger', $finger); 64 66 } trunk/Phergie/Plugin/Dice.php
r203 r204 69 69 } elseif ($substr === ')') { 70 70 $out .= $substr; 71 $next = substr($expr, 1, $ptr+1); 72 if (!empty($next) && !in_array($next, array('+', '-', '/', '*', ')'))) { 73 $out .= '*'; 74 } 71 75 $expr = substr($expr, $ptr); 72 76 $ptr = 0; … … 170 174 $source = $this->event->getSource(); 171 175 $ctcp = strtoupper($this->event->getArgument(1)); 172 list($ctcp, $message) = explode(' ', $ctcp.' ', 2);176 list($ctcp, $message) = array_pad(explode(' ', $ctcp, 2), 2, null); 173 177 174 178 if (($ctcp == 'DICE' || $ctcp == 'ROLL') and $result = $this->processDice($message)) { trunk/Phergie/Plugin/Drink.php
r203 r204 353 353 354 354 /** 355 * Alias to Beer 356 * 357 * @param string $target Target for the request 358 * @return void 359 */ 360 public function onDoBooze($target) 361 { 362 $this->throwDrink('beer', $target); 363 } 364 365 /** 355 366 * Handles cocktail requests. 356 367 * trunk/Phergie/Plugin/FeedTicker.php
r200 r204 164 164 { 165 165 if (!empty ($this->queue) && time() > $this->nextOutput) { 166 list ($title, $url, $chans, $feedTitle) = array_ shift($this->queue);166 list ($title, $url, $chans, $feedTitle) = array_pad(array_shift($this->queue), 4, null); 167 167 foreach ($chans as $chan) { 168 168 $this->doPrivmsg( … … 208 208 // Retrieve each feed 209 209 foreach ($this->feeds as $id => $feed) { 210 list ($url, $chans) = $feed;210 list ($url, $chans) = array_pad($feed, 2, null); 211 211 212 212 $content = @file_get_contents($url, null, $context); … … 218 218 try { 219 219 // RSS/RDF Feed 220 if (str pos($content, '<rss version=') !== false || strpos($content, '<rdf') !== false) {220 if (stripos($content, '<rss version=') !== false || stripos($content, '<rdf') !== false) { 221 221 $xml = new SimpleXMLElement($content); 222 222 $feedTitle = (string) $xml->channel->title; … … 224 224 $retrieved[$id][] = array((string) $item->title, (string) $item->link, $chans, $feedTitle); 225 225 } 226 } elseif(str pos($content, '/Atom') !== false) { // ATOM Feed226 } elseif(stripos($content, '/Atom') !== false) { // ATOM Feed 227 227 $xml = new SimpleXMLElement($content); 228 228 $feedTitle = (string) $xml->title; trunk/Phergie/Plugin/Karma.php
r203 r204 61 61 protected $negativeAnswers; 62 62 63 /** #@+63 /** 64 64 * Prepared PDO statements 65 65 * … … 70 70 protected $fetchKarma; 71 71 protected $insertComment; 72 /**#@-*/73 72 74 73 /** … … 92 91 93 92 $this->fixedKarma = array ( 94 'phergie' => '%s has karma of awesome', 95 'pi' => 'pi has karma of ' . M_PI, 96 'chucknorris' => '%s has karma of Warning: Integer out of range', 93 'phergie' => '%s has karma of awesome', 94 'pi' => '%s has karma of ' . M_PI, 95 'Π' => '%s has karma of ' . M_PI, 96 'π' => '%s has karma of ' . M_PI, 97 'chucknorris' => '%s has karma of Warning: Integer out of range', 97 98 'chuck norris' => '%s has karma of Warning: Integer out of range', 98 'c' => '%s has karma of 299 792 458 m/s',99 'e' => '%s has karma of ' . M_E,100 'euler' => '%s has karma of ' . M_EULER,101 'mole' => '%s has karma of 6.02214e23 molecules',102 'avogadro' => '%s has karma of 6.02214e23 molecules',103 'spoon' => '%s has no karma. There is no spoon',104 'mc^2' => '%s has karma of e',105 'mc2' => '%s has karma of e',106 'mc²' => '%s has karma of e',107 'i' => 'Ihaz big karma',99 'c' => '%s has karma of 299 792 458 m/s', 100 'e' => '%s has karma of ' . M_E, 101 'euler' => '%s has karma of ' . M_EULER, 102 'mole' => '%s has karma of 6.02214e23 molecules', 103 'avogadro' => '%s has karma of 6.02214e23 molecules', 104 'spoon' => '%s has no karma. There is no spoon', 105 'mc^2' => '%s has karma of e', 106 'mc2' => '%s has karma of e', 107 'mc²' => '%s has karma of e', 108 'i' => '%s haz big karma', 108 109 'karma' => 'The karma law says that all living creatures are responsible for their karma - their actions and the effects of their actions. You should watch yours.' 109 110 ); … … 282 283 $m[3] = (isset($m[5]) ? $m[5] : null); # Comment 283 284 unset($m[4], $m[5]); 284 list(, $sign, $word, $comment) = $m;285 list(, $sign, $word, $comment) = array_pad($m, 4, null); 285 286 286 287 // Clean the word trunk/Phergie/Plugin/Lart.php
r203 r204 346 346 } 347 347 348 $adminOnly = $this->getPluginIni('admin_only');349 if (preg_match('/^(' . $nick . '\s*:?\s+)?lartinfo\s+(.*?)$/i', $message, $match)) {350 if ($this->fromAdmin()) {351 list (, $address, $name) = $match;352 $name = trim(strtolower($name));353 if (!empty($name)) {354 $this->select->execute(array(':name' => $name));355 $info = $this->select->fetch();356 if ($info && count($info) > 0) {357 $name = $info['name'];358 $desc = $info['definition'];359 $host = (isset($info['hostmask']) ? substr($info['hostmask'], 0, strpos($info['hostmask'], '!')) : 'N/A');360 $time = (isset($info['tstamp']) ? $this->getCountdown(time() -$info['tstamp']) : 'N/A');361 $aliases = $this->getAliases($name, false);362 $aliases = (count($aliases) > 0 ? implode(', ', $aliases) : 'N/A');363 364 $this->doPrivmsg($this->event->getSource(),365 $target . ': Lart Info -> Term: '.$name.' | Definition: '.$desc.' | User: '.$host.' | Added: '.$time.' ago | Aliases: '.$aliases);366 } else {367 $this->doNotice($target, 'Unknown Lart: ' . $name);368 }369 unset($info);370 }371 } else {372 $this->doNotice($target, 'You do not have permission to view the lart info.');373 }374 } else if (preg_match('/^(' . $nick . '\s*:?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) {375 list (, $address, $name, $definition) = $match;376 if (!empty($name) && !empty($definition) && (empty($address) xor $source[0] == '#')) {377 if (!$adminOnly || $this->fromAdmin()) {378 $name = trim($name);379 $definition = trim($definition);380 381 $this->debug('Replacing term: ' . $name . ' = ' . $definition);382 $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow));383 $this->doNotice($target, 'Added lart "'. $name . '".');384 $this->cache[$name] = $definition;385 } else {386 $this->doNotice($target, 'You do not have permission to add larts.');387 }388 }389 } else if (preg_match('/^(' . $nick . '\s*:?\s+)?forget\s+(.*)$/i', $message, $match)) {390 if (!$adminOnly || $this->fromAdmin()) {391 list (, $address, $name) = $match;392 if (!empty($name) && (empty($address) xor $source[0] == '#')) {393 $name = trim(strtolower($name));394 $this->deleteLart($name);395 $this->doNotice($target, 'Removed lart "'. $name . '" and all its alises.');396 }397 } else {398 $this->doNotice($target, 'You do not have permission to remove larts.');399 }400 } else {401 $this->checkLart($message);402 }348 $adminOnly = $this->getPluginIni('admin_only'); 349 if (preg_match('/^(' . $nick . '\s*:?\s+)?lartinfo\s+(.*?)$/i', $message, $match)) { 350 if ($this->fromAdmin()) { 351 list (, $address, $name) = array_pad($match, 3, null); 352 $name = trim(strtolower($name)); 353 if (!empty($name)) { 354 $this->select->execute(array(':name' => $name)); 355 $info = $this->select->fetch(); 356 if ($info && count($info) > 0) { 357 $name = $info['name']; 358 $desc = $info['definition']; 359 $host = (isset($info['hostmask']) ? substr($info['hostmask'], 0, strpos($info['hostmask'], '!')) : 'N/A'); 360 $time = (isset($info['tstamp']) ? $this->getCountdown(time() -$info['tstamp']) : 'N/A'); 361 $aliases = $this->getAliases($name, false); 362 $aliases = (count($aliases) > 0 ? implode(', ', $aliases) : 'N/A'); 363 364 $this->doPrivmsg($this->event->getSource(), 365 $target . ': Lart Info -> Term: '.$name.' | Definition: '.$desc.' | User: '.$host.' | Added: '.$time.' ago | Aliases: '.$aliases); 366 } else { 367 $this->doNotice($target, 'Unknown Lart: ' . $name); 368 } 369 unset($info); 370 } 371 } else { 372 $this->doNotice($target, 'You do not have permission to view the lart info.'); 373 } 374 } else if (preg_match('/^(' . $nick . '\s*:?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 375 list (, $address, $name, $definition) = array_pad($match, 4, null); 376 if (!empty($name) && !empty($definition) && (empty($address) xor $source[0] == '#')) { 377 if (!$adminOnly || $this->fromAdmin()) { 378 $name = trim($name); 379 $definition = trim($definition); 380 381 $this->debug('Replacing term: ' . $name . ' = ' . $definition); 382 $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow)); 383 $this->doNotice($target, 'Added lart "'. $name . '".'); 384 $this->cache[$name] = $definition; 385 } else { 386 $this->doNotice($target, 'You do not have permission to add larts.'); 387 } 388 } 389 } else if (preg_match('/^(' . $nick . '\s*:?\s+)?forget\s+(.*)$/i', $message, $match)) { 390 if (!$adminOnly || $this->fromAdmin()) { 391 list (, $address, $name) = array_pad($match, 3, null); 392 if (!empty($name) && (empty($address) xor $source[0] == '#')) { 393 $name = trim(strtolower($name)); 394 $this->deleteLart($name); 395 $this->doNotice($target, 'Removed lart "'. $name . '" and all its alises.'); 396 } 397 } else { 398 $this->doNotice($target, 'You do not have permission to remove larts.'); 399 } 400 } else { 401 $this->checkLart($message); 402 } 403 403 } 404 404 trunk/Phergie/Plugin/Logging.php
r203 r204 83 83 */ 84 84 const TOPIC = 9; 85 86 /** 87 * Indicates a QUERY event in the type column of the logs table 88 * This indicates that the message type is a PM 89 * 90 * @const int 91 */ 92 const QUERY = 10; 85 93 86 94 /** … … 212 220 parent::onPrivmsg(); 213 221 214 if ($this->event->isInChannel()) { 215 $this->insertEvent( 216 self::PRIVMSG, 217 $this->event->getSource(), 218 $this->event->getNick(), 219 $this->event->getArgument(1) 220 ); 221 } 222 $this->insertEvent( 223 ($this->event->isInChannel() ? self::PRIVMSG : self::QUERY), 224 $this->event->getSource(), 225 $this->event->getNick(), 226 $this->event->getArgument(1) 227 ); 222 228 } 223 229 … … 352 358 353 359 public static function databaseExists() { 354 return ( self::$db? true : false);360 return (is_object(self::$db) ? true : false); 355 361 } 356 362 trunk/Phergie/Plugin/Math.php
r200 r204 9 9 { 10 10 /** 11 * Backwards compatibility for constants not defined in PHP 5.1.x 12 */ 13 public function init() 14 { 15 if (version_compare('5.2', PHP_VERSION, '>')) { 16 define('M_EULER', '0.57721566490153286061'); 17 define('M_LNPI', '1.14472988584940017414'); 18 define('M_SQRT3', '1.73205080756887729352'); 19 define('M_SQRTPI', '1.77245385090551602729'); 20 } 21 } 22 23 /** 11 24 * Holds the allowed function, characters, operators and constants 12 25 * … … 19 32 'abs(', 'ceil(', 'floor(', 'exp(', 20 33 'log10(', 21 'cos(', 'sin(', 'sqrt(', 'tan(', 22 'M_PI', 'INF', 'M_E', 34 'cos(', 'sin(', 'sqrt(', 'tan(', 'rad2deg(', 35 'acosh(', 'asin(', 'atan(', 'atanh(', 'cosh(', 36 'sinh(', 'tanh(', 'hexdec(', 'decoct(', 'dechex(', 37 'decbin(', 'bindec(', 'ord(', 'chr(', 38 'M_PI', 'INF', 'M_E', 'M_LOG2E', 'M_LOG10E', 39 'M_LN2', 'M_LN10', 'M_PI_2', 'M_PI_4', 'M_1_PI', 40 'M_2_PI', 'M_SQRTPI', 'M_2_SQRTPI', 'M_SQRT2', 41 'M_SQRT2', 'M_SQRT1_2', 'M_LNPI', 'M_EULER' 42 ); 43 44 /** 45 * Holds the functions that are allowed that are contained in the class 46 * 47 * @return void 48 */ 49 protected $classFuncs = array 50 ( 51 'sind(', 'cosd(', 'tand(', 52 'atand(', 'asind(', 'acosd(' 23 53 ); 24 54 … … 32 62 'round(', 'log(', 'pow(', 33 63 'max(', 'min(', 'rand(', 64 'atan2(', 'mt_rand(', 65 'base_convert(' 34 66 ); 35 67 36 68 /** 69 * Custom functions as defined in $classFuncs to be used in math operations 70 * these automatically get prepended with $this-> before the calculations 71 * take place. 72 */ 73 //return sine of <an angle in degrees> 74 protected function sind($degrees) { 75 return sin(deg2rad($degrees)); 76 } 77 //return cosd of <an angle in degrees> 78 protected function cosd($degrees) { 79 return cos(deg2rad($degrees)); 80 } 81 //return tand of <an angle in degrees> 82 protected function tand($degrees) { 83 return tan(deg2rad($degrees)); 84 } 85 //return atand of <an angle in degrees> 86 protected function atand($x) { 87 return rad2deg(atan($x)); 88 } 89 //return asind of <an angle in degrees> 90 protected function asind($x) { 91 return rad2deg(asin($x)); 92 } 93 //return acosd of <an angle in degrees> 94 protected function acosd($x) { 95 return rad2deg(acos($x)); 96 } 97 98 /** 37 99 * Processes a request to perform a calculations. 38 100 * … … 40 102 * @return void 41 103 */ 42 protected function processRequest($expr )104 protected function processRequest($expr, $quietMode = false) 43 105 { 44 106 $user = $this->event->getNick(); … … 51 113 ); 52 114 $equationSrc = $equation; 115 $this->allowed = array_merge($this->allowed, $this->classFuncs); 53 116 54 117 // Parse equation … … 94 157 95 158 $out .= $substr; 159 $next = substr($equation, 1, $ptr+1); 160 if (!empty($next) && !in_array($next, array('+', '-', '/', '*', ')'))) { 161 $out .= '*'; 162 } 96 163 $equation = substr($equation, $ptr); 97 164 $ptr = 0; 98 165 // Parse error if we've consumed the entire equation without finding anything valid 99 166 } elseif ($ptr >= strlen($equation)) { 100 $this->doNotice($user, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"'); 167 if (!$quietMode) { 168 $this->doNotice($user, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"'); 169 } 101 170 return; 102 171 } else { … … 104 173 } 105 174 } 175 176 foreach ($this->classFuncs as $func) { 177 $out = str_replace($func, '$this->' . $func, $out); 178 } 179 106 180 $res = @eval('return ' . $out . ';'); 107 181 $source = $this->event->getSource(); 108 182 if($res === false) { 109 $this->doNotice($user, 'Computation error, division by zero?'); 183 if (!$quietMode) { 184 $this->doNotice($user, 'Computation error, division by zero?'); 185 } 110 186 } else { 111 $this->doPrivmsg($source, $ res);187 $this->doPrivmsg($source, $user .': Result -> ' . $res); 112 188 } 113 189 } … … 120 196 public function onDoMath($expr) 121 197 { 198 $this->processRequest($expr, true); 199 } 200 201 /** 202 * Forwards calc commands onto a central handler. 203 * 204 * @return void 205 */ 206 public function onDoCalc($expr) 207 { 122 208 $this->processRequest($expr); 123 209 } 124 125 /**126 * Forwards calc commands onto a central handler.127 *128 * @return void129 */130 public function onDoCalc($expr)131 {132 $this->processRequest($expr);133 }134 210 } trunk/Phergie/Plugin/ModuleList.php
r203 r204 96 96 97 97 // Checks to see if the plugin is a muted plugin or not 98 if ((isset($data->muted[$target]) && $data->muted[$target]) || 99 (isset($data->muted['global']) && $data->muted['global'])) { 100 $pluginData['Muted'][] = $plugin . ($data->muted['global'] ? '*' : ''); 101 if ($data->muted['global']) { 102 $pluginData['Global_Muted'][] = $plugin; 103 } 104 if ($data->muted[$target]) { 105 $pluginData['Local_Muted'][] = $plugin; 106 } 98 if (!empty($data->muted[$target]) || !empty($data->muted['global'])) { 99 $pluginData['Muted'][] = $plugin . (!empty($data->muted['global']) ? '*' : ''); 100 if (!empty($data->muted['global'])) { 101 $pluginData['Global_Muted'][] = $plugin; 102 } 103 if (!empty($data->muted[$target])) { 104 $pluginData['Local_Muted'][] = $plugin; 105 } 107 106 } else { 108 107 $pluginData['Unmuted'][] = $plugin; … … 131 130 // Extended/Verbose plugins list that shows every plugin and their state 132 131 $state = null; 133 if ( $args['v']&& is_array($pluginData)) {132 if (isset($args['v']) && is_array($pluginData)) { 134 133 foreach ($this->verboseList as $key => $value) { 135 134 if (isset($pluginData[$key]) and is_array($pluginData[$key]) && … … 147 146 // Go through the list of any passed arugments and generate the plugin list for them 148 147 $message = null; 149 if (! $args['v']&& is_array($args) && count($args) > 0) {148 if (!isset($args['v']) && is_array($args) && count($args) > 0) { 150 149 foreach($args as $arg => $value) { 151 150 $plugin = $this->argList[$arg]; … … 163 162 // If the message is empty, aka no args were passed, return the full plugin list 164 163 if (empty($message)) { 165 $display = ( $args['v']? 'Verbose' : 'Plugins');164 $display = (isset($args['v']) ? 'Verbose' : 'Plugins'); 166 165 if (is_array($pluginData[$display])) { 167 166 sort($pluginData[$display]); trunk/Phergie/Plugin/Quit.php
r203 r204 8 8 { 9 9 /** 10 * Flag indicating whether or not the plugin is an admin plugin or not11 *12 * @var bool13 */10 * Flag indicating whether or not the plugin is an admin plugin or not 11 * 12 * @var bool 13 */ 14 14 public $needsAdmin = true; 15 15 16 16 /** 17 * Random reconnect messages used if a quit message isn't given18 *19 * @var array20 */17 * Random reconnect messages used if a quit message isn't given 18 * 19 * @var array 20 */ 21 21 protected $messages = array 22 22 ( … … 29 29 30 30 /** 31 * Path to the PHP executable file 32 * 33 * @var string 34 */ 35 protected $phpPath; 36 37 /** 38 * Attempts to auto-detect the path to the PHP executable if the path isn't 39 * set in the setting file 40 * 41 * @return void 42 */ 43 public function init() 44 { 45 $phpPath = trim($this->getPluginIni('php_path')); 46 if (empty($phpPath) || !is_file($phpPath) || 47 strtolower($phpPath) == 'autodetect' || strtolower($phpPath) == 'auto-detect') { 48 /** 49 * Array of file names to check for when auto-detecting the path to PHP 50 */ 51 $files = array( 52 'php', 53 'php.exe', 54 'php-win.exe' 55 ); 56 57 /** 58 * Array of file paths to check for the PHP executable 59 */ 60 $paths = array(); 61 if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { 62 $paths = array_merge($paths, explode(';', ini_get('include_path'))); 63 $paths = array_merge($paths, explode(';', ini_get('extension_dir'))); 64 } else { 65 $paths = array_merge($paths, explode(':', ini_get('include_path'))); 66 $paths = array_merge($paths, explode(':', ini_get('extension_dir'))); 67 } 68 69 if (!empty($phpPath) && 70 strtolower($phpPath) != 'autodetect' && strtolower($phpPath) != 'auto-detect') { 71 $files[] = $phpPath; 72 $paths[] = $phpPath; 73 } 74 75 /** 76 * Attempt to auto-detect the path to the PHP executable from the list of file names and paths