Improve failed open handling
authorJoey Schulze <joey@infodrom.org>
Wed, 3 Feb 2016 09:58:55 +0000 (09:58 +0000)
committerJoey Schulze <joey@infodrom.org>
Wed, 3 Feb 2016 09:58:55 +0000 (09:58 +0000)
Styles/quote.style
src/Debian/lists.wml
src/Infodrom/fortunes/fortunes.inc
src/Infodrom/fortunes/lookup.wml
src/Infodrom/fortunes/news.wml
src/Linux/HOWTO/index.wml
src/Mail-Archive/index.wml
src/News/ticker/index.wml

index 0763b08..c876865 100644 (file)
@@ -30,7 +30,7 @@
     <ifont><font size=-1 color="#<box-fgcolor>">
     <?
       # FIXME: Was gibt fopen() zurück, wenn die Datei nicht geöffnet werden konnte?
-      if (is_file ("<get-var fortune>") && ($fortune = fopen ("<get-var fortune>", "r"))) {
+      if (is_file ("<get-var fortune>") && (($fortune = fopen ("<get-var fortune>", "r")) !== false)) {
        while (!feof ($fortune)) {
          $line = fgets ($fortune, 255);
          echo $line;
@@ -89,7 +89,7 @@
        bgcolor="#<box-bgcolor>">
     <font face="helvetica,arial" size=-1 color="#<box-fgcolor>">
 <?
-  if ($fortune = fopen ("index-fortune.html", "r")) {
+  if (($fortune = fopen ("index-fortune.html", "r")) !== false) {
     while (!feof ($fortune)) {
       $line = fgets ($fortune, 255);
       echo $line;
        bgcolor="#<box-bgcolor>">
     <font face="helvetica,arial" size=-1 color="#<box-fgcolor>">
 <?
-  if ($fortune = fopen ("index-fortune.html", "r")) {
+  if (($fortune = fopen ("index-fortune.html", "r")) !== false) {
     while (!feof ($fortune)) {
       $line = fgets ($fortune, 255);
       echo $line;
   } else {
     $fortune = popen ("<get-var source>", "r");
   }
-  if ($fortune) {
+  if ($fortune !== false) {
     $cookie = array ();
     while (!feof ($fortune)) {
       $line = fgets ($fortune, 255);
index 431c94b..09d3236 100644 (file)
@@ -7,7 +7,7 @@
 
 <?
   if (($s = stat ("mailing-lists.txt"))) {
-    if (($f = fopen ("mailing-lists.txt", "r"))) {
+    if (($f = fopen ("mailing-lists.txt", "r")) != false) {
       $lists = array ("debian-user-de","debian-events-de");
       while (!feof ($f)) {
         $line = fgets ($f, 255);
index 884056f..073ee47 100644 (file)
@@ -8,7 +8,7 @@
     else
       $fortunes = fopen ("$db", "r");
 
-    while (!feof ($fortunes) && $skip > 0) {
+    while ($fortunes !== false && !feof ($fortunes) && $skip > 0) {
       $line = fgets ($fortunes, 255);
       if ($line == "%\n") {
         $skip--;
@@ -58,7 +58,7 @@
     $fortunes = fopen ($file, "r");
 
     $count = 0;
-    while (!feof ($fortunes)) {
+    while ($fortunes !== false && !feof ($fortunes)) {
       $line = fgets ($fortunes, 255);
       if ($line == "%\n") {
        $count++;
index cc81351..0201c3d 100644 (file)
@@ -20,7 +20,7 @@
       chdir ("/org/infodrom.org/fortunes");
 
       $fortunes = popen ($cmd, "r");
-      if (!$fortunes) exit();
+      if ($fortunes === false) exit();
 
       while (!feof ($fortunes)) {
         $line = fgets ($fortunes, 255);
index 8b379bc..c6105f2 100644 (file)
@@ -66,7 +66,7 @@
     } else {
       $skipfirst = 0;
     }
-    while (!feof ($fortune)) {
+    while ($fortunes !== false && !feof ($fortune)) {
       $line = chop (fgets ($fortune, 255));
       if ($lineno >= $ignore) {
        if (!strcmp ($line, "%")) {
index b1aa243..92194a5 100644 (file)
@@ -19,7 +19,7 @@
 
   
   if (($s = stat ("index.txt"))) {
-    if (($f = fopen ("index.txt", "r"))) {
+    if (($f = fopen ("index.txt", "r")) !== false) {
       $howto = array ();
       while (!feof ($f)) {
        $line = fgets ($f, 255);
index 136761c..24f339a 100644 (file)
@@ -54,7 +54,7 @@
     $file = $dirs[$i] . "/" . "index.inc";
     if (is_file ($file)) {
       $f = fopen ($file, "r");
-      if ($f) {
+      if ($f !== false) {
         while (!feof ($f)) {
           $line = fgets ($f, 255);
          print ($line);
index d23265d..8bf92d7 100644 (file)
@@ -10,7 +10,7 @@
     $file = "ticker.inc";
     if (is_file ($file)) {
       $f = fopen ($file, "r");
-      if ($f) {
+      if ($f !== false) {
         while (!feof ($f)) {
           $line = fgets ($f, 255);
           print ($line);