<?php

if (!defined('UPGRADE_RUN')) { exit; }

/* INSTALLER - VERSION
---------------------------------------------------*/

$q = $DB->db_query("UPDATE `" . DB_PREFIX . "settings` SET `version` = '" . SCRIPT_VERSION . "'", true);
if ($q === 'err') {
  $ERR = $DB->db_error(true);
  mswUpLog(DB_PREFIX . 'settings', $ERR[1], $ERR[0], __line__, __file__, $DB, 'Column Update');
} else {
  mswUpLog('Version updated to ' . SCRIPT_VERSION, 'instruction');
}

$Q = $DB->db_query("SELECT * FROM `" . DB_PREFIX . "settings`", true);
$SETTINGS = $DB->db_object($Q);

if ($SETTINGS->reason == 'msw-offline-run') {
  $q = $DB->db_query("UPDATE `" . DB_PREFIX . "settings` SET
       `sysstatus` = 'yes',
       `reason` = ''
       ", true);
  if ($q === 'err') {
    $ERR = $DB->db_error(true);
    mswUpLog(DB_PREFIX . 'settings', $ERR[1], $ERR[0], __line__, __file__, $DB, 'System Online');
  } else {
    mswUpLog('System back online', 'instruction');
  }
}

?>