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();
20 <body onload="init()">
24 exit ("\n</body></html>");
26 function wiz_success ($message) {
27 printf ("<p class=\"success center\">%s</p>", $message);
29 function wiz_error ($message) {
30 printf ("<p class=\"error center\">%s</p>", $message);
33 function wiz_warn ($message) {
34 printf ("<p class=\"warn center\">%s</p>", $message);
37 if (version_compare (PHP_VERSION, '5.0.0', '<')) {
38 wiz_error (trans ("You need at least PHP version 5"));
41 require_once ("./inc/settings.php");
42 require_once ("./inc/db/mysql.php");
45 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
46 } catch (Exception $e) {
47 switch ($e->getMessage ()) {
48 case anydbConnection::err_driver_unavailable:
49 wiz_error ($connection->getdbname() . ': ' . trans ('not supported'));
50 case anydbConnection::err_connection:
51 wiz_error (trans ('Could not connect to database.'));
52 case anydbConnection::err_unknown_database:
53 wiz_error (trans ('Database does not exist.'));
55 wiz_error (trans ('Unknown error when connecting to database.'));
59 $users_table_exists = $connection->users_table_exists ();
60 } catch(Exception $e) {
61 wiz_error (trans ('Unknown error when checking user table.'));
64 if ($users_table_exists) {
65 wiz_success (trans ('Found user table.'));
67 if (isset($_POST ["password"])) {
69 $connection->create_users_table (true);
70 } catch (Exception $e) {
71 wiz_error (trans ('Error when creating user table.'));
73 wiz_success (trans ('User table created.'));
75 $connection->setpwd ("admin", $_POST ["password"]);
76 } catch (Exception $e) {
77 wiz_error (trans ('Error when initializing password.'));
79 wiz_success (trans ('Admin password initialized.'));
82 print ('<form class="center" method="post" action="">
83 <label for="password">' . trans ("choose admin password") . '</label>
84 <input id="password" name="password" type="password">
93 $items_table_exists = $connection->items_table_exists ();
94 } catch (Exception $e) {
95 wiz_error (trans ('Unknown error when checking data table.'));
97 if ($items_table_exists) {
98 wiz_success (trans ('Found data table.'));
101 $connection->create_items_table (true);
102 } catch (Exception $e) {
103 wiz_error (trans ('Error when creating data table.'));
105 wiz_success (trans ('Data table created.'));
107 if (!is_dir (UPLOADDIR)) {
108 if (file_exists (UPLOADDIR)) {
109 wiz_error (UPLOADDIR . ": " . trans ('exist but is not a directory'));
111 if (!mkdir (UPLOADDIR)) {
112 wiz_error (UPLOADDIR . ": " . trans ('could not create directory'));
114 wiz_success (UPLOADDIR . ": " . trans ('directory created'));
117 if (!is_writeable (UPLOADDIR) || !is_executable (UPLOADDIR)) {
118 wiz_error (UPLOADDIR . ": " . trans ('could not write in directory'));
120 wiz_success (trans ('SYP is installed. You can now go to <a href="admin.en.php">admin area</a>'));