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) {
31 $row = sqlQuery("SHOW TABLES LIKE '$tblname'");
32 if (empty($row)) return false;
36 function upgradeFromSqlFile_de($filename) {
37 global $webserver_root;
40 echo "<font color='green'>"; echo xl('Processing'); echo " ".$filename."...</font><br />\n";
42 $fullname = "$webserver_root/sql/$filename";
44 $fd = fopen($fullname, 'r');
46 echo xl("Error, unable to open file"); echo " ".$fullname."\n";
57 $line = fgets($fd, 2048);
60 if (preg_match('/^\s*--/', $line)) continue;
61 if ($line == "") continue;
63 if (preg_match('/^#IfNotTable\s+(\S+)/', $line, $matches)) {
64 $skipping = tableExists_de($matches[1]);
65 if ($skipping) echo "<font color='green'>"; echo xl('Skipping section'); echo " ".$line."</font><br />\n";
67 else if (preg_match('/^#EndIf/', $line)) {
70 if (preg_match('/^\s*#/', $line)) continue;
71 if ($skipping) continue;
73 if($proc == 1) $query .= "\n";
74 $query = $query . $line;
76 if (substr($query, -1) == '$')
78 $query = rtrim($query, '$');
83 $proc = 0; //executes procedures and functions
84 if (!sqlStatement($query))
86 echo "<font color='red'>"; echo xl("The above statement failed"); echo ": " .
87 getSqlLastError() . "<br />"; echo xl("Upgrading will continue"); echo ".<br /></font>\n";
94 if (substr($query, -1) == ';'and $proc == 0) {
95 $query = rtrim($query, ';');
96 echo "$query<br />\n"; //executes sql statements
97 if (!sqlStatement($query)) {
98 echo "<font color='red'>"; echo xl("The above statement failed"); echo ": " .
99 getSqlLastError() . "<br />"; echo xl("Upgrading will continue"); echo ".<br /></font>\n";
108 $sqldir = "$webserver_root/sql";
109 $dh = opendir($sqldir);
110 if (! $dh) die( xl("Cannot read","e")." ".$sqldir);
115 <title
><?php
xl('OpenEMR Database Upgrade','e'); ?
></title
>
116 <link rel
='STYLESHEET' href
='../../interface/themes/style_sky_blue.css'>
120 <span
class='title'><?php
xl('OpenEMR Database Upgrade for De-identification','e'); ?
></span
>
124 if (!empty($_POST['form_submit'])) {
125 upgradeFromSqlFile_de("database_de_identification.sql");
127 // grant file privilege to user
129 $dbh = $GLOBALS['dbh'];
133 echo "<p>".getSqlLastError()." (#".getSqlLastErrorNo().")\n";
135 } $login=$sqlconf["login"]; $loginhost=$sqlconf["host"];
136 generic_sql_select_db($sqlconf['dbase']) or die(getSqlLastError());
137 if (sqlStatement("GRANT FILE ON *.* TO '$login'@'$loginhost'") == FALSE) {
138 echo xl("Error when granting file privilege to the OpenEMR user."); echo "\n";
139 echo "<p>".getSqlLastError()." (#".getSqlLastErrorNo().")\n";
140 echo xl("Error"); echo "\n";
144 echo "<font color='green'>"; echo xl("File privilege granted to OpenEMR user."); echo "<br></font>\n";
146 echo "<p><font color='green'>"; echo xl("Database upgrade finished."); echo "</font></p>\n";
147 echo "<p><font color='red'>"; echo xl("Please restart the apache server before playing with de-identification"); echo "</font></p>\n";
148 echo "<p><font color='red'>"; echo xl("Please set de_identification_config variable back to zero"); echo "</font></p>\n"; echo "</body></html>\n";
154 <script language
="JavaScript">
155 function form_validate()
157 if(document
.forms
[0].root_user_name
.value
== "")
159 alert("<?php echo xl('Enter Database root Username');?>");
162 /*if(document.forms[0].root_user_pass.value == "")
164 alert("<?php echo xl('Enter Database root Password');?>");
172 <form method
='post' action
='de_identification_upgrade.php' onsubmit
="return form_validate();">
174 <p
><?php
if($de_identification_config != 1)
176 echo "<p><font color='red'>";
177 echo xl("Please set"); echo " 'de_identification_config' "; echo xl("variable to one to run de-identification upgrade script"); echo "</br></br>";
178 echo "([OPENEMR]/contrib/util/de_identification_upgrade.php)";
182 xl('Upgrades the OpenEMR database to include Procedures, Functions and tables needed for De-identification process','e');?
></p
></br
>
183 <table
class="de_id_upgrade_login" align
="center">
184 <tr
><td
> 
;</td
><td colspan
=3 align
=center
> 
;</td
><td
> 
;</td
></tr
>
187 <td
><?php
xl('Enter Database root Username','e'); ?
></td
>
189 <td
> <input type
='text' size
='20' name
='root_user_name' id
='root_user_name'
190 value
= "" title
="<?php xl('Enter Database root Username','e'); ?>" /> </td
>
195 <td
><?php
xl('Enter Database root Password','e'); ?
></td
>
197 <td
><input type
='password' size
='20' name
='root_user_pass' id
='root_user_pass'
198 value
= "" title
="<?php xl('Enter Database root Password','e'); ?>" /> </td
>
201 <tr
><td
> 
;</td
><td colspan
=3 align
=center
> 
;</td
><td
> 
;</td
></tr
>
204 <p
><input type
='submit' name
='form_submit' value
="<?php xl('Upgrade Database','e');?>" /></p
>