diff --git a/includes/alerts/transport.irc.php b/includes/alerts/transport.irc.php index 71e0591c0..5e98f6ca8 100644 --- a/includes/alerts/transport.irc.php +++ b/includes/alerts/transport.irc.php @@ -21,4 +21,11 @@ * @subpackage Alerts */ -return file_put_contents($config['install_dir']."/.ircbot.alert", json_encode($obj)."\n", FILE_APPEND); +$f = $config['install_dir']."/.ircbot.alert"; +$f = fopen($f,"w+"); +$f = fwrite($f,json_encode($obj)."\n"); +if( $f === false ) { + return false; +} else { + return true; +} diff --git a/irc.php b/irc.php index ed3e832a2..84ac73ccb 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) && !posix_mkfifo($f,0644) ) ) { $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])."'"); }