Пример #1
0
	public function omgzold($line, $args)
	{
		if ($line['to'] == $this->ircClass->getNick())
		{
			return;
		}
		
		$chan = irc::myStrToLower($line['to']);
		if(preg_match('@(https?://[^ ]*)@',$line['text']. " ",$url))
		{
			//print("URLZ: ". $url[1]);
			
			$values = array(	$url[1],
						$chan,
					);

			$query = $this->db->query("SELECT * FROM omgzold WHERE url='[1]' AND channel='[2]' AND deleted='0' LIMIT 1",$values);
			if($this->db->numRows($query))
			{
				$quote	= $this->db->fetchArray($query);
				$diff = $this->timeDiff(time(),$quote['time']);
				$msg = BOLD."OMGZOLD: " .BOLD.$quote['author'] . " wrote ". $quote['url'] ." ". $diff ."ago";
				$this->ircClass->privMsg($chan,$msg);
			}
			else
			{
				$values = array(	$line['fromNick'],
							$url[1],
							$chan,
						);
				$query = $this->db->query("INSERT INTO omgzold (author,url,channel) VALUES('[1]', '[2]', '[3]')",$values);
			}
		}	
	}
Пример #2
0
     public function priv_throw( $line, $args )
     {
          $chan = irc::myStrToLower( $line[ 'to' ] );
          $nick = irc::myStrToLower( $line[ 'fromNick' ] );

          if( $args[ 'nargs' ] < 3 )
          {
               $this->ircClass->notice( $nick, "Syntax: !throw <item> at <user>" );
          }
          else
          {

               $this->ircClass->action( $chan, "throws {$args['query']}");
          }

     }
Пример #3
0
 public function bad_words($line, $args)
 {
     if ($line['to'] == $this->ircClass->getNick()) {
         return;
     }
     $chan = irc::myStrToLower($line['to']);
     if (!$this->ircClass->hasModeSet($line['to'], $this->ircClass->getNick(), "hoa")) {
         return;
         // we don't have power to kick!
     }
     if (isset($this->badWords[$chan])) {
         foreach ($this->badWords[$chan] as $bw => $blah) {
             if (preg_match("/ " . $bw . " /i", " " . $line['text'] . " ")) {
                 $this->ircClass->sendRaw("KICK " . $line['to'] . " " . $line['fromNick'] . " :Bad word!");
                 break;
             }
         }
     }
 }
Пример #4
0
 private function news_clear($line, $args)
 {
     $chan = irc::myStrToLower($line['to']);
     $nick = irc::myStrToLower($line['fromNick']);
     if (!$this->ircClass->hasModeSet($chan, $nick, "oa")) {
         return;
     }
     if ($this->news[$args['cmd']]->sectionExists($chan)) {
         $this->news[$args['cmd']]->deleteSection($chan);
         $this->news[$args['cmd']]->writeIni();
         $this->ircClass->notice($line['fromNick'], "All lines from this channel have been cleared.");
     } else {
         $this->ircClass->notice($line['fromNick'], "That channel does not have any news items set.");
     }
 }
Пример #5
0
 public function priv_ad($line, $args)
 {
     $channel = irc::myStrToLower($line['to']);
     if ($channel == $this->ircClass->getNick()) {
         return;
     }
     if (!$this->ircClass->isMode($line['fromNick'], $channel, "o")) {
         return;
     }
     if ($args['nargs'] == 0) {
         $timerString = "";
         $timers = $this->timerClass->getTimers();
         foreach ($timers as $timer) {
             if (substr($timer->name, 0, 2) == "ad") {
                 if ($timer->args['channel'] == $channel) {
                     $timerString .= $timer->name . " ";
                 }
             }
         }
         if ($timerString == "") {
             $this->ircClass->notice($line['fromNick'], "No ads currently for " . $channel . ".");
         } else {
             $this->ircClass->notice($line['fromNick'], "Current ads for " . $channel . ":");
             $this->ircClass->notice($line['fromNick'], $timerString);
         }
         $this->ircClass->notice($line['fromNick'], "Type !ad <interval(seconds)> <msg> to add an ad, or !ad <ad[id]> to view an ad.");
     } else {
         if ($args['nargs'] >= 1) {
             if (substr($args['arg1'], 0, 2) == "ad" && strlen($args['arg1']) > 2) {
                 $id = $args['arg1'];
                 $timers = $this->timerClass->getTimers();
                 foreach ($timers as $timer) {
                     if ($timer->name == $id) {
                         break;
                     }
                 }
                 if ($timer == null || $channel != $timer->args['channel']) {
                     $this->ircClass->notice($line['fromNick'], "There is no ad by that id.");
                 } else {
                     if ($args['nargs'] >= 2) {
                         if (irc::myStrToLower($args['arg2']) == "delete") {
                             $this->ads->deleteSection($timer->name);
                             $this->ads->writeIni();
                             $this->timerClass->removeTimer($timer->name);
                             $this->ircClass->notice($line['fromNick'], "Ad successfully deleted.");
                         } else {
                             $this->ircClass->notice($line['fromNick'], "Invalid option.  Valid options: delete");
                         }
                     } else {
                         $this->ircClass->notice($line['fromNick'], "Ad: " . $timer->name);
                         $this->ircClass->notice($line['fromNick'], $timer->args['msg']);
                         $this->ircClass->notice($line['fromNick'], "Use '!ad " . $timer->name . " delete' to delete this ad.");
                     }
                 }
             } else {
                 if ($args['nargs'] == 1) {
                     $this->ircClass->notice($line['fromNick'], "You must specify a message!");
                 } else {
                     $int = intval($args['arg1']);
                     if ($int <= 5) {
                         $this->ircClass->notice($line['fromNick'], "Invalid Interval. Interval must be greater than 5 seconds.");
                     } else {
                         $ad = substr($args['query'], strlen($args['arg1']) + 1);
                         $argArray = array('msg' => $ad, 'channel' => $channel);
                         //Find next id
                         $highest = 0;
                         $timers = $this->timerClass->getTimers();
                         foreach ($timers as $timer) {
                             if (substr($timer->name, 0, 2) == "ad") {
                                 $id = intval(substr($timer->name, 2));
                                 if ($id > $highest) {
                                     $highest = $id;
                                 }
                             }
                         }
                         $highest++;
                         $this->timerClass->addTimer('ad' . $highest, $this, "misc_adTimer", $argArray, $int, true);
                         $this->ircClass->notice($line['fromNick'], "The ad was successfully added.");
                         $this->ads->setIniVal('ad' . $highest, "int", $int);
                         $this->ads->setIniVal('ad' . $highest, "chan", $channel);
                         $this->ads->setIniVal('ad' . $highest, "msg", $ad);
                         $this->ads->writeIni();
                     }
                 }
             }
         }
     }
 }
Пример #6
0
 public function priv_seen($line, $args)
 {
     if ($this->seen->getError()) {
         $this->ircClass->notice($line['fromNick'], "There was an error while attempting to access the seen database.");
         return;
     }
     if ($line['to'] == $this->ircClass->getNick()) {
         return;
     }
     if ($args['nargs'] <= 0) {
         $this->ircClass->notice($line['fromNick'], "Usage: !seen <nick>");
         return;
     }
     $user = irc::myStrToLower($args['arg1']);
     if ($user == irc::myStrToLower($line['fromNick'])) {
         $this->ircClass->privMsg($line['to'], $line['fromNick'] . ", umm...  O..kay...");
         $this->ircClass->action($line['to'], "points at " . $line['fromNick'] . "...");
         return;
     }
     $data = $this->getLast($user);
     if ($data === false) {
         $this->ircClass->privMsg($line['to'], $line['fromNick'] . ", I have never seen " . $args['arg1'] . " before.");
         return;
     }
     $time = time() - $data['time'];
     if ($time > 3600 * 24) {
         $timeString = irc::timeFormat($time, "%d days %h hours %m min %s sec");
     } else {
         if ($time > 3600) {
             $timeString = irc::timeFormat($time, "%h hours %m min %s sec");
         } else {
             if ($time > 60) {
                 $timeString = irc::timeFormat($time, "%m min %s sec");
             } else {
                 $timeString = irc::timeFormat($time, "%s sec");
             }
         }
     }
     $action = "";
     switch ($data['act']) {
         case "privmsg":
             $action = "saying in a channel";
             break;
         case "notice":
             $action = "noticing a channel";
             break;
         case "join":
             $action = "joining a channel";
             break;
         case "kick":
             $action = "being kicked from a channel";
             break;
         case "part":
             $action = "parting a channel";
             break;
         case "quit":
             $action = "quitting";
             break;
     }
     if ($data['txt'] != "") {
         $action .= ": " . $data['txt'];
     }
     $this->ircClass->privMsg($line['to'], $line['fromNick'] . ", I last saw " . $data['user'] . " " . $timeString . " ago " . $action . ".");
 }
Пример #7
0
 public function dcc_function($chat, $args)
 {
     $cmdList = $this->parserClass->getCmdList();
     if ($args['nargs'] == 0) {
         $chat->dccSend("-- All user-defined function status --");
         $num = 0;
         foreach ($cmdList['priv'] as $cmd => $data) {
             $chat->dccSend($cmd . " => " . ($data['active'] == true ? "active" : "inactive") . ", Usage: " . $data['usage']);
             $num++;
         }
         $chat->dccSend($num . " total functions.");
     } else {
         if ($args['nargs'] == 2) {
             if ($args['arg1'] == "activate") {
                 if ($args['arg2'] == "all") {
                     foreach ($cmdList['priv'] as $cmd => $data) {
                         //$cmdList['priv'][$cmd]['active'] = true;
                         $this->parserClass->setCmdListValue('priv', $cmd, 'active', true);
                     }
                     $chat->dccSend("All functions activated.");
                 } else {
                     $cmdLower = irc::myStrToLower($args['arg2']);
                     if (isset($cmdList['priv'][$cmdLower])) {
                         $this->parserClass->setCmdListValue('priv', $cmdLower, 'active', true);
                         //$cmdList['priv'][$cmdLower]['active'] = true;
                         $chat->dccSend("Function " . $cmdLower . " activated.");
                     } else {
                         $chat->dccSend("Invalid function specified.");
                     }
                 }
             } else {
                 if ($args['arg1'] == "deactivate") {
                     if ($args['arg2'] == "all") {
                         foreach ($cmdList['priv'] as $cmd => $data) {
                             if ($data['canDeactivate'] != false) {
                                 $this->parserClass->setCmdListValue('priv', $cmd, 'active', false);
                                 //$cmdList['priv'][$cmd]['active'] = false;
                             }
                         }
                         $chat->dccSend("All functions deactivated.");
                     } else {
                         $cmdLower = irc::myStrToLower($args['arg2']);
                         if (isset($cmdList['priv'][$cmdLower])) {
                             if ($cmdList['priv'][$cmdLower]['canDeactivate'] != false) {
                                 $this->parserClass->setCmdListValue('priv', $cmdLower, 'active', false);
                                 //$cmdList['priv'][$cmdLower]['active'] = false;
                                 $chat->dccSend("Function " . $cmdLower . " deactivated.");
                             } else {
                                 $chat->dccSend("Cannot modify read-only function " . $cmdLower . ".");
                             }
                         } else {
                             $chat->dccSend("Invalid function specified.");
                         }
                     }
                 } else {
                     $chat->dccSend("Invalid Syntax, use 'all', or specify a function name.");
                 }
             }
         } else {
             $chat->dccSend("Invalid Syntax, use 'activate' or 'deactivate'.");
         }
     }
 }
Пример #8
0
 public function addChat($nick, $host, $port, $admin, $handler, $fromTimer = false)
 {
     $lnick = irc::myStrToLower($nick);
     foreach ($this->dccList as $index => $dcc) {
         if ($dcc->type == CHAT) {
             if (irc::myStrToLower($dcc->nick) == $lnick) {
                 $dcc->disconnect();
                 break;
             }
         }
     }
     $reverse = false;
     if ($this->ircClass->getClientConf("mircdccreverse") != "" && $fromTimer == false) {
         $port = intval($this->ircClass->getClientConf("mircdccreverse"));
         if ($port == 0) {
             return NULL;
         }
         $args = new argClass();
         $args->arg1 = $nick;
         $args->arg2 = $host;
         $args->arg3 = $port;
         $args->arg4 = $admin;
         $args->arg5 = $handler;
         $args->arg7 = time();
         $args->arg8 = CHAT;
         $this->ircClass->notice($nick, "DCC: NOTICE: This server is using the mIRC Chat Server Protocol.  Please use ' /dccserver +c on " . $this->ircClass->getClientConf("mircdccreverse") . " ' to chat with me!  Starting 6 second delay...", 0);
         $this->ircClass->sendRaw("WHOIS " . $nick);
         $this->timerClass->addTimer(irc::randomHash(), $this, "reverseTimer", $args, 6, false);
         return;
     }
     if ($fromTimer == true) {
         $reverse = DCC_REVERSE;
         // using mIRC dcc reverse protocol
     }
     if ($host == NULL || $port == NULL) {
         $conn = new connection(null, null, 0);
         $listening = true;
         $status = DCC_LISTENING;
     } else {
         $conn = new connection($host, $port, CONNECT_TIMEOUT);
         $listening = false;
         $status = DCC_CONNECTING;
     }
     $conn->setSocketClass($this->socketClass);
     $conn->setIrcClass($this->ircClass);
     $conn->setCallbackClass($this);
     $conn->setTimerClass($this->timerClass);
     $port = $conn->init();
     if ($conn->getError()) {
         $this->ircClass->log("Start Chat Error: " . $conn->getErrorMsg());
         return false;
     }
     $sockInt = $conn->getSockInt();
     $this->chatCount++;
     $id = $this->highestId();
     $chat = new chat($id, $nick, $admin, $sockInt, $host, $port, $handler, $reverse);
     $chat->setIrcClass($this->ircClass);
     $chat->setDccClass($this);
     $chat->setParserClass($this->parserClass);
     $chat->setSocketClass($this->socketClass);
     $chat->setTimerClass($this->timerClass);
     $chat->connection = $conn;
     $chat->status = $status;
     $chat->removed = false;
     $this->dccList[$sockInt] = $chat;
     $chat->initialize();
     $conn->setCallbackClass($chat);
     if ($listening == true) {
         $this->timerClass->addTimer(irc::randomHash(), $this, "checkDccTimeout", $chat, 30, true);
     } else {
         $conn->connect();
     }
     return $port;
 }
Пример #9
0
 private function parseCtcp($line, $msgs = "PRIVMSG")
 {
     $cmd = str_replace(chr(1), "", $line['text']) . " ";
     $query = trim(substr($cmd, strpos($cmd, chr(32)) + 1));
     $cmd = substr(irc::myStrToLower($cmd), 0, strpos($cmd, chr(32)));
     $msg = "";
     switch ($cmd) {
         case "version":
             $this->dccClass->dccInform("CTCP VERSION: " . $line['fromNick'] . " versioned us.");
             break;
         case "time":
             $this->dccClass->dccInform("CTCP TIME: " . $line['fromNick'] . " requested the time.");
             break;
         case "uptime":
             $this->dccClass->dccInform("CTCP UPTIME: " . $line['fromNick'] . " requested our uptime.");
             break;
         case "ping":
             $this->dccClass->dccInform("CTCP PING: " . $line['fromNick'] . " pinged us.");
             break;
         case "dcc":
             $vars = explode(chr(32), $query);
             $this->dccParse($line, $vars, $query);
             break;
     }
     if ($msg != "") {
         $this->notice($this->lVars['fromNick'], chr(1) . $msg . chr(1));
     }
     if (isset($this->cmdList['ctcp'][$cmd])) {
         $func = $this->cmdList['ctcp'][$cmd]['function'];
         $class = $this->cmdList['file'][$this->cmdList['ctcp'][$cmd]['module']]['class'];
         $args = $this->createLine($cmd . " " . $query);
         $class->{$func}($line, $args);
     }
 }
Пример #10
0
 public function getSendCount()
 {
     $dccTransfers = $this->dccClass->getDccList();
     $sendCount = array();
     foreach ($dccTransfers as $sockInt => $xfer) {
         if ($xfer->type == FILE && $xfer->transferType == UPLOAD) {
             $nick = irc::myStrToLower($xfer->nick);
             if (!isset($sendCount[$nick])) {
                 $sendCount[$nick] = 1;
             } else {
                 $sendCount[$nick]++;
             }
         }
     }
     return $sendCount;
 }
Пример #11
0
 public function sendLeoResults($line, $args, $result, $response)
 {
     if ($result == QUERY_SUCCESS) {
         // <td nowrap width="5%">
         // this tag appears only when we have a search result, so lets look for this
         // better than using regexps :)
         //
         // old variant:
         //$wordExistsExpr = "#\<TR\>\<TD ALIGN=CENTER COLSPAN=5\>.*?\<B\>(.*?)\</B\>.*?\</table\>#i";
         //if (0 == preg_match_all($wordExistsExpr, $response, $matches, PREG_SET_ORDER))
         if (false == strstr($response, '<td nowrap width="5%">')) {
             $this->sendMsg($line, $args, 'Your search - ' . BOLD . $args['query'] . BOLD . ' - did not match anything.');
             return;
         }
         // .*? == ? makes the last quantifier ungreedy
         // so: match any char before next part of expression, but smallest version possible
         $wordMatchExpr = '\\<td valign="middle" width="43%"\\>(.*?)\\</td\\>';
         // not used
         //$wordJumpExpr  = '\<td class="td1" valign="middle" width="43%"\>.*?\</td\>';
         $wordCountExpr = '\\<tr valign="top".*?' . $wordMatchExpr . '.*?' . $wordMatchExpr . '.*?\\</tr\\>';
         $wordCount = preg_match_all('#' . $wordCountExpr . '#i', $response, $matchesWordCount, PREG_SET_ORDER);
         // $matchesWordCount[x][y]
         // x: result number 0-n
         // y = 0: trash
         // y = 1: english/spanish/french
         // y = 2: german (needs cleaning from <b></b> tags
         if ($wordCount > $this->max_results) {
             $wordCount = $this->max_results;
         }
         $result = "";
         for ($i = 0; $i < $wordCount; $i++) {
             $result .= $this->cleanup($matchesWordCount[$i][1]) . BOLD . ' = ' . BOLD . $this->cleanup($matchesWordCount[$i][2]) . BOLD . ' / ' . BOLD;
         }
         $cmdLower = irc::myStrToLower($args['cmd']);
         switch ($cmdLower) {
             case '!fra':
                 $lang = 'frde';
                 break;
             case '!esp':
                 $lang = 'esde';
                 break;
             case '!ita':
                 $lang = 'itde';
                 break;
                 //case '!chn':
                 //	$lang = 'chde';
                 //	break;
             //case '!chn':
             //	$lang = 'chde';
             //	break;
             default:
                 $lang = 'ende';
         }
         // switch
         $result .= 'more: ' . UNDERLINE . 'http://dict.leo.org/' . $lang . '?search=' . $args['query'] . UNDERLINE;
         $this->ircClass->privMsg($line['to'], $result);
     } else {
         $this->sendMsg($line, $args, 'Leo says NO! (server didn\'t respond)');
         return false;
     }
 }
Пример #12
0
     public function priv_adminslap( $line, $args )
     {
          $chan = irc::myStrToLower( $line[ 'to' ] );
          $nick = irc::myStrToLower( $line[ 'fromNick' ] );
          $host = $line[ 'fromIdent' ] . "@" . $line[ 'fromHost' ];

          if( !in_array( $host, $this->allow ) )
          {
               $this->ircClass->notice( $nick, "You don't have access." );
               return;
          }
          
          if( $args[ 'nargs' ] < 1 )
          {
               if( !$this->slaps->getSection( "all" ) )
               {
                    $this->ircClass->notice( $chan, "None." );
                    return;
               }
               $approve = $this->slaps->getSection( "all" );

               $this->ircClass->notice( $nick, "The following slaps aren't approved yet:" );

               foreach( $approve as $msg => $approved )
               {
                    if( $approved == "wait" )
                    {
                         $this->ircClass->notice( $nick, $msg );
                    }
               }
          }
          else
          {
               if( $args[ 'nargs' ] < 2 )
               {
                    $this->ircClass->notice( $nick, "Syntax: !adminslap <ok|del> <slap>" );
               }
               else
               {
                    $approve = $this->slaps->getSection( "all" );
                    $newQ = stristr( $args[ 'query' ], " " );
                    $slapLen = strlen( $newQ );
                    $newSlap = substr( $newQ, 1, $slapLen );

                    if( $args[ 'arg1' ] == "ok" )
                    {
                         if( $approve[ $newSlap ] == "wait" )
                         {
                              $this->slaps->setIniVal( "all", $newSlap, "approved" );
                              $this->slaps->writeIni( );
                              $this->ircClass->notice( $nick, "The slap is now approved." );
                         }
                         else
                         {
                              $this->ircClass->notice( $nick, "That slap already is approved or does not exist." );
                         }
                    }
                    else if( $args[ 'arg1' ] == "del" )
                    {
                         if( isset( $approve[ $newSlap ] ) )
                         {
                              $this->slaps->deleteVar( "all", $newSlap );
                              $this->slaps->writeIni( );
                              $this->ircClass->notice( $nick, "The slap has been deleted!" );
                         }
                         else
                         {
                              $this->ircClass->notice( $nick, "That slap does not exit." );
                         }
                    }
                    else
                    {
                         $this->ircClass->notice( $nick, "Syntax: !adminslap <ok|del> <slap>" );
                    }
               }
          }
     }