\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 (file_exists($systablefile)) { echo "- systables.xml found for version ".MCMS."

\n"; $tablesdef = simplexml_load_file($systablefile); foreach ($tablesdef as $tabledef) { $tableInfo = TableInfo::fromXML($tabledef); echo "-- table defined: ".$tableInfo->getName().' (columns: '.$tableInfo->getColumnCount().")
\n"; } } else { echo "- systables.xml missing for version ".MCMS."

\n"; $valid = false; } if ($valid) echo 'Install'; } else { $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"; echo "
\n"; echo "verifing database connection
\n"; try { $db = DB::newInstance($cfg['db']['dsn'],$cfg['db']['user'],$cfg['db']['passwd']); echo "- database connection successfull


\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); 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().'
'; } } } else { echo "- systables.xml missing

\n"; $valid = false; } if ($valid) { echo 'Go to next step page'; } else echo 'go back'; break; case 2: echo ''; break; case 3: echo 'clearing tables
'; foreach (array('websites','websitesettings','accounts','accountsettings') as $table) { echo " {$table}
"; $db->query("DELETE FROM {$table}"); } echo 'filling tables
'; echo ' websites
'; $data = array( 'parent_id' => 0, 'domain' => '*', 'online' => 1 ); $db->table('websites')->insert($data); $siteId = $db->getInsertId(); echo " generated site id: {$siteId}
"; echo ' websitesettings
'; $data = array( 'site_id' => $siteId, 'instance' => '', 'key' => 'title', 'value' => $_POST['pagename'] ); $db->table('websitesettings')->insert($data); $data = array( 'site_id' => $siteId, 'instance' => '', 'key' => 'layout', 'value' => 'default' ); $db->table('websitesettings')->insert($data); $data = array( 'site_id' => $siteId, 'instance' => '', 'key' => 'defaultlocale', 'value' => 'de_DE' ); $db->table('websitesettings')->insert($data); $data = array( 'site_id' => $siteId, 'instance' => '', 'key' => 'startinstance', 'value' => 'home' ); $db->table('websitesettings')->insert($data); echo ' accounts
'; $data = array( 'seed' => rand(1000,100000), 'login' => trim($_POST['alogin']), 'password' => sha1(trim($_POST['apasswd'])), 'email' => trim($_POST['apasswd']), 'authtoken' => sha1($_POST['apasswd'].time()), 'masteradmin' => 1 ); $db->table('accounts')->insert($data); echo '
All done, now remove the /install directory
'; echo 'Then you can admin page or the main page'; break; } } ?>