Mammut Install&Upgrade

Set up your system

tr('install_check_syssettings'); ?>

syscfg found and loaded

tr('check_checking_tables')."
\n"; try { $db = DB::newInstance($cfg['db']['dsn'],$cfg['db']['user'],$cfg['db']['passwd']); echo "- database connection successfull
"; echo "-- type: ".$db->getDialect().' '.$db->getServerVersion(); if (file_exists($systablefile)) { echo "- systables.xml found for version ".MCMS."
\n"; $tablesdef = simplexml_load_file($systablefile); if (isset($_REQUEST['quickfix'])) { switch ($_REQUEST['quickfix']) { case 'coltype': try { $tname = $_REQUEST['table']; $cname = $_REQUEST['c']; echo "fixing column $cname in table $tname
"; foreach ($tablesdef as $tabledef) { $tableInfo = TableInfo::fromXML($tabledef); if ($tableInfo->getName() == $tname) { $cInfo = $tableInfo->getColumnInfo($cname); $db->table($tname)->alterColumn($cInfo->getName(), $cInfo); } } } catch (Exception $ex) { echo 'ERROR:'.$ex->getMessage().'
'.$ex->getTraceAsString().'
'; } break; } } foreach ($tablesdef as $tabledef) { $tableInfo = TableInfo::fromXML($tabledef); echo "-- table defined: ".$tableInfo->getName().' (columns: '.$tableInfo->getColumnCount()."), "; if ($db->tableExists($tableInfo->getName())) { $realTableInfo = $db->table($tableInfo->getName())->getInfo(); $diff = $tableInfo->compareTo($realTableInfo); if (isset($diff->missingColumns)) echo '
---- missing columns: '.implode(', ',$diff->missingColumns)." getName()."\"/>"; if (isset($diff->additionalColumns)) echo '
---- removeable columns: '.implode(', ',$diff->additionalColumns)." getName()."\"/>"; if (isset($diff->differentColumns)) { foreach ($diff->differentColumns as $name => $colDiffs) { foreach ($colDiffs as $type => $colDiff) { switch ($type) { case 'size': echo '
--- different sizes of '.$name.':'.$colDiff['this'].'!='.$colDiff['other']; echo ' (try to fix this)'; break; case 'null': echo '
--- different null parameters of '.$name.':'.var_export($colDiff['this'], true).'!='.var_export($colDiff['other'], true); echo ' (try to fix this)'; break; case 'type': echo '
--- different types of '.$name.':'.$colDiff['this'].'!='.$colDiff['other']; break; case 'enum': echo '
--- different enum options of '.$name.':'.implode(',',$colDiff['this']).'!='.implode(',',$colDiff['other']); break; } } } } if (isset($diff->missingColumns) || isset($diff->additionalColumns) || isset($diff->differentColumns)) echo "
mismatch!
\n"; else echo "found and ok
\n"; } else echo "missing! check to create getName()."\"/>
\n"; } } else { echo "- systables.xml missing for version ".MCMS."/
\n"; $valid = false; } } catch (DBException $e) { echo "- error: ".$e->getMessage(); $valid=false; } ?>
\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 "; } catch (DBException $e) { echo "- error: ".$e->getMessage()." "; $valid=false; } echo "
\n"; if (!$valid) die('terminated'); switch ($_REQUEST['step']) { case 1: if (file_exists($systablefile)) { echo "using database:".$db->getDatabase()."
\n"; echo "- systables.xml found
\n"; $tablesdef = simplexml_load_file($systablefile); foreach ($tablesdef as $tabledef) { $tableInfo = TableInfo::fromXML($tabledef); if (isset($_REQUEST['createtable']) && in_array($tableInfo->getName(),$_REQUEST['createtable'])) { echo "-- creating table : ".$tableInfo->getName(); try { if ($db->tableExists($tableInfo->getName())) $db->dropTable($tableInfo->getName()); $db->createTable($tableInfo); echo "... OK
"; } catch (SQLException $e) { echo "...error!
 ".$e->getMessage()."
 ".$e->getQuery().'
'; } } if ($db->tableExists($tableInfo->getName())) { $realTableInfo = $db->table($tableInfo->getName())->getInfo(); $diff = $tableInfo->compareTo($realTableInfo); if (isset($diff->missingColumns)) { foreach ($diff->missingColumns as $missing) { $colNum = $tableInfo->getColumnNum($missing); $colInfo = $tableInfo->getColumnInfo($colNum); $preCol = false; if ($colNum > 0) $preCol = $tableInfo->getColumnInfo($colNum-1)->getName(); if ($preCol) $db->table($tableInfo->getName())->addColumn($colInfo,$preCol); else $db->table($tableInfo->getName())->addColumn($colInfo); } } if (isset($_REQUEST['removecolumns']) && in_array($tableInfo->getName(),$_REQUEST['removecolumns'])) { echo "-- fixing table : ".$tableInfo->getName(); try { if (isset($diff->additionalColumns)) { foreach($diff->additionalColumns as $colToRemove) $db->table($tableInfo->getName())->removeColumn($colToRemove); } echo "... OK
"; } catch (SQLException $e) { echo "...error!
 ".$e->getMessage()."
 ".$e->getQuery().'
'; } } } } } else { echo "- systables.xml missing
\n"; $valid = false; } if ($valid) { echo 'Go to next step page'; } else echo 'go back'; break; case 3: echo '

All done, now remove the /install directory

'; echo 'Then you can go to the admin page or the main page'; break; } echo ''; } ?>