mlmmj

changeset b37f66e0852b

Ensure files written by php-admin have Unix EOL and sane permissions
author Ben Schmidt
date Sat, 31 Jul 2010 00:28:40 +1000
parents e29893b9f581
children d03fae037eb4
files contrib/web/php-admin/htdocs/save.php
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/contrib/web/php-admin/htdocs/save.php	Sat Jul 31 00:26:30 2010 +1000
     1.2 +++ b/contrib/web/php-admin/htdocs/save.php	Sat Jul 31 00:28:40 2010 +1000
     1.3 @@ -39,6 +39,8 @@
     1.4      {
     1.5  	if(!touch($file))
     1.6  	    die("Couldn't open ".$file." for writing");
     1.7 +	if (!chmod($file, 0644))
     1.8 +	    die("Couldn't chmod ".$file);
     1.9      }
    1.10      else
    1.11  	@unlink($file);
    1.12 @@ -60,8 +62,11 @@
    1.13  	if (!$fp = fopen($file, "w"))
    1.14  	    die("Couldn't open ".$file." for writing");
    1.15  
    1.16 -	fwrite($fp, $HTTP_POST_VARS[$name]);
    1.17 +	fwrite($fp, preg_replace('/\\r\\n/',"\n",$HTTP_POST_VARS[$name]));
    1.18  	fclose($fp);
    1.19 +
    1.20 +	if (!chmod($file, 0644))
    1.21 +	    die("Couldn't chmod ".$file);
    1.22      }
    1.23      else
    1.24  	@unlink($file);