diff --git a/includes/alerts/transport.irc.php b/includes/alerts/transport.irc.php index 71e0591c0..03fcc3cda 100644 --- a/includes/alerts/transport.irc.php +++ b/includes/alerts/transport.irc.php @@ -21,4 +21,14 @@ * @subpackage Alerts */ -return file_put_contents($config['install_dir']."/.ircbot.alert", json_encode($obj)."\n", FILE_APPEND); +$f = $config['install_dir']."/.ircbot.alert"; +if( file_exists($f) && filetype($f) == "fifo" ) { + $f = fopen($f,"w+"); + $r = fwrite($f,json_encode($obj)."\n"); + $f = fclose($f); + if( $r === false ) { + return false; + } else { + return true; + } +} diff --git a/irc.php b/irc.php index ed3e832a2..9e4025305 100755 --- a/irc.php +++ b/irc.php @@ -128,11 +128,11 @@ class ircbot { private function connect_alert() { $f = $this->config['install_dir']."/.ircbot.alert"; - if( (file_exists($f) || !touch($f)) && (!unlink($f) || !touch($f)) ) { + if( ( file_exists($f) && filetype($f) != "fifo" && !unlink($f) ) || ( !file_exists($f) && !shell_exec("mkfifo $f && echo 1") ) ) { $this->log("Error - Cannot create Alert-File"); return false; } - if( ($this->socket['alert'] = fopen($f,'r')) ) { + if( ($this->socket['alert'] = fopen($f,'r+')) ) { $this->log("Opened Alert-File"); stream_set_blocking($this->socket['alert'], false); return true; @@ -147,7 +147,7 @@ class ircbot { $r = strlen($r); if(strstr($this->buff[$buff],"\n")) { $tmp = explode("\n",$this->buff[$buff],2); - $this->buff[$buff] = substr($this->buff[$buff], strlen($tmp[0])+2); + $this->buff[$buff] = substr($this->buff[$buff], strlen($tmp[0])+1); if( $this->debug ) { $this->log("Returning buffer '$buff': '".trim($tmp[0])."'"); }