Assembla home | Assembla project page
 

Changeset 205

Show
Ignore:
Timestamp:
04/04/08 10:28:52 (8 months ago)
Author:
Slynderdale
Message:

Replaced every tab in Phergie with spaces for a more unified formatting

Files:

Legend:

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

    r204 r205  
    159159    public function getPluginList($dirList = false, $preserveExt = false) 
    160160    { 
    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($filename, '.php')); 
    170                        
    171                
    172                unset($iterator, $filename, $dirList); 
    173  
    174                return $plugins; 
    175        
     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($filename, '.php')); 
     170               
     171           
     172            unset($iterator, $filename, $dirList); 
     173 
     174            return $plugins; 
     175       
    176176    } 
    177177 
     
    184184    public function getPlugin($plugin) 
    185185    { 
    186        $plugin = strtolower($plugin); 
    187        if (isset($this->plugins[$plugin])) 
    188                return $this->plugins[$plugin]; 
    189        return false; 
     186        $plugin = strtolower($plugin); 
     187        if (isset($this->plugins[$plugin])) 
     188            return $this->plugins[$plugin]; 
     189        return false; 
    190190    } 
    191191 
  • trunk/Phergie/Driver/Streams.php

    r204 r205  
    116116        } elseif ($this->getIni('keepalive')) { 
    117117            $timeout = 600; 
    118        } else { 
    119                $timeout = false; 
    120        
    121        $lastPacket = time(); 
     118        } else { 
     119            $timeout = false; 
     120       
     121        $lastPacket = time(); 
    122122 
    123123        unset($port); 
     
    167167                $buffer = fgets($this->socket, 512); 
    168168 
    169                        // Check if we timed out 
    170                        if ($timeout !== false) { 
    171                                // Reset last packet timestamp if we received something 
    172                                if (!empty($buffer)) { 
    173                                        $lastPacket = time(); 
    174                                
    175                                // Timed out, exit 
    176                                if ($lastPacket < (time() - $timeout)) { 
    177                                        $this->debug('Timed out'); 
    178                        foreach ($this->plugins as $plugin) { 
    179                            $plugin->shutdown(); 
    180                        } 
    181                                        break 2; 
    182                                
    183                        
     169                // Check if we timed out 
     170                if ($timeout !== false) { 
     171                    // Reset last packet timestamp if we received something 
     172                    if (!empty($buffer)) { 
     173                        $lastPacket = time(); 
     174                   
     175                    // Timed out, exit 
     176                    if ($lastPacket < (time() - $timeout)) { 
     177                        $this->debug('Timed out'); 
     178                        foreach ($this->plugins as $plugin) { 
     179                            $plugin->shutdown(); 
     180                        } 
     181                        break 2; 
     182                   
     183               
    184184            } 
    185185            if (!isset($buffer) || empty($buffer)) { 
     
    294294                // Skip disabled plugins 
    295295                if ($plugin->enabled === false) { 
    296                        continue; 
     296                    continue; 
    297297                } 
    298298                $plugin->setEvent($event); 
     
    604604        $version = trim($version); 
    605605        if (empty($version)) { 
    606                $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)'; 
     606            $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)'; 
    607607        } 
    608608        $this->doCtcpReply($target, 'version', $version); 
  • trunk/Phergie/Plugin/Abstract/Base.php

    r204 r205  
    285285                return chr(0); 
    286286                case ($code & 0x7F): 
    287                        return chr($code); 
     287                      return chr($code); 
    288288 
    289289                // 2 bytes, 11 bits 
    290290                case ($code & 0x7FF): 
    291                        return chr(0xC0 | (($code >> 6) & 0x1F)) . 
     291                      return chr(0xC0 | (($code >> 6) & 0x1F)) . 
    292292                       chr(0x80 | ($code & 0x3F)); 
    293293 
    294294                // 3 bytes, 16 bits 
    295295                case ($code & 0xFFFF): 
    296                        return chr(0xE0 | (($code >> 12) & 0x0F)) . 
     296                      return chr(0xE0 | (($code >> 12) & 0x0F)) . 
    297297                       chr(0x80 | (($code >> 6) & 0x3F)) . 
    298298                       chr(0x80 | ($code & 0x3F)); 
     
    300300                // 4 bytes, 21 bits 
    301301                case ($code & 0x1FFFFF): 
    302                        return chr(0xF0 | ($code >> 18)) . 
     302                      return chr(0xF0 | ($code >> 18)) . 
    303303                       chr(0x80 | (($code >> 12) & 0x3F)) . 
    304304                       chr(0x80 | (($code >> 6) & 0x3F)) . 
     
    358358        // Loop through the results 
    359359        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); 
     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); 
    398398        } 
    399399 
     
    431431 
    432432        if ($time > 0 || count($return) <= 0) { 
    433                $return[] = ($time > 0 ? $time : '0') . 's'; 
     433            $return[] = ($time > 0 ? $time : '0') . 's'; 
    434434        } 
    435435 
  • trunk/Phergie/Plugin/Dice.php

    r204 r205  
    104104            if (preg_match('{^(?:([0-9]+)[\#|:|\s])?(?:([0-9]+)[\s|d])?(?:[\s|d]?([0-9]+))(?:([+-])(.*))?$}ix', $message, $m)) { 
    105105                if (isset($m[1]) && (!isset($m[2]) or empty($m[2]))) { 
    106                        $m[2] = $m[1]; $m[1] = null; 
     106                    $m[2] = $m[1]; $m[1] = null; 
    107107                } 
    108108                $numDice = ($m[1] < 1 ? 1 : ($m[1] > $this->max['total'] ? $this->max['total'] : $m[1])); 
     
    114114                $bonus = 0; 
    115115                if (!empty($expression) && $this->allowExpressions) { 
    116                        $bonus = $this->processExpression($expression); 
    117                        if (is_null($bonus)) { 
    118                                return ' Error while processing the dice expression.'; 
    119                        
     116                    $bonus = $this->processExpression($expression); 
     117                    if (is_null($bonus)) { 
     118                        return ' Error while processing the dice expression.'; 
     119                   
    120120                } 
    121121 
  • trunk/Phergie/Plugin/Eval.php

    r203 r205  
    2424        // Check to see if the admin is a hostmask admin only and not an op 
    2525        if ($this->fromAdmin(false)) { 
    26                $code = trim($code); 
     26            $code = trim($code); 
    2727            if (empty($code)) { 
    2828                return; 
    2929            } 
    3030 
    31                // Check to see if the -r arg is set, if so, run the code as is, else prepend return 
    32                if (substr(strtolower($code), 0, 2) == '-r') { 
    33                        $code = trim(substr($code, 2)); 
    34                } else { 
    35                        $code = trim((strtolower(substr($code, 0, 6)) != 'return'?'return ':'') . $code); 
    36                
     31            // Check to see if the -r arg is set, if so, run the code as is, else prepend return 
     32            if (substr(strtolower($code), 0, 2) == '-r') { 
     33                $code = trim(substr($code, 2)); 
     34            } else { 
     35                $code = trim((strtolower(substr($code, 0, 6)) != 'return'?'return ':'') . $code); 
     36           
    3737 
    38                if (!empty($code)) { 
    39                        if (substr($code, -1) != ';') { 
    40                            $code .= ';'; 
    41                        
     38            if (!empty($code)) { 
     39                if (substr($code, -1) != ';') { 
     40                    $code .= ';'; 
     41               
    4242 
    4343                // Use output buffering to catch any output from eval 
    44                        ob_start(); 
    45                        $eval = eval($code); 
    46                        $contents = ob_get_contents(); 
    47                        ob_end_clean(); 
     44                ob_start(); 
     45                $eval = eval($code); 
     46                $contents = ob_get_contents(); 
     47                ob_end_clean(); 
    4848 
    4949                // Dump the content of the output buffering to the console 
    50                        if (!empty($contents)) { 
    51                                $this->debug('OUTPUT:' . PHP_EOL . trim($contents)); 
    52                                unset($contents); 
    53                        
     50                if (!empty($contents)) { 
     51                    $this->debug('OUTPUT:' . PHP_EOL . trim($contents)); 
     52                    unset($contents); 
     53               
    5454 
    55                        if (!empty($eval)) { 
    56                                $this->doPrivmsg($this->event->getSource(), trim($eval)); 
    57                                unset($eval); 
    58                        
    59                
     55                if (!empty($eval)) { 
     56                    $this->doPrivmsg($this->event->getSource(), trim($eval)); 
     57                    unset($eval); 
     58               
     59           
    6060        } else { 
    61                $this->doNotice($user, 'You do not have permission to use eval.'); 
     61            $this->doNotice($user, 'You do not have permission to use eval.'); 
    6262        } 
    6363    } 
     
    7575        // Check to see if the admin is a hostmask admin only and not an op 
    7676        if ($this->fromAdmin(false)) { 
    77                $code = trim($code); 
     77            $code = trim($code); 
    7878            if (empty($code)) { 
    7979                return; 
    8080            } 
    8181 
    82                $console = false; 
    83                // Check to see if the -c arg is set, if so, dump the entire exec result to console 
    84                if (substr(strtolower($code), 0, 2) == '-c') { 
    85                        $code = trim(substr($code, 2)); 
    86                        $console = true; 
    87                
     82            $console = false; 
     83            // Check to see if the -c arg is set, if so, dump the entire exec result to console 
     84            if (substr(strtolower($code), 0, 2) == '-c') { 
     85                $code = trim(substr($code, 2)); 
     86                $console = true; 
     87           
    8888 
    89                if (!empty($code)) { 
    90                    $exec = exec($code, $output); 
    91                    if (!empty($exec)) { 
    92                            $this->doPrivmsg($this->event->getSource(), trim($exec)); 
    93                            unset($exec); 
    94                        
    95                        if (!empty($output)) { 
    96                                if ($console) { 
    97                                        $this->debug('OUTPUT:' . PHP_EOL . implode("\n", $output)); 
    98                                
    99                                unset($output); 
    100                        
    101                
     89            if (!empty($code)) { 
     90                $exec = exec($code, $output); 
     91                if (!empty($exec)) { 
     92                    $this->doPrivmsg($this->event->getSource(), trim($exec)); 
     93                    unset($exec); 
     94               
     95                if (!empty($output)) { 
     96                    if ($console) { 
     97                        $this->debug('OUTPUT:' . PHP_EOL . implode("\n", $output)); 
     98                   
     99                    unset($output); 
     100               
     101           
    102102        } else { 
    103                $this->doNotice($user, 'You do not have permission to use exec.'); 
     103            $this->doNotice($user, 'You do not have permission to use exec.'); 
    104104        } 
    105105    } 
  • trunk/Phergie/Plugin/JoinPart.php

    r203 r205  
    6161                    } 
    6262                    if (!$this->usersEnabled) { 
    63                         // A fallback, most IRC servers cause the user to part all channels if they try to join 0 
    64                         $this->doJoin('0'); 
     63                        // A fallback, most IRC servers cause the user to part all channels if they try to join 0 
     64                        $this->doJoin('0'); 
    6565                    } else { 
    6666                        $channels = implode(',', Phergie_Plugin_Users::getChannels()); 
  • trunk/Phergie/Plugin/Karma.php

    r204 r205  
    117117 
    118118        $this->positiveAnswers = array ( 
    119                'No kidding, %owner% totally kicks %owned%\'s ass !', 
    120                'True that.', 
    121                'I concur.', 
    122                'Yay, %owner% ftw !', 
    123                '%owner% is made of WIN!', 
    124                'Nothing can beat %owner%!', 
     119            'No kidding, %owner% totally kicks %owned%\'s ass !', 
     120            'True that.', 
     121            'I concur.', 
     122            'Yay, %owner% ftw !', 
     123            '%owner% is made of WIN!', 
     124            'Nothing can beat %owner%!', 
    125125        ); 
    126126 
    127127        $this->negativeAnswers = array 
    128128        ( 
    129                'No sir, not at all.', 
    130                'You\'re wrong dude, %owner% wins.', 
    131                'I\'d say %owner% is better than %owned%.', 
    132                'You must be joking, %owner% ftw!', 
    133                '%owned% is made of LOSE!', 
    134                '%owned% = Epic Fail', 
     129            'No sir, not at all.', 
     130            'You\'re wrong dude, %owner% wins.', 
     131            'I\'d say %owner% is better than %owned%.', 
     132            'You must be joking, %owner% ftw!', 
     133            '%owned% is made of LOSE!', 
     134            '%owned% = Epic Fail', 
    135135        ); 
    136136 
     
    376376 
    377377            // Fetch first word 
    378                if ($word1 === '*' || $word1 === 'all' || $word1 === 'everything') { 
     378            if ($word1 === '*' || $word1 === 'all' || $word1 === 'everything') { 
    379379                   $res = array('karma' => 0); 
    380380                   $word1 = 'everything'; 
    381                } else { 
     381            } else { 
    382382                $this->fetchKarma->execute(array(':word'=>$word1)); 
    383383                $res = $this->fetchKarma->fetch(PDO::FETCH_ASSOC); 
    384                
     384           
    385385            // If it exists, fetch second word 
    386386            if ($res) { 
    387                        if ($word2 === '*' || $word2 === 'all' || $word2 === 'everything') { 
     387                if ($word2 === '*' || $word2 === 'all' || $word2 === 'everything') { 
    388388                    $res2 = array('karma' => 0); 
    389389                    $word2 = 'everything'; 
    390                        } else { 
     390                } else { 
    391391                    $this->fetchKarma->execute(array(':word'=>$word2)); 
    392392                    $res2 = $this->fetchKarma->fetch(PDO::FETCH_ASSOC); 
    393                        
     393               
    394394                // If it exists, compare and return value 
    395395                if ($res2 && $res['karma'] != $res2['karma']) { 
     
    397397                       // Switch arguments if they are in the wrong order 
    398398                       if ($operator === '<') { 
    399                                $tmp = $word2; $word2 = $word1; $word1 = $tmp; 
     399                           $tmp = $word2; $word2 = $word1; $word1 = $tmp; 
    400400                       } 
    401401                       $this->doPrivmsg($source, $assertion ? $this->fetchPositiveAnswer($word1, $word2) : $this->fetchNegativeAnswer($word1, $word2) ); 
  • trunk/Phergie/Plugin/Lart.php

    r204 r205  
    8181    { 
    8282        try { 
    83                // Initialize the database connection 
    84                $this->db = new PDO('sqlite:' . $this->dir . 'lart.db'); 
     83            // Initialize the database connection 
     84            $this->db = new PDO('sqlite:' . $this->dir . 'lart.db'); 
    8585            if (!$this->db) { 
    8686                return; 
    8787            } 
    8888 
    89                // Check to see if the table exists 
    90                $table = $this->db 
    91                    ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . $this->db->quote('lart')) 
    92                    ->fetchColumn(); 
    93  
    94                // Create database tables if necessary 
    95                if (!$table) { 
    96                        $this->debug('Creating the database schema'); 
    97                        $this->db->exec(' 
    98                            CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 
    99                            CREATE UNIQUE INDEX lart_name ON lart (name) 
    100                        '); 
    101                
    102                unset($table); 
    103  
    104                // Get the list of columns from the table 
    105                $table = $this->db 
    106                    ->query('PRAGMA table_info(' . $this->db->quote('lart') . ')') 
    107                    ->fetchAll(); 
    108  
    109                $columns = array(); 
    110                foreach($table as $key => $column) { 
    111                        $columns[] = $column['name']; 
    112                
    113                unset($table); 
    114  
    115                // Update table as neccessary 
    116                if (!in_array('hostmask', $columns)) { 
    117                        $this->debug('Updating the database schema'); 
    118                        $this->db->exec(' 
    119                            BEGIN TRANSACTION; 
    120                            CREATE TEMPORARY TABLE lart_backup (name VARCHAR(255), definition TEXT); 
    121                            INSERT INTO lart_backup SELECT name, definition FROM lart; 
    122                            DROP TABLE lart; 
    123                            CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 
    124                            INSERT INTO lart SELECT name, definition, NULL, NULL FROM lart_backup; 
    125                            DROP TABLE lart_backup; 
    126                            COMMIT; 
    127                            CREATE UNIQUE INDEX lart_name ON lart (name) 
    128                        '); 
    129                
    130                unset($table, $key, $column, $columns); 
    131  
    132                // Initialize prepared statements for common operations 
    133                $this->replace = $this->db->prepare(' 
    134                    REPLACE INTO lart (name, definition, hostmask, tstamp) VALUES (:name, :definition, :hostmask, :tstamp) 
    135                '); 
    136                $this->defination = $this->db->prepare(' 
    137                    SELECT definition FROM lart WHERE LOWER(name) = LOWER(:name) 
    138                '); 
    139                $this->alias = $this->db->prepare(' 
    140                    SELECT name FROM lart WHERE LOWER(definition) = LOWER(:definition) 
    141                '); 
    142                $this->select = $this->db->prepare(' 
    143                    SELECT * FROM lart WHERE LOWER(name) = LOWER(:name) 
    144                '); 
    145                $this->delete = $this->db->prepare(' 
    146                    DELETE FROM lart WHERE LOWER(name) = LOWER(:name) 
    147                '); 
     89            // Check to see if the table exists 
     90            $table = $this->db 
     91                ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . $this->db->quote('lart')) 
     92                ->fetchColumn(); 
     93 
     94            // Create database tables if necessary 
     95            if (!$table) { 
     96                $this->debug('Creating the database schema'); 
     97                $this->db->exec(' 
     98                    CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 
     99                    CREATE UNIQUE INDEX lart_name ON lart (name) 
     100                '); 
     101           
     102            unset($table); 
     103 
     104            // Get the list of columns from the table 
     105            $table = $this->db 
     106                ->query('PRAGMA table_info(' . $this->db->quote('lart') . ')') 
     107                ->fetchAll(); 
     108 
     109            $columns = array(); 
     110            foreach($table as $key => $column) { 
     111                $columns[] = $column['name']; 
     112           
     113            unset($table); 
     114 
     115            // Update table as neccessary 
     116            if (!in_array('hostmask', $columns)) { 
     117                $this->debug('Updating the database schema'); 
     118                $this->db->exec(' 
     119                    BEGIN TRANSACTION; 
     120                    CREATE TEMPORARY TABLE lart_backup (name VARCHAR(255), definition TEXT); 
     121                    INSERT INTO lart_backup SELECT name, definition FROM lart; 
     122                    DROP TABLE lart; 
     123                    CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 
     124                    INSERT INTO lart SELECT name, definition, NULL, NULL FROM lart_backup; 
     125                    DROP TABLE lart_backup; 
     126                    COMMIT; 
     127                    CREATE UNIQUE INDEX lart_name ON lart (name) 
     128                '); 
     129           
     130            unset($table, $key, $column, $columns); 
     131 
     132            // Initialize prepared statements for common operations 
     133            $this->replace = $this->db->prepare(' 
     134                REPLACE INTO lart (name, definition, hostmask, tstamp) VALUES (:name, :definition, :hostmask, :tstamp) 
     135            '); 
     136            $this->defination = $this->db->prepare(' 
     137                SELECT definition FROM lart WHERE LOWER(name) = LOWER(:name) 
     138            '); 
     139            $this->alias = $this->db->prepare(' 
     140                SELECT name FROM lart WHERE LOWER(definition) = LOWER(:definition) 
     141            '); 
     142            $this->select = $this->db->prepare(' 
     143                SELECT * FROM lart WHERE LOWER(name) = LOWER(:name) 
     144            '); 
     145            $this->delete = $this->db->prepare(' 
     146                DELETE FROM lart WHERE LOWER(name) = LOWER(:name) 
     147            '); 
    148148        } catch (PDOException $e) { } 
    149149    } 
     
    162162        if (!extension_loaded('PDO') 
    163163            || !extension_loaded('pdo_sqlite')) { 
    164                return false; 
     164            return false; 
    165165        } 
    166166 
     
    179179    { 
    180180        if (!isset($this->cache[$term])) { 
    181                $this->defination->execute(array(':name' => $term)); 
    182                $definition = $this->defination->fetchColumn(); 
    183                if ($definition) { 
    184                        $this->cache[$term] = $definition; 
    185                } else { 
    186                        return false; 
    187                
     181            $this->defination->execute(array(':name' => $term)); 
     182            $definition = $this->defination->fetchColumn(); 
     183            if ($definition) { 
     184                $this->cache[$term] = $definition; 
     185            } else { 
     186                return false; 
     187           
    188188        } 
    189189        return $this->cache[$term]; 
     
    202202        $names = $this->alias->fetchAll(); 
    203203        if ($names && count($names) > 0) { 
    204                return $names; 
     204            return $names; 
    205205        } else { 
    206                return false; 
     206            return false; 
    207207        } 
    208208    } 
     
    219219    { 
    220220        if (empty($message) || strlen($message) > 255) { 
    221                return; 
     221            return; 
    222222        } 
    223223 
     
    226226 
    227227        if (!empty($definition)) { 
    228                do { 
    229                        if (strtolower($message) == strtolower($definition)) { 
    230                                break; 
    231                        
    232                        $redirect = trim($this->getDefinition($definition)); 
    233                        if (!empty($redirect)) { 
    234                                if (strtolower($definition) == strtolower($redirect)) { 
    235                                        $definition = $redirect; 
    236                                        break; 
    237                                
    238                                $seen[] = strtolower($definition); 
    239                                if (in_array($redirect, $seen)) { 
    240                                        $this->debug('Alias redirection loop detected'); 
    241                                        $this->deleteLart($message); 
    242                                        $mod = $this->getIni('gender') == 'F' ? 'her' : 'his'; 
    243                                        $this->doAction( 
    244                                        $this->event->getArgument(0), 
    245                                            'puts ' . $mod . ' hands over ' . $mod . ' ears and cries, "Stop confusing me!"' 
    246                                        ); 
    247                                        return; 
    248                                
    249                                $definition = $redirect; 
    250                        
    251                } while(!empty($redirect)); 
    252  
    253                if (substr($definition, 0, 3) == '/me') { 
    254                        $definition = trim(substr($definition, 3)); 
    255                        $this->doAction($this->event->getSource(), $definition); 
    256                } else { 
    257                        $this->doPrivmsg($this->event->getSource(), $definition); 
    258                
     228            do { 
     229                if (strtolower($message) == strtolower($definition)) { 
     230                    break; 
     231               
     232                $redirect = trim($this->getDefinition($definition)); 
     233                if (!empty($redirect)) { 
     234                    if (strtolower($definition) == strtolower($redirect)) { 
     235                        $definition = $redirect; 
     236                        break; 
     237                   
     238                    $seen[] = strtolower($definition); 
     239                    if (in_array($redirect, $seen)) { 
     240                        $this->debug('Alias redirection loop detected'); 
     241                        $this->deleteLart($message); 
     242                        $mod = $this->getIni('gender') == 'F' ? 'her' : 'his'; 
     243                        $this->doAction( 
     244                        $this->event->getArgument(0), 
     245                            'puts ' . $mod . ' hands over ' . $mod . ' ears and cries, "Stop confusing me!"' 
     246                        ); 
     247                        return; 
     248                   
     249                    $definition = $redirect; 
     250               
     251            } while(!empty($redirect)); 
     252 
     253            if (substr($definition, 0, 3) == '/me') { 
     254                $definition = trim(substr($definition, 3)); 
     255                $this->doAction($this->event->getSource(), $definition); 
     256            } else { 
     257                $this->doPrivmsg($this->event->getSource(), $definition); 
     258           
    259259        } 
    260260    } 
     
    270270    { 
    271271        if (!is_array($this->aCache) || $firstRun) { 
    272                unset($this->aCache); $this->aCache = array(); 
     272            unset($this->aCache); $this->aCache = array(); 
    273273        } 
    274274 
    275275        $alias = $this->getAlias(trim($term)); 
    276276        if ($alias) { 
    277                foreach($alias as $key => $value) { 
    278                        $name = $value['name']; 
    279                        if (empty($name)) 
    280                        continue; 
    281                        if (!in_array($name, $this->aCache)) { 
    282                                $this->aCache[] = strtolower($name); 
    283                                if ($recursive) { 
    284                                        $this->getAliases($name, true, false); 
    285                                
    286                        
    287                
     277            foreach($alias as $key => $value) { 
     278                $name = $value['name']; 
     279                if (empty($name)) 
     280                continue; 
     281                if (!in_array($name, $this->aCache)) { 
     282                    $this->aCache[] = strtolower($name); 
     283                    if ($recursive) { 
     284                        $this->getAliases($name, true, false); 
     285                   
     286               
     287           
    288288        }