2004-10-20 00:24:10 +02:00
|
|
|
|
<?php
|
2005-06-11 13:35:58 +02:00
|
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2005-01-08 12:40:21 +01:00
|
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
|
|
|
|
|
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
2004-02-05 00:11:46 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*/
|
2005-01-08 12:40:21 +01:00
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/install/etape5.php
|
2005-10-22 15:48:19 +02:00
|
|
|
|
\brief Page de fin d'installation ou de migration
|
2005-01-08 12:40:21 +01:00
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-02-12 22:25:39 +01:00
|
|
|
|
include_once("./inc.php");
|
|
|
|
|
|
|
2006-01-04 17:22:38 +01:00
|
|
|
|
$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
|
2005-10-30 02:07:00 +01:00
|
|
|
|
$langs->setDefaultLang($setuplang);
|
|
|
|
|
|
|
2005-02-13 17:47:32 +01:00
|
|
|
|
$langs->load("admin");
|
2005-02-12 22:25:39 +01:00
|
|
|
|
$langs->load("install");
|
|
|
|
|
|
|
2004-02-05 00:24:24 +01:00
|
|
|
|
$success=0;
|
|
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
|
2007-05-10 20:58:52 +02:00
|
|
|
|
dolibarr_install_syslog("etape5: Entering etape5.php page");
|
2004-01-27 15:36:40 +01:00
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
|
2005-10-03 03:14:50 +02:00
|
|
|
|
if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
|
2004-01-27 15:36:40 +01:00
|
|
|
|
{
|
2005-10-03 03:14:50 +02:00
|
|
|
|
// If install, check pass and pass_verif used to create admin account
|
|
|
|
|
|
if ($_POST["action"] == "set")
|
2004-02-12 17:44:49 +01:00
|
|
|
|
{
|
2005-10-03 03:14:50 +02:00
|
|
|
|
if ($_POST["pass"] <> $_POST["pass_verif"])
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: etape4.php?error=1&selectlang=$setuplang");
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($_POST["pass"])) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: etape4.php?error=2&selectlang=$setuplang");
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($_POST["login"])) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: etape4.php?error=3&selectlang=$setuplang");
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
2004-02-12 17:44:49 +01:00
|
|
|
|
}
|
2005-10-03 03:14:50 +02:00
|
|
|
|
|
|
|
|
|
|
// If upgrade
|
|
|
|
|
|
if ($_POST["action"] == "upgrade")
|
2004-02-12 17:44:49 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
pHeader($langs->trans("SetupEnd"),"etape5");
|
2004-01-27 15:36:40 +01:00
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
print '<table cellspacing="0" cellpadding="2" width="100%">';
|
|
|
|
|
|
$error=0;
|
2007-04-30 13:33:10 +02:00
|
|
|
|
|
|
|
|
|
|
// on d<>code le mot de passe de la base si besoin
|
|
|
|
|
|
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.inc.php");
|
|
|
|
|
|
if ($dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass);
|
2004-01-27 15:36:40 +01:00
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
$conf->db->type = $dolibarr_main_db_type;
|
|
|
|
|
|
$conf->db->host = $dolibarr_main_db_host;
|
|
|
|
|
|
$conf->db->name = $dolibarr_main_db_name;
|
|
|
|
|
|
$conf->db->user = $dolibarr_main_db_user;
|
|
|
|
|
|
$conf->db->pass = $dolibarr_main_db_pass;
|
2006-10-19 20:51:35 +02:00
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
|
|
|
|
|
$ok = 0;
|
|
|
|
|
|
|
2005-10-22 15:48:19 +02:00
|
|
|
|
// Active module user
|
|
|
|
|
|
$modName='modUser';
|
|
|
|
|
|
$file = $modName . ".class.php";
|
|
|
|
|
|
include_once("../includes/modules/$file");
|
|
|
|
|
|
$objMod = new $modName($db);
|
|
|
|
|
|
$objMod->init();
|
|
|
|
|
|
|
2005-10-03 03:14:50 +02:00
|
|
|
|
// If first install
|
|
|
|
|
|
if ($_POST["action"] == "set")
|
2004-01-27 15:36:40 +01:00
|
|
|
|
{
|
2005-10-03 03:14:50 +02:00
|
|
|
|
if ($db->connected == 1)
|
|
|
|
|
|
{
|
2006-10-19 20:51:35 +02:00
|
|
|
|
$conf->setValues($db);
|
|
|
|
|
|
|
2007-03-11 16:03:05 +01:00
|
|
|
|
// todo: a supprimer ou modifier car le champs code n'existe plus
|
|
|
|
|
|
/*
|
2006-10-19 20:51:35 +02:00
|
|
|
|
$code=0;
|
|
|
|
|
|
|
|
|
|
|
|
// Recherche du code AD99 le plus <20>lev<65>.
|
|
|
|
|
|
$sql.= "select code from llx_user where code like 'AD%'";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
|
$codefound=substr($obj->code,2);
|
|
|
|
|
|
if (is_numeric($codefound) && $codefound > $code) $code=$codefound;
|
|
|
|
|
|
//print "Found code=$code";
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$code++;
|
|
|
|
|
|
$code=sprintf("%02d",$code);
|
2007-03-11 16:03:05 +01:00
|
|
|
|
*/
|
|
|
|
|
|
$sql = "INSERT INTO llx_user(datec,login,pass,admin,name) VALUES (now()";
|
2006-10-19 20:51:35 +02:00
|
|
|
|
$sql.= ",'".$_POST["login"]."'";
|
2006-11-25 22:39:58 +01:00
|
|
|
|
$sql.= ",'".($conf->password_encrypted?md5($_POST["pass"]):$_POST["pass"])."'";
|
2007-03-11 16:03:05 +01:00
|
|
|
|
$sql.= ",1,'Administrateur')";
|
2006-10-19 20:51:35 +02:00
|
|
|
|
//print "sql=".$sql." ".mysql_errno($db->db);
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])."<br>";
|
|
|
|
|
|
$success = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("AdminLoginAlreadyExists",$_POST["login"])."<br>";
|
|
|
|
|
|
$success = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("FailedToCreateAdminLogin")."<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($success)
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->query("DELETE FROM llx_const WHERE name='MAIN_NOT_INSTALLED'");
|
|
|
|
|
|
|
|
|
|
|
|
// Si install non Fran<61>ais, on configure pour fonctionner en mode internationnal
|
|
|
|
|
|
if ($langs->defaultlang != "fr_FR")
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->query("UPDATE llx_const set value='eldy_backoffice.php' WHERE name='MAIN_MENU_BARRETOP';");
|
|
|
|
|
|
$db->query("UPDATE llx_const set value='eldy_backoffice.php' WHERE name='MAIN_MENU_BARRELEFT';");
|
|
|
|
|
|
|
|
|
|
|
|
$db->query("UPDATE llx_const set value='eldy_frontoffice.php' WHERE name='MAIN_MENUFRONT_BARRETOP';");
|
|
|
|
|
|
$db->query("UPDATE llx_const set value='eldy_frontoffice.php' WHERE name='MAIN_MENUFRONT_BARRELEFT';");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("Error")."<br>";
|
|
|
|
|
|
}
|
2005-06-26 00:18:06 +02:00
|
|
|
|
}
|
2005-10-30 02:07:00 +01:00
|
|
|
|
|
2007-07-08 21:39:04 +02:00
|
|
|
|
// May fail if parameter already defined
|
|
|
|
|
|
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_LANG_DEFAULT','".$setuplang."','chaine',0,'Default language')");
|
|
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
2004-01-27 15:36:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-06-11 13:35:58 +02:00
|
|
|
|
print "<br>";
|
2004-01-30 17:00:18 +01:00
|
|
|
|
|
2005-06-26 00:06:00 +02:00
|
|
|
|
|
2005-10-03 03:14:50 +02:00
|
|
|
|
// If first install
|
|
|
|
|
|
if ($_POST["action"] == "set")
|
|
|
|
|
|
{
|
|
|
|
|
|
// Fin install
|
|
|
|
|
|
print $langs->trans("SystemIsInstalled")."<br>";
|
|
|
|
|
|
print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
|
|
|
|
|
|
|
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
|
|
|
|
|
|
print $langs->trans("YouNeedToPersonalizeSetup")."<br><br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If upgrade
|
|
|
|
|
|
if ($_POST["action"] == "upgrade")
|
|
|
|
|
|
{
|
|
|
|
|
|
// Fin install
|
|
|
|
|
|
print $langs->trans("SystemIsUpgraded")."<br>";
|
|
|
|
|
|
print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
|
|
|
|
|
|
|
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-06-26 19:40:08 +02:00
|
|
|
|
|
2005-06-26 00:06:00 +02:00
|
|
|
|
print '<a href="'.$dolibarr_main_url_root .'/admin/index.php?mainmenu=home&leftmenu=setup">';
|
2005-02-13 17:47:32 +01:00
|
|
|
|
print $langs->trans("GoToSetupArea");
|
|
|
|
|
|
print '</a>';
|
2004-02-05 00:24:24 +01:00
|
|
|
|
|
2005-06-26 00:06:00 +02:00
|
|
|
|
|
2006-06-17 16:13:49 +02:00
|
|
|
|
dolibarr_install_syslog("Dolibarr install/setup finished");
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-30 02:07:00 +01:00
|
|
|
|
pFooter(1,$setuplang);
|
|
|
|
|
|
|
2004-01-27 15:36:40 +01:00
|
|
|
|
?>
|