Assembla home | Assembla project page
 

Changeset 203

Show
Ignore:
Timestamp:
04/03/08 01:31:13 (8 months ago)
Author:
tobias382
Message:

Fixed the autoloader in the bootstrap file not to emit a notice for unidentified classes and corrected some whitespace issues

Files:

Legend:

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

    r200 r203  
    140140            case 'util': 
    141141                $file = constant('PHERGIE_' . strtoupper($type) . '_DIR') . $name . '.php'; 
     142                if (file_exists($file) && is_readable($file)) { 
     143                    require_once($file); 
     144                    if (class_exists($class)) { 
     145                        return; 
     146                    } 
     147                } 
    142148                break; 
    143         } 
    144  
    145         if (file_exists($file) && is_readable($file)) { 
    146             require_once($file); 
    147             if (class_exists($class)) { 
    148                 return; 
    149             } 
    150149        } 
    151150    } 
  • trunk/Phergie/Driver/Abstract.php

    r200 r203  
    77abstract class Phergie_Driver_Abstract 
    88{ 
    9        /**#@+ 
    10         * Return codes for the run function, that tells the Bot script whether 
    11         * it should re-run or not 
    12         */ 
    13        const RETURN_RECONNECT = "reconnect"; 
    14        const RETURN_KEEPALIVE = "keepalive"; 
    15        const RETURN_END = "end"; 
    16        /**#@-*/ 
     9    /**#@+ 
     10    * Return codes for the run function, that tells the Bot script whether 
     11    * it should re-run or not 
     12    */ 
     13    const RETURN_RECONNECT = "reconnect"; 
     14    const RETURN_KEEPALIVE = "keepalive"; 
     15    const RETURN_END = "end"; 
     16    /**#@-*/ 
    1717 
    1818    /** 
     
    140140    } 
    141141 
    142        /** 
    143        * Returns all the plugins. 
    144     * 
    145        * @return Phergie_Plugin_Abstract_Base 
    146        */ 
    147        public function getPlugins() 
    148        
    149            return $this->plugins; 
    150        
    151  
    152        /** 
    153        * Returns a list of all the plugins either currently loaded or within the 
    154        * plugin directory. 
    155        
    156        * @param $plugin $dirList If true, scan the Plugin directory for the list 
    157        * @return array 
    158        */ 
    159        public function getPluginList($dirList = false, $preserveExt = false) 
    160        
    161               if (!$dirList) { 
    162                       return array_keys($this->plugins); 
    163               } else { 
    164                       $iterator = new DirectoryIterator(PHERGIE_PLUGIN_DIR); 
    165                       $plugins = array(); 
    166  
    167                       foreach ($iterator as $filename) { 
    168                               if ($iterator->isFile() && pathinfo($filename, PATHINFO_EXTENSION) == 'php') { 
    169                                       $plugins[] = ($preserveExt ? (string) $filename : basename((string) $filename, '.php')); 
    170                               } 
    171                       } 
    172                       unset($iterator, $filename, $dirList); 
    173  
    174                       return $plugins; 
    175               } 
    176        
    177  
    178        /** 
    179        * Returns a plugin instance. 
    180     * 
    181        * @param $plugin The plugin class name (without the Phergie_Plugin_ prefix) 
    182        * @return Phergie_Plugin_Abstract_Base 
    183        */ 
    184        public function getPlugin($plugin) 
    185        
    186               $plugin = strtolower($plugin); 
    187               if (isset($this->plugins[$plugin])) 
    188                       return $this->plugins[$plugin]; 
    189               return false; 
    190        
     142    /** 
     143    * Returns all the plugins. 
     144    * 
     145    * @return Phergie_Plugin_Abstract_Base 
     146    */ 
     147    public function getPlugins() 
     148   
     149        return $this->plugins; 
     150   
     151 
     152    /** 
     153    * Returns a list of all the plugins either currently loaded or within the 
     154    * plugin directory. 
     155   
     156    * @param $plugin $dirList If true, scan the Plugin directory for the list 
     157    * @return array 
     158    */ 
     159    public function getPluginList($dirList = false, $preserveExt = false) 
     160   
     161      if (!$dirList) { 
     162              return array_keys($this->plugins); 
     163      } else { 
     164              $iterator = new DirectoryIterator(PHERGIE_PLUGIN_DIR); 
     165              $plugins = array(); 
     166 
     167              foreach ($iterator as $filename) { 
     168                      if ($iterator->isFile() && pathinfo($filename, PATHINFO_EXTENSION) == 'php') { 
     169                              $plugins[] = ($preserveExt ? (string) $filename : basename((string) $filename, '.php')); 
     170                      } 
     171              } 
     172              unset($iterator, $filename, $dirList); 
     173 
     174              return $plugins; 
     175      } 
     176   
     177 
     178    /** 
     179    * Returns a plugin instance. 
     180    * 
     181    * @param $plugin The plugin class name (without the Phergie_Plugin_ prefix) 
     182    * @return Phergie_Plugin_Abstract_Base 
     183    */ 
     184    public function getPlugin($plugin) 
     185   
     186      $plugin = strtolower($plugin); 
     187      if (isset($this->plugins[$plugin])) 
     188              return $this->plugins[$plugin]; 
     189      return false; 
     190   
    191191 
    192192    /** 
  • trunk/Phergie/Driver/Streams.php

    r192 r203  
    103103    public function run() 
    104104    { 
    105        $this->startTime = time(); 
    106        $returnCode = $this->getIni('keepalive') ? self::RETURN_KEEPALIVE : self::RETURN_END; 
     105        $this->startTime = time(); 
     106        $returnCode = $this->getIni('keepalive') ? self::RETURN_KEEPALIVE : self::RETURN_END; 
    107107        $server = $this->getIni('server'); 
    108108        $port = $this->getIni('port'); 
     
    118118 
    119119        if ($this->getIni('timeout')) { 
    120                $timeout = $this->getIni('timeout') * 60; 
     120            $timeout = $this->getIni('timeout') * 60; 
    121121        } elseif ($this->getIni('keepalive')) { 
    122                $timeout = 600; 
    123               } else { 
    124                       $timeout = false; 
    125               } 
    126               $lastPacket = time(); 
     122            $timeout = 600; 
     123      } else { 
     124              $timeout = false; 
     125      } 
     126      $lastPacket = time(); 
    127127 
    128128        unset($port); 
     
    163163                $buffer = fgets($this->socket, 512); 
    164164 
    165                               // Check if we timed out 
    166                               if ($timeout !== false) { 
    167                                       // Reset last packet timestamp if we received something 
    168                                       if (!empty($buffer)) { 
    169                                               $lastPacket = time(); 
    170                                       } 
    171                                       // Timed out, exit 
    172                                       if ($lastPacket < (time() - $timeout)) { 
    173                                               $this->debug('Timed out'); 
    174                               foreach ($this->plugins as $plugin) { 
    175                                   $plugin->shutdown(); 
    176                               } 
    177                                               break 2; 
    178                                       } 
    179                               } 
     165                      // Check if we timed out 
     166                      if ($timeout !== false) { 
     167                              // Reset last packet timestamp if we received something 
     168                              if (!empty($buffer)) { 
     169                                      $lastPacket = time(); 
     170                              } 
     171                              // Timed out, exit 
     172                              if ($lastPacket < (time() - $timeout)) { 
     173                                      $this->debug('Timed out'); 
     174                      foreach ($this->plugins as $plugin) { 
     175                          $plugin->shutdown(); 
     176                      } 
     177                                      break 2; 
     178                              } 
     179                      } 
    180180            } 
    181181            $buffer = rtrim($buffer); 
     
    202202                    $temp = preg_split('/ :?/', trim($args), 2); 
    203203                    if(substr($temp[1], 0, 1) === chr(1) && substr($temp[1], -1) === chr(1)) { 
    204                        $ctcp = trim(substr($temp[1], 1, -1)); 
    205                            list ($cmd, $args) = explode(' ', $ctcp.' ', 2); 
     204                        $ctcp = trim(substr($temp[1], 1, -1)); 
     205                        list ($cmd, $args) = explode(' ', $ctcp.' ', 2); 
    206206                        $cmd = strtolower($cmd); 
    207207 
    208208                       // Check for the type of Notice message and handle it accordingly 
    209209                       if ($cmd == 'action') { 
    210                                   // Return sender as source and the action as its first argument 
     210                              // Return sender as source and the action as its first argument 
    211211                           $args = array($nick, trim($args)); 
    212212                       } elseif ($cmd == 'ping' || $cmd == 'version' || $cmd == 'time') { 
    213                                   // Return sender as source and the rest of the args as its first argument 
    214                                   $cmd = $cmd.'Reply'; 
     213                              // Return sender as source and the rest of the args as its first argument 
     214                              $cmd = $cmd.'Reply'; 
    215215                           $args = array($nick, trim($args)); 
    216216                       } else { 
    217                                   // Return sender as source and the ctcp as its first argument 
     217                              // Return sender as source and the ctcp as its first argument 
    218218                           $cmd = 'ctcpReply'; 
    219219                           $args = array($nick, $ctcp); 
     
    240240                    if(substr($temp[1], 0, 1) === chr(1) && substr($temp[1], -1) === chr(1)) { 
    241241                        $ctcp = trim(substr($temp[1], 1, -1)); 
    242                            list ($cmd, $args) = explode(' ', $ctcp.' ', 2); 
     242                        list ($cmd, $args) = explode(' ', $ctcp.' ', 2); 
    243243                        $cmd = strtolower($cmd); 
    244244 
    245245                       // Check for the type of CTCP message and handle it accordingly 
    246246                       if ($cmd == 'action') { 
    247                                   $botnick = $this->getIni('nick'); 
    248                                   // If sent within a channel, use the chanel as the source, else use the sender 
    249                                   $source = (strtolower($temp[0]) == strtolower($botnick) ? $nick : $temp[0]); 
    250                                   // Return channel/sender as source and the action as its first argument 
     247                              $botnick = $this->getIni('nick'); 
     248                              // If sent within a channel, use the chanel as the source, else use the sender 
     249                              $source = (strtolower($temp[0]) == strtolower($botnick) ? $nick : $temp[0]); 
     250                              // Return channel/sender as source and the action as its first argument 
    251251                           $args = array($source, trim($args)); 
    252252                       } elseif ($cmd == 'ping' && !empty($args)) { 
    253                                   // Return nick of sender as source and the handshake as its first argument 
    254                                   $args = array($nick, trim($args)); 
     253                              // Return nick of sender as source and the handshake as its first argument 
     254                              $args = array($nick, trim($args)); 
    255255                       } elseif (($cmd == 'version' || $cmd == 'time') && empty($args)) { 
    256                                   // Return nick of sender as source and the ctcp as its first argument 
     256                              // Return nick of sender as source and the ctcp as its first argument 
    257257                           $args = array($nick, $ctcp); 
    258258                       } else { 
    259                                   // Return nick of sender as source and the ctcp as its first argument 
     259                              // Return nick of sender as source and the ctcp as its first argument 
    260260                           $cmd = 'ctcp'; 
    261261                           $args = array($nick, $ctcp); 
     
    286286            foreach ($this->plugins as $plugin) { 
    287287                // Skip disabled plugins 
    288                if ($plugin->enabled === false) { 
    289                       continue; 
    290                
     288                if ($plugin->enabled === false) { 
     289                      continue; 
     290               
    291291                $plugin->setEvent($event); 
    292292                // onRaw Handlers 
     
    317317                } 
    318318                if (isset($this->queue['quit'][0][1])) { 
    319                        $returnCode = ($this->queue['quit'][0][1] === true ? self::RETURN_RECONNECT : self::RETURN_END); 
     319                    $returnCode = ($this->queue['quit'][0][1] === true ? self::RETURN_RECONNECT : self::RETURN_END); 
    320320                } 
    321321                $this->doQuit($reason); 
     
    340340    public function send($command, array $arguments = array()) 
    341341    { 
    342        $command = strtolower($command); 
     342        $command = strtolower($command); 
    343343        if ($this->queueing) { 
    344344            if (!isset($this->queue[$command])) { 
     
    347347            $this->queue[$command][] = $arguments; 
    348348        } else { 
    349                if ($command == Phergie_Event_Request::TYPE_RAW) { 
     349            if ($command == Phergie_Event_Request::TYPE_RAW) { 
    350350                $buffer = (count($arguments) > 0 ? implode(' ', $arguments) : ''); 
    351                } else { 
     351            } else { 
    352352                $buffer = strtoupper($command); 
    353353                if (count($arguments) > 0) { 
     
    373373    { 
    374374        if ($this->queueing) { 
    375                $this->send(Phergie_Event_Request::TYPE_QUIT, array($reason, $reconnect)); 
     375            $this->send(Phergie_Event_Request::TYPE_QUIT, array($reason, $reconnect)); 
    376376        } else { 
    377                $this->send(Phergie_Event_Request::TYPE_QUIT, array($reason)); 
     377            $this->send(Phergie_Event_Request::TYPE_QUIT, array($reason)); 
    378378        } 
    379379    } 
     
    559559    public function doCtcp($target, $command, $arguments = '') 
    560560    { 
    561        if (is_array($arguments)) { 
     561        if (is_array($arguments)) { 
    562562            $arguments = implode(' ', $arguments); 
    563        
     563       
    564564        $this->doPrivmsg($target, chr(1) . trim(strtoupper($command) . ' ' . $arguments) . chr(1)); 
    565565    } 
     
    595595    public function doVersionReply($target, $version = '') 
    596596    { 
    597        $version = trim($version); 
    598        if (empty($version)) { 
    599               $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)'; 
    600        
     597        $version = trim($version); 
     598        if (empty($version)) { 
     599              $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)'; 
     600       
    601601        $this->doCtcpReply($target, 'version', $version); 
    602602    } 
     
    610610    public function doTimeReply($target, $time = '') 
    611611    { 
    612        $time = trim($time); 
    613        if (empty($time) || ctype_digit($time)) { 
    614            if (empty($time)) $time = time(); 
    615            $time = date('D M d H:i:s o', $time); 
    616        
     612        $time = trim($time); 
     613        if (empty($time) || ctype_digit($time)) { 
     614            if (empty($time)) $time = time(); 
     615            $time = date('D M d H:i:s o', $time); 
     616       
    617617        $this->doCtcpReply($target, 'time', $time); 
    618618    } 
     
    626626    public function doCtcpReply($target, $command, $reply = '') 
    627627    { 
    628        $command = trim($command); 
    629        if (empty($command)) 
    630            return; 
     628        $command = trim($command); 
     629        if (empty($command)) 
     630            return; 
    631631        $this->send(Phergie_Event_Request::TYPE_NOTICE, array($target, chr(1).trim(strtoupper($command).' '.$reply).chr(1))); 
    632632    } 
  • trunk/Phergie/Plugin/Abstract/Base.php

    r202 r203  
    122122    public final function onBaseError($errno, $errstr, $errfile, $errline) { 
    123123        if (!isset($this)) { 
    124                return false; 
     124            return false; 
    125125        } 
    126126        return call_user_func_array(array($this, 'onPhpError'), array($errno, $errstr, $errfile, $errline)); 
     
    258258        // Use the translit extension if installed else fallback on to basic transliteration 
    259259        if (extension_loaded('iconv')) { 
    260                  $text = iconv($charSetFrom, $charSetTo.'//TRANSLIT', $text); 
     260                $text = iconv($charSetFrom, $charSetTo.'//TRANSLIT', $text); 
    261261        // Transliteration supprt via the translit extension is still experimental 
    262262          } else if (false && extension_loaded('translit')) { 
     
    284284            case 0: 
    285285                return chr(0); 
    286                    case ($code & 0x7F): 
    287                       return chr($code); 
    288  
    289                    // 2 bytes, 11 bits 
    290                    case ($code & 0x7FF): 
    291                       return chr(0xC0 | (($code >> 6) & 0x1F)) . 
     286                case ($code & 0x7F): 
     287                      return chr($code); 
     288 
     289                // 2 bytes, 11 bits 
     290                case ($code & 0x7FF): 
     291                      return chr(0xC0 | (($code >> 6) & 0x1F)) . 
    292292                       chr(0x80 | ($code & 0x3F)); 
    293293 
    294                    // 3 bytes, 16 bits 
    295                    case ($code & 0xFFFF): 
    296                       return chr(0xE0 | (($code >> 12) & 0x0F)) . 
     294                // 3 bytes, 16 bits 
     295                case ($code & 0xFFFF): 
     296                      return chr(0xE0 | (($code >> 12) & 0x0F)) . 
    297297                       chr(0x80 | (($code >> 6) & 0x3F)) . 
    298298                       chr(0x80 | ($code & 0x3F)); 
    299299 
    300                    // 4 bytes, 21 bits 
    301                    case ($code & 0x1FFFFF): 
    302                       return chr(0xF0 | ($code >> 18)) . 
     300                // 4 bytes, 21 bits 
     301                case ($code & 0x1FFFFF): 
     302                      return chr(0xF0 | ($code >> 18)) . 
    303303                       chr(0x80 | (($code >> 12) & 0x3F)) . 
    304304                       chr(0x80 | (($code >> 6) & 0x3F)) . 
     
    328328    */ 
    329329    public function parseArguments($args) { 
    330        // Strip away multiple spaces 
    331        $args = ' '.preg_replace('#\s+#', ' ', trim($args)).' '; 
    332  
    333        // Check the args string for agurments 
    334        preg_match_all('{'. 
    335        // String Regex: Matches "" | "foo" | "foo bar" | "foo \" bar" | foo 
    336        '(".*?(?<!\\\)" | [^-+\s]+) | '. 
    337        // Option Regex: Matches --opt | --opt foo | --opt= | --opt=foo | --opt="" | --opt="foo" | --opt="foo bar" 
    338        '(--\w+ (?:=".*?(?<!\\\)" | [=\s][^-+"\s]*)?) | '. 
    339        // Flag Regex: Matches -flag +flag 
    340        '([-+]\w+)'. 
    341        '}xi', 
    342        $args, $matches); 
    343        // Shifts the first group matches element off of matches 
    344        $matches = array_shift($matches); 
    345  
    346        // Returned data structure 
    347        $data = array( 
    348            'strings'    => array(), 
    349            'commands' => array(), 
    350            'flags'    => array(), 
    351            'all'      => array( 
    352                'strings'    => '', 
    353                'commands' => array(), 
    354                'flags'    => array() 
    355            ) 
    356        ); 
    357  
    358        // Loop through the results 
    359        foreach ($matches as $match) { 
    360               $match = trim($match); 
    361               // Check to see if the current match an an --option 
    362               if (substr($match, 0, 2 ) === '--') { 
    363                       $value = preg_split('/[=\s]/', $match, 2); 
    364                       $com   = substr(array_shift($value), 2); 
    365                       $value = trim(join($value)); 
    366                       // Strip quotes from the option's value 
    367                       $realValue = (substr($value, 0, 1) === '"' && substr($value, -1) === '"' || substr($match, -1) === '='); 
    368                       if(substr($value, 0, 1) === '"' && substr($value, -1) === '"') { 
    369                               $value = trim(substr($value, 1, -1)); 
    370                       } 
    371                       if (!in_array($com, $data['all']['commands'])) 
    372                       $data['all']['commands'][] = $com; 
    373                       $data['commands'][$com] = (!empty($value) || $realValue? str_replace('\"', '"', $value) : true); 
    374                       continue; 
    375               } 
    376  
    377               // Check to see if the current match is a -flag 
    378               if (substr($match, 0, 1) === '-' || substr($match, 0, 1) === '+') { 
    379                       $flag = substr($match, 1); 
    380                       if (!in_array($flag, $data['all']['flags'])) 
    381                       $data['all']['flags'][] = $flag; 
    382                       // Handle the flags using bitwise operations. 1=-flag, 2=+flag, 3=Both a plus and minus 
    383                       if (isset($data['flags'][$flag])) { 
    384                           $data['flags'][$flag] |= (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 
    385                   } else { 
    386                       $data['flags'][$flag] = (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 
    387                   } 
    388                       continue; 
    389               } 
    390  
    391               // Strip the quotes away from match 
    392               if(substr($match, 0, 1) === '"' && substr($match, -1) === '"') { 
    393                       $match = trim(substr($match, 1, -1)); 
    394               } 
    395               // The match value isn't a flag or an option so consider it a string 
    396               if (!empty($match)) 
    397               $data['strings'][] = str_replace('\"', '"', $match); 
    398        
    399  
    400        $data['all']['strings'] = trim(implode(' ', $data['strings'])); 
    401        return $data; 
     330        // Strip away multiple spaces 
     331        $args = ' '.preg_replace('#\s+#', ' ', trim($args)).' '; 
     332 
     333        // Check the args string for agurments 
     334        preg_match_all('{'. 
     335        // String Regex: Matches "" | "foo" | "foo bar" | "foo \" bar" | foo 
     336        '(".*?(?<!\\\)" | [^-+\s]+) | '. 
     337        // Option Regex: Matches --opt | --opt foo | --opt= | --opt=foo | --opt="" | --opt="foo" | --opt="foo bar" 
     338        '(--\w+ (?:=".*?(?<!\\\)" | [=\s][^-+"\s]*)?) | '. 
     339        // Flag Regex: Matches -flag +flag 
     340        '([-+]\w+)'. 
     341        '}xi', 
     342        $args, $matches); 
     343        // Shifts the first group matches element off of matches 
     344        $matches = array_shift($matches); 
     345 
     346        // Returned data structure 
     347        $data = array( 
     348            'strings'    => array(), 
     349            'commands' => array(), 
     350            'flags'    => array(), 
     351            'all'      => array( 
     352                'strings'    => '', 
     353                'commands' => array(), 
     354                'flags'    => array() 
     355            ) 
     356        ); 
     357 
     358        // Loop through the results 
     359        foreach ($matches as $match) { 
     360              $match = trim($match); 
     361              // Check to see if the current match an an --option 
     362              if (substr($match, 0, 2 ) === '--') { 
     363                      $value = preg_split('/[=\s]/', $match, 2); 
     364                      $com   = substr(array_shift($value), 2); 
     365                      $value = trim(join($value)); 
     366                      // Strip quotes from the option's value 
     367                      $realValue = (substr($value, 0, 1) === '"' && substr($value, -1) === '"' || substr($match, -1) === '='); 
     368                      if(substr($value, 0, 1) === '"' && substr($value, -1) === '"') { 
     369                              $value = trim(substr($value, 1, -1)); 
     370                      } 
     371                      if (!in_array($com, $data['all']['commands'])) 
     372                      $data['all']['commands'][] = $com; 
     373                      $data['commands'][$com] = (!empty($value) || $realValue? str_replace('\"', '"', $value) : true); 
     374                      continue; 
     375              } 
     376 
     377              // Check to see if the current match is a -flag 
     378              if (substr($match, 0, 1) === '-' || substr($match, 0, 1) === '+') { 
     379                      $flag = substr($match, 1); 
     380                      if (!in_array($flag, $data['all']['flags'])) 
     381                      $data['all']['flags'][] = $flag; 
     382                      // Handle the flags using bitwise operations. 1=-flag, 2=+flag, 3=Both a plus and minus 
     383                      if (isset($data['flags'][$flag])) { 
     384                          $data['flags'][$flag] |= (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 
     385                  } else { 
     386                      $data['flags'][$flag] = (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 
     387                  } 
     388                      continue; 
     389              } 
     390 
     391              // Strip the quotes away from match 
     392              if(substr($match, 0, 1) === '"' && substr($match, -1) === '"') { 
     393                      $match = trim(substr($match, 1, -1)); 
     394              } 
     395              // The match value isn't a flag or an option so consider it a string 
     396              if (!empty($match)) 
     397              $data['strings'][] = str_replace('\"', '"', $match); 
     398       
     399 
     400        $data['all']['strings'] = trim(implode(' ', $data['strings'])); 
     401        return $data; 
    402402    } 
    403403 
     
    430430        } 
    431431 
    432        if ($time > 0 || count($return) <= 0) { 
    433               $return[] = $time . 's'; 
    434        
     432        if ($time > 0 || count($return) <= 0) { 
     433              $return[] = $time . 's'; 
     434       
    435435 
    436436        return implode(' ', $return); 
     
    450450        if (!empty($plugin)) { 
    451451            if (!$client) { 
    452                $client = $this->client; 
     452                $client = $this->client; 
    453453            } 
    454454            if (!is_array($plugins) || count($plugins) <= 0) { 
     
    748748        } 
    749749        if (((isset($source) && isset($this->muted[$source]) && $this->muted[$source]) || 
    750                (isset($this->muted['global']) && $this->muted['global'])) && 
    751                substr($method, 0, 2) === 'do') { 
    752                return false; 
     750            (isset($this->muted['global']) && $this->muted['global'])) && 
     751            substr($method, 0, 2) === 'do') { 
     752            return false; 
    753753        } 
    754754 
  • trunk/Phergie/Plugin/Abstract/Command.php

    r202 r203  
    8383                if ($this->needsAdmin && !$this->fromAdmin()) { 
    8484                    $this->doNotice($user, 'You do not have permission to use the command "' . $command . '."'); 
    85                    return; 
     85                    return; 
    8686                } 
    8787 
  • trunk/Phergie/Plugin/Acronym.php

    r200 r203  
    108108        $today = date('md'); 
    109109 
    110        // Matches an optional "Nick: " followed by an acronym formatted as A.B.C. or ABC 
     110        // Matches an optional "Nick: " followed by an acronym formatted as A.B.C. or ABC 
    111111        if (!preg_match('/^(?:[A-Za-z0-9\[\]`|{}_-]+: )?((?:[A-Z]\.?){2,})\?$/', $message, $acronym)) { 
    112112            return; 
  • trunk/Phergie/Plugin/ChuckNorris.php

    r200 r203  
    182182    private function findChuckNorris() { 
    183183        if (!$this->db) { 
    184                return false; 
     184            return false; 
    185185        } 
    186186 
     
    211211    private function feedChuckNorris() { 
    212212          if (!$this->db) { 
    213                  return false; 
     213                return false; 
    214214          } 
    215215 
     
    242242    { 
    243243        if (!$this->db) { 
    244                return; 
     244            return; 
    245245        } 
    246246 
     
    259259    { 
    260260        if (!$this->db) { 
    261                return; 
     261            return; 
    262262        } 
    263263 
     
    296296 
    297297        if (!$this->db) { 
    298                return; 
     298            return; 
    299299        } 
    300300 
  • trunk/Phergie/Plugin/Debug.php

    r200 r203  
    2323    { 
    2424        if (function_exists('memory_get_usage')) { 
    25                $target = $this->event->getNick(); 
     25            $target = $this->event->getNick(); 
    2626            $text = 'Current : '.number_format(memory_get_usage() / 1024).'KB' . 
    2727                    (function_exists('memory_get_peak_usage') ? ' / Peak : '.number_format(memory_get_peak_usage() / 1024).'KB' : ''); 
     
    7676 
    7777        if (empty($prog)) { 
    78                $message = 'Phergie Version: ' . PHERGIE_VERSION; 
     78            $message = 'Phergie Version: ' . PHERGIE_VERSION; 
    7979        } else if ($prog == 'php') { 
    80                $message = 'PHP Version: ' . phpversion(); 
     80            $message = 'PHP Version: ' . phpversion(); 
    8181        } else if (is_array($extensions) && in_array($prog, $extensions)) { 
    82                $version = phpversion($prog); 
    83                $message = ucfirst($prog) . ' Version: ' . ($version ? $version : 'N/A'); 
     82            $version = phpversion($prog); 
     83            $message = ucfirst($prog) . ' Version: ' . ($version ? $version : 'N/A'); 
    8484        } else { 
    85                $message = 'Unknown Extension: ' . ucfirst($prog); 
     85            $message = 'Unknown Extension: ' . ucfirst($prog); 
    8686        } 
    8787        $this->doPrivmsg($this->event->getSource(), $target . ': ' . $message); 
  • trunk/Phergie/Plugin/Dice.php

    r200 r203  
    2222    */ 
    2323    protected $max = array( 
    24        'total' => 20, 
    25        'dice' => 100, 
    26        'sides' => 100 
     24        'total' => 20, 
     25        'dice' => 100, 
     26        'sides' => 100 
    2727    ); 
    2828 
     
    9999        if (!empty($message)) { 
    100100            if (preg_match('{^(?:([0-9]+)[\#|:|\s])?(?:([0-9]+)[\s|d])?(?:[\s|d]?([0-9]+))(?:([+-])(.*))?$}ix', $message, $m)) { 
    101                if (isset($m[1]) && (!isset($m[2]) or empty($m[2]))) { 
    102                       $m[2] = $m[1]; $m[1] = null; 
    103                
    104                    $numDice = ($m[1] < 1 ? 1 : ($m[1] > $this->max['total'] ? $this->max['total'] : $m[1])); 
    105                    $dice = ($m[2] < 1 ? 1 : ($m[2] > $this->max['dice'] ? $this->max['dice'] : $m[2])); 
    106                    $sides = ($m[3] < 1 ? 1 : ($m[3] > $this->max['sides'] ? $this->max['sides'] : $m[3])); 
    107                    $operator = (isset($m[4]) && $m[4] == '+' ? true : false); 
    108                    $expression = ((isset($m[5]) && !empty($m[5])) ? trim($m[5]) : '0'); 
     101                if (isset($m[1]) && (!isset($m[2]) or empty($m[2]))) { 
     102                      $m[2] = $m[1]; $m[1] = null; 
     103               
     104                $numDice = ($m[1] < 1 ? 1 : ($m[1] > $this->max['total'] ? $this->max['total'] : $m[1])); 
     105                $dice = ($m[2] < 1 ? 1 : ($m[2] > $this->max['dice'] ? $this->max['dice'] : $m[2])); 
     106                $sides = ($m[3] < 1 ? 1 : ($m[3] > $this->max['sides'] ? $this->max['sides'] : $m[3])); 
     107                $operator = (isset($m[4]) && $m[4] == '+' ? true : false); 
     108                $expression = ((isset($m[5]) && !empty($m[5])) ? trim($m[5]) : '0'); 
    109109 
    110110                $bonus = 0; 
    111                    if (!empty($expression) && $this->allowExpressions) { 
    112                       $bonus = $this->processExpression($expression); 
    113                       if (is_null($bonus)) { 
    114                               return ' Error while processing the dice expression.'; 
    115                       } 
    116                    } 
     111                if (!empty($expression) && $this->allowExpressions) { 
     112                      $bonus = $this->processExpression($expression); 
     113                      if (is_null($bonus)) { 
     114                              return ' Error while processing the dice expression.'; 
     115                      } 
     116                } 
    117117 
    118118                $output = array(); 
     
    120120                    $total = 0; 
    121121                    for($d = 0; $d < $dice; $d++) { 
    122                        $total += intval(mt_rand(1, $sides) + ($operator ? $bonus : ($bonus * -1))); 
     122                        $total += intval(mt_rand(1, $sides) + ($operator ? $bonus : ($bonus * -1))); 
    123123                    } 
    124124                    $output[] = $total; 
  • trunk/Phergie/Plugin/Drink.php

    r200 r203  
    8888            $this->db = new PDO('sqlite:' . $this->dir . 'drink.db'); 
    8989            if (!$this->db) { 
    90                    return; 
     90        &n