diff --git a/cronjobs/shared.inc.php b/cronjobs/shared.inc.php
index 4d41a54e3..83e5499f6 100644
--- a/cronjobs/shared.inc.php
+++ b/cronjobs/shared.inc.php
@@ -67,4 +67,11 @@
// Mark cron as running for monitoring
$log->logDebug('Marking cronjob as running for monitoring');
$monitoring->setStatus($cron_name . '_starttime', 'date', time());
+
+// Check if we need to halt our crons due to an outstanding upgrade
+if ($setting->getValue('db_upgrade_required') == 1 || $setting->getValue('config_upgrade_required') == 1) {
+ $log->logFatal('Cronjob is currently disabled due to required upgrades. Import any outstanding SQL files and check your configuration file.');
+ $monitoring->endCronjob($cron_name, 'E0075', 0, true, false);
+}
+
?>
diff --git a/public/include/autoloader.inc.php b/public/include/autoloader.inc.php
index a46632231..c2d605fe0 100644
--- a/public/include/autoloader.inc.php
+++ b/public/include/autoloader.inc.php
@@ -61,4 +61,7 @@
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
require_once(INCLUDE_DIR . '/lib/scrypt.php');
+// Include our versions
+require_once(INCLUDE_DIR . '/version.inc.php');
+
?>
diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php
index f0979fc19..a157f14b0 100644
--- a/public/include/config/error_codes.inc.php
+++ b/public/include/config/error_codes.inc.php
@@ -72,4 +72,5 @@
$aErrorCodes['E0072'] = 'Worker names must be alphanumeric';
$aErrorCodes['E0073'] = 'Worker name is too long; try entering a shorter name';
$aErrorCodes['E0074'] = 'Failed deleting expired tokens';
+$aErrorCodes['E0075'] = 'Upgrade required';
?>
diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php
index e4c690272..704d01ebf 100644
--- a/public/include/config/global.inc.dist.php
+++ b/public/include/config/global.inc.dist.php
@@ -2,6 +2,13 @@
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
+/**
+ * Do not edit this unless you have confirmed that your config has been updated!
+ * This is used in the version check to ensure you run the latest version of the configuration file.
+ * Once you upgraded your config, change the version here too.
+ **/
+$config['version'] = '0.0.1';
+
// Our include directory for additional features
define('INCLUDE_DIR', BASEPATH . 'include');
diff --git a/public/include/pages/admin/dashboard.inc.php b/public/include/pages/admin/dashboard.inc.php
new file mode 100644
index 000000000..af32639a1
--- /dev/null
+++ b/public/include/pages/admin/dashboard.inc.php
@@ -0,0 +1,45 @@
+isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
+ header("HTTP/1.1 404 Page not found");
+ die("404 Page not found");
+}
+
+if ($bitcoin->can_connect() === true){
+ $aGetInfo = $bitcoin->query('getinfo');
+} else {
+ $aGetInfo = array('errors' => 'Unable to connect');
+ $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to wallet RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
+}
+
+// Fetch version information
+$version['CURRENT'] = array('DB' => DB_VERSION, 'CONFIG' => CONFIG_VERSION, 'CORE' => MPOS_VERSION);
+$version['INSTALLED'] = array('DB' => $setting->getValue('DB_VERSION'), 'CONFIG' => $config['version'], 'CORE' => MPOS_VERSION);
+
+// Fetch cron information
+$aCrons = array('statistics','payouts','token_cleanup','archive_cleanup','blockupdate','findblock','notifications','tickerupdate');
+// Data array for template
+$cron_errors = 0;
+$cron_disabled = 0;
+foreach ($aCrons as $strCron) {
+ $status = $monitoring->getStatus($strCron . '_status');
+ $disabled = $monitoring->isDisabled($strCron);
+ if ($status['value'] != 0)
+ $cron_errors++;
+ if ($disabled['value'] == 1)
+ $cron_disabled++;
+}
+$smarty->assign('CRON_ERROR', $cron_errors);
+$smarty->assign('CRON_DISABLED', $cron_disabled);
+
+// Wallet status
+$smarty->assign('WALLET_ERROR', $aGetInfo['errors']);
+
+// Tempalte specifics
+$smarty->assign('VERSION', $version);
+$smarty->assign("CONTENT", "default.tpl");
+?>
diff --git a/public/include/version.inc.php b/public/include/version.inc.php
new file mode 100644
index 000000000..026707ea1
--- /dev/null
+++ b/public/include/version.inc.php
@@ -0,0 +1,24 @@
+getValue('DB_VERSION');
+if ($db_version != DB_VERSION) {
+ $setting->setValue('db_upgrade_required', 1);
+ // Notify admins via error popup
+ if (isset($_SESSION['USERDATA']) && $user->isAdmin($_SESSION['USERDATA']['id']))
+ $_SESSION['POPUP'][] = array('CONTENT' => 'Database version mismatch (Installed: ' . $db_version . ', Current: ' . DB_VERSION . '). Database update required, please import any new SQL files. Cronjobs have been halted.', 'TYPE' => 'errormsg');
+}
+
+if (@$config['version'] != CONFIG_VERSION) {
+ $setting->setValue('config_upgrade_required', 1);
+ // Notify admins via error popup
+ if (isset($_SESSION['USERDATA']) && $user->isAdmin($_SESSION['USERDATA']['id']))
+ $_SESSION['POPUP'][] = array('CONTENT' => 'Configuration file version mismatch (Installed: ' . @$config['version'] . ', Current: ' . CONFIG_VERSION . '). Configuration update required, please check dist config for changes. Cronjobs have been halted.', 'TYPE' => 'errormsg');
+} else {
+ // Reset option, maybe there is a better way?
+ $setting->setValue('config_upgrade_required', 0);
+}
diff --git a/public/templates/mpos/admin/dashboard/default.tpl b/public/templates/mpos/admin/dashboard/default.tpl
new file mode 100644
index 000000000..2ac4b0a47
--- /dev/null
+++ b/public/templates/mpos/admin/dashboard/default.tpl
@@ -0,0 +1,66 @@
+{nocache}
+
+
+
+
+
+ Component |
+ Current |
+ Installed |
+
+
+
+
+ MPOS |
+ {$VERSION['CURRENT']['CORE']} |
+
+ {$VERSION['INSTALLED']['CORE']}
+ |
+
+
+ Config |
+ {$VERSION['CURRENT']['CONFIG']} |
+
+ {$VERSION['INSTALLED']['CONFIG']}
+ |
+
+
+ Database |
+ {$VERSION['CURRENT']['DB']} |
+
+ {$VERSION['INSTALLED']['DB']}
+ |
+
+
+
+
+
+
+
+
+{/nocache}
diff --git a/public/templates/mpos/global/navigation.tpl b/public/templates/mpos/global/navigation.tpl
index 588014992..fd2da85ad 100644
--- a/public/templates/mpos/global/navigation.tpl
+++ b/public/templates/mpos/global/navigation.tpl
@@ -16,6 +16,7 @@
{if $smarty.session.AUTHENTICATED|default:"0" == 1 && $GLOBAL.userdata.is_admin == 1}
Admin Panel
+ - Dashboard
- Monitoring
- User Info
- Wallet Info
diff --git a/sql/000_base_structure.sql b/sql/000_base_structure.sql
index f33143927..c9bb21908 100644
--- a/sql/000_base_structure.sql
+++ b/sql/000_base_structure.sql
@@ -99,6 +99,8 @@ CREATE TABLE IF NOT EXISTS `notification_settings` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.1');
+
CREATE TABLE IF NOT EXISTS `payouts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
diff --git a/sql/012_db_version.sql b/sql/012_db_version.sql
new file mode 100644
index 000000000..1efd1cddb
--- /dev/null
+++ b/sql/012_db_version.sql
@@ -0,0 +1,2 @@
+INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.1') ON DUPLICATE KEY UPDATE `value` = '0.0.1';
+INSERT INTO `settings` (`name`, `value`) VALUES ('db_upgrade_required', 0) ON DUPLICATE KEY UPDATE `value` = 0;