4 * lang_constant.php script
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("language.inc.php");
15 use OpenEMR\Common\Acl\AclMain
;
16 use OpenEMR\Common\Csrf\CsrfUtils
;
18 // Ensure this script is not called separately
19 if ($langModuleFlag !== true) {
20 die(function_exists('xlt') ?
xlt('Authentication Error') : 'Authentication Error');
24 $thisauth = AclMain
::aclCheckCore('admin', 'language');
26 echo "<html>\n<body>\n";
27 echo "<p>" . xlt('You are not authorized for this.') . "</p>\n";
28 echo "</body>\n</html>\n";
32 if (!empty($_POST['add'])) {
33 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
34 CsrfUtils
::csrfNotVerified();
38 if ($_POST['constant_name'] == "") {
39 echo xlt('Constant name is blank') . '<br />';
43 $sql = "SELECT * FROM lang_constants WHERE constant_name=? limit 1" ;
44 $res = SqlQuery($sql, array($_POST['constant_name']));
46 echo xlt('Data Alike is already in database, please change constant name') . '<br />';
50 if (!empty($err) && ($err == 'y')) {
51 $val_constant = $_POST['constant_name'];
53 //insert into the main table
54 $sql = "INSERT INTO lang_constants SET constant_name=?";
55 SqlStatement($sql, array($_POST['constant_name']));
57 //insert into the log table - to allow persistant customizations
58 insert_language_log('', '', $_POST['constant_name'], '');
60 echo xlt('Constant') . ' ' . text($_POST['constant_name']) . ' ' . xlt('added') . '<br />';
70 <form name
="cons_form" method
="post" action
="?m=constant&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>" onsubmit
="return top.restoreSession()">
71 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
72 <!-- Constant Name
-->
73 <div
class="form-group">
74 <label
for="constantName"><?php
echo xlt('Constant Name'); ?
>:</label
>
75 <input type
="text" class="form-control" id
="constantName" name
="constant_name" size
="100" value
="<?php echo attr($val_constant ?? ''); ?>">
77 <!-- Submit Button
-->
78 <div
class="form-group">
79 <input type
="submit" class="btn btn-primary" name
="add" value
="<?php echo xla('Add'); ?>">
83 <span
class="text"><?php
echo xlt('Please Note: constants are case sensitive and any string is allowed.'); ?
></span
>
85 <?php
echo activate_lang_tab('constant-link'); ?
>