bye jquery 1.11.1 (#849)
[openemr.git] / sql_patch.php
blob84269c84906368325e716be5131ecb18fa2ca2fc
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 // Checks if the server's PHP version is compatible with OpenEMR:
14 require_once(dirname(__FILE__) . "/common/compatibility/Checker.php");
16 $response = OpenEMR\Checker::checkPhpVersion();
17 if ($response !== true) {
18 die($response);
21 // Disable PHP timeout. This will not work in safe mode.
22 ini_set('max_execution_time', '0');
24 $ignoreAuth = true; // no login required
26 require_once('interface/globals.php');
27 require_once('library/sql_upgrade_fx.php');
29 $versionService = new \services\VersionService();
31 // Fetching current version because it was updated by the sql_upgrade_fx
32 // script and this script will further modify it.
33 $currentVersion = $versionService->fetch();
35 $desiredVersion = $currentVersion;
36 $desiredVersion->setDatabase($v_database);
37 $desiredVersion->setTag($v_tag);
38 $desiredVersion->setRealPatch($v_realpatch);
39 $desiredVersion->setPatch($v_patch);
40 $desiredVersion->setMinor($v_minor);
41 $desiredVersion->setMajor($v_major);
43 // Force logging off
44 $GLOBALS["enable_auditlog"]=0;
46 $EMRversion = trim(preg_replace('/\s*\([^)]*\)/', '', $GLOBALS['openemr_version']));
50 <html>
51 <head>
52 <title>OpenEMR <?php echo attr($EMRversion) ?> <?php echo xlt('Database Patch'); ?></title>
53 <link rel='STYLESHEET' href='interface/themes/style_blue.css'>
54 <link rel="shortcut icon" href="public/images/favicon.ico" />
55 </head>
56 <body style="color:green;">
58 <div style="box-shadow: 3px 3px 5px 6px #ccc; border-radius: 20px; padding: 10px 40px;background-color:#EFEFEF; width:500px; margin:40px auto">
60 <p style="font-weight:bold; font-size:1.8em; text-align:center">OpenEMR <?php echo text($EMRversion),' ',xlt('Database Patch'),' ',text($desiredVersion->getRealPatch()) ?></p>
61 <p style="font-weight:bold; text-align:center;"><?php echo xlt('Applying Patch to site'),' : ',text($_SESSION['site_id']) ?></p>
64 <?php
65 upgradeFromSqlFile('patch.sql');
66 flush();
68 echo '<p style="font-weight:bold; text-align:left; color:green">',xlt('Updating global configuration defaults'),'...</p>';
69 require_once("library/globals.inc.php");
70 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
71 foreach ($grparr as $fldid => $fldarr) {
72 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
73 if ( is_array($fldtype) || (substr($fldtype, 0, 2) !== 'm_') ) {
74 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
75 if (empty($row['count'])) {
76 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
77 "VALUES ( '$fldid', '0', '$flddef' )");
83 $canRealPatchBeApplied = $versionService->canRealPatchBeApplied($desiredVersion);
84 if ($canRealPatchBeApplied) {
85 echo '<p style="font-weight:bold; text-align:left;">',xlt('Updating version indicators'),'...</p>';
86 $result = $versionService->update($desiredVersion);
88 if (!$result) {
89 echo '<p style="font-weight:bold; text-align:left; color:red">',xlt('Unable insert version information into database'),'...</p>';
93 echo '<p style="text-align:center; font-size:1.8em;">',xlt('Database Patch'),' ',text($desiredVersion->getRealPatch()),' ',xlt('finished'),'.</p>';
95 echo '<p style="text-align:center; font-size:1.8em;">OpenEMR ',xlt('Version'),' = ',text($EMRversion.'('.$desiredVersion->getRealPatch().')'),'.</p>';
97 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>';
99 if(isset($_SERVER['HTTP_REFERER'])) {
100 $split = preg_split('/\//',$_SERVER['HTTP_REFERER']);
101 if($split[count($split) - 1] == 'admin.php')
102 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>';
106 </div>
107 </body>
108 </html>