]> dev.renevier.net Git - syp.git/commitdiff
password is defined by user in wizard + localize wizard
authorarno <arenevier@fdn.fr>
Sat, 25 Jul 2009 10:49:51 +0000 (12:49 +0200)
committerarno <arenevier@fdn.fr>
Sat, 25 Jul 2009 10:49:51 +0000 (12:49 +0200)
12 files changed:
build.sh
inc/db/anydb.php
inc/db/mysql.php
inc/i10n/en/syp.php
inc/i10n/fr/syp.php
inc/i10n/updatelang.php
inc/settings.php
inc/templates_admin.php
inc/templates_wizard.php [new file with mode: 0644]
wizard.en.php [new symlink]
wizard.fr.php [new symlink]
wizard.php

index b51f8fb59ed7126484e2c2f47d7ffb74d9f9976b..1d91b8080f01bbd52dcafb25e024503c7de5e22e 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -15,7 +15,7 @@ mkdir -p $DESTDIR
 cp -RLp inc/ $DESTDIR/
 
 # other php files
-cp -p admin.*php index.*php api.php items.php logout.php wizard.php $DESTDIR/
+cp -p admin.*php index.*php wizard.*php api.php items.php logout.php $DESTDIR/
 
 # media
 cp -RLp media/ $DESTDIR/
index c88367a46277fb081309b020288e58eed88a6647..47d9a06dc3a154b9870aa0ddfd28affc6445caee 100644 (file)
@@ -69,10 +69,10 @@ interface anydbConnection {
     public function users_table_exists();
 
     /*
-     * create users table; if $error_if_exists is true; throws an err_query
-     * error in case users table already exists.
+     * create users table; 
+     * throws an err_query error in case users table already exists.
      */
-    public function create_users_table($error_if_exists);
+    public function create_users_table();
 
     /*
      * return true if items table already exists
@@ -80,10 +80,10 @@ interface anydbConnection {
     public function items_table_exists();
 
     /*
-     * create items table; if $error_if_exists is true; throws an err_query
-     * error in case items table already exists.
+     * create items table;
+     * throws an err_query error in case items table already exists.
      */
-    public function create_items_table($error_if_exists);
+    public function create_items_table();
 
     /*
      * set password $pwd for user $usrname. If $usrname does not exist, create
index e4c61d2c8e629a6fa2ccd6ddbbe639c07a1f2d1e..8fa49d52b68730a1a7edf980a18692e67cb06b6a 100644 (file)
@@ -28,9 +28,8 @@ class mysqlConnection implements anydbConnection {
     public function users_table_exists () {
         return $this->_tblexists ("users");
     }
-    public function create_users_table ($error_if_exists) {
+    public function create_users_table () {
         $query = sprintf ("CREATE TABLE " .
-                           ($error_if_exists ? " " : "IF NOT EXISTS ") .
                            "%susers (
                             name VARCHAR(255) NOT NULL, pwd CHAR(32),
                             PRIMARY KEY (name));", $this->dbprefix);
@@ -40,9 +39,8 @@ class mysqlConnection implements anydbConnection {
     public function items_table_exists () {
         return $this->_tblexists ("items");
     }
-    public function create_items_table ($error_if_exists) {
+    public function create_items_table () {
         $query = sprintf ("CREATE TABLE " .
-                           ($error_if_exists ? " " : "IF NOT EXISTS ") .
                             "%sitems (
                                 id MEDIUMINT NOT NULL AUTO_INCREMENT,
                                 location POINT,
index 843a97c22e23504dd229342733a07f7236891049..ffaf07a54b415c1187396071dea4930484c8bf4b 100644 (file)
         "_language_name" => "english",
 
         /* starts translation */
+        "SYP wizard"
+          => "",
+
+        "You need at least PHP version 5"
+          => "",
+
+        "not supported"
+          => "",
+
+        "Could not connect to database."
+          => "",
+
+        "Database does not exist."
+          => "",
+
+        "Unknown error when connecting to database."
+          => "",
+
+        "Unknown error when checking user table."
+          => "",
+
+        "Found user table."
+          => "",
+
+        "Error when creating user table."
+          => "",
+
+        "User table created."
+          => "",
+
+        "Error when initializing password."
+          => "",
+
+        "Admin password initialized."
+          => "",
+
+        "choose admin password"
+          => "",
+
+        "Unknown error when checking data table."
+          => "",
+
+        "Found data table."
+          => "",
+
+        "Error when creating data table."
+          => "",
+
+        "Data table created."
+          => "",
+
+        "exist but is not a directory"
+          => "",
+
+        "could not create directory"
+          => "",
+
+        "directory created"
+          => "",
+
+        "could not write in directory"
+          => "",
+
+        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
+          => "",
 
         "SYP needs javascript. Please activate scripts in your browser."
           => "",
@@ -24,8 +89,8 @@
         "SYP admin"
           => "",
 
-        "SYP is not correctly installed. Please read README.txt file and follow\n" .
-        "       installation instructions."
+        "SYP is not correctly installed. Please follow README.txt instructions\n" .
+        "       and go to <a href=\"wizard.en.php\">wizard</a>."
           => "",
 
         "add a place"
index acc6b69a201c28a0ca95d64831e9c9b6e4de1c54..1b7031ab8994a89cc3a9ada10511e8a4671dd0b2 100644 (file)
         /* starts translation */
 
 
+        "SYP wizard"
+          =>
+        "Assistant d'installation de SYP"
+          ,
+
+        "You need at least PHP version 5"
+          =>
+        "Vous devez utiliser une version de PHP au moins égale à la version 5"
+          ,
+
+        "not supported"
+          =>
+        "support non détecté"
+          ,
+
+        "Could not connect to database."
+          =>
+        "Impossible de se connecter à la base de donnée."
+          ,
+
+        "Database does not exist."
+          =>
+        "La base de donnée n'existe pas."
+          ,
+
+        "Unknown error when connecting to database."
+          =>
+        "Erreur inconnue lors de la connexion à la base."
+          ,
+
+        "Unknown error when checking user table."
+          =>
+        "Erreur inconnue lors de la vérification de la table utilisateur."
+          ,
+
+        "Found user table."
+          =>
+        "Table utilisateur trouvée."
+          ,
+
+        "Error when creating user table."
+          =>
+        "Erreur lors de la création de la table utilisateur."
+          ,
+
+        "User table created."
+          =>
+        "Table utilisateur créée."
+          ,
+
+        "Error when initializing password."
+          =>
+        "Erreur lors de l'initialisation du mot de passe."
+          ,
+
+        "Admin password initialized."
+          =>
+        "Mot de passe administrateur initialisé."
+          ,
+
+        "choose admin password"
+          =>
+        "choisir un mot de passe administrateur"
+          ,
+
+        "Unknown error when checking data table."
+          =>
+        "Erreur inconnue lors de la vérification de la table des données."
+          ,
+
+        "Found data table."
+          =>
+        "Table des données trouvée."
+          ,
+
+        "Error when creating data table."
+          =>
+        "Erreur lors de la création de la table des données."
+          ,
+
+        "Data table created."
+          =>
+        "Table des données créée."
+          ,
+
+        "exist but is not a directory"
+          =>
+        "existe mais n'est pas un répertoire"
+          ,
+
+        "could not create directory"
+          =>
+        "Impossible de créer le répertoire"
+          ,
+
+        "directory created"
+          =>
+        "Répertoire créé"
+          ,
+
+        "could not write in directory"
+          =>
+        "Impossible d'écrire dans le répertoire"
+          ,
+
+        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
+          =>
+        "SYP est installé. Vous pouvez maintenant vous rendre dans <a href=\"admin.fr.php\">la partie administration.</a>"
+          ,
+
         "SYP needs javascript. Please activate scripts in your browser."
           =>
         "SYP a besoin de javascript pour fonctionner. Veuillez activer les scripts dans votre navigateur."
         "administration de SYP"
           ,
 
-        "SYP is not correctly installed. Please read README.txt file and follow\n" .
-        "       installation instructions."
+        "SYP is not correctly installed. Please follow README.txt instructions\n" .
+        "       and go to <a href=\"wizard.en.php\">wizard</a>."
           =>
         "SYP n'est pas correctement installé. Veuillez\n" .
-        "       consulter le fichier README.txt et suivez les instructions\n" .
-        "       d'installation."
+        "       suivre les instructions du fichier README.txt et vous rendre\n" .
+        "       sur la page du <a href=\"wizard.fr.php\">wizard</a>."
           ,
 
         "add a place"
index 3133e845d07a4cb787f698e62b58ef89e5615c18..04b12ec85359061de865d9f97b509f3686c41462 100755 (executable)
@@ -7,7 +7,7 @@ if (!(isset ($argc)) || !(isset ($argv))) {
 }
 
 $ROOTDIR="../../";
-$SCRIPTS=array("admin"); // scripts in rootdir we need to link to
+$SCRIPTS=array("admin", "index", "wizard"); // scripts in rootdir we need to link to
 
 function usage() {
     global $argv;
index 8ec2d4ba62055e6a23b0bcd03314c2e0d1c02529..68bc142aee3799e1420a0455ec69948bca945f4b 100644 (file)
@@ -17,12 +17,6 @@ define ("DBNAME", "syp");
 // tables prefix. This prefix will also be used as a prefix for cookie names.
 define ("DBPREFIX", "syp_");
 
-// admin password. It will be read from here during site installation.
-// Then, it will be stored in database. So, if you need to change password
-// once it's set, changing it here will not work; you'll need to change it
-// in the database.
-define ("ADMINPWD", "");
-
 // directory where images will be uploaded and stored. That directory needs
 // to be writeable by SYP.
 define ("UPLOADDIR", "upload");
index eda657d7577c7ff50fa12274c4b9796829d239e3..ce7e3b4230069f83bcfb124307bdae92a3210105 100644 (file)
@@ -28,8 +28,8 @@ if (!$usrtblexists || !$itemstblexists) {
       <link rel="stylesheet" href="./media/admin.css" type="text/css">
 </head>
 <body>
-    <p class="error center"><?php ptrans('SYP is not correctly installed. Please read README.txt file and follow
-       installation instructions.')?></p>
+    <p class="error center"><?php ptrans('SYP is not correctly installed. Please follow README.txt instructions
+       and go to <a href="wizard.en.php">wizard</a>.')?></p>
 </body>
 </html>
 <?php
diff --git a/inc/templates_wizard.php b/inc/templates_wizard.php
new file mode 100644 (file)
index 0000000..f556991
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+       "http://www.w3.org/TR/html4/loose.dtd">  
+<html>
+<head>
+      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
+      <link rel="stylesheet" href="./media/common.css" type="text/css" />
+      <title><?php ptrans ('SYP wizard')?></title>
+      <script type="text/javascript">
+      function init () {
+        if (document.getElementById('password')) { 
+            document.getElementById('password').focus();
+            document.getElementById('password').select();
+        }
+      </script>
+</head>
+<body onload="init()">
+
+<?php
+    function leave () {
+        exit ("\n</body></html>");
+    }
+    function wiz_success ($message) {
+        printf ("<p class=\"success center\">%s</p>", $message);
+    }
+    function wiz_error ($message) {
+        printf ("<p class=\"error center\">%s</p>", $message);
+        leave ();
+    }
+    function wiz_warn ($message) {
+        printf ("<p class=\"warn center\">%s</p>", $message);
+    }
+
+    if (version_compare (PHP_VERSION, '5.0.0', '<')) {
+        wiz_error (trans ("You need at least PHP version 5"));
+    }
+
+    require_once ("./inc/settings.php");
+    require_once ("./inc/db/mysql.php");
+
+    try {
+        $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
+    } catch (Exception $e) {
+        switch ($e->getMessage ()) {
+            case anydbConnection::err_driver_unavailable:
+                wiz_error ($connection->getdbname() . ': ' . trans ('not supported'));
+            case anydbConnection::err_connection:
+                wiz_error (trans ('Could not connect to database.'));
+            case anydbConnection::err_unknown_database:
+                wiz_error (trans ('Database does not exist.'));
+            default:
+                wiz_error (trans ('Unknown error when connecting to database.'));
+        }
+    }
+    try {
+        $users_table_exists = $connection->users_table_exists ();
+    } catch(Exception $e) {
+        wiz_error (trans ('Unknown error when checking user table.'));
+    }
+
+    if ($users_table_exists) {
+        wiz_success (trans ('Found user table.'));
+    } else {
+        if (isset($_POST ["password"])) {
+            try {
+                $connection->create_users_table (true);
+            } catch (Exception $e) {
+                wiz_error (trans ('Error when creating user table.'));
+            }
+            wiz_success (trans ('User table created.'));
+            try {
+                $connection->setpwd ("admin", $_POST ["password"]);
+            } catch (Exception $e) {
+                wiz_error (trans ('Error when initializing password.'));
+            }
+            wiz_success (trans ('Admin password initialized.'));
+
+        } else {
+            print ('<form class="center" method="post" action="">
+                    <label for="password">' . trans ("choose admin password") . '</label>
+                    <input id="password" name="password" type="password">
+                    <input type="submit">
+                 </form>');
+            leave ();
+        }
+
+    }
+
+    try {
+        $items_table_exists = $connection->items_table_exists ();
+    } catch (Exception $e) {
+        wiz_error (trans ('Unknown error when checking data table.'));
+    }
+    if ($items_table_exists) {
+        wiz_success (trans ('Found data table.'));
+    } else {
+        try {
+            $connection->create_items_table (true);
+        } catch (Exception $e) {
+            wiz_error (trans ('Error when creating data table.'));
+        }
+        wiz_success (trans ('Data table created.'));
+    }
+    if (!is_dir (UPLOADDIR)) {
+        if (file_exists (UPLOADDIR)) {
+            wiz_error (UPLOADDIR . ": " . trans ('exist but is not a directory'));
+        }
+        if (!mkdir (UPLOADDIR)) {
+            wiz_error (UPLOADDIR . ": " . trans ('could not create directory'));
+        } else {
+            wiz_success (UPLOADDIR . ": " . trans ('directory created'));
+        }
+    }
+    if (!is_writeable (UPLOADDIR) || !is_executable (UPLOADDIR)) {
+        wiz_error (UPLOADDIR . ": " . trans ('could not write in directory'));
+    }
+    wiz_success (trans ('SYP is installed. You can now go to <a href="admin.en.php">admin area</a>'));
+?>
+
+</body>
+</html>
diff --git a/wizard.en.php b/wizard.en.php
new file mode 120000 (symlink)
index 0000000..d9bd4cf
--- /dev/null
@@ -0,0 +1 @@
+wizard.php
\ No newline at end of file
diff --git a/wizard.fr.php b/wizard.fr.php
new file mode 120000 (symlink)
index 0000000..d9bd4cf
--- /dev/null
@@ -0,0 +1 @@
+wizard.php
\ No newline at end of file
index 9710d8fbb97db0157e3f847f1f436d4efb37014e..eca50984a5d74e348f84dc32079d46203846fa63 100644 (file)
@@ -1,108 +1,7 @@
 <?php
 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
    license. */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-       "http://www.w3.org/TR/html4/loose.dtd">  
-<html>
-<head>
-      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
-      <link rel="stylesheet" href="./media/common.css" type="text/css" />
-      <title>SYP wizard</title>
-</head>
-<body>
-
-<?php
-    function wiz_success ($message) {
-        printf ("<p class=\"success center\">%s</p>", $message);
-    }
-    function wiz_error ($message) {
-        exit (sprintf ("<p class=\"error center\">%s</p>", $message));
-    }
-    function wiz_warn ($message) {
-        printf ("<p class=\"warn center\">%s</p>", $message);
-    }
-
-    if (version_compare (PHP_VERSION, '5.0.0', '<')) {
-        wiz_error ("Vous devez utiliser une version de PHP au moins égale à la version 5");
-    }
-
-    if (!function_exists ("exif_read_data")) {
-        wiz_warn ("Cette version de php ne supporte pas la lecture des données exif");
-    }
 
-    require_once ("./inc/settings.php");
-    require_once ("./inc/db/mysql.php");
-
-    try {
-        $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
-    } catch (Exception $e) {
-        switch ($e->getMessage ()) {
-            case anydbConnection::err_driver_unavailable:
-                wiz_error ('Support de ' . $connection->getdbname () . ' non détecté.');
-            case anydbConnection::err_connection:
-                wiz_error ('Impossible de se connecter à la base de donnée.');
-            case anydbConnection::err_unknown_database:
-                wiz_error ('La base de donnée n\'existe pas.');
-            default:
-                wiz_error ('Erreur inconnue lors de la connexion à la base.');
-        }
-    }
-    try {
-        $users_table_exists = $connection->users_table_exists ();
-    } catch(Exception $e) {
-        wiz_error ('Erreur inconnue lors de la vérification de la table utilisateur.');
-    }
-
-    if ($users_table_exists) {
-        wiz_success ('Table utilisateur trouvée.');
-    } else {
-        try {
-            $connection->create_users_table (true);
-        } catch (Exception $e) {
-            wiz_error ('Erreur lors de la création de la table utilisateur.');
-        }
-        wiz_success ('Table utilisateur crée.');
-        try {
-            $connection->setpwd ("admin", ADMINPWD);
-        } catch (Exception $e) {
-            wiz_error ('Erreur lors de l\'initialisation du mot de passe.');
-        }
-        wiz_success ('Mot de passe administrateur initialisé.');
-    }
-
-    try {
-        $items_table_exists = $connection->items_table_exists ();
-    } catch (Exception $e) {
-        wiz_error ('Erreur inconnue lors de la vérification de la table des données.');
-    }
-    if ($items_table_exists) {
-        wiz_success ('Table utilisateur trouvée.');
-    } else {
-        try {
-            $connection->create_items_table (true);
-        } catch (Exception $e) {
-            wiz_error ('Erreur lors de la création de la table des données.');
-        }
-        wiz_success ('Table des données crée.');
-    }
-    if (!is_dir (UPLOADDIR)) {
-        if (file_exists (UPLOADDIR)) {
-            wiz_error (sprintf ("%s existe et n'est pas un répertoire.",
-                                UPLOADDIR));
-        }
-        if (!mkdir (UPLOADDIR)) {
-            wiz_error (sprintf ("Impossible de créer le répertoire %s.",
-                                UPLOADDIR));
-        } else {
-            wiz_success (sprintf ('Répertoire %s crée.', UPLOADDIR));
-        }
-    }
-    if (!is_writeable (UPLOADDIR) || !is_executable (UPLOADDIR)) {
-        wiz_error (sprintf ("Impossible d'écrire dans %s.", UPLOADDIR));
-    }
-    wiz_success ('SYP est installé. Vous pouvez maintenant vous rendre dans <a href="admin.php">la partie administration.');
+    require ('inc/langutils.php');
+    require ('inc/templates_wizard.php');
 ?>
-
-</body>
-</html>