function checkDbSetup() { global $dbh; log_update("Checking DB..."); if (hasTable($dbh, "cfg_mpd")) { // DB exists ; check for table "updates" if (hasTable($dbh, "updates")) { log_update("... DB already OK"); } else { // Table doesn't exist => create it runFirstUpdateDb(); } } else { // Doesn't exist => create it runInitDb(); } }
* version: 1 */ include "cmn_updates.php"; global $upd_db; $dbh = new PDO($upd_db); if (!$dbh) { echo "Cannot open database"; exit; } $isUpToDate = true; $htmlReport = "<ul id='update-report' style='display: none;'>\n"; if (!hasTable($dbh, "cfg_mpd")) { $htmlReport .= "<li>Can't find valid database. Need to update.</li>\n"; $isUpToDate = false; } else { if (!hasTable($dbh, "updates")) { $htmlReport .= "<li>Database is not ready to support incremental updates. Please update.</li>\n"; $isUpToDate = false; } } if ($isUpToDate) { // Check for update scripts $content = file_get_contents(ROOTPATH . "updates/modules.json"); $jsonModules = json_decode($content, true); foreach ($jsonModules as $module => $version) { // Read currently installed modules from DB $stmt = $dbh->prepare("SELECT version FROM updates WHERE modulename='{$module}' LIMIT 1"); $stmt->execute(); $installedVersion = $stmt->fetch()["version"]; if ($installedVersion == $version) { $htmlReport .= "<li>Module '{$module}' already up to date</li>\n";