load($configDir."/settings.xml"); /** * Check if ENABLE_INSTALL_TOOL exists in config dir */ if (!file_exists($configDir."/ENABLE_INSTALL_TOOL")) { echo "For installation of SeedDMS, you must create the file conf/ENABLE_INSTALL_TOOL"; exit; } $theme = "bootstrap"; require_once("../inc/inc.Language.php"); include "../languages/en_GB/lang.inc"; require_once("../inc/inc.ClassUI.php"); UI::htmlStartPage('Database update'); UI::globalBanner(); UI::contentStart(); UI::contentHeading("SeedDMS Installation for version ".$_GET['version']); UI::contentContainerStart(); $sqlfile = "update.sql"; switch($settings->_dbDriver) { case 'mysql': case 'mysqli': case 'mysqlnd': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) $dsn .= ";port=".$tmp[1]; break; case 'sqlite': $dsn = $settings->_dbDriver.":".$settings->_dbDatabase; if(file_exists('update-'.$_GET['version'].'/update-sqlite3.sql')) $sqlfile = "update-sqlite3.sql"; break; case 'pgsql': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) $dsn .= ";port=".$tmp[1]; if(file_exists('update-'.$_GET['version'].'/update-postgres.sql')) $sqlfile = "update-postgres.sql"; } $db = new PDO($dsn, $settings->_dbUser, $settings->_dbPass); if (!$db) { die; } $errorMsg = ''; $res = $db->query('select * from tblVersion'); $recs = $res->fetchAll(PDO::FETCH_ASSOC); if(!empty($recs)) { $rec = $recs[0]; if($_GET['version'] > $rec['major'].'.'.$rec['minor'].'.'.$rec['subminor']) { if(file_exists('update-'.$_GET['version'].'/'.$sqlfile)) { $queries = file_get_contents('update-'.$_GET['version'].'/'.$sqlfile); $queries = explode(";", $queries); // execute queries if($queries) { echo "
SQL file for update missing!
"; } } else { echo "Database schema already up to date.
"; } if(!$errorMsg) { if(file_exists('update-'.$_GET['version'].'/update.php')) { echo "Go back to installation and recheck.
"; } else { echo "Could not determine database schema version.
"; } $db = null; // just remove info for web page installation $settings->_printDisclaimer = false; $settings->_footNote = false; // end of the page UI::contentContainerEnd(); UI::contentEnd(); UI::htmlEndPage(); ?>