X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fattachments.php;h=2f41d80c14cc15cef973f5dedb2e4b3b0b1232e9;hb=66b76b3be910e0f5dc5a26384c4cfce20579a70d;hp=b34cbe33675eb8c23c0103d88bd102967980ea79;hpb=3dd813441cccef5dc1fe245a245b99d89020b55d;p=fa-stable.git diff --git a/admin/attachments.php b/admin/attachments.php index b34cbe33..2f41d80c 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -19,6 +19,7 @@ include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/admin/db/attachments_db.inc"); +include_once($path_to_root . "/admin/db/transactions_db.inc"); if (isset($_GET['vw'])) $view_id = $_GET['vw']; @@ -81,8 +82,8 @@ if (isset($_GET['trans_no'])) if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { - if (!$_POST['trans_no']) - display_error(_("No transaction has been selected.")); + if (!transaction_exists($_POST['filterType'], $_POST['trans_no'])) + display_error(_("Selected transaction does not exists.")); elseif ($Mode == 'ADD_ITEM' && (!isset($_FILES['filename']) || $_FILES['filename']['size'] == 0)) display_error(_("Select attachment file.")); else { @@ -107,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); } @@ -130,7 +134,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') display_notification(_("Attachment has been updated.")); } } - refresh_pager('trans_table'); + refresh_pager('trans_tbl'); $Ajax->activate('_page_body'); $Mode = 'RESET'; }