Mammut Install&Upgrade

Set up your system
tr('install_check_syssettings')."
\n"; if (file_exists('../cfg/cfg.system.php')) include('../cfg/cfg.system.php'); else die('missing syscfg'); echo "- syscfg found and loaded
\n"; echo "
\n"; echo $LANG->tr('upgrade_check_dbcon')."
\n"; try { $db = DB::newInstance($cfg['db']['dsn'],$cfg['db']['user'],$cfg['db']['passwd']); echo "- database connection successfull
"; echo "-- type: ".$db->getDialect().' '.$db->getServerVersion(); } catch (DBException $e) { echo "- error: ".$e->getMessage(); $valid=false; die(); } echo "
\n"; $target = MCMS_DB; if (isset($_GET['target'])) $target = trim($_GET['target']); if ($db->tableExists('installinfo')) $i = $db->getObject("SELECT * FROM installinfo WHERE \"type\"='system' AND \"key\"='mcmsdb'"); else $i = $db->getObject("SELECT * FROM installinfos WHERE \"type\"='system' AND \"key\"='mcmsdb'"); if (is_object($i)) $dbv = $i->version; if (empty($dbv)) $dbv = '1.0.0.0'; if ($dbv==$target) echo $LANG->tr('upgrade_not_required',[$target])."!
\n"; else { echo $LANG->tr('upgrade_from_to_info',[$dbv, $target])."
\n"; if (file_exists('./updates/update-'.$dbv.'-'.$target.'.php')) echo "upgrade script found
\n"; else { echo "upgrade script missing
\n"; echo "possible update paths:
\n"; $updates = scandir('./updates/'); $found = false; foreach ($updates as $update) { if (preg_match('#update-'.$dbv.'-([0-9.]+)\\.php#',$update, $match)) { echo 'Upgrade to '.$match[1].'
'; $found = true; } } if (!$found) echo 'No upgrade path found, sorry!
'; $valid = false; } if ($valid) echo 'Upgrade'; } } else { $STEP = $_REQUEST['step']; $valid = true; echo $LANG->tr('install_check_syssettings')."
\n"; if (file_exists('../cfg/cfg.system.php')) include('../cfg/cfg.system.php'); else die('missing syscfg'); echo "- syscfg found and loaded
\n"; if (!defined('RUNNER')) define('RUNNER','\\MCMS\\Runner'); if (!defined('SYSTEM')) define('SYSTEM','\\MCMS\\System'); $classes = array(); $lastdot = false; // foreach (array('system' => SYSTEM, 'runner' => RUNNER) as $type => $classpath) { foreach (array('system' => SYSTEM) as $type => $classpath) { $lastdot = strlastpos($classpath,'.'); $class = ($lastdot === false) ? $classpath : substr($classpath,$lastdot+1); if (!class_exists($class)) die('class does not exist: '.$class.' for '.$type); $classes[$type] = $class; } unset($lastdot, $class, $classpath, $type); call_user_func(array($classes['system'],'init')); // initalize the system class $system = call_user_func(array($classes['system'],'getInstance')); // get the system instance if (!$system->getRequest()->isValid()) { call_user_func(array($classes['system'],'shutdown')); die('invalid request'); } $dbcfg = $system->getConfig('db'); // connect to the database if (!isset($cfg['db']['option'])) $cfg['db']['option'] = array(); $system->initDB($cfg['db']['dsn'],$cfg['db']['user'],$cfg['db']['passwd'],$cfg['db']['option']); echo "
\n"; echo $LANG->tr('upgrade_check_dbcon')."
\n"; try { $db = DB::newInstance($cfg['db']['dsn'],$cfg['db']['user'],$cfg['db']['passwd']); echo "- database connection successfull"; } catch (DBException $e) { echo "- error: ".$e->getMessage(); $valid=false; } echo "
\n"; if (!$valid) die('terminated'); if ($db->tableExists('installinfo')) $i = $db->getObject("SELECT * FROM installinfo WHERE \"type\"='system' AND \"key\"='mcmsdb'"); else $i = $db->getObject("SELECT * FROM installinfos WHERE \"type\"='system' AND \"key\"='mcmsdb'"); if (is_object($i)) $dbv = $i->version; if (empty($dbv)) $dbv = '1.0.0.0'; $target = MCMS_DB; if (isset($_GET['target'])) $target = trim($_GET['target']); echo $LANG->tr('upgrade_from_to_info',[$dbv, $target])."
\n"; if (file_exists('./updates/update-'.$dbv.'-'.$target.'.php')) { $VERSION = $target; require('./updates/update-'.$dbv.'-'.$target.'.php'); } else { echo "upgrade script missing
\n"; $valid = false; } } ?>