Improve url catcher
[banana.git] / banana / NetNNTP.inc.php
index 3cebaed..3934cd5 100644 (file)
@@ -20,6 +20,8 @@ class nntp
     var $lasterrorcode;
     /** last NNTP error text */
     var $lasterrortext;
+    /** test validity */
+    var $valid = true;
 
     /** constructor
      * @param $_host STRING NNTP host
@@ -33,6 +35,7 @@ class nntp
         $url         = parse_url($_url);
         $this->ns    = fsockopen($url['host'], $url['port'], $errno, $errstr, $_timeout);
         if (!$this->ns) {
+            $this->valid = false;
             return null;
         }
 
@@ -43,7 +46,7 @@ class nntp
             $result        = $this->gline();
             $this->posting = ($result{0}=="200");
         }
-        if ($result{0}=="2" && $url['user'] && $url['user']!='anonymous') {
+        if ($result{0}=="2" && isset($url['user']) && $url['user'] != 'anonymous') {
             return $this->authinfo($url['user'], $url['pass']);
         }
         return ($result{0}=="2");
@@ -472,8 +475,9 @@ class nntp
             
         $array  = array();
         while (($result = $this->gline()) != '.') {
-            preg_match("/([^ \t]+) (.*)$/", $result, $regs);
-            $array[$regs[1]] = $regs[2];
+            if (preg_match("/([^ \t]+) (.*)$/", $result, $regs)) {
+                $array[$regs[1]] = $regs[2];
+            }
         }
         return $array;
     }
@@ -504,4 +508,5 @@ class nntp
     }
 }
 
+// vim:set et sw=4 sts=4 ts=4 
 ?>