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; }
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; }
private function doHandShake() { $this->dccSend("120 " . $this->ircClass->getNick() . " " . $this->filesize . " " . $this->filenameNoDir . "\n"); $this->handShakeSent = true; $this->timerClass->addTimer(irc::randomHash(), $this, "handShakeTimeout", "", 8); }
private function loadClassDef($filename, $classname) { $stat = stat($filename); if ($stat === false) { $this->loadClassError($filename, "Could not find function file"); return false; } $modified = $stat['mtime']; if (isset($this->fileModified[$filename])) { if ($modified == $this->fileModified[$filename]['modified']) { return $this->fileModified[$filename]['classdef']; } } $fileData = file_get_contents($filename); if ($fileData === false) { $this->loadClassError($filename, "Could not find function file"); return false; } //Okay, we have the module now.. now we need to find some stuff. if (!preg_match("/class[\\s]+?" . $classname . "[\\s]+?extends[\\s]+?module[\\s]+?{/", $fileData)) { $this->loadClassError($filename, "Could not find valid classdef in function file"); return false; } //Okay, our module is in the file... replace it with random hash. $newHash = irc::randomHash(); $newClassDef = $classname . "_" . $newHash; $fileData = preg_replace("/(class[\\s]+?)" . $classname . "([\\s]+?extends[\\s]+?module[\\s]+?{)/", "\\1" . $newClassDef . "\\2", $fileData); /* Interesting idea, but lets leave it out for now foreach($this->aliasArray AS $func => $class) { $fileData = preg_replace("/([=\n\(\t\s]+?)".$func."[\s\t\n\r]*?\(/s", "\\1\$this->" . $class . "->" . $func . "(", $fileData); } */ $success = eval("?>" . $fileData . "<?php "); if ($success === false) { $this->loadClassError($filename, "Error in function file"); /* Attempt to fallback on a previous revision that worked! */ if (isset($this->fileModified[$filename])) { $this->loadClassError($filename, "Using a cached version of the class definition"); $this->loadDefError = true; return $this->fileModified[$filename]['classdef']; } return false; } $this->fileModified[$filename]['modified'] = $modified; $this->fileModified[$filename]['classdef'] = $newClassDef; return $newClassDef; }
private function doHandShake() { $this->dccSendRaw("100 " . $this->ircClass->getNick() . "\n"); $this->handShakeSent = true; $this->timerClass->addTimer(irc::randomHash(), $this, "handShakeTimeout", "", 8); }