2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
6 "http://www.w3.org/TR/html4/loose.dtd">
9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
10 <link rel="stylesheet" href="./media/common.css" type="text/css" />
11 <title><?php ptrans ('SYP wizard')?></title>
12 <script type="text/javascript">
14 if (document.getElementById('password')) {
15 document.getElementById('password').focus();
16 document.getElementById('password').select();
21 <body onload="init()">
25 exit ("\n</body></html>");
27 function wiz_success ($message) {
28 printf ("<p class=\"success center\">%s</p>", $message);
30 function wiz_error ($message) {
31 printf ("<p class=\"error center\">%s</p>", $message);
34 function wiz_warn ($message) {
35 printf ("<p class=\"warn center\">%s</p>", $message);
38 if (version_compare (PHP_VERSION, '5.0.0', '<')) {
39 wiz_error (trans ("You need at least PHP version 5"));
42 require_once ("./inc/settings.php");
43 require_once ("./inc/db/mysql.php");
46 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
47 } catch (Exception $e) {
48 switch ($e->getMessage ()) {
49 case anydbConnection::err_driver_unavailable:
50 wiz_error ($connection->getdbname() . ': ' . trans ('not supported'));
51 case anydbConnection::err_connection:
52 wiz_error (trans ('Could not connect to database.'));
53 case anydbConnection::err_unknown_database:
54 wiz_error (trans ('Database does not exist.'));
56 wiz_error (trans ('Unknown error when connecting to database.'));
60 $users_table_exists = $connection->users_table_exists ();
61 } catch(Exception $e) {
62 wiz_error (trans ('Unknown error when checking user table.'));
65 if ($users_table_exists) {
66 wiz_success (trans ('Found user table.'));
68 if (isset($_POST ["password"])) {
70 $connection->create_users_table (true);
71 } catch (Exception $e) {
72 wiz_error (trans ('Error when creating user table.'));
74 wiz_success (trans ('User table created.'));
76 $connection->setpwd ("admin", $_POST ["password"]);
77 } catch (Exception $e) {
78 wiz_error (trans ('Error when initializing password.'));
80 wiz_success (trans ('Admin password initialized.'));
83 print ('<form class="center" method="post" action="">
84 <label for="password">' . trans ("choose admin password") . '</label>
85 <input id="password" name="password" type="password">
94 $items_table_exists = $connection->items_table_exists ();
95 } catch (Exception $e) {
96 wiz_error (trans ('Unknown error when checking data table.'));
98 if ($items_table_exists) {
99 wiz_success (trans ('Found data table.'));
102 $connection->create_items_table (true);
103 } catch (Exception $e) {
104 wiz_error (trans ('Error when creating data table.'));
106 wiz_success (trans ('Data table created.'));
108 if (!is_dir (UPLOADDIR)) {
109 if (file_exists (UPLOADDIR)) {
110 wiz_error (UPLOADDIR . ": " . trans ('exist but is not a directory'));
112 if (!mkdir (UPLOADDIR)) {
113 wiz_error (UPLOADDIR . ": " . trans ('could not create directory'));
115 wiz_success (UPLOADDIR . ": " . trans ('directory created'));
118 if (!is_writeable (UPLOADDIR) || !is_executable (UPLOADDIR)) {
119 wiz_error (UPLOADDIR . ": " . trans ('could not write in directory'));
121 wiz_success (trans ('SYP is installed. You can now go to <a href="admin.en.php">admin area</a>'));