rendered paste body<?PHP
class WCon {
public $config = array();
public $con = array();
public $buffer;
function WCon($config) {
$this->config = $config;
$this->buffer = new buffer();
}
function connect() {
$this->outPut(">> Attempting to connect to {$this->config['serv']} on port {$this->config['port']}");
$this->con['socket'] = fsockopen($this->config['serv'], $this->config['port']);
if (!$this->con['socket']) {
$this->outPut(">> There was an error connecting to {$this->config['serv']} on port {$this->config['port']}");
} else {
$this->outPut(">> Successfully connected to {$this->config['serv']}");
$this->sendCMD("USER {$this->config['nick']}{$this->config['user']} :{$this->config['user']}");
$this->sendCMD("NICK {$this->config['nick']}");
$this->sendCMD("JOIN {$this->config['chan']}");
while (!feof($this->con['socket'])) {
$this->con['buffer'] = trim(fgets($this->con['socket'], 4096));
//$this->outPut($this->con['buffer']);
if(substr($this->con['buffer'], 0, 6) == "PING :") {
$this->sendCMD("PONG :".substr($this->con['buffer'], 6));
if ($this->config['inch'] == 0) {
$this->sendCMD("JOIN {$this->config['chan']}");
$this->config['inch'] = 1;
}
} else {
$buffer = new buffer();
$newBuff = $buffer->WCBuffer($this->con['buffer']);
}
}
}
}
function sendCMD($cmd) {
fputs($this->con['socket'], "{$cmd}\n");
echo date("\[j, g:i A\]")." > {$cmd}\n";
}
function outPut($in) {
echo date("\[H:i:s\]")." < {$in}\n";
}
}
?>