<?php
set_time_limit 
) ;
ignore_user_abort true ) ;

include ( 
'TheDarkestDayFuncs.php' ) ;
print ( 
"\033[0;32;1m" ) ;
$Servers = array (
    array (
        
'host' => 'irc.xettex.net',
        
'port' => 6667,
        
'timeout' => 15,
        
'nick' => 'SomeBot',
        
'password' => '',
        
'join' => '#xettexnet',    
        
'owner' => '',
        
'oper' => '' //most people won't use this anyway
    
),
    array (
        
'host' => 'irc.dal.net',
        
'port' => 6667,
        
'timeout' => 15,
        
'nick' => 'SystemReboot',
        
'password' => '',
        
'join' => '#rohitab',    
        
'owner' => '',
        
'oper' => ''
    
)
) ;
for ( 
$i $i count $Servers ) ; $i ++ )
{
    
$PID pcntl_fork ( ) ;
    if ( 
$PID != -&& ! $PID )
    {
        
$Host $Servers[$i]['host'] ;
        
$Port $Servers[$i]['port'] ;
        
$TimeOut $Servers[$i]['timeout'] ;
        
$PassHaxs $Servers[$i]['password'] ;
        
$Join $Servers[$i]['join'] ;
        
$OperInfo $Servers[$i]['oper'] ;
        
$MyNick $Servers[$i]['nick'] ;
        
$Authed = array ( ) ;
        
$Auth trim ( @ file_get_contents 'auth' ) ) ;
        
$Locks explode "\n"trim ( @ file_get_contents 'lock' ) )  );
        
$Live true ;
        
$Vers explode "\n"trim ( @ file_get_contents 'vers' ) ) ) ;
        
$STFUAlready false ;
        global 
$STFUAlready ;

        while ( 
$Live )
        {
            
$Socket fsockopen $Host$Port$ErrNo$ErrStr$TimeOut ) ;
            if ( 
$Socket )
            {
                
Send $Socket"USER {$MyNick} {$MyNick} {$MyNick} {$MyNick}\n" ) ;
                
Send $Socket"NICK {$MyNick}\n" ) ;
                if ( 
$OperInfo )
                {
                    
Send $Socket"OPER {$OperInfo}\n" ) ;
                }
                
$STFUAlready true ;
                while ( ! 
feof $Socket ) )
                {
        
/*            $Data = file_get_contents ( 'http://localhost:8082/NowPlaying.htm' ) ;
                    if ( preg_match ( '/Title:(.+)/', $Data, $Title ) && preg_match ( '/Artist:(.+)/', $Data, $Artist ) )
                    {
                        $Return = "\2\3" . '6' . "{$Artist[1]}\2\3 - \3" . '8' . "\x1f{$Title[1]}\x1f\3" ;
                    }
                    elseif ( preg_match ( '/PLAYLIST FILENAME:([^\/]*\/)+([^\.]+)/', $Data, $FileName ) )
                    {
                        $FileName = $FileName[2] ;
                        if ( strpos ( $FileName, '-' ) !== false )
                        {
                            $Return = $FileName ;
                        }
                    }
                    $Return = ( $Return ) ? $Return : 'I just don\'t know.' ;
                    if ( $LastReturn != $Return && $Return != 'I just don\'t know.' )
                    {
                        $LastReturn = $Return ;
                        Send ( $Socket, "PRIVMSG {$LastChan} :\1ACTION is dancing to: {$Return} :D|-<\1\n" ) ;
                    }*/
                    
if ( ! feof $Socket ) )
                    {
                        
$LolMsg trim fgets $Socket1024 ) ) ;
                        
$Message explode ' '$LolMsg) ;
                        
$Nick explode '!'substr $Message[0], ) ) ;
                        
$Nick $Nick[0] ;
                        
$Chan = ( $Message[2] == $MyNick ) ? $Nick $Message[2] ;
                        if ( 
$Nick == $Owner || in_array strtolower $Nick ), $Authed ) )
                        {
                            
$Msgs explode ' 'substr $Message[3], ), ) ;
                            
$Deauths explode ' '$Message[3] ) ;
                            
$Message[2] = ( $Message[2] == $MyNick ) ? $Nick $Message[2] ;
                            switch ( 
strtolower $Msgs[0] ) )
                            {
                                case 
'^eval' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        eval ( 
substr $Message[3], strlen $Msgs[0] ) ) ) ;
                                    }
                                    break ;
                                case 
'^quit' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        
$Live false ;
                                        
$QuitMessage substr $Message[3], strlen $Msgs[0] ) ) ;
                                        
$QuitMessage preg_replace '/\s+$/'''preg_replace '/\s{2,}/'''$QuitMessage ) ) ;
                                        if ( ! 
$QuitMessage )
                                        {
                                            
$QuitMessage 'Auf Wiedersehen' ;
                                        }
                                        
Send $Socket"QUIT :{$QuitMessage}\n" ) ;
                                    }
                                    break ;
                                case 
'^raw' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        
Send $Socketsubstr $Message[3], strlen $Msgs[0] ) ) . "\n" ) ;
                                    }
                                    break ;
                                case 
'^ain' :
                                    for ( 
$i $i count $Deauths ) ; $i ++ )
                                    {
                                        if ( ! ( 
preg_match "/^{$Deauths[$i]}\b/i"$Auth ) || preg_match "/\b{$Deauths[$i]}\b/i"$Auth ) || preg_match "/\b{$Deauths[$i]}$/i"$Auth ) ) )
                                        {
                                            
$Auth .= " {$Deauths[$i]}" ;
                                        }
                                        else
                                        {
                                            
Send $Socket"NOTICE {$Nick} :{$Deauths[$i]} is already authed!\n" ) ;
                                        }
                                    }
                                    
$Auth trim $Auth ) ;
                                    break ;
                                case 
'^aout' :
                                    for ( 
$i $i count $Deauths ) ; $i ++ )
                                    {
                                        
$Auth trim str_replace '  '' 'str_replace " {$Deauths[$i]}"' 'str_replace "{$Deauths[$i]} "''$Auth ) ) ) ) ;
                                    }
                                    break ;
                                case 
'^stfu' :
                                    
$STFUAlready = ( $STFUAlready ) ? false true ;
                                    break ;
                                case 
'^server' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        if ( 
count $Msgs ) > )
                                        {
                                            
$Host $Msgs[1] ;
                                            
$Port $Msgs[2] ;
                                            
$TimeOut $Msgs[3] ;
                                            
$MyNick $Msgs[4] ;
                                            
$Join $Msgs[5] ;
                                            
$Owner $Msgs[6] ;
                                            
$StartCmd $Msgs[7] ;
                                            
$Socket fsockopen $Host$Port$ErrNo$ErrStr$TimeOut ) ;
                                            if ( 
$Socket )
                                            {
                                                
Send $Socket"USER {$MyNick} {$MyNick} {$MyNick} {$MyNick}\nNICK {$MyNick}\nJOIN {$Join}\n{$StartCmd}\n" ) ;
                                            }
                                            else
                                            {
                                                
$Live false;
                                            }
                                        }
                                        else
                                        {
                                            
Send $Socket"NOTICE {$Nick} :^server HOST PORT TIMEOUT NICK JOIN OWNER [Startup Command]\n" ) ;
                                        }
                                    }
                                    break ;
                                case 
'^say' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" substr $Message[3], strlen $Msgs[0] ) ) . "\n" ) ;
                                    break ;
                                case 
'^nick' :
                                    
Send $Socket"NICK {$Msgs[1]}\n" ) ;
                                    
$MyNick $Msgs[1] ;
                                    break ;
                                case 
'^fix' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" str_replace "\xA0"' 'substr $Message[3], strlen $Msgs[0] ) ) ) . "\n" ) ;
                                    break ;
                                case 
'^join' :
                                    
Send $Socket"JOIN " substr $Message[3], strlen $Msgs[0] ) ) . "\n" ) ;
                                    break ;
                                case 
'^list' :
                                    
$Colors = ( $Nick == $Owner ) ? '9,1' '4,1' ;
                                    
$TempAuth preg_replace "/(.*?){$Nick}(.*?)/"'\\1' chr(3) . "9{$Nick}" chr(3) . '\\2'$Auth 
            
) ;
                                    
Send $Socket"NOTICE {$Nick} :\3{$Colors}\2{$Owner}\2\3 {$TempAuth}\n" ) ;
                                    break ;
                                case 
'^rehash' :
                                    
$File fopen 'auth''w' ) ;
                                    
fwrite $File$Auth ) ;
                                    
fclose $File ) ;
                                    
$File fopen 'vers''w' ) ;
                                    for ( 
$i $i count $Vers ) ; $i ++ )
                                    {
                                        
fwrite $File"{$Vers[$i]}\n" ) ;
                                    }
                                    
fclose $File ) ;
                                    break ;
                                case 
'^reload' :
                                    
$Auth trim ( @ file_get_contents 'auth' ) ) ;
                                    
$Vers explode "\n"trim ( @ file_get_contents 'vers' ) ) ) ;
                                    break ;
                                case 
'^veradd' :
                                    
$Vers[( count $Vers ) )] = trim substr $Message[3], strlen $Msgs[0] ) ) ) ;
                                    break ;
                                case 
'^download' :
                                    
$File preg_replace '/(.+?)(;|&&)(.*)/''\\1'trim substr $Message[3], strlen $Msgs[0] ) ) ) ) ;
                                    
Send $Socket"PRIVMSG {$Message[2]} :Attempting to Download {$File}\n" ) ;
                                    
exec "wget {$File}"$Output ) ;
                                    break ;
                                case 
'^copy' :
                                    
$Copy $Msgs[1] ;
                                    break ;
                                case 
'^ypoc' :
                                    
$Ypoc $Msgs[1] ;
                                    break ;
                                case 
'^random' :
                                    
$RandomizeMe explode ' '$Message[3], ) ;
                                    
$RandomizeMe $RandomizeMe[1] ;
                                    
Send $Socket"PRIVMSG {$Message[2]} :" randomizeMe $RandomizeMe ) . "\n" ) ;
                                    break ;
                                case 
'^deutsch' :
                                    switch ( 
$Msgs[1] )
                                    {
                                        case 
'a' :
                                            
$Char "\xE4" ;
                                            break ;
                                        case 
'o' :
                                            
$Char "\xF6" ;
                                            break ;
                                        case 
'u' :
                                            
$Char "\xFC" ;
                                            break ;
                                        case 
'ss' :
                                            
$Char "\xDF" ;
                                            break ;
                                        case 
'A' :
                                            
$Char "\xC4" ;
                                            break ;
                                        case 
'O' :
                                            
$Char "\xD6" ;
                                            break ;
                                        case 
'U' :
                                            
$Char "\xDC" ;
                                            break ;
                                        case 
'SS' :
                                            
$Char 'SS' ;
                                            break ;
                                        default :
                                            
$Char 'LOL, FAIL' ;
                                            break ;
                                    }
                                    
Send $Socket"NOTICE {$Nick} :{$Char}\n" ) ;
                                    break ;
                                case 
'^mix' :
                                    
$MIX $Msgs[1] ;
                                    break ;
                                case 
'^command' :
                                case 
'^commands' :
                                case 
'^help' :
                                case 
'^cmd' :
                                    if ( 
$Msgs[1] )
                                    {
                                        switch ( 
strtolower $Msgs[1] ) )
                                        {
                                            case 
'saset' :
                                                
Send $Socket"NOTICE {$Nick} :^saset greet <NICK> <GREET MESSAGE>\n" .
                                                
"NOTICE {$Nick} :^saset check <NICK>\n" .
                                                
"NOTICE {$Nick} :^saset del <NICK>\n" ) ;
                                                break ;
                                            default :
                                                
Send $Socket"NOTICE {$Nick} :Sorry, Help for {$Msgs[1]} not found\n" ) ;
                                                break ;
                                        }
                                    }
                                    else
                                    {
                                        if ( 
$Nick == $Owner )
                                        {
                                            
Send $Socket"NOTICE {$Nick} :^quit <QUIT MESSAGE>\n" .
                                                                        
"NOTICE {$Nick} :^eval <PHP CODE>\n" .
                                                                        
"NOTICE {$Nick} :^server  <HOST> <PORT> <TIMEOUT> <NICK> <JOIN> <OWNER> [Startup Command]\n" ) ;
                                        }
                                        
Send $Socket"NOTICE {$Nick} :^ain <USER(S) TO GIVE AUTHS TO>\n" .
                                        
"NOTICE {$Nick} :^aout <USER(S) TO REMOVE AUTHS FROM>\n" .
                                        
"NOTICE {$Nick} :^say <MSG TO SAY>\n" .
                                        
"NOTICE {$Nick} :^nick <NEW_NICK>\n" .
                                        
"NOTICE {$Nick} :^join <ROOM_TO_JOIN>\n" .
                                        
"NOTICE {$Nick} :^list (NO PARAMETERS. Shows Authed Users.)\n" .
                                        
"NOTICE {$Nick} :^rehash (NO PARAMETERS. Saves current authlist and version list)\n" .
                                        
"NOTICE {$Nick} :^reload (NO PARAMETERS. Loads authlist and version list from file)\n" .
                                        
"NOTICE {$Nick} :^veradd <VERSION REPLY TO ADD>\n" .
                                        
"NOTICE {$Nick} :^download <FILE_TO_DOWNLOAD>\n" .
                                        
"NOTICE {$Nick} :^copy <PERSON_TO_COPY>\n" .
                                        
"NOTICE {$Nick} :^ypoc <YPOC_OT_NOSREP>\n" .
                                        
"NOTICE {$Nick} :^greet <GREET MESSAGE>\n" .
                                        
"NOTICE {$Nick} :^checkgreet (NO PARAMETERS. Check your greet message.)\n" .
                                        
"NOTICE {$Nick} :^delgreet (NO PARAMETERS. Delete all greet messages for you)\n" .
                                        
"NOTICE {$Nick} :^saset (See {$Msgs[0]} saset)\n" .
                                        
"NOTICE {$Nick} :^nthprime <N>\n" .
                                        
"NOTICE {$Nick} :! <X> (x!)\n" .
                                        
"NOTICE {$Nick} :^str2bin <STRING>\n" .
                                        
"NOTICE {$Nick} :^bin2str <BINARY> (separate by spaces)\n" .
                                        
"NOTICE {$Nick} :^e (NO PARAMETERS. Roughly calculate e.)\n" .
                                        
"NOTICE {$Nick} :^random <Randomize This> (char to be replaced by random character is *)\n" ) ;
                                    }
                                    break ;
                                case 
'^add' :
                                    
$Numbers $Msgs[1] + $Msgs[3] ;
                                    
Send $Socket"PRIVMSG {$Message[2]} :{$Numbers}\n" ) ;
                                    break ;
                                case 
'^lock' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        
array_push $Locksstrtolower trim substr $Message[3], strlen $Msgs[0] ) ) ) ) ) ;
                                    }
                                    break ;
                                case 
'^unlock' :
                                    if ( 
$Nick == $Owner )
                                    {
                                        while ( 
false !== ( $ArrKey array_search strtolower trim substr $Message[3], strlen $Msgs[0] ) ) ) ), $Locks ) ) ) ;
                                        
array_splice $Locks$ArrKey ) ;
                                    }
                                    break ;
                                case 
'e' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" calc_e intval trim substr $Message[3], strlen $Msgs[0] ) ) ) ) ) . "\n" ) ;
                                    break ;
                                case 
'^exaile' :
                                    
$ED substr $Message[3], strlen $Msgs[0] ) ) ;
                                    
exec "python exaile {$ED}"$ExaileData ) ;
                                    for ( 
$i $i count $ExaileData ) ; $i ++ )
                                    {
                                        
$ExaileD .= "NOTICE {$Nick} :{$ExaileData[$i]}\n" ;
                                    }
                                    
Send $Socket$ExaileD ) ;
                                    unset ( 
$ExaileD ) ;
                                    unset ( 
$ExaileData ) ;
                                    unset ( 
$ED ) ;
                                    break ;
                                case 
'^bin2str' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" str_replace ( array ( "\r""\n""\r\n" ), array ( "\\r""\\n""\\r\\n" ), binstrTDD substr $Message[3], strlen $Msgs[0] ) ) ) ) . "\n" ) ;
                                    break ;
                                case 
'^str2bin' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" strbinTDD substr $Message[3], strlen $Msgs[0] ) ) ) . "\n" ) ;
                                    break ;
                                case 
'!' :
                                    if ( 
substr $Message[3], strlen $Msgs[0] ) ) > 170 && is_numeric substr $Message[3], strlen $Msgs[0] ) ) ) )
                                    {
                                        
Send $Socket"PRIVMSG {$Message[2]} :OMFG LOL !" substr $Message[3], strlen $Msgs[0] ) ) . " == INFINITY !!\n" ) ;
                                    }
                                    elseif ( 
is_numeric substr $Message[3], strlen $Msgs[0] ) ) ) && substr $Message[3], strlen $Msgs[0] ) ) > )
                                    {
                                        
Send $Socket"PRIVMSG {$Message[2]} :!" substr $Message[3], strlen $Msgs[0] ) ) . ' == ' factorial substr $Message[3], strlen $Msgs[0] ) ) ) . "\n" ) ;
                                    }
                                    break ;
                                case 
'^nthprime' :
                                    
Send $Socket"PRIVMSG {$Message[2]} :" find_nth_prime substr $Message[3], strlen $Msgs[0] ) ) ) . "\n" ) ;
                                    break ;
                                case 
'^saset' :
                                    switch ( 
$Msgs[1] )
                                    {
                                        case 
'greet' :
                                            
$FileHandle fopen "greet.log"'a' ) ;
                                            
fwrite $FileHandle"{$Msgs[2]}:|awefoicanec`nwocinwqoxm|:" trim substr $Message[3], strlen "{$Msgs[0]} {$Msgs[1]} {$Msgs[2]}" ) ) ) . "\n" ) ;
                                            
fclose $FileHandle ) ;
                                            break ;
                                        case 
'check' :
                                            
$Dataz explode "\n", @ file_get_contents 'greet.log' ) ) ;
                                            for ( 
$i $i count $Dataz ) ; $i ++ )
                                            {
                                                
$Data explode ':|awefoicanec`nwocinwqoxm|:'$Dataz[$i] ) ;
                                                if ( 
strtolower $Data[0] ) == strtolower $Msgs[2] ) )
                                                {
                                                    
$UserGreet $i ;
                                                }
                                                
$Dataz[$i] = $Data[1] ;
                                            }
                                            if ( 
$UserGreet !== false )
                                            {
                                                
Send $Socket"NOTICE {$Nick} :[{$Msgs[2]}] {$Dataz[$UserGreet]}\n" ) ;
                                            }
                                            break ;
                                        case 
'del' :
                                            
$CurFile file_get_contents 'greet.log' ) ;
                                            
$FileHandle fopen 'greet.log''w' ) ;
                                            
fwrite $FileHandlepreg_replace '/' $Msgs[2] . ':\|awefoicanec`nwocinwqoxm\|:.*\\n/'''$CurFile ) ) ;
                                            
fclose $FileHandle ) ;
                                            break ;
                                        default :
                                            break ;
                                    }
                                default :
                                    break ;
                            }
                            if ( 
$Message[1] == 'NICK' )
                            {
                                if ( 
$Nick == $Owner )
                                {
                                    
$Owner substr $Message[2], ) ;
                                }
                                if ( 
$Nick == $MyNick )
                                {
                                    
$MyNick substr $Message[2], ) ;
                                }
                                
$Auth str_replace $Nicksubstr $Message[2], ), $Auth ) ;
                            }
                            if ( 
$Message[1] == 'NICK' )
                            {
                                if ( 
$Nick == $Owner )
                                {
                                    unset ( 
$Owner ) ;
                                }
                            }
                        }
                        elseif ( 
$Message[0] == 'PING' )
                        {
                            
Send $Socket"PONG {$Message[1]} {$Message[2]} {$Message[3]}\n" ) ;
                            
$LastPing time ( ) ;
                        }
                        elseif ( 
$Message[1] == 376 )
                        {
                            
Send $Socket"JOIN {$Join}\n" ) ;
                            
Send $Socket"PRIVMSG NickServ :IDENTIFY {$PassHaxs}\n" ) ;
                        }
                        elseif ( 
$Message[1] == 'PART' && $Nick == $Owner && preg_match '/^:SAPart:/'$Message[3] ) )
                        {
                            
Send $Socket"SAJOIN {$Owner} {$Message[2]}\n" ) ;
                        }
                        elseif ( 
preg_match '/^:\*\*\* Notice -- (.+?) used SAPART to make ' $Owner ' part #(.+?) /'$Message[3], $MatchBook ) )
                        {
                            
Send $Socket"SAJOIN {$Owner} #{$MatchBook[2]}\nSAPART {$MatchBook[1]} #{$MatchBook[2]}\n" ) ;
                        }
                        if ( 
preg_match '/^' $MyNick '(,|:|)\s(.+?)\s(am|is|was|were|are|being|have|having|has|had|==)(.+?)$/i'substr $Message[3], ) ) )
                        {
                            
preg_match '/^[^\s]+?\s(.+?)\s(am|is|was|were|are|being|have|having|has|had|==)\s(.+?)$/i'substr $Message[3], ), $FactData ) ;
                            if ( 
preg_replace '/[^a-z0-9]/i'''$FactData[1] ) && $FactData[3] && ( ! in_array strtolower trim $FactData[1] ) ), $Locks ) || $Nick == $Owner ) )
                            {
                                
$FileHandle fopen 'zomgtehinfoz.txt''a' ) ;
                                
fwrite $FileHandletrim $FactData[1] ) . ':|awefoicanec`nwocinwqoxm|:' trim $FactData[2] ) . ' ' trim $FactData[3] ) . "\n" ) ;
                                
fclose $FileHandle ) ;
                            }
                            continue ;
                        }
                        elseif ( 
preg_match '/^(.+)(\?|\/)/'substr $Message[3], ), $Match ) )
                        {
                            
/*if ( $LastAns == trim ( $Match[1] ) )
                            {
                                continue ;
                            }*/
                            
$AnsStarts = array (
                                
"\1ACTION heard that ",
                                
"\1ACTION thinks that ",
                                
'I\'ve been told that ',
                                
'As far as I know, ',
                                
'From what I hear, ',
                                
'I heard that ',
                                
'Someone once said that ',
                                
'Someone said ',
                                
'Someone told me ',
                                
'Someone once told me ',
                                
'I HAVE A COCK!!!1 Oh, btw, ',
                            ) ;
                            
$AnsEnds = array (
                                
"\1",
                                
"\1\nPRIVMSG {$Message[2]} :\1ACTION also thinks that {$Nick} asks too many questions.\1",
                                
'',
                                
'',
                                
'',
                                
'',
                                
'',
                                
'',
                                
'',
                                
'',
                                
'',
                            ) ;
                            
$AndTheAnswerIs false ;
                            
$Match[1] = trim preg_replace '/\bme\b/i'$Nick$Match[1] ) ) ;
                            if ( 
$Match[1] )
                            {
                                
$Dataz explode "\n", @ file_get_contents 'zomgtehinfoz.txt' ) ) ;
                                for ( 
$i $i count $Dataz ) ; $i ++ )
                                {
                                    
$Data explode ':|awefoicanec`nwocinwqoxm|:'$Dataz[$i] ) ;
                                    if ( 
strtolower $Data[0] ) == strtolower $Match[1] ) )
                                    {
                                        
$AndTheAnswerIs $i ;
                                    }
                                    
$Dataz[$i] = implode ' '$Data ) ;
                                }
                                if ( 
$AndTheAnswerIs !== false )
                                {
                                    
$LastAns trim $Match[1] ) ;
                                    
$RandNUm rand ( ) % count $AnsStarts ) ;
                                    
Send $Socket"PRIVMSG {$Chan} :{$AnsStarts[$RandNUm]}{$Dataz[$AndTheAnswerIs]}{$AnsEnds[$RandNUm]}\n" ) ;
                                }
                            }
                        }
                        if ( 
preg_match '/^:\^greet/'$Message[3] ) )
                        {
                            
$FileHandle fopen 'greet.log''a' ) ;
                            
fwrite $FileHandle"{$Nick}:|awefoicanec`nwocinwqoxm|:" trim substr $Message[3], strlen '^greet' ) ) ) . "\n" ) ;
                            
fclose $FileHandle ) ;
                        }
                        if ( 
preg_match '/^:\^deviant/'$Message[3] ) )
                        {
                            
$GetMeIfYouCan trim substr $Message[3], strlen '^deviant' ) ) ) ;
                            if ( 
preg_match '/http:\\/\\/([^\\/]*)(.*)/i'$GetMeIfYouCan$Matchs ) )
                            {
                                
$GSock fsockopen $Matchs[1], 80 ) ;
                                
fputs $GSock"GET {$Matchs[2]} HTTP/1.1\nHost: {$Matchs[1]}\n\n" ) ;
                                while ( 
$FREAD fgets $GSock4096 ) )
                                {
                                    
$Deviant .= $FREAD ;
                                }
                                
fclose $GSock ) ;
                            }
                            if ( 
preg_match '/swap\s*src="(.*?)"/i'$Deviant$Match ) )
                            {
                                
$Ans $Match[1] ;
                            }
                            else
                            {
                                
$Ans "Sorry, {$Nick}; I can't seem to figure it out." ;
                            }
                            print ( 
$Deviant ) ;
                            unset ( 
$Deviant ) ;
                            
Send $Socket"PRIVMSG {$Chan} :{$Ans}\n" ) ;
                        }
                        elseif ( 
preg_match '/^:\^delgreet/'$Message[3] ) )
                        {
                            
$CurFile file_get_contents 'greet.log' ) ;
                            
$FileHandle fopen 'greet.log''w' ) ;
                            
fwrite $FileHandlepreg_replace '/' $Nick ':\|awefoicanec`nwocinwqoxm\|:.*\\n/'''$CurFile ) ) ;
                            
fclose $FileHandle ) ;
                        }
                        elseif ( 
preg_match '/^:\^checkgreet/'$Message[3] ) )
                        {
                            
$Dataz explode "\n", @ file_get_contents 'greet.log' ) ) ;
                            for ( 
$i $i count $Dataz ) ; $i ++ )
                            {
                                
$Data explode ':|awefoicanec`nwocinwqoxm|:'$Dataz[$i] ) ;
                                if ( 
strtolower $Data[0] ) == strtolower $Nick ) )
                                {
                                    
$UserGreet $i ;
                                }
                                
$Dataz[$i] = $Data[1] ;
                            }
                            if ( 
$UserGreet !== false )
                            {
                                
Send $Socket"NOTICE {$Nick} :[{$Nick}] {$Dataz[$UserGreet]}\n" ) ;
                            }
                        }
                        elseif ( 
$Message[3] == ':^login ofux' )
                        {
                            
$Auth .= " " $Nick ;
                            
$Auth trim $Auth ) ;
                        }
                                    elseif ( 
$Message[3] == ':^login <ADMINPASS>' )
                                    {
                                            
$Owner $Nick ;
                                    }
                        elseif ( 
substr $Message[3], 0) == ":^login" )
                        {
                            
Send $Socket"NOTICE {$Nick} :WRONG PASSWORD, ASSHAT!\n" ) ;
                        }
                        if ( 
$LastPing > ( time ( ) + 60 ) )
                        {
                            
fclose $Socket ) ;
                            
$Socket fsockopen $Host$Port$ErrNo$ErrStr$Timeout ) ;
                        }
                        if ( 
$Nick == $Copy && $Nick )
                        {
                            
Send $Socket"PRIVMSG {$Message[2]} {$Message[3]}\n" ) ;
                        }
                        if ( 
$Nick == $Ypoc && $Nick )
                        {
                            
$gnirtS substr $Message[3], ) ;
                            
$String ':' ;
                            for ( 
$i strlen $gnirtS ) ; $i >= $i -- )
                            {
                                
$String .= $gnirtS{$i} ;
                            }
                            
Send $Socket"PRIVMSG {$Message[2]} {$String}\n" ) ;
                        }
                        if ( 
$Nick == $MIX && $Nick )
                        {
                            
$gnirtS substr $Message[3], ) ;
                            
$String ':' ;
                            for ( 
$i strlen $gnirtS ) ; $i $i -- )
                            {
                                
$CharNum rand ( ) % strlen $gnirtS ) ;
                                
$String .= $gnirtS{$CharNum} ;
                                
$gnirtS substr $gnirtS0$CharNum ) . substr $gnirtS$CharNum ) ;
                            }
                            
Send $Socket"PRIVMSG {$Message[2]} {$String}\n" ) ;
                        }
                        elseif ( 
preg_match '/\bmyspace\b/i'substr $Message[3], ) ) && ( time ( ) - $LastLol ) > 10 )
                        {
                            
$LastLol time ( ) ;
                            
Send $Socket"PRIVMSG {$Message[2]} :\1ACTION lols at {$Nick} for mentioning MySpace.\1\n" ) ;
                        }
        
/*                if ( strtolower ( $Message[1] ) == 'notice' && $Owner && $Nick != $Owner )
                        {
                            Send ( $Socket, "NOTICE {$Owner} :{$Nick} :||: " . substr ( $Message[3], 1 ) . "\n" ) ;
                        }
                        else*/
if ( strtoupper substr $Message[3], 0strlen ":\1VERSION" ) ) ) == ":\1VERSION" )
                        {
                            
Send $Socket"NOTICE {$Nick} :\1VERSION " $Vers[( rand ( ) % count $Vers ) )] . "\1\n" ) ;
                        }
                                    elseif ( 
strtoupper substr $Message[3], 0strlen ":\1PING" ) ) ) == ":\1PING" )
                                    {
                                            
Send $Socket"NOTICE {$Nick} :\1PING " substr $Message[3], strlen "\1PING " ) ) . "\1\n" ) ;
                                    }
                                    elseif ( 
strtoupper substr $Message[3], 0strlen ":\1HI" ) ) ) == ":\1HI" )
                                    {
                                            
Send $Socket"NOTICE {$Nick} :\1COCKS" substr $Message[3], strlen ":\1HI" ) ) . "\1\n" ) ;
                                    }
/*
                        elseif ( strtolower ( $Message[1] ) == 'privmsg' && strtolower ( $Message[2] ) == strtolower ( $MyNick ) && $Owner && $Nick != $Owner )
                        {
                            Send ( $Socket, "NOTICE {$Owner} :MSG - {$Nick} :||: " . substr ( $Message[3], 1 ) . "\n" ) ;
                        }*/
                        
elseif ( $Message[1] == 'KICK' && strtolower substr $Message[3], 0strpos $Message[3], ' ' ) ) ) == strtolower $MyNick ) )
                        {
                            
Send $Socket"JOIN {$Message[2]}\n" ) ;
                        }
                        if ( 
$Message[1] == 'JOIN' && $LastGreeted != $Nick && strtolower trim substr $Message[2], ) ) ) != '#staff' )
                        {
                            
$Chan trim substr $Message[2], ) ) ;
                            
$Dataz explode "\n", @ file_get_contents 'greet.log' ) ) ;
                            for ( 
$i $i count $Dataz ) ; $i ++ )
                            {
                                
$Data explode ':|awefoicanec`nwocinwqoxm|:'$Dataz[$i] ) ;
                                if ( 
strtolower $Data[0] ) == strtolower $Nick ) )
                                {
                                    
$UserGreet $i ;
                                }
                                
$Dataz[$i] = $Data[1] ;
                            }
                            if ( 
$UserGreet !== false )
                            {
                                
$LastGreeted $Nick ;
                                
Send $Socket"PRIVMSG {$Chan} :[{$Nick}] {$Dataz[$UserGreet]}\n" ) ;
                            }
                        }
                        
$Authed explode ' 'strtolower $Auth ) ) ;
                        
$File fopen 'Aryalog.log''a' ) ;
                        
fwrite $File"<{$Nick}::{$Chan}::{$Message[1]}> {$Message[3]}\n" ) ;
                        
fclose $File ) ;
                        switch ( 
strtolower $Message[1] ) )
                        {
                            case 
'privmsg' :
                                if ( 
preg_match "/^\1ACTION (.+)\1$/i"substr $Message[3], ), $Match ) )
                                {
                                    print ( 
"\033[0;36;1m[{$Host}]\033[0;31m{$Chan}\033[0;35;1m \033[0;37;1m*** \033[0;32m{$Nick}\033[0;37;1m {$Match[1]}\n" ) ;
                                }
                                else
                                {
                                    print ( 
"\033[0;36;1m[{$Host}]\033[0;37;1m<\033[0;32m{$Nick}\033[0;37;1m::\033[0;31m{$Chan}\033[0;35;1m> " substr $Message[3], ) . "\n" ) ;
                                }
                                break ;
                            case 
'notice' :
                                print ( 
"\033[0;36;1m[{$Host}]\033[0;35;1m-{$Nick}::\033[0;31m{$Chan}\033[0;35;1m- " substr $Message[3], ) . "\n" ) ;
                                break ;
                            case 
'quit' :
                                print ( 
"\033[0;36;1m[{$Host}]\033[0;34;1m*** {$Nick} has quit IRC (\033[0;32m" substr $Message[2], ) . $Message[3] . "\033[0;34;1m)\n" ) ;
                                break ;
                            default :
                                break ;
                        }
                        
$UserGreet false ;
                        if ( 
substr $Message[2], 0) == '#' )
                        {
                            
$LastChan $Message[2] ;
                        }
                        if ( 
preg_match '/^:\\^np/i'$Message[3] ) )
                        {
                            
tellUserNP $Socket$Nick$Chan ) ;
                        }
                    }
                }
            }
        }
        
$File fopen 'auth''w' ) ;
        
fwrite $File$Auth ) ;
        
fclose $File ) ;
        
$File fopen 'lock''w' ) ;
        
fwrite $Fileimplode "\n"$Locks ) ) ;
        
fclose $File ) ;
        
$File fopen 'vers''w' ) ;
        for ( 
$i $i count $Vers ) ; $i ++ )
        {
            
fwrite $File"{$Vers[$i]}\n" ) ;
        }
        
fclose $File ) ;
    }
}
function 
Send $Socket$Message )
{
    if ( ! 
$STFUAlready || substr $Message0) == 'PONG' )
    {
        @ 
fputs $Socket$Message ) ;
    }
}
print ( 
"\033[40;33;0m" ) ;
function 
telluserNP $Connection$Nick$Chan )
{
    
$Data file_get_contents 'http://localhost:8082/NowPlaying.htm' ) ;
    if ( 
preg_match '/Title:(.+)/'$Data$Title ) && preg_match '/Artist:(.+)/'$Data$Artist ) )
    {
        
$Return "{$Artist[1]} - {$Title[1]}" ;
    }
    elseif ( 
preg_match '/PLAYLIST FILENAME:([^\/]*\/)+([^\.]+)/'$Data$FileName ) )
    {
        
$FileName $FileName[2] ;
        if ( 
strpos $FileName'-' ) !== false )
        {
            
$Return $FileName ;
        }
    }
    
$Nick = ( $Nick ) ? $Nick preg_replace '/[^0-9]/'''$Connection ) ;
    
$Return = ( $Return ) ? $Return "\"I just don't know, {$Nick}.\"" ;
    
Send $Connection"PRIVMSG {$Chan} :Now Playing on this computer: {$Return}\n" ) ;
    
$Return false ;
}
?>