Naming convention applied
[mailer.git] / inc / install-inc.php
index 0b0cfb120706e8df2202d349bb41ac5c67d2f86d..f4146a707e5dee5e7a5b9b72aee5ac0b35fce1d0 100644 (file)
@@ -43,23 +43,23 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
 }
 
 //
-function install_WriteData ($FILE, $COMMENT, $PREFIX, $SUFFIX, $DATA, $SNEAK=0)
+function install_WriteData ($file, $COMMENT, $PREFIX, $SUFFIX, $DATA, $SNEAK=0)
 {
        $DONE = false;  $SNEAK++;
-       if (file_exists($FILE))
+       if (file_exists($file))
        {
-               $SEARCH = "CFG: ".$COMMENT;
-               $TMP = $FILE.".tmp";
-               $fp = fopen($FILE, 'r') or OUTPUT_HTML ("<STRONG>READ:</STRONG> ".$FILE."<BR>");
-               if ($fp)
+               $search = "CFG: ".$COMMENT;
+               $tmp = $file.".tmp";
+               $fp = @fopen($file, 'r') or OUTPUT_HTML ("<STRONG>READ:</STRONG> ".$file."<BR>");
+               if (is_resource($fp))
                {
-                       $fp_tmp = fopen($TMP, 'w') or OUTPUT_HTML ("<STRONG>WRITE:</STRONG> ".$TMP."<BR>");
-                       if ($fp_tmp)
+                       $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML ("<STRONG>WRITE:</STRONG> ".$tmp."<BR>");
+                       if (is_resource($fp_tmp))
                        {
                                while (! feof($fp))
                                {
                                        $line = fgets ($fp, 10240);
-                                       if (strpos($line, $SEARCH) > -1) $next = 0;
+                                       if (strpos($line, $search) > -1) $next = 0;
                                        if ($next > -1)
                                        {
                                                if ($next == $SNEAK)
@@ -78,12 +78,15 @@ function install_WriteData ($FILE, $COMMENT, $PREFIX, $SUFFIX, $DATA, $SNEAK=0)
                                // Finished writing tmp file
                                $DONE = true;
                        }
+
+                       // Close source directory
                        fclose($fp);
-                       if ($DONE)
+
+                       if (($DONE) && (is_writeable($file)))
                        {
                                // Copy back tmp file and delete tmp :-)
-                               @copy($TMP, $FILE);
-                               @unlink($TMP);
+                               @copy($tmp, $file);
+                               @unlink($tmp);
                        }
                         else
                        {
@@ -93,7 +96,7 @@ function install_WriteData ($FILE, $COMMENT, $PREFIX, $SUFFIX, $DATA, $SNEAK=0)
        }
         else
        {
-               OUTPUT_HTML ("<STRONG>404:</STRONG> ".$FILE."<BR>");
+               OUTPUT_HTML ("<STRONG>404:</STRONG> ".$file."<BR>");
        }
 }