2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 /********************************************************************************/
20 // Disable PHP timeout. This will not work in safe mode.
21 ini_set('max_execution_time', '0');
23 $ignoreAuth = true; // no login required
25 //set de_identification_config to 1 to run the de_identification_upgrade script
26 $de_identification_config = 0;
28 require_once('../../interface/globals.php');
30 function tableExists_de($tblname)
32 $row = sqlQuery("SHOW TABLES LIKE '$tblname'");
40 function upgradeFromSqlFile_de($filename)
42 global $webserver_root;
45 echo "<font color='green'>";
46 echo xl('Processing');
47 echo " ".$filename."...</font><br />\n";
49 $fullname = "$webserver_root/sql/$filename";
51 $fd = fopen($fullname, 'r');
53 echo xl("Error, unable to open file");
54 echo " ".$fullname."\n";
65 $line = fgets($fd, 2048);
68 if (preg_match('/^\s*--/', $line)) {
76 if (preg_match('/^#IfNotTable\s+(\S+)/', $line, $matches)) {
77 $skipping = tableExists_de($matches[1]);
79 echo "<font color='green'>";
82 echo xl('Skipping section');
83 echo " ".$line."</font><br />\n";
84 } else if (preg_match('/^#EndIf/', $line)) {
88 if (preg_match('/^\s*#/', $line)) {
100 $query = $query . $line;
102 if (substr($query, -1) == '$') {
103 $query = rtrim($query, '$');
107 $proc = 0; //executes procedures and functions
108 if (!sqlStatement($query)) {
109 echo "<font color='red'>";
110 echo xl("The above statement failed"); echo ": " .
111 getSqlLastError() . "<br />";
112 echo xl("Upgrading will continue");
113 echo ".<br /></font>\n";
120 if (substr($query, -1) == ';'and $proc == 0) {
121 $query = rtrim($query, ';');
122 echo "$query<br />\n"; //executes sql statements
123 if (!sqlStatement($query)) {
124 echo "<font color='red'>";
125 echo xl("The above statement failed"); echo ": " .
126 getSqlLastError() . "<br />";
127 echo xl("Upgrading will continue");
128 echo ".<br /></font>\n";
139 $sqldir = "$webserver_root/sql";
140 $dh = opendir($sqldir);
142 die(xl("Cannot read", "e")." ".$sqldir);
149 <title
><?php
xl('OpenEMR Database Upgrade', 'e'); ?
></title
>
150 <link rel
='STYLESHEET' href
='../../interface/themes/style_sky_blue.css'>
154 <span
class='title'><?php
xl('OpenEMR Database Upgrade for De-identification', 'e'); ?
></span
>
158 if (!empty($_POST['form_submit'])) {
159 upgradeFromSqlFile_de("database_de_identification.sql");
161 // grant file privilege to user
163 $dbh = $GLOBALS['dbh'];
167 echo "<p>".getSqlLastError()." (#".getSqlLastErrorNo().")\n";
169 } $login=$sqlconf["login"];
170 $loginhost=$sqlconf["host"];
171 generic_sql_select_db($sqlconf['dbase']) or die(getSqlLastError());
172 if (sqlStatement("GRANT FILE ON *.* TO '$login'@'$loginhost'") == false) {
173 echo xl("Error when granting file privilege to the OpenEMR user.");
175 echo "<p>".getSqlLastError()." (#".getSqlLastErrorNo().")\n";
180 echo "<font color='green'>";
183 echo xl("File privilege granted to OpenEMR user.");
184 echo "<br></font>\n";
186 echo "<p><font color='green'>";
187 echo xl("Database upgrade finished.");
188 echo "</font></p>\n";
189 echo "<p><font color='red'>";
190 echo xl("Please restart the apache server before playing with de-identification");
191 echo "</font></p>\n";
192 echo "<p><font color='red'>";
193 echo xl("Please set de_identification_config variable back to zero");
194 echo "</font></p>\n";
195 echo "</body></html>\n";
201 <script language
="JavaScript">
202 function form_validate()
204 if(document
.forms
[0].root_user_name
.value
== "")
206 alert("<?php echo xl('Enter Database root Username');?>");
209 /*if(document.forms[0].root_user_pass.value == "")
211 alert("<?php echo xl('Enter Database root Password');?>");
219 <form method
='post' action
='de_identification_upgrade.php' onsubmit
="return form_validate();">
221 <p
><?php
if ($de_identification_config != 1) {
222 echo "<p><font color='red'>";
223 echo xl("Please set");
224 echo " 'de_identification_config' ";
225 echo xl("variable to one to run de-identification upgrade script");
227 echo "([OPENEMR]/contrib/util/de_identification_upgrade.php)";
229 xl('Upgrades the OpenEMR database to include Procedures, Functions and tables needed for De-identification process', 'e');?
></p
></br
>
230 <table
class="de_id_upgrade_login" align
="center">
231 <tr
><td
> 
;</td
><td colspan
=3 align
=center
> 
;</td
><td
> 
;</td
></tr
>
234 <td
><?php
xl('Enter Database root Username', 'e'); ?
></td
>
236 <td
> <input type
='text' size
='20' name
='root_user_name' id
='root_user_name'
237 value
= "" title
="<?php xl('Enter Database root Username', 'e'); ?>" /> </td
>
242 <td
><?php
xl('Enter Database root Password', 'e'); ?
></td
>
244 <td
><input type
='password' size
='20' name
='root_user_pass' id
='root_user_pass'
245 value
= "" title
="<?php xl('Enter Database root Password', 'e'); ?>" /> </td
>
248 <tr
><td
> 
;</td
><td colspan
=3 align
=center
> 
;</td
><td
> 
;</td
></tr
>
251 <p
><input type
='submit' name
='form_submit' value
="<?php xl('Upgrade Database', 'e');?>" /></p
>