Fix references when replying to a post with artid = 0
[banana.git] / banana / nntpcore.inc.php
index 0a1f3c1..5d8bc63 100644 (file)
@@ -98,29 +98,17 @@ class BananaNNTPCore
      */
     private function getLine()
     {
-        return rtrim(@fgets($this->ns, 1200));
+        return rtrim(@fgets($this->ns, 1200), "\r\n");
     }
 
     /** fetch data (and on delimitor)
      * @param STRING $delim string indicating and of transmission
      */
-    private function fetchResult($callback = null)
+    private function &fetchResult()
     {
         $array = Array();
         while (($result = $this->getLine()) != '.') {
-            if (!is_null($callback)) {
-                list($key, $result) = call_user_func($callback, $result);
-                if (is_null($result)) {
-                    continue;
-                }
-                if (is_null($key)) {
-                    $array[] = $result;
-                } else {
-                    $array[$key] = $result;
-                }
-            } else {
-                $array[] = $result;
-            }
+            $array[] = $result;
         }
         if ($this->debug && $this->bt) {
             $this->bt[count($this->bt) - 1]['response'] = count($array);
@@ -471,9 +459,9 @@ class BananaNNTPCore
         if (!$this->execLine("XGTITLE $pattern ")) {
             return false;
         }
-        $array  = $this->fetchResult();
+        $array  =& $this->fetchResult();
         $groups = array();
-        foreach ($array as $result) {
+        foreach ($array as &$result) {
             list($group, $desc) = split("[ \t]", $result, 2);
             $groups[$group] = $desc;
         }
@@ -495,7 +483,7 @@ class BananaNNTPCore
         if (!$this->execLine("XHDR $hdr $range ")) {
             return false;
         }
-        $array   = $this->fetchResult();
+        $array   =& $this->fetchResult();
         $headers = array();
         foreach ($array as &$result) {
             @list($head, $value) = explode(' ', $result, 2);
@@ -515,7 +503,7 @@ class BananaNNTPCore
         if (!$this->execLine("XPAT $hdr $range $pat")) {
             return false;
         }
-        $array   = $this->fetchResult();
+        $array   =& $this->fetchResult();
         $headers = array();
         foreach ($array as &$result) {
             list($head, $value) = explode(' ', $result, 2);