Beispiel #1
0
 public function index($arguments)
 {
     $news = new news(ConnectionFactory::get('mongo'));
     $articles = new articles(ConnectionFactory::get('mongo'));
     $notices = new notices(ConnectionFactory::get('redis'));
     $irc = new irc(ConnectionFactory::get('redis'));
     $quotes = new quotes(ConnectionFactory::get('mongo'));
     $forums = new forums(ConnectionFactory::get('redis'));
     // Set all site-wide notices.
     foreach ($notices->getAll() as $notice) {
         Error::set($notice, true);
     }
     // Fetch the easy data.
     $this->view['news'] = $news->getNewPosts();
     $this->view['shortNews'] = $news->getNewPosts(true);
     $this->view['newArticles'] = $articles->getNewPosts('new', 1, 5);
     $this->view['ircOnline'] = $irc->getOnline();
     $this->view['randomQuote'] = $quotes->getRandom();
     $this->view['fPosts'] = $forums->getNew();
     // Get online users.
     $apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/');
     $this->view['onlineUsers'] = array();
     while ($apc->valid()) {
         $current = $apc->current();
         array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5));
         $apc->next();
     }
     // Set title.
     Layout::set('title', 'Home');
 }
Beispiel #2
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);
			}
		}	
	}
Beispiel #3
0
 public static function build($action, $settings)
 {
     global $config;
     if ($action == 'all') {
         file_write($config['dir']['home'] . $settings['file'], irc::install($settings));
     }
 }
Beispiel #4
0
	public function priv_pizza($line, $args)
	{
    	if ($args['nargs'] < 1)
		{
    		$this->ircClass->privMsg($line['to'], chr(2).'Usage'.chr(2).': !pizza <time> , in minutes, 0<'.chr(2).'x'.chr(2).'<=240');
    		return;
    	}
    	if (!is_numeric($args['arg1']))
		{
    		$this->ircClass->privMsg($line['to'], chr(2).'Usage'.chr(2).': !pizza <time> , in minutes, 0<'.chr(2).'x'.chr(2).'<=240');
    		return;
    	}
    	$args['arg1']++;
    	$args['arg1']--;
    	if (!is_integer($args['arg1']))
		{
			$this->ircClass->privMsg($line['to'], chr(2).'Usage'.chr(2).': !pizza <time> , in minutes, integer, 0<'.chr(2).'x'.chr(2).'<=240');
			return;
		}
    	if ($args['arg1']>240)
		{
    		$this->ircClass->privMsg($line['to'], chr(2).'Usage'.chr(2).': !pizza <time> , in minutes, integer, 0<'.chr(2).'x'.chr(2).'<=240');
    		return;
    	}
    	$pizza_id = "pizza_". irc::randomhash();
    	$time = $args['arg1'] *60;
    	$this->timerClass->addTimer($pizza_id, $this, "pizzaRemind", $line, $time, false);
    	$this->ircClass->privMsg($line['to'], $line['fromNick'].", you will be notified at ".date("d.m.y, H:i", time()+$time).", ".$args['arg1']. " minutes from now");
	}
Beispiel #5
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']}");
          }

     }
Beispiel #6
0
 private function getStatus()
 {
     $sqlCount = 0;
     $bwStats = $this->ircClass->getStats();
     if (is_object($this->db)) {
         $sqlCount = $this->db->numQueries();
     }
     $bwUp = irc::intToSizeString($bwStats['BYTESUP']);
     $bwDown = irc::intToSizeString($bwStats['BYTESDOWN']);
     $fileBwUp = irc::intToSizeString($this->dccClass->getBytesUp());
     $fileBwDown = irc::intToSizeString($this->dccClass->getBytesDown());
     $txtQueue = $this->ircClass->getTextQueueLength() + 1;
     $ircStat = $this->ircClass->getStatusString($this->ircClass->getStatusRaw());
     $permin = round($sqlCount / $this->ircClass->getRunTime(), 1);
     $kbs = ($bwStats['BYTESUP'] + $bwStats['BYTESDOWN']) / 1024;
     $kbs = round($kbs / $this->ircClass->getRunTime(), 2);
     $status = "Status: " . number_format($sqlCount) . " SQL / {$permin} Q/sec (irc BW: " . $bwUp . " up, " . $bwDown . " down avg ~{$kbs} kbps)";
     return $status;
 }
 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;
             }
         }
     }
 }
Beispiel #8
0
 private function onAccept()
 {
     //Get the sockInt from the socketClass
     $newSockInt = $this->socketClass->hasAccepted($this->sockInt);
     if ($newSockInt === false) {
         //False alarm.. just ignore it.
         return false;
     }
     //Create a new connection object for the new socket connection, then return it to onAccept
     //We must assume that onAccept will handle the connection object.  Otherwise it'll die, and the
     //connection will be orphaned.
     $newConn = new connection(null, null, 0);
     $newConn->setSocketClass($this->socketClass);
     $newConn->setIrcClass($this->ircClass);
     $newConn->setCallbackClass($this->callbackClass);
     //Can be overwritten in the onAccept function
     $newConn->setTimerClass($this->timerClass);
     $newConn->listen();
     //We don't need to call init(), we're already setup.
     //Setup our connection transmission timeout thing.
     if ($this->transTimeout > 0) {
         $this->timerClass->addTimer(irc::randomHash(), $newConn, "transTimeout", "", $this->transTimeout);
     }
     $newConn->setTransTimeout($this->transTimeout);
     //Set handler for our new sockInt to new connection class
     $this->socketClass->setHandler($newSockInt, $this->ircClass, $newConn, "handle");
     //Set our new sockInt
     $newConn->setSockInt($newSockInt);
     //Call our callback function for accepting with old object, and new object.
     $this->callbackClass->onAccept($this, $newConn);
     return false;
 }
Beispiel #9
0
 public function link($arguments)
 {
     if (!Session::isLoggedIn()) {
         return Error::set('Please login.');
     }
     $irc = new irc(ConnectionFactory::get('redis'));
     $username = Session::getVar('username');
     $this->view['valid'] = true;
     $this->view['pending'] = $nicks = $irc->getPending($username);
     $this->view['nicks'] = $goodNicks = $irc->getNicks($username);
     if (!empty($arguments[0]) && $arguments[0] == 'add') {
         if (!isset($nicks[$arguments[1]])) {
             return Error::set('Invalid nick id.');
         }
         $irc->addNick($username, $nicks[$arguments[1]]);
         $this->view['pending'] = $irc->getPending($username);
         $this->view['nicks'] = $irc->getNicks($username);
     } else {
         if (!empty($arguments[0]) && $arguments[0] == 'delP') {
             if (!isset($nicks[$arguments[1]])) {
                 return Error::set('Invalid nick id.');
             }
             $irc->delNick($username, $nicks[$arguments[1]]);
             $this->view['pending'] = $irc->getPending($username);
         } else {
             if (!empty($arguments[0]) && $arguments[0] == 'delA') {
                 if (!isset($goodNicks[$arguments[1]])) {
                     return Error::set('Invalid nick id.');
                 }
                 $irc->delAcceptedNick($username, $goodNicks[$arguments[1]]);
                 $this->view['nicks'] = $irc->getPending($username);
             }
         }
     }
 }
Beispiel #10
0
 public function search_response($line, $args, $result, $site)
 {
     if ($result == QUERY_ERROR) {
         $this->ircClass->notice($line['fromNick'], "Error: " . $site);
         return;
     }
     $site = str_replace("&#160;", ";", $site);
     $site = str_replace("\r", "", $site);
     $site = html_entity_decode($site);
     preg_match_all("/<li>\\s*<a href=\"\\/title\\/(.+?)\\/.+?>(.+?)<\\/a>\\s*(\\(.+?\\)){1}?(\\s)?(.+?)*?<\\/li>/i", $site, $matches, PREG_PATTERN_ORDER);
     $topTen = array();
     for ($i = 0; $i < count($matches[1]); $i++) {
         if ($matches[4][$i] == " ") {
             continue;
         }
         $link = trim($matches[1][$i]);
         $title = trim($matches[2][$i]);
         $date = trim($matches[3][$i]);
         $lTitle = strtolower($title);
         if (!isset($this->cache[$lTitle])) {
             $this->cache[$lTitle] = array();
             $this->cache[$lTitle][$date] = $link;
         } else {
             if (!isset($this->cache[$lTitle][$date])) {
                 $this->cache[$lTitle][$date] = $link;
                 krsort($this->cache[$lTitle]);
             }
         }
         $topTen[] = $title . " " . $date;
     }
     $tkey = strtolower($args["query"]);
     $lArgs = explode(chr(32), $tkey);
     $tCount = count($lArgs);
     if ($tCount > 0) {
         $date = $lArgs[count($lArgs) - 1];
         $title = trim(str_replace($date, "", $tkey));
     }
     if (isset($this->cache[$tkey])) {
         foreach ($this->cache[$tkey] as $date => $link) {
             break;
         }
         $line["link"] = $link;
         $line["title"] = $tkey;
         $line["date"] = $date;
         $search = socket::generateGetQuery("", "www.imdb.com", "/title/" . $link . "/", "1.0");
         $this->ircClass->addQuery("www.imdb.com", 80, $search, $line, $this, "title_response");
     } else {
         if ($tCount > 0 && isset($this->cache[$title]) && isset($this->cache[$title][$date])) {
             $link = $this->cache[$title][$date];
             $line["link"] = $link;
             $line["title"] = $title;
             $line["date"] = $date;
             $search = socket::generateGetQuery("", "www.imdb.com", "/title/" . $link . "/", "1.0");
             $this->ircClass->addQuery("www.imdb.com", 80, $search, $line, $this, "title_response");
         } else {
             $total = count($topTen);
             $total = $total > 10 ? 10 : $total;
             if ($total <= 0) {
                 $this->ircClass->notice($line['fromNick'], "No responses from server.  Try broadening your search.  If you included a date, remove it and try again.");
                 return;
             }
             $this->ircClass->notice($line['fromNick'], "Top " . $total . " responses from www.imdb.com");
             $resp = "";
             for ($i = 0; $i < $total; $i++) {
                 $resp .= DARK . "[" . BRIGHT . $topTen[$i] . DARK . "] - ";
             }
             $multi = irc::multiLine($resp);
             foreach ($multi as $mult) {
                 $this->ircClass->notice($line['fromNick'], $mult);
             }
         }
     }
 }
Beispiel #11
0
 public function addFile($nick, $host, $port, $type, $filename, $size, $fromTimer = false)
 {
     $reverse = false;
     if ($this->ircClass->getClientConf("mircdccreverse") != "" && $fromTimer == false && $type != DOWNLOAD) {
         $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 = $type;
         $args->arg5 = $filename;
         $args->arg6 = $size;
         $args->arg7 = time();
         $args->arg8 = FILE;
         $this->ircClass->notice($nick, "DCC: NOTICE: This server is using the mIRC File Server Protocol.  Please use ' /dccserver +s on " . $this->ircClass->getClientConf("mircdccreverse") . " ' to recieve files from me!  Starting 6 second delay...", 0);
         $this->ircClass->sendRaw("WHOIS " . $nick);
         $this->timerClass->addTimer(irc::randomHash(), $this, "reverseTimer", $args, 6);
         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->setTransTimeout(30);
     $conn->setTimerClass($this->timerClass);
     $port = $conn->init();
     if ($conn->getError()) {
         $this->ircClass->log("File transfer start error: " . $conn->getErrorMsg());
         return false;
     }
     $sockInt = $conn->getSockInt();
     $id = $this->highestId();
     $file = new file($id, $nick, $sockInt, $host, $port, $type, $reverse);
     if ($file->transferType == UPLOAD) {
         $this->fileUlCount++;
     } else {
         $this->fileDlCount++;
     }
     $file->setIrcClass($this->ircClass);
     $file->setDccClass($this);
     $file->setSocketClass($this->socketClass);
     $file->setProcQueue($this->procQueue);
     $file->setTimerClass($this->timerClass);
     $file->connection = $conn;
     $file->status = $status;
     $file->removed = false;
     $this->dccList[$sockInt] = $file;
     $file->initialize($filename, $size);
     $conn->setCallbackClass($file);
     if ($listening == true) {
         $this->timerClass->addTimer(irc::randomHash(), $this, "checkDccTimeout", $file, 30, true);
     }
     if ($reverse == true) {
         $conn->connect();
     }
     return $port;
 }
Beispiel #12
0
 private function getStatus()
 {
     $sqlCount = 0;
     $bwStats = $this->ircClass->getStats();
     if (is_object($this->db)) {
         $sqlCount = $this->db->numQueries();
     }
     $bwUp = irc::intToSizeString($bwStats['BYTESUP']);
     $bwDown = irc::intToSizeString($bwStats['BYTESDOWN']);
     $fileBwUp = irc::intToSizeString($this->dccClass->getBytesUp());
     $fileBwDown = irc::intToSizeString($this->dccClass->getBytesDown());
     $txtQueue = $this->ircClass->getTextQueueLength() + 1;
     $ircStat = $this->ircClass->getStatusString($this->ircClass->getStatusRaw());
     $status = "Status: [" . $ircStat . "] " . $sqlCount . " SQL, " . $txtQueue . " SrQ, (irc BW: " . $bwUp . " up, " . $bwDown . " down, file BW: " . $fileBwUp . " up, " . $fileBwDown . " down)";
     return $status;
 }
Beispiel #13
0
 function dccParse($line, $vars, $txt)
 {
     $cVars = count($vars);
     if ($cVars < 1) {
         return;
     }
     $cmd = irc::myStrToUpper($vars[0]);
     switch ($cmd) {
         case "CHAT":
             if ($cVars == 4) {
                 $iplong = long2ip((double) $vars[2]);
                 $port = $vars[3];
                 $this->dccClass->addChat($line['fromNick'], $iplong, (int) $port, false, null);
             }
             break;
         case "SEND":
             if ($this->ircClass->getClientConf('upload') != 'yes') {
                 $this->ircClass->notice($line['fromNick'], "DCC: I do not accept dcc transfers at this time.", 0);
                 break;
             }
             if ($cVars >= 5) {
                 //Some bastard sent a file with spaces.  Shit. Ass.
                 if (strpos($query, chr(34)) !== false) {
                     $first = strpos($query, chr(34));
                     $second = strpos($query, chr(34), $first + 1);
                     $filename = substr($query, $first + 1, $second - $first - 1);
                     $query = str_replace("\"" . $filename . "\"", "file.ext", $query);
                     $vars = explode(chr(32), $query);
                 } else {
                     $filename = $vars[1];
                 }
                 $iplong = long2ip((double) $vars[2]);
                 $port = $vars[3];
                 $filesize = $vars[4];
                 $this->dccClass->addFile($line['fromNick'], $iplong, (int) $port, DOWNLOAD, $filename, $filesize);
             }
             break;
         case "ACCEPT":
             if ($cVars == 4) {
                 $port = $vars[2];
                 $bytes = $vars[3];
                 $this->dccClass->dccAccept($port, $bytes);
             }
             break;
         case "RESUME":
             if ($cVars == 4) {
                 $port = $vars[2];
                 $bytes = $vars[3];
                 $this->dccClass->dccResume($port, $bytes);
             }
             break;
     }
 }
Beispiel #14
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>" );
                    }
               }
          }
     }
Beispiel #15
0
 private function doHandShake()
 {
     $this->dccSendRaw("100 " . $this->ircClass->getNick() . "\n");
     $this->handShakeSent = true;
     $this->timerClass->addTimer(irc::randomHash(), $this, "handShakeTimeout", "", 8);
 }
Beispiel #16
0
 public function priv_admin($line, $args)
 {
     if ($args['nargs'] < 2) {
         return;
     }
     if ($this->ircClass->getClientConf('dccadminpass') == "") {
         return;
     }
     if (md5($args['arg1']) != $this->ircClass->getClientConf('dccadminpass')) {
         return;
     }
     $query = substr($args['query'], strlen($args['arg1']) + 1);
     $myArgs = parser::createLine($query);
     switch ($args['arg2']) {
         case "chatme":
             $port = $this->dccClass->addChat($line['fromNick'], null, null, true, null);
             if ($port === false) {
                 $this->ircClass->notice($line['fromNick'], "Error starting chat, please try again.", 1);
             }
             break;
         default:
             $chat = new chat_wrapper($line['fromNick'], $this->ircClass);
             $cmdList = $this->parserClass->getCmdList();
             $cmdLower = $myArgs['cmd'];
             if (isset($cmdList['dcc'][$cmdLower])) {
                 if ($myArgs['nargs'] < $cmdList['dcc'][$cmdLower]['numArgs']) {
                     $chat->dccSend("Usage: " . $cmdLower . " " . $cmdList['dcc'][$cmdLower]['usage']);
                     break;
                 }
                 $module = $cmdList['dcc'][$cmdLower]['module'];
                 $class = $cmdList['file'][$module]['class'];
                 $func = $cmdList['dcc'][$cmdLower]['function'];
                 $class->{$func}($chat, $myArgs);
                 $chat->dccSend("ADMIN " . irc::myStrToUpper($cmdLower) . " Requested");
             } else {
                 $chat->dccSend("Invalid Command: " . $myArgs['cmd']);
             }
             break;
     }
 }
Beispiel #17
0
 public function priv_findquote($line, $args)
 {
     $channel = $line['to'];
     if ($channel == $this->ircClass->getNick()) {
         return;
     }
     $cqDB = $this->openDatabase($channel);
     if (!$cqDB) {
         $this->ircClass->notice($line['fromNick'], "Error attempting to access quotes database!");
         return;
     }
     if ($args['nargs'] == 0) {
         $this->ircClass->notice($line['fromNick'], "Usage: " . $args['cmd'] . " <search>");
     } else {
         if (strlen($args['query']) <= 2) {
             $this->ircClass->notice($line['fromNick'], "Query must be more than 2 characters.");
             return;
         }
         $type = "author";
         if ($args['cmd'] == "!findquote") {
             $type = "quote";
         }
         $results = $cqDB->searchSectionsByVar($type, $args['query'], CONTAINS_MATCH);
         $count = count($results);
         if ($count > 0) {
             $this->ircClass->notice($line['fromNick'], "There are " . $count . " quotes matching your query:");
             sort($results);
             $resultArray = irc::multiLine(implode(" ", $results));
             foreach ($resultArray as $quoteLine) {
                 $this->ircClass->notice($line['fromNick'], $quoteLine);
             }
             $this->ircClass->notice($line['fromNick'], "End of results.");
         } else {
             $this->ircClass->notice($line['fromNick'], "No quotes matching your query.");
         }
     }
 }
Beispiel #18
0
/*
A.I.R.C.O
chat module
@author #urk team
*/
if (isset($_POST['msg']) or isset($externalMsg)) {
    set_time_limit(0);
    if (isset($_POST['msg'])) {
        $msg = $_POST['msg'];
    }
    if (isset($externalMsg)) {
        $msg = $externalMsg;
    }
    /* IRC */
    require 'classes/irc.class.php';
    $irc = new irc($config);
    $irc->login();
    $count = 0;
    do {
        if ($count == 15) {
            foreach ($config['channels'] as $channel) {
                $irc->send("PRIVMSG", $channel . ' :' . $msg);
            }
            $irc->send("NICK", "dwa");
            break;
        }
        $irc->run();
        $count++;
    } while (true);
}
$bodyLoad = " onload=\"document.form.msg.focus();\"";
Beispiel #19
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;
     }
 }
Beispiel #20
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 . ".");
 }
Beispiel #21
0
 public function initialize($filename, $size = 0)
 {
     $this->reportedRecieved = 0;
     $this->completed = 0;
     $this->filesize = $size;
     $this->timeConnected = time();
     $this->timeOutLevel = 0;
     $this->readQueue = "";
     $this->type = FILE;
     if ($this->transferType == UPLOAD) {
         $this->filename = $filename;
         if (strpos($filename, "/") !== false) {
             $filenameArray = explode("/", $filename);
             $this->filenameNoDir = $filenameArray[count($filenameArray) - 1];
         } else {
             if (strpos($filename, "\\") !== false) {
                 $filenameArray = explode("\\", $filename);
                 $this->filenameNoDir = $filenameArray[count($filenameArray) - 1];
             } else {
                 $this->filenameNoDir = $filename;
             }
         }
         $this->filenameNoDir = $this->cleanFilename($this->filenameNoDir);
         $this->dccClass->dccInform($this->dccString . "Initiating file transfer of (" . $this->filenameNoDir . ") to " . $this->nick);
         if (!$this->file_exists($this->filename)) {
             $this->disconnect("File does not exist");
             return;
         }
         $fileSize = $this->filesize($this->filename);
         if ($fileSize === false) {
             $this->disconnect("File does not exist");
             return;
         }
         $this->filesize = $fileSize;
         $kbSize = irc::intToSizeString($fileSize);
         if ($this->reverse == false) {
             $this->ircClass->privMsg($this->nick, "DCC SEND " . $this->filenameNoDir . " " . $this->ircClass->getClientIP(1) . " " . $this->port . " " . $fileSize . "", 0);
         }
         $this->ircClass->notice($this->nick, "DCC: Sending you (\"" . $this->filenameNoDir . "\") which is " . $kbSize . " (resume supported)", 0);
     } else {
         $uldir = $this->ircClass->getClientConf('uploaddir');
         $lastChar = substr($uldir, strlen($uldir) - 1, 1);
         if ($lastChar != "\\" || $lastChar != "/") {
             $uldir .= "/";
         }
         $filename = $this->cleanFilename($filename);
         $this->filename = $uldir . $filename;
         $this->dccClass->dccInform($this->dccString . "Initiating file transfer of (" . $filename . ") from " . $this->nick);
         if ($this->file_exists($this->filename)) {
             $bytesFinished = $this->filesize($this->filename);
             if ($bytesFinished >= $this->filesize) {
                 $this->disconnect("Connection aborted. I already have that file.");
                 return;
             } else {
                 $this->status = DCC_WAITING;
                 $this->bytesTransfered = $bytesFinished;
                 $this->resumedSize = $bytesFinished;
                 $this->ircClass->privMsg($this->nick, "DCC RESUME file.ext " . $this->port . " " . $bytesFinished . "", 0);
             }
             return;
         }
         $this->ircClass->notice($this->nick, "DCC: Upload accepted, connecting to you (" . $this->connectHost . ") on port " . $this->port . ".", 0);
         $this->status = DCC_CONNECTING;
         $this->connection->connect();
     }
 }
Beispiel #22
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.");
     }
 }
Beispiel #23
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;
 }