* Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien DiCintio * * 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. */ /** \file htdocs/install/etape5.php \ingroup install \brief Page de fin d'installation ou de migration \version $Id$ */ include_once("./inc.php"); $setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto'); $langs->setDefaultLang($setuplang); $langs->load("admin"); $langs->load("install"); $success=0; // Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard. if (! isset($force_install_type)) $force_install_type=''; if (! isset($force_install_port)) $force_install_port=''; if (! isset($force_install_database)) $force_install_database=''; if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; if (! isset($force_install_databaserootpass)) $force_install_databaserootpass=''; if (! isset($force_install_renamedir)) $force_install_renamedir=''; if (file_exists("./install.forced.php")) include_once("./install.forced.php"); dolibarr_install_syslog("etape5: Entering etape5.php page", LOG_INFO); /* * Actions */ // If install, check pass and pass_verif used to create admin account if ($_POST["action"] == "set") { if ($_POST["pass"] <> $_POST["pass_verif"]) { Header("Location: etape4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:'')); exit; } if (strlen(trim($_POST["pass"])) == 0) { Header("Location: etape4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:'')); exit; } if (strlen(trim($_POST["login"])) == 0) { Header("Location: etape4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:'')); exit; } } /* * View */ pHeader($langs->trans("SetupEnd"),"etape5"); if ($_POST["action"] == "set" || $_POST["action"] == "upgrade") { print ''; $error=0; // on décode le mot de passe de la base si besoin require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); if (! empty($dolibarr_main_db_encrypted_pass)) { require_once(DOL_DOCUMENT_ROOT ."/lib/security.lib.php"); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; $conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $ok = 0; // Active module user $modName='modUser'; $file = $modName . ".class.php"; dolibarr_install_syslog('install/etape5.php Load module user '.DOL_DOCUMENT_ROOT ."/includes/modules/".$file, LOG_INFO); include_once(DOL_DOCUMENT_ROOT ."/includes/modules/".$file); $objMod = new $modName($db); $objMod->init(); // If first install if ($_POST["action"] == "set") { if ($db->connected == 1) { $conf->setValues($db); // Create user include_once(DOL_DOCUMENT_ROOT ."/user.class.php"); $createuser=new User($db); $createuser->id=0; $newuser = new User($db); $newuser->nom='Admin'; $newuser->prenom=''; $newuser->login=$_POST["login"]; $newuser->pass=$_POST["pass"]; $newuser->admin=1; $result=$newuser->create($createuser,1); if ($result > 0) { print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])."
"; $success = 1; } else { if ($newuser->error == 'ErrorLoginAlreadyExists') { dolibarr_install_syslog('install/etape5.php ErrorLoginAlreadyExists', LOG_WARNING); print '
'.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."

"; $success = 1; } else { dolibarr_install_syslog('install/etape5.php FailedToCreateAdminLogin', LOG_ERR); print '
'.$langs->trans("FailedToCreateAdminLogin").'

'; } } if ($success) { // Si install non Franç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';"); } dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const', LOG_ERR); $db->query("DELETE FROM llx_const WHERE name='MAIN_VERSION_LAST_INSTALL'"); $db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_VERSION_LAST_INSTALL','".DOL_VERSION."','chaine',0,'Dolibarr version for last install')"); dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_ERR); $db->query("DELETE FROM llx_const WHERE name='MAIN_NOT_INSTALLED'"); } } else { print $langs->trans("Error")."
"; } } // If upgrade if ($_POST["action"] == "upgrade") { dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const', LOG_ERR); $db->query("DELETE FROM llx_const WHERE name='MAIN_VERSION_LAST_UPGRADE'"); $db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_VERSION_LAST_UPGRADE','".DOL_VERSION."','chaine',0,'Dolibarr version for last upgrade')"); } // 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')"); print '
'; $db->close(); } print "
"; // If first install if ($_POST["action"] == "set") { // Fin install print $langs->trans("SystemIsInstalled")."
"; if (empty($force_install_renamedir)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } else { // Open the file and erase the contents if any $fp = fopen("../../install.lock", "w"); fwrite($fp, "This is a lock file to prevent use of install pages"); fclose($fp); } print "
"; print $langs->trans("YouNeedToPersonalizeSetup")."

"; } // If upgrade if ($_POST["action"] == "upgrade") { // Fin install print $langs->trans("SystemIsUpgraded")."
"; if (empty($force_install_renamedir)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } else { // Open the file and erase the contents if any $fp = fopen("../../install.lock", "w"); fwrite($fp, "This is a lock file to prevent use of install pages"); fclose($fp); } print "
"; } print ''; print $langs->trans("GoToSetupArea"); print ''; // Clear cache files clearstatcache(); dolibarr_install_syslog("Dolibarr install/setup finished", LOG_INFO); pFooter(1,$setuplang); ?>