diff --git a/INSTALL b/INSTALL index be90c1a2d32..fd87b3142af 100644 --- a/INSTALL +++ b/INSTALL @@ -40,7 +40,17 @@ fichier Makefile. 'make load' charge les donnees necessaire dans les tables de constantes. - 'make dev' charge un ensemble de donnees de test + 'make dev' charge un ensemble de donnees de test, cette étapes +est facultative + Une fois ces 3 commandes passees votre base de donnees est -pretes a etre utilisee. \ No newline at end of file +pretes a etre utilisee. + +Initialisation +-------------- + + Pour créer votre premier compte qui sera admin/admin allez à +l'url /public/password.php, cette page créé un compte avec le login +'admin' et le passe 'admin' dans la base, si et seulement si la table +des login est vide. \ No newline at end of file diff --git a/htdocs/public/password.php b/htdocs/public/password.php new file mode 100644 index 00000000000..d0ccb2b8d8c --- /dev/null +++ b/htdocs/public/password.php @@ -0,0 +1,65 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +require("../main.inc.php3"); + + +$db = new Db(); + +$sql = "SELECT count(*) FROM llx_user"; +$result = $db->query($sql); + +if ($result) +{ + if ($db->num_rows()) + { + $row = $db->fetch_row(0); + + $db->free(); + + if ($row[0] > 0) + { + print "La base contient déjà des mots de passes"; + } + else + { + $user = new User($db); + + $user->login = "admin"; + + $user->create(); + + $user->id = 1; + + $user->password("admin"); + + print "Compte admin/admin créé"; + } + } +} +else +{ + print $db->error(); +} + + + +?> diff --git a/htdocs/user.class.php3 b/htdocs/user.class.php3 index 1f56b32a1f0..da7bb315bd3 100644 --- a/htdocs/user.class.php3 +++ b/htdocs/user.class.php3 @@ -103,6 +103,38 @@ class User { * * */ + Function create() + { + $sql = "SELECT login FROM llx_user WHERE login ='$this->login'"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $this->db->free(); + + if ($num) + { + $this->errorstr = "Ce login existe déjà"; + return 0; + } + else + { + $sql = "INSERT INTO llx_user (login) values ('$this->login');"; + if ($this->db->query($sql)) + { + if ($this->db->affected_rows()) + { + return 1; + } + } + } + } + } + /* + * + * + */ + Function update() { $sql = "SELECT login FROM llx_user WHERE login ='$this->login'"; @@ -149,10 +181,12 @@ class User { * * */ - Function password() + Function password($password='') { - - $password = substr(crypt(uniqid("")),0,8); + if (! $password) + { + $password = substr(crypt(uniqid("")),0,8); + } $sql = "UPDATE llx_user SET pass = '".crypt($password, "CRYPT_STD_DES")."'"; $sql .= " WHERE rowid = $this->id"; diff --git a/htdocs/user/index.php3 b/htdocs/user/index.php3 index 6a753e93081..a5bb631a2c5 100644 --- a/htdocs/user/index.php3 +++ b/htdocs/user/index.php3 @@ -50,7 +50,7 @@ if ($result) { print ''.$obj->firstname.''; print ''.$obj->name.''; print ''.$obj->code.''; - print ''.$obj->login.''; + print ''.$obj->login.''; print ''.$obj->module_comm.''; print ''.$obj->module_compta.''; print "\n"; diff --git a/httpd.conf.dist b/httpd.conf.dist index fa863aa9be1..b8978171107 100644 --- a/httpd.conf.dist +++ b/httpd.conf.dist @@ -26,7 +26,7 @@ Auth_MySQL_Password_Table llx_user Auth_MySQL_Username_Field login Auth_MySQL_Password_Field pass - Auth_MySQL_Encryption_Types Plaintext + Auth_MySQL_Encryption_Types Crypt_DES Auth_MySQL_Encrypted_Passwords off AuthName "Dolibarr"