From 9a2fd0085dd4982577355a66d8e7bc59159c8d91 Mon Sep 17 00:00:00 2001 From: roberto Date: Wed, 27 Apr 2016 14:40:03 -0700 Subject: [PATCH] Converted deleter.php to standard security model, take 2. --- interface/patient_file/deleter.php | 163 +++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 80 deletions(-) diff --git a/interface/patient_file/deleter.php b/interface/patient_file/deleter.php index e3a9bba5a..a4609fea7 100644 --- a/interface/patient_file/deleter.php +++ b/interface/patient_file/deleter.php @@ -24,6 +24,9 @@ * @link http://www.open-emr.org */ + $fake_register_globals=false; + $sanitize_all_escapes=true; + require_once('../globals.php'); require_once($GLOBALS['srcdir'].'/log.inc'); require_once($GLOBALS['srcdir'].'/acl.inc'); @@ -51,14 +54,14 @@ require_once($GLOBALS['srcdir'].'/sl_eob.inc.php'); foreach ($trow as $key => $value) { if (! $value || $value == '0000-00-00 00:00:00') continue; if ($logstring) $logstring .= " "; - $logstring .= $key . "='" . addslashes($value) . "'"; + $logstring .= $key . "= $value "; } newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "$table: $logstring"); ++$count; } if ($count) { $query = "DELETE FROM $table WHERE $where"; - echo $query . "
\n"; + echo text($query) . "
\n"; sqlStatement($query); } } @@ -70,7 +73,7 @@ require_once($GLOBALS['srcdir'].'/sl_eob.inc.php'); if (sqlQuery("SELECT * FROM $table WHERE $where")) { newEvent("deactivate", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "$table: $where"); $query = "UPDATE $table SET $set WHERE $where"; - echo $query . "
\n"; + echo text($query) . "
\n"; sqlStatement($query); } } @@ -96,16 +99,16 @@ function decorateString($fmt, $str) { // This is special because it has to replace the inventory. // function delete_drug_sales($patient_id, $encounter_id=0) { - $where = $encounter_id ? "ds.encounter = '$encounter_id'" : - "ds.pid = '$patient_id' AND ds.encounter != 0"; + $where = $encounter_id ? "ds.encounter = '" . add_escape_custom($encounter_id) . "'" : + "ds.pid = '" . add_escape_custom($patient_id) . "' AND ds.encounter != 0"; sqlStatement("UPDATE drug_sales AS ds, drug_inventory AS di " . "SET di.on_hand = di.on_hand + ds.quantity " . "WHERE $where AND di.inventory_id = ds.inventory_id"); if ($encounter_id) { - row_delete("drug_sales", "encounter = '$encounter_id'"); + row_delete("drug_sales", "encounter = '" . add_escape_custom($encounter_id) . "'"); } else { - row_delete("drug_sales", "pid = '$patient_id'"); + row_delete("drug_sales", "pid = '" . add_escape_custom($patient_id ) . "'"); } } @@ -114,24 +117,24 @@ function delete_drug_sales($patient_id, $encounter_id=0) { function form_delete($formdir, $formid) { $formdir = ($formdir == 'newpatient') ? 'encounter' : $formdir; if (substr($formdir,0,3) == 'LBF') { - row_delete("lbf_data", "form_id = '$formid'"); + row_delete("lbf_data", "form_id = '" . add_escape_custom($formid) . "'"); } else if ($formdir == 'procedure_order') { $tres = sqlStatement("SELECT procedure_report_id FROM procedure_report " . "WHERE procedure_order_id = ?", array($formid)); while ($trow = sqlFetchArray($tres)) { $reportid = 0 + $trow['procedure_report_id']; - row_delete("procedure_result", "procedure_report_id = '$reportid'"); + row_delete("procedure_result", "procedure_report_id = '" . add_escape_custom($reportid) . "'"); } - row_delete("procedure_report", "procedure_order_id = '$formid'"); - row_delete("procedure_order_code", "procedure_order_id = '$formid'"); - row_delete("procedure_order", "procedure_order_id = '$formid'"); + row_delete("procedure_report", "procedure_order_id = '" . add_escape_custom($formid) . "'"); + row_delete("procedure_order_code", "procedure_order_id = '" . add_escape_custom($formid) . "'"); + row_delete("procedure_order", "procedure_order_id = '" . add_escape_custom($formid) . "'"); } else if ($formdir == 'physical_exam') { - row_delete("form_$formdir", "forms_id = '$formid'"); + row_delete("form_$formdir", "forms_id = '" . add_escape_custom($formid) . "'"); } else { - row_delete("form_$formdir", "id = '$formid'"); + row_delete("form_$formdir", "id = '" . add_escape_custom($formid) . "'"); } } @@ -151,7 +154,7 @@ function delete_document($document) { -<?php xl('Delete Patient, Encounter, Form, Issue, Document, Payment, Billing or Transaction','e'); ?> +<?php echo xlt('Delete Patient, Encounter, Form, Issue, Document, Payment, Billing or Transaction'); ?>