Minor fix to commit fff1980dd0a7cfd88dfbf2d8f1acb1f4b53a929a
[openemr.git] / sql_patch.php
blobc30dcd4a7c058ccc6849de19a339d902387a1674
1 <?php
2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This may be run after an upgraded OpenEMR has been installed.
10 // Its purpose is to upgrade the MySQL OpenEMR database as needed
11 // for the new release.
13 // Disable PHP timeout. This will not work in safe mode.
14 ini_set('max_execution_time', '0');
16 $ignoreAuth = true; // no login required
18 require_once('interface/globals.php');
19 require_once('library/sql.inc');
20 require_once('library/sql_upgrade_fx.php');
21 require_once('version.php');
23 // Force logging off
24 $GLOBALS["enable_auditlog"]=0;
26 $EMRversion = trim(preg_replace('/\s*\([^)]*\)/', '', $GLOBALS['openemr_version']));
27 ?>
30 <html>
31 <head>
32 <title>OpenEMR <?php echo attr($EMRversion) ?> <?php echo xlt('Database Patch'); ?></title>
33 <link rel='STYLESHEET' href='interface/themes/style_blue.css'>
34 </head>
35 <body style="color:green;">
36 <div style="box-shadow: 3px 3px 5px 6px #ccc; border-radius: 20px; padding: 10px 40px;background-color:#EFEFEF; width:500px; margin:40px auto">
38 <p style="font-weight:bold; font-size:1.8em; text-align:center">OpenEMR <?php echo text($EMRversion),' ',xlt('Database Patch'),' ',text($v_realpatch) ?></p>
39 <p style="font-weight:bold; text-align:center;"><?php echo xlt('Applying Patch to site'),' : ',text($_SESSION['site_id']) ?></p>
42 <?php
43 upgradeFromSqlFile('patch.sql');
44 flush();
46 echo '<p style="font-weight:bold; text-align:left; color:green">',xlt('Updating global configuration defaults'),'...</p>';
47 require_once("library/globals.inc.php");
48 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
49 foreach ($grparr as $fldid => $fldarr) {
50 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
51 if (substr($fldtype, 0, 2) !== 'm_') {
52 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
53 if (empty($row['count'])) {
54 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
55 "VALUES ( '$fldid', '0', '$flddef' )");
61 echo '<p style="font-weight:bold; text-align:left;">',xlt('Updating version indicators'),'...</p>';
62 sqlStatement("UPDATE version SET v_realpatch = '$v_realpatch'");
65 echo '<p style="text-align:center; font-size:1.8em;">',xlt('Database Patch'),' ',text($v_realpatch),' ',xlt('finished'),'.</p>';
67 echo '<p style="text-align:center; font-size:1.8em;">OpenEMR ',xlt('Version'),' = ',text($EMRversion.'('.$v_realpatch.')'),'.</p>';
69 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="index.php?site=',attr($_SESSION['site_id']).'">',xlt('Log in'),'</a></p>';
71 if(isset($_SERVER['HTTP_REFERER'])) {
72 $split = preg_split('/\//',$_SERVER['HTTP_REFERER']);
73 if($split[count($split) - 1] == 'admin.php')
74 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="admin.php">',xlt('Back to Admin Page'),'</a></p>';
78 </div>
79 </body>
80 </html>