\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 "verifing database connection
\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";
$i = $db->getObject("SELECT * FROM installinfo WHERE \"type\"='system' AND \"key\"='mcmsdb'");
if (is_object($i))
$dbv = $i->version;
if (empty($dbv))
$dbv = '1.0.0.0';
if ($dbv==MCMS_DB)
echo 'No upgrade required for version '.MCMS_DB;
else {
echo "upgrading from ".$dbv.' to '.MCMS_DB."
\n";
if (file_exists('./updates/update-'.$dbv.'-'.MCMS_DB.'.php'))
echo "upgrade script found
\n";
else {
echo "upgrade script missing
\n";
$valid = false;
}
if ($valid)
echo 'Upgrade';
}
}
else {
$STEP = $_REQUEST['step'];
$valid = true;
echo "checking system config:
\n";
if (file_exists('../cfg/cfg.system.php'))
include('../cfg/cfg.system.php');
else
die('missing syscfg');
echo "- syscfg found and loaded
\n";
if (file_exists('../cfg/defines.php'))
include_once('../cfg/defines.php');
// define paths which aren't defined
if (!defined('_CFGPATH_'))
define('_CFGPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'cfg');
if (!defined('_LIBPATH_')) // system libary path
define('_LIBPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'lib');
if (!defined('_LIBPATHX_')) // custom libary path
define('_LIBPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'libx');
if (!defined('_DATAPATH_')) // system data path
define('_DATAPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'data');
if (!defined('_DATAPATHX_')) // custom data path
define('_DATAPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'datax');
if (!defined('_PLUGINPATH_')) // system plugin path
define('_PLUGINPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'plugin');
if (!defined('_PLUGINPATHX_')) // custom plugin path
define('_PLUGINPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'pluginx');
if (!defined('_COMPATH_')) // system component path
define('_COMPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'component');
if (!defined('_COMPATHX_')) // custom component path
define('_COMPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'componentx');
if (!defined('_MODPATH_')) // system module path
define('_MODPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'module');
if (!defined('_MODPATHX_')) // custom module path
define('_MODPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'modulex');
if (!defined('_JSPATH_')) // system javascript path
define('_JSPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'jscript');
if (!defined('_JSPATHX_')) // custom javascript path
define('_JSPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'jscriptx');
if (!defined('_LAYOUTPATH_')) // system plugin path
define('_LAYOUTPATH_', _BASEPATH_.DIRECTORY_SEPARATOR.'layout');
if (!defined('_LAYOUTPATHX_')) // custom plugin path
define('_LAYOUTPATHX_', _BASEPATH_.DIRECTORY_SEPARATOR.'layoutx');
require_once('MCMS'.DIRECTORY_SEPARATOR.'lib.system.php');
require_once('Mammut'.DIRECTORY_SEPARATOR.'lib.mammut.php');
if (!defined('RUNNER'))
define('RUNNER','\\MCMS\\Runner');
if (!defined('SYSTEM'))
define('SYSTEM','\\MCMS\\System');
import(SYSTEM);
// import(RUNNER);
$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 "verifing database connection
\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');
$i = $db->getObject("SELECT * FROM installinfo WHERE \"type\"='system' AND \"key\"='mcmsdb'");
if (is_object($i))
$dbv = $i->version;
if (empty($dbv))
$dbv = '1.0.0.0';
echo "upgrading from ".$dbv.' to '.MCMS_DB."
\n";
if (file_exists('./updates/update-'.$dbv.'-'.MCMS_DB.'.php'))
require('./updates/update-'.$dbv.'-'.MCMS_DB.'.php');
else {
echo "upgrade script missing
\n";
$valid = false;
}
}
?>