]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Ensure files written by php-admin have Unix EOL and sane permissions
authorBen Schmidt <none@none>
Fri, 30 Jul 2010 14:28:40 +0000 (00:28 +1000)
committerBen Schmidt <none@none>
Fri, 30 Jul 2010 14:28:40 +0000 (00:28 +1000)
contrib/web/php-admin/htdocs/save.php

index 908b8144d8c0ebbf12cc1c23b284ee00f3045b8b..27b01da68daa35f94f130a485b4579c985c049d4 100644 (file)
@@ -39,6 +39,8 @@ function mlmmj_boolean($name, $nicename, $text)
     {
        if(!touch($file))
            die("Couldn't open ".$file." for writing");
+       if (!chmod($file, 0644))
+           die("Couldn't chmod ".$file);
     }
     else
        @unlink($file);
@@ -60,8 +62,11 @@ function mlmmj_list($name, $nicename, $text)
        if (!$fp = fopen($file, "w"))
            die("Couldn't open ".$file." for writing");
 
-       fwrite($fp, $HTTP_POST_VARS[$name]);
+       fwrite($fp, preg_replace('/\\r\\n/',"\n",$HTTP_POST_VARS[$name]));
        fclose($fp);
+
+       if (!chmod($file, 0644))
+           die("Couldn't chmod ".$file);
     }
     else
        @unlink($file);