[0003084] Database password with special chars was stored distorted in config_db.
[fa-stable.git] / admin / attachments.php
index 9540327a47a2aab99751be678356a287e9e4774b..4803ca771e00744abfeab67b1999db85882a1def 100644 (file)
@@ -69,7 +69,7 @@ if ($download_id != -1)
 }
 
 $js = "";
-if ($use_popup_windows)
+if ($SysPrefs->use_popup_windows)
        $js .= get_js_open_window(800, 500);
 page(_($help_context = "Attach Documents"), false, false, "", $js);
 
@@ -94,7 +94,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
                if (!file_exists($dir))
                {
                        mkdir ($dir,0777);
-                       $index_file = "<?php\nheader(\"Location: ../index.php\");\n?>";
+                       $index_file = "<?php\nheader(\"Location: ../index.php\");\n";
                        $fp = fopen($dir."/index.php", "w");
                        fwrite($fp, $index_file);
                        fclose($fp);
@@ -108,7 +108,10 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
                // protect against directory traversal
                if ($Mode == 'UPDATE_ITEM')
                {
-                       $unique_name = preg_replace('/[^a-zA-Z0-9.\-_]/', '', $_POST['unique_name']);
+                   $row = get_attachment($selected_id);
+                   if ($row['filename'] == "")
+                       exit();
+                       $unique_name = $row['unique_name'];
                        if ($filename && file_exists($dir."/".$unique_name))
                                unlink($dir."/".$unique_name);
                }
@@ -255,4 +258,3 @@ end_form();
 
 end_page();
 
-?>