Skip to content

Commit

Permalink
fix: Uninitialised zip and missing file size error in Native Data Loa…
Browse files Browse the repository at this point in the history
…ds (openemr#7081)

* Fix zip and missing error in Native Data Loads

* Fix PHPCBF violation
  • Loading branch information
jack5github authored Dec 8, 2023
1 parent 54aa28c commit 7a430c3
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions interface/super/load_codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

set_time_limit(0);

require_once('../globals.php');
require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
require_once '../globals.php';
require_once $GLOBALS['fileroot'] . '/custom/code_types.inc.php';

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Csrf\CsrfUtils;
Expand Down Expand Up @@ -124,27 +124,16 @@
}

$seen_codes[$code] = 1;
++$inscount;
if (!$form_replace) {
$tmp = sqlQuery(
"SELECT id FROM codes WHERE code_type = ? AND code = ? LIMIT 1",
array($code_type_id, $code)
);
if ($tmp['id']) {
sqlStatementNoLog(
"UPDATE codes SET code_text = ? WHERE code_type = ? AND code = ?",
array($a[14], $code_type_id, $code)
);
++$repcount;
continue;
$tmp = sqlQuery("SELECT id FROM codes WHERE code_type = ? AND code = ? LIMIT 1", array($code_type_id, $code));
if (!empty($tmp)) {
sqlStatementNoLog("UPDATE codes SET code_text = ? WHERE code_type = ? AND code = ?", array($a[14], $code_type_id, $code));
++$repcount;
continue;
}
}

sqlStatementNoLog(
"INSERT INTO codes SET code_type = ?, code = ?, code_text = ?, " .
"fee = 0, units = 0",
array($code_type_id, $code, $a[14])
);
sqlStatementNoLog("INSERT INTO codes SET code_type = ?, code = ?, code_text = ?, fee = 0, units = 0", array($code_type_id, $code, $a[14]));
++$inscount;
}

Expand All @@ -156,13 +145,16 @@
sqlStatementNoLog("SET autocommit=1");

fclose($eres);
$zipin->close();
}
// Cannot close ZIP object if not initialised, catch and do nothing
try {
$zipin->close();
} catch (ValueError $e) {
}

echo "<p class='text-success'>" .
xlt('LOAD SUCCESSFUL. Codes inserted') . ": " . text($inscount) . ", " .
xlt('replaced') . ": " . text($repcount) .
"</p>\n";
echo "<p class='text-success'>" . xlt('LOAD SUCCESSFUL. Codes inserted') . ": " . text($inscount) . ", " . xlt('replaced') . ": " . text($repcount) . "</p>\n";
} else {
echo "<p class='text-danger'>" . xlt('ERROR. Could not open') . ". " . (php_ini_loaded_file() ?? "Server") . " upload_max_filesize: " . xlt('Your file is too large') . ". " . xlt('Set To') . " ≥ post_max_size.";
}
}

?>
Expand Down

0 comments on commit 7a430c3

Please sign in to comment.