<?php // Services // db $db = new Helpers\Db(); $db->loadCurrent(); if (!$db->upToDate()) { die(Template::instance()->render('maintenance.html')); } $f3->set('notif', new \Helpers\Notification()); // Load user if he is logged in :) $user = new Models\User(); $user->loadCurrent(); //===================================================== // Functions function convertRankToText($rank) { switch ($rank) { case 0: return 'banned'; break; case 1: return 'user'; break; case 2: return 'support'; break; case 3: return 'admin'; break; }
*/ $nl = "\n"; set_include_path(__DIR__); // Kickstart the framework $f3 = (require __DIR__ . '/../lib/base.php'); $f3->set('DEBUG', 3); // Load configuration $f3->config(__DIR__ . '/../app/conf/config.ini'); $f3->set('AUTOLOAD', __DIR__ . '/../app/'); $dbHelp = new Helpers\Db(); $dbHelp->loadCurrent(); $db = $f3->get('db.instance'); $dbConf = new Helpers\DbConfig(); $dbVersion = $dbHelp->tableExists('options') ? $dbConf->isOpt('dbVersion') ? $dbConf->getOpt('dbVersion') : '0.0.0' : '0.0.0'; echo 'Database version is: ' . $dbVersion . $nl; if (!$dbHelp->upToDate()) { echo 'Database is not up to date, updating...' . $nl . $nl; } else { echo 'Database is up-to-date !' . $nl; die; } $migrations = $dbHelp->getVersionsAfter($dbVersion); echo 'Updating ' . count($migrations) . ' versions: ' . implode(', ', $migrations) . ' ...' . $nl; foreach ($migrations as $migration) { echo '- Upgrading to: ' . $migration . ' ...'; $mysql_queries = file_get_contents(__DIR__ . '/migrations/' . $migration . '.sql'); $db->exec(explode(';', $mysql_queries)); $dbConf->setOpt('dbVersion', $migration); echo ' ✓' . $nl; } echo $nl . 'Done updating !' . $nl;