Source code raw phps
<?php
require_once 'libraries/class.Link.php';
class Link_IRC extends Link {
protected $_stream = null;
public $error = '';
static public $status = parent::S_NOT_CONNECTED;
public function connect ($host, $port)
{
if ($this->_stream = fsockopen($host, $port, $errno, $errstr)) {
self::$status = parent::S_CONNECTED;
return true;
} else {
$this->error = $errstr;
self::$status = parent::S_NOT_CONNECTED;
return false;
}
}
public function read ($length = 2048)
{
if (is_resource($this->_stream) && ($input = fread($this->_stream, $length)) !== false) {
$input = trim($input);
if (!empty($input)) {
return $input;
} else {
return false;
}
} else {
// make the bot reconnect
Bot::$status = Bot::S_RECONNECT;
return false;
}
}
public function write ($content)
{
if (is_resource($this->_stream)) {
return fwrite($this->_stream, $content."\n");
} else {
// make the bot reconnect
Bot::$status = Bot::S_RECONNECT;
return false;
}
}
public function isValid()
{
return (self::$status == parent::S_CONNECTED);
}
public function eof()
{
return false;
}
}
?>
Comments
There is currently no comment here.