if(!array_key_exists($name, $this->botdb["bots"])) {
$this->botdb["bots"][$name] = $botfile;
}
+ return true;
}
private function unloadBot($name, $delete = true) {
if(array_key_exists($name, $this->botdb["bots"]) && $delete) {
unset($this->botdb["bots"][$name]);
}
+ return true;
}
private function rehashBot($name) {
if(!$bot) return false;
$bot->load($this->uplink, $data);
$this->loadedBots[strtolower($name)] = $bot;
+ return true;
}
private function listLoadedBots() {
$this->uplink->privmsg($this->modman, $channel, "error.");
}
break;
+ case "~list":
+ foreach(BotLoader::listBots() as $name => $bot) {
+ $this->uplink->privmsg($this->modman, $channel, $name);
+ }
+ break;
case "~debug":
$exp=explode(" ",$message,2);
ob_start();
class {$_NAME} extends Bot {
private $uplink;
- private $php, $phpcache;
+ private $php, $phpcache = array();
public function load($uplink, $old = false) {
$this->uplink = $uplink;
}
public function unload($rehash = false) {
- foreach($this->phpcache as $id => &$php) {
+ foreach($this->phpcache as $id => $php) {
fclose($php['pipes'][1]);
fclose($php['pipes'][2]);
proc_terminate($php['proc'],9);
}
public function loop() {
- foreach($this->phpcache as $id => &$php) {
- if(!$this->checkstate(&$php)) {
+ foreach($this->phpcache as $id => $php) {
+ if(!$this->checkstate($php)) {
unset($this->phpcache[$id]);
}
}
$opOnPHPChannel = ($privs & P10_Channel::USERPRIV_OPED);
}
if(!$user->getModes()->hasMode('o') && !$opOnPHPChannel) return 0;
- $exp=explode(" ",$message);
+ $exp=explode(" ", $message, 2);
switch (strtolower($exp[0])) {
case "~php":
if(count($this->phpcache) > 5) {
private $socket;
private $traffic = array("in" => 0, "out" => 0);
+ private $timeout;
public function connect($host, $port, $bind = null, $ssl = false, $blocking = 0) {
if($bind)
$context = stream_context_create($options);
$sock = stream_socket_client(($ssl ? 'ssl://' : '').$host.':'.$port, $errno, $errstr, 3, STREAM_CLIENT_CONNECT, $context);
if($sock) {
- if($blocking) {
- stream_set_blocking($sock, true);
- stream_set_timeout($sock, 0, ($blocking / 1000));
- } else {
- stream_set_blocking($sock, false);
- }
+ $this->timeout = $blocking * 1000;
+ stream_set_blocking($sock, false);
$this->socket = $sock;
return true;
} else
$read = array($this->socket);
$write= null;
$except=null;
- $n=@stream_select($read, $write, $except, 0);
+ $n=@stream_select($read, $write, $except, 0, $this->timeout);
if($n === FALSE || feof($this->socket)) {
$this->socket = false;
return null;