2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.com>
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.
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');
24 $GLOBALS["enable_auditlog"]=0;
26 $EMRversion = trim(preg_replace('/\s*\([^)]*\)/', '', $GLOBALS['openemr_version']));
32 <title
>OpenEMR
<?php
echo attr($EMRversion) ?
> <?php
echo xlt('Database Patch'); ?
></title
>
33 <link rel
='STYLESHEET' href
='interface/themes/style_blue.css'>
34 <link rel
="shortcut icon" href
="public/images/favicon.ico" />
36 <body style
="color:green;">
37 <div style
="box-shadow: 3px 3px 5px 6px #ccc; border-radius: 20px; padding: 10px 40px;background-color:#EFEFEF; width:500px; margin:40px auto">
39 <p style
="font-weight:bold; font-size:1.8em; text-align:center">OpenEMR
<?php
echo text($EMRversion),' ',xlt('Database Patch'),' ',text($v_realpatch) ?
></p
>
40 <p style
="font-weight:bold; text-align:center;"><?php
echo xlt('Applying Patch to site'),' : ',text($_SESSION['site_id']) ?
></p
>
44 upgradeFromSqlFile('patch.sql');
47 echo '<p style="font-weight:bold; text-align:left; color:green">',xlt('Updating global configuration defaults'),'...</p>';
48 require_once("library/globals.inc.php");
49 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
50 foreach ($grparr as $fldid => $fldarr) {
51 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
52 if (substr($fldtype, 0, 2) !== 'm_') {
53 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
54 if (empty($row['count'])) {
55 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
56 "VALUES ( '$fldid', '0', '$flddef' )");
62 echo '<p style="font-weight:bold; text-align:left;">',xlt('Updating version indicators'),'...</p>';
63 sqlStatement("UPDATE version SET v_realpatch = '$v_realpatch'");
66 echo '<p style="text-align:center; font-size:1.8em;">',xlt('Database Patch'),' ',text($v_realpatch),' ',xlt('finished'),'.</p>';
68 echo '<p style="text-align:center; font-size:1.8em;">OpenEMR ',xlt('Version'),' = ',text($EMRversion.'('.$v_realpatch.')'),'.</p>';
70 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>';
72 if(isset($_SERVER['HTTP_REFERER'])) {
73 $split = preg_split('/\//',$_SERVER['HTTP_REFERER']);
74 if($split[count($split) - 1] == 'admin.php')
75 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>';