* @copyright Copyright (c) 2018 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ use OpenEMR\Common\Acl\AclMain; use OpenEMR\Common\Csrf\CsrfUtils; // Ensure this script is not called separately if ($langModuleFlag !== true) { die(function_exists('xlt') ? xlt('Authentication Error') : 'Authentication Error'); } // gacl control $thisauth = AclMain::aclCheckCore('admin', 'language'); if (!$thisauth) { echo "\n\n"; echo "

" . xlt('You are not authorized for this.') . "

\n"; echo "\n\n"; exit(); } if (!empty($_POST['add'])) { if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) { CsrfUtils::csrfNotVerified(); } //validate $pat = "^[a-z]{2}\$"; if (!check_pattern($_POST['lang_code'], $pat)) { echo xlt("Code must be two letter lowercase") . '
'; $err = 'y'; } $sql = "SELECT * FROM lang_languages WHERE lang_code LIKE ? or lang_description LIKE ? limit 1" ; $res = SqlQuery($sql, array("%" . $_POST['lang_code'] . "%","%" . $_POST['lang_name'])); if ($res) { echo xlt("Data Alike is already in database, please change code and/or description") . '
'; $err = 'y'; } if (!empty($err) && ($err == 'y')) { $val_lang_code = $_POST['lang_code']; $val_lang_name = $_POST['lang_name']; } else { //insert into the main table $sql = "INSERT INTO lang_languages SET lang_code=?, lang_description=?"; SqlStatement($sql, array($_POST['lang_code'],$_POST['lang_name'])); //insert into the log table - to allow persistant customizations insert_language_log($_POST['lang_name'], $_POST['lang_code'], '', ''); echo xlt('Language definition added') . '
'; } } ?>