index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <?php
  2. /**
  3. * Wizard to configure and initialize the iTop application
  4. */
  5. require_once('../application/utils.inc.php');
  6. require_once('../core/config.class.inc.php');
  7. require_once('../core/cmdbsource.class.inc.php');
  8. require_once('./setuppage.class.inc.php');
  9. define('TMP_CONFIG_FILE', '../tmp-config-itop.php');
  10. define('FINAL_CONFIG_FILE', '../config-itop.php');
  11. define('SETUP_DATA_DIR', './data');
  12. define('PHP_MIN_VERSION', '5.2.0');
  13. define('MYSQL_MIN_VERSION', '5.0.0');
  14. $sOperation = Utils::ReadParam('operation', 'step1');
  15. $oP = new setup_web_page('iTop configuration wizard');
  16. /**
  17. * Helper function to check if the current version of PHP
  18. * is compatible with the application
  19. * @return boolean true if this is Ok, false otherwise
  20. */
  21. function CheckPHPVersion(setup_web_page $oP)
  22. {
  23. $oP->log('Info - CheckPHPVersion');
  24. if (version_compare(phpversion(), PHP_MIN_VERSION, '>='))
  25. {
  26. $oP->ok("The current PHP Version (".phpversion().") is greater than the minimum required version (".PHP_MIN_VERSION.")");
  27. }
  28. else
  29. {
  30. $oP->error("Error: The current PHP Version (".phpversion().") is lower than the minimum required version (".PHP_MIN_VERSION.")");
  31. return false;
  32. }
  33. $aMandatoryExtensions = array('mysql', 'iconv', 'simplexml');
  34. asort($aMandatoryExtensions); // Sort the list to look clean !
  35. $aExtensionsOk = array();
  36. $aMissingExtensions = array();
  37. $aMissingExtensionsLinks = array();
  38. foreach($aMandatoryExtensions as $sExtension)
  39. {
  40. if (extension_loaded($sExtension))
  41. {
  42. $aExtensionsOk[] = $sExtension;
  43. }
  44. else
  45. {
  46. $aMissingExtensions[] = $sExtension;
  47. $aMissingExtensionsLinks[] = "<a href=\"http://www.php.net/manual/en/book.$sExtension.php\">$sExtension</a>";
  48. }
  49. }
  50. if (count($aExtensionsOk) > 0)
  51. {
  52. $oP->ok("Required PHP extension(s): ".implode(', ', $aExtensionsOk).".");
  53. }
  54. if (count($aMissingExtensions) > 0)
  55. {
  56. $oP->error("Missing PHP extension(s): ".implode(', ', $aMissingExtensionsLinks).".");
  57. return false;
  58. }
  59. return true;
  60. }
  61. /**
  62. * Helper function check the connection to the database and (if connected) to enumerate
  63. * the existing databases
  64. * @return Array The list of databases found in the server
  65. */
  66. function CheckServerConnection(setup_web_page $oP, $sDBServer, $sDBUser, $sDBPwd)
  67. {
  68. $aResult = array();
  69. $oP->log('Info - CheckServerConnection');
  70. try
  71. {
  72. $oDBSource = new CMDBSource;
  73. $oDBSource->Init($sDBServer, $sDBUser, $sDBPwd);
  74. $oP->ok("Connection to '$sDBServer' as '$sDBUser' successful.");
  75. $sDBVersion = $oDBSource->GetDBVersion();
  76. if (version_compare($sDBVersion, MYSQL_MIN_VERSION, '>='))
  77. {
  78. $oP->ok("Current MySQL version ($sDBVersion), greater than minimum required version (".MYSQL_MIN_VERSION.")");
  79. }
  80. else
  81. {
  82. $oP->error("Error: Current MySQL version is ($sDBVersion), minimum required version (".MYSQL_MIN_VERSION.")");
  83. return false;
  84. }
  85. try
  86. {
  87. $aResult = $oDBSource->ListDB();
  88. }
  89. catch(Exception $e)
  90. {
  91. $oP->warning("Warning: unable to enumerate the current databases.");
  92. $aResult = true; // Not an array to differentiate with an empty array
  93. }
  94. }
  95. catch(Exception $e)
  96. {
  97. $oP->error("Error: Connection to '$sDBServer' as '$sDBUser' failed.");
  98. $oP->p($e->GetHtmlDesc());
  99. $aResult = false;
  100. }
  101. return $aResult;
  102. }
  103. /**
  104. * Helper function to initialize the ORM and load the data model
  105. * from the given file
  106. * @param $sConfigFileName string The name of the configuration file to load
  107. * @param $bAllowMissingDatabase boolean Whether or not to allow loading a data model with no corresponding DB
  108. * @return none
  109. */
  110. function InitDataModel(setup_web_page $oP, $sConfigFileName, $bAllowMissingDatabase = true)
  111. {
  112. require_once('../core/coreexception.class.inc.php');
  113. require_once('../core/attributedef.class.inc.php');
  114. require_once('../core/filterdef.class.inc.php');
  115. require_once('../core/stimulus.class.inc.php');
  116. require_once('../core/MyHelpers.class.inc.php');
  117. require_once('../core/expression.class.inc.php');
  118. require_once('../core/cmdbsource.class.inc.php');
  119. require_once('../core/sqlquery.class.inc.php');
  120. require_once('../core/dbobject.class.php');
  121. require_once('../core/dbobjectsearch.class.php');
  122. require_once('../core/dbobjectset.class.php');
  123. require_once('../core/userrights.class.inc.php');
  124. $oP->log("Info - MetaModel::Startup from file '$sConfigFileName' (AllowMissingDB = $bAllowMissingDatabase)");
  125. MetaModel::Startup($sConfigFileName, $bAllowMissingDatabase);
  126. }
  127. /**
  128. * Helper function to create the database structure
  129. * @return boolean true on success, false otherwise
  130. */
  131. function CreateDatabaseStructure(setup_web_page $oP, Config $oConfig, $sDBName, $sDBPrefix)
  132. {
  133. InitDataModel($oP, TMP_CONFIG_FILE, true); // Allow the DB to NOT exist since we're about to create it !
  134. $oP->log('Info - CreateDatabaseStructure');
  135. $oP->info("Creating the structure in '$sDBName' (prefix = '$sDBPrefix').");
  136. //MetaModel::CheckDefinitions();
  137. if (!MetaModel::DBExists())
  138. {
  139. MetaModel::DBCreate();
  140. $oP->ok("Database structure created in '$sDBName' (prefix = '$sDBPrefix').");
  141. }
  142. else
  143. {
  144. $oP->error("Error: database '$sDBName' (prefix = '$sDBPrefix') already exists.");
  145. $oP->p("Tables with conflicting names already exist in the database.
  146. Try selecting another database instance or specifiy a prefix to prevent conflicting table names.");
  147. return false;
  148. }
  149. return true;
  150. }
  151. /**
  152. * Helper function to create and administrator account for iTop
  153. * @return boolean true on success, false otherwise
  154. */
  155. function CreateAdminAccount(setup_web_page $oP, Config $oConfig, $sAdminUser, $sAdminPwd)
  156. {
  157. $oP->log('Info - CreateAdminAccount');
  158. InitDataModel($oP, TMP_CONFIG_FILE, true); // allow missing DB
  159. if (UserRights::CreateAdministrator($sAdminUser, $sAdminPwd))
  160. {
  161. $oP->ok("Administrator account '$sAdminUser' created.");
  162. return true;
  163. }
  164. else
  165. {
  166. $oP->error("Failed to create the administrator account '$sAdminUser'.");
  167. return false;
  168. }
  169. }
  170. /**
  171. * Scans the ./data directory for XML files and output them as a Javascript array
  172. */
  173. function PopulateDataFilesList(setup_web_page $oP)
  174. {
  175. if ($hDir = @opendir(SETUP_DATA_DIR))
  176. {
  177. $aFilesToLoad = array();
  178. // This is the correct way to loop over the directory. (according the documentation)
  179. while (($sFile = readdir($hDir)) !== false)
  180. {
  181. $sExtension = pathinfo($sFile, PATHINFO_EXTENSION );
  182. if (strcasecmp($sExtension, 'xml') == 0)
  183. {
  184. $aFilesToLoad[] = SETUP_DATA_DIR.'/'.$sFile;
  185. }
  186. }
  187. closedir($hDir);
  188. // Load order is important we expect the files to be ordered
  189. // like numbered 1.Organizations.xml 2.Locations.xml , etc.
  190. asort($aFilesToLoad);
  191. // Menus can be loaded any time... like here at the end
  192. $oP->add("<script type=\"text/javascript\">\n");
  193. $oP->add("function PopulateDataFilesList()\n");
  194. $oP->add("{\n");
  195. $index = 0;
  196. foreach($aFilesToLoad as $sFile)
  197. {
  198. $oP->add("aFilesToLoad[aFilesToLoad.length] = '$sFile';\n");
  199. $index++;
  200. }
  201. $oP->add("}\n");
  202. $oP->add("</script>\n");
  203. }
  204. else
  205. {
  206. $oP->error("Data directory (".SETUP_DATA_DIR.") no found or not readable.");
  207. }
  208. }
  209. /**
  210. * Display the form for the first step of the configuration wizard
  211. * which consists in the database server selection
  212. */
  213. function DisplayStep1(setup_web_page $oP)
  214. {
  215. $sNextOperation = 'step2';
  216. $oP->add("<h1>iTop configuration wizard</h1>\n");
  217. $oP->add("<h2>Checking prerequisites</h2>\n");
  218. if (CheckPHPVersion($oP))
  219. {
  220. $sRedStar = '<span class="hilite">*</span>';
  221. $oP->add("<h2>Step 1: Configuration of the database connection</h2>\n");
  222. $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Connection to the database...', 1)\">\n");
  223. // Form goes here
  224. $oP->add("<fieldset><legend>Database connection</legend>\n");
  225. $aForm = array();
  226. $aForm[] = array('label' => "Server name$sRedStar:", 'input' => "<input id=\"db_server\" type=\"text\" name=\"db_server\" value=\"\">",
  227. 'help' => 'E.g. "localhost", "dbserver.mycompany.com" or "192.142.10.23".');
  228. $aForm[] = array('label' => "User name$sRedStar:", 'input' => "<input id=\"db_user\" type=\"text\" name=\"db_user\" value=\"\">");
  229. $aForm[] = array('label' => 'Password:', 'input' => "<input id=\"db_pwd\" type=\"password\" name=\"db_pwd\" value=\"\">");
  230. $oP->form($aForm);
  231. $oP->add("</fieldset>\n");
  232. $oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
  233. $oP->add("<button type=\"submit\">Next >></button>\n");
  234. $oP->add("</form>\n");
  235. }
  236. }
  237. /**
  238. * Display the form for the second step of the configuration wizard
  239. * which consists in
  240. * 1) Validating the parameters by connecting to the database server
  241. * 2) Prompting to select an existing database or to create a new one
  242. */
  243. function DisplayStep2(setup_web_page $oP, Config $oConfig, $sDBServer, $sDBUser, $sDBPwd)
  244. {
  245. $sNextOperation = 'step3';
  246. $oP->add("<h1>iTop configuration wizard</h1>\n");
  247. $oP->add("<h2>Step 2: Database selection</h2>\n");
  248. $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Creating database structure...', 2);\">\n");
  249. $aDatabases = CheckServerConnection($oP, $sDBServer, $sDBUser, $sDBPwd);
  250. if ($aDatabases === false)
  251. {
  252. // Connection failed, invalid credentials ? Go back
  253. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  254. }
  255. else
  256. {
  257. // Connection is Ok, save it and continue the setup wizard
  258. $oConfig->SetDBHost($sDBServer);
  259. $oConfig->SetDBUser($sDBUser);
  260. $oConfig->SetDBPwd($sDBPwd);
  261. $oConfig->WriteToFile();
  262. $oP->add("<fieldset><legend>Specify a database<span class=\"hilite\">*</span></legend>\n");
  263. $aForm = array();
  264. if (is_array($aDatabases))
  265. {
  266. foreach($aDatabases as $sDBName)
  267. {
  268. $aForm[] = array('label' => "<input id=\"db_$sDBName\" type=\"radio\" name=\"db_name\" value=\"$sDBName\" /><label for=\"db_$sDBName\"> $sDBName</label>");
  269. }
  270. }
  271. else
  272. {
  273. $aForm[] = array('label' => "<input id=\"current_db\" type=\"radio\" name=\"db_name\" value=\"-1\" /><label for=\"current_db\"> Use the existing database:</label> <input type=\"text\" id=\"current_db_name\" name=\"current_db_name\" value=\"\" maxlength=\"32\"/>");
  274. $oP->add_ready_script("$('#current_db_name').click( function() { $('#current_db').attr('checked', true); });");
  275. }
  276. $aForm[] = array('label' => "<input id=\"new_db\" type=\"radio\" name=\"db_name\" value=\"\" /><label for=\"new_db\"> Create a new database:</label> <input type=\"text\" id=\"new_db_name\" name=\"new_db_name\" value=\"\" maxlength=\"32\"/>");
  277. $oP->form($aForm);
  278. $oP->add_ready_script("$('#new_db_name').click( function() { $('#new_db').attr('checked', true); })");
  279. $oP->add("</fieldset>\n");
  280. $aForm = array();
  281. $aForm[] = array('label' => "Add a prefix to all the tables: <input id=\"db_prefix\" type=\"text\" name=\"db_prefix\" value=\"\" maxlength=\"32\"/>");
  282. $oP->form($aForm);
  283. $oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
  284. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  285. $oP->add("&nbsp;&nbsp;&nbsp;&nbsp;\n");
  286. $oP->add("<button type=\"submit\">Next >></button>\n");
  287. }
  288. $oP->add("</form>\n");
  289. }
  290. /**
  291. * Display the form for the third step of the configuration wizard
  292. * which consists in
  293. * 1) Validating the parameters by connecting to the database server & selecting the database
  294. * 2) Creating the database structure
  295. * 3) Prompting for the admin account to be created
  296. */
  297. function DisplayStep3(setup_web_page $oP, Config $oConfig, $sDBName, $sDBPrefix)
  298. {
  299. $sNextOperation = 'step4';
  300. $oP->add("<h1>iTop configuration wizard</h1>\n");
  301. $oP->add("<h2>Creation of the database structure</h2>\n");
  302. $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Creating user and profiles...', 3);\">\n");
  303. $oConfig->SetDBName($sDBName);
  304. $oConfig->SetDBSubname($sDBPrefix);
  305. $oConfig->WriteToFile(TMP_CONFIG_FILE);
  306. if (CreateDatabaseStructure($oP, $oConfig, $sDBName, $sDBPrefix))
  307. {
  308. $sRedStar = "<span class=\"hilite\">*</span>";
  309. $oP->add("<h2>Step 3: Definition of the administrator account</h2>\n");
  310. // Database created, continue with admin creation
  311. $oP->add("<fieldset><legend>Administrator account</legend>\n");
  312. $aForm = array();
  313. $aForm[] = array('label' => "Login$sRedStar:", 'input' => "<input id=\"auth_user\" type=\"text\" name=\"auth_user\" value=\"\">");
  314. $aForm[] = array('label' => "Password$sRedStar:", 'input' => "<input id=\"auth_pwd\" type=\"password\" name=\"auth_pwd\" value=\"\">");
  315. $aForm[] = array('label' => "Retype password$sRedStar:", 'input' => "<input id=\"auth_pwd2\" type=\"password\" name=\"auth_pwd2\" value=\"\">");
  316. $oP->form($aForm);
  317. $oP->add("</fieldset>\n");
  318. $oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
  319. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  320. $oP->add("&nbsp;&nbsp;&nbsp;&nbsp;\n");
  321. $oP->add("<button type=\"submit\">Next >></button>\n");
  322. }
  323. else
  324. {
  325. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  326. }
  327. // Form goes here
  328. $oP->add("</form>\n");
  329. }
  330. /**
  331. * Display the form for the fourth step of the configuration wizard
  332. * which consists in
  333. * 1) Creating the admin user account
  334. * 2) Prompting to load some sample data
  335. */
  336. function DisplayStep4(setup_web_page $oP, Config $oConfig, $sAdminUser, $sAdminPwd)
  337. {
  338. $sNextOperation = 'step5';
  339. $oP->add("<h1>iTop configuration wizard</h1>\n");
  340. $oP->add("<h2>Creation of the administrator account</h2>\n");
  341. $oP->add("<form method=\"post\"\">\n");
  342. if (CreateAdminAccount($oP, $oConfig, $sAdminUser, $sAdminPwd))
  343. {
  344. $oP->add("<h2>Step 4: Loading of sample data</h2>\n");
  345. $oP->p("<fieldset><legend> Do you want to load sample data into the database ? </legend>\n");
  346. $oP->p("<input type=\"radio\" id=\"sample_data\" name=\"sample_data\" checked value=\"yes\"> Yes, for testing purposes, populate the database with sample data.\n");
  347. $oP->p("<input type=\"radio\" name=\"sample_data\" unchecked value=\"no\"> No, this is a production system, I will load real data myself.\n");
  348. $oP->p("</fieldset>\n");
  349. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  350. $oP->add("&nbsp;&nbsp;&nbsp;&nbsp;\n");
  351. $oP->add("<button onclick=\"DoSubmit('Finalizing configuration and loading data...', 4);\">Finish</button>\n");
  352. }
  353. else
  354. {
  355. // Creation failed
  356. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  357. }
  358. // End of visible form
  359. $oP->add("</form>\n");
  360. // Hidden form
  361. $oP->add("<form id=\"GoToNextStep\" method=\"post\">\n");
  362. $oP->add("<input type=\"hidden\" name=\"auth_user\" value=\"$sAdminUser\">\n"); // To be compatible with login page
  363. $oP->add("<input type=\"hidden\" name=\"auth_pwd\" value=\"$sAdminPwd\">\n"); // To be compatible with login page
  364. $oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
  365. $oP->add("</form>\n");
  366. $oP->add_linked_script('./jquery.progression.js');
  367. PopulateDataFilesList($oP);
  368. }
  369. /**
  370. * Display the form for the fifth (and final) step of the configuration wizard
  371. * which consists in
  372. * 1) Creating the final configuration file
  373. * 2) Prompting the user to make the file read-only
  374. */
  375. function DisplayStep5(setup_web_page $oP, Config $oConfig, $sAuthUser, $sAuthPwd)
  376. {
  377. try
  378. {
  379. session_start();
  380. // Write the final configuration file
  381. $oConfig->WriteToFile(FINAL_CONFIG_FILE);
  382. // Start the application
  383. InitDataModel($oP, FINAL_CONFIG_FILE, false); // DO NOT allow missing DB
  384. if (UserRights::Login($sAuthUser, $sAuthPwd))
  385. {
  386. $_SESSION['auth_user'] = $sAuthUser;
  387. $_SESSION['auth_pwd'] = $sAuthPwd;
  388. // remove the tmp config file
  389. @unlink(TMP_CONFIG_FILE);
  390. // try to make the final config file read-only
  391. @chmod(FINAL_CONFIG_FILE, 0440); // Read-only for owner and group, nothing for others
  392. $oP->add("<h1>iTop configuration wizard</h1>\n");
  393. $oP->add("<h2>Configuration completed</h2>\n");
  394. $oP->add("<form method=\"get\" action=\"../index.php\">\n");
  395. $oP->ok("The initialization completed successfully.");
  396. // Form goes here
  397. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  398. $oP->add("&nbsp;&nbsp;&nbsp;&nbsp;\n");
  399. $oP->add("<button type=\"submit\">Enter iTop</button>\n");
  400. $oP->add("</form>\n");
  401. }
  402. else
  403. {
  404. $oP->add("<h1>iTop configuration wizard</h1>\n");
  405. $oP->add("<h2>Step 5: Configuration completed</h2>\n");
  406. @unlink(FINAL_CONFIG_FILE); // remove the aborted config
  407. $oP->error("Error: Failed to login for user: '$sAuthUser'\n");
  408. $oP->add("<form method=\"get\" action=\"../index.php\">\n");
  409. $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
  410. $oP->add("&nbsp;&nbsp;&nbsp;&nbsp;\n");
  411. $oP->add("</form>\n");
  412. }
  413. }
  414. catch(Exception $e)
  415. {
  416. $oP->error("Error: unable to create the configuration file.");
  417. $oP->p($e->getHtmlDesc());
  418. $oP->p("Did you forget to remove the previous (read-only) configuration file ?");
  419. }
  420. }
  421. /**
  422. * Main program
  423. */
  424. clearstatcache(); // Make sure we know what we are doing !
  425. if (file_exists(FINAL_CONFIG_FILE))
  426. {
  427. // The configuration file already exists
  428. if (is_writable(FINAL_CONFIG_FILE))
  429. {
  430. $oP->warning("<b>Warning:</b> a configuration file '".FINAL_CONFIG_FILE."' already exists, and will be overwritten.");
  431. }
  432. else
  433. {
  434. $oP->add("<h1>iTop configuration wizard</h1>\n");
  435. $oP->add("<h2>Fatal error</h2>\n");
  436. $oP->error("<b>Error:</b> the configuration file '".FINAL_CONFIG_FILE."' already exists and cannot be overwritten.");
  437. $oP->p("The wizard cannot create the configuration file for you. Please remove the file '<b>".realpath(FINAL_CONFIG_FILE)."</b>' or change its access-rights/read-only flag before continuing.");
  438. $oP->output();
  439. exit;
  440. }
  441. }
  442. else
  443. {
  444. // No configuration file yet
  445. // Check that the wizard can write into the root dir to create the configuration file
  446. if (!is_writable(dirname(FINAL_CONFIG_FILE)))
  447. {
  448. $oP->add("<h1>iTop configuration wizard</h1>\n");
  449. $oP->add("<h2>Fatal error</h2>\n");
  450. $oP->error("<b>Error:</b> the directory where to store the configuration file is not writable.");
  451. $oP->p("The wizard cannot create the configuration file for you. Please make sure that the directory '<b>".realpath(dirname(FINAL_CONFIG_FILE))."</b>' is writable for the web server.");
  452. $oP->output();
  453. exit;
  454. }
  455. }
  456. try
  457. {
  458. $oConfig = new Config(TMP_CONFIG_FILE);
  459. }
  460. catch(Exception $e)
  461. {
  462. // We'll end here when the tmp config file does not exist. It's normal
  463. $oConfig = new Config(TMP_CONFIG_FILE, false /* Don't try to load it */);
  464. }
  465. try
  466. {
  467. switch($sOperation)
  468. {
  469. case 'step1':
  470. $oP->log("Info - ========= Wizard step 1 ========");
  471. DisplayStep1($oP);
  472. break;
  473. case 'step2':
  474. $oP->no_cache();
  475. $oP->log("Info - ========= Wizard step 2 ========");
  476. $sDBServer = Utils::ReadParam('db_server');
  477. $sDBUser = Utils::ReadParam('db_user');
  478. $sDBPwd = Utils::ReadParam('db_pwd');
  479. DisplayStep2($oP, $oConfig, $sDBServer, $sDBUser, $sDBPwd);
  480. break;
  481. case 'step3':
  482. $oP->no_cache();
  483. $oP->log("Info - ========= Wizard step 3 ========");
  484. $sDBName = Utils::ReadParam('db_name');
  485. if (empty($sDBName))
  486. {
  487. $sDBName = Utils::ReadParam('new_db_name');
  488. }
  489. $sDBPrefix = Utils::ReadParam('db_prefix');
  490. DisplayStep3($oP, $oConfig, $sDBName, $sDBPrefix);
  491. break;
  492. case 'step4':
  493. $oP->no_cache();
  494. $oP->log("Info - ========= Wizard step 4 ========");
  495. $sAdminUser = Utils::ReadParam('auth_user');
  496. $sAdminPwd = Utils::ReadParam('auth_pwd');
  497. DisplayStep4($oP, $oConfig, $sAdminUser, $sAdminPwd);
  498. break;
  499. case 'step5':
  500. $oP->no_cache();
  501. $oP->log("Info - ========= Wizard step 5 ========");
  502. $sAdminUser = Utils::ReadParam('auth_user');
  503. $sAdminPwd = Utils::ReadParam('auth_pwd');
  504. DisplayStep5($oP, $oConfig, $sAdminUser, $sAdminPwd);
  505. break;
  506. default:
  507. $oP->error("Error: unsupported operation '$sOperation'");
  508. }
  509. }
  510. catch(Exception $e)
  511. {
  512. $oP->error("Error: '".$e->getMessage()."'");
  513. }
  514. catch(CoreException $e)
  515. {
  516. $oP->error("Error: '".$e->getHtmlDesc()."'");
  517. }
  518. $oP->output();
  519. ?>