translate: Use /tmp for user-submitted translation files.
And detect a failure to create the tmpfile!
diff --git a/submit.php b/submit.php
index d5a8883..4b7f7cb 100644
--- a/submit.php
+++ b/submit.php
@@ -35,11 +35,16 @@
$i = 0;
do {
- $filename = sprintf("apps/lang/%s.lang%s.new", $_REQUEST['lang'], $i == 0 ? '' : '.'.$i);
+ $filename = sprintf("/tmp/%s.lang%s.new", $_REQUEST['lang'], $i == 0 ? '' : '.'.$i);
$i++;
} while (file_exists($filename));
$fp = fopen($filename, 'w');
+ if ($fp === false) {
+ header("HTTP/1.1 500 Internal Server Error");
+ print "\nUnable to write tmpfile\n";
+ exit(1);
+ }
// Write a header if one exists
$original_lines = file(sprintf("apps/lang/%s.lang", $_REQUEST['lang']));
@@ -51,7 +56,7 @@
$original = parselangfile(sprintf("apps/lang/%s.lang.update", $_REQUEST['lang']));
$english = parselangfile("apps/lang/english.lang");
print("Copyright by individual Rockbox contributors\n");
- printf("See\nhttp://git.rockbox.org/?p=rockbox.git;a=history;f=apps/lang/%s.lang;hb=HEAD\nfor details.\n", $_REQUEST['lang']);
+ printf("See\nhttps://git.rockbox.org/?p=rockbox.git;a=history;f=apps/lang/%s.lang;hb=HEAD\nfor details.\n", $_REQUEST['lang']);
print("May be distributed under the terms of the GNU GPL version 2 or later\n");
print("This file generated by http://translate.rockbox.org/\n\n");
printf("This translation was based on git hash %s of the original.\n\n", $langs[$_REQUEST['lang']]);