}
//
-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)
// 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
{
}
else
{
- OUTPUT_HTML ("<STRONG>404:</STRONG> ".$FILE."<BR>");
+ OUTPUT_HTML ("<STRONG>404:</STRONG> ".$file."<BR>");
}
}