* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2006 Laurent Destailleur * * 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$ */ /** \file htdocs/admin/boutique.php \ingroup boutique \brief Page d'administration/configuration du module OsCommerce \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); $langs->load("admin"); $langs->load("oscommerce"); if (!$user->admin) accessforbidden(); /* * Actions */ if ($_POST["save"]) { $db->begin(); $i=0; $i+=dolibarr_set_const($db,'OSC_DB_HOST',trim($_POST["oscommerce_dbhost"]),'chaine',0); $i+=dolibarr_set_const($db,'OSC_DB_NAME',trim($_POST["oscommerce_dbname"]),'chaine',0); $i+=dolibarr_set_const($db,'OSC_DB_USER',trim($_POST["oscommerce_dbuser"]),'chaine',0); $i+=dolibarr_set_const($db,'OSC_DB_PASS',trim($_POST["oscommerce_dbpass"]),'chaine',0); $i+=dolibarr_set_const($db,'OSC_DB_TABLE_PREFIX',trim($_POST["oscommerce_db_table_prefix"]),'chaine',0); $i+=dolibarr_set_const($db,'OSC_LANGUAGE_ID',1,'chaine',0); if ($i >= 4) { $db->commit(); $mesg = "".$langs->trans("OSCommerceSetupSaved").""; } else { $db->rollback(); header("Location: ".$_SERVER["PHP_SELF"]); exit; } } elseif ($_POST["test"]) { //$resql=$db->query("select count(*) from llx_const"); //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n"; // Test de la connexion a la database webcalendar $conf->oscommerce->db->type=$dolibarr_main_db_type; $conf->oscommerce->db->host=$_POST["oscommerce_dbhost"]; $conf->oscommerce->db->port=$_POST["oscommerce_dbport"]; $conf->oscommerce->db->name=$_POST["oscommerce_dbname"]; $conf->oscommerce->db->user=$_POST["oscommerce_dbuser"]; $conf->oscommerce->db->pass=$_POST["oscommerce_dbpass"]; $oscommercedb=new DoliDB($conf->oscommerce->db->type,$conf->oscommerce->db->host,$conf->oscommerce->db->user,$conf->oscommerce->db->pass,$conf->oscommerce->db->name,$conf->oscommerce->db->port); //print "D ".$db." - ".$db->db."
\n"; //print "W ".$oscommercedb." - ".$oscommercedb->db."
\n"; if ($oscommercedb->connected == 1 && $oscommercedb->database_selected == 1) { // V�rifie si bonne base par requete sur une table OSCommerce $sql ="SELECT configuration_value"; $sql.=" FROM ".$_POST["oscommerce_db_table_prefix"]."configuration"; $sql.=" WHERE configuration_key='STORE_NAME'"; $resql=$oscommercedb->query($sql); if ($resql) { $mesg ="
".$langs->trans("OSCommerceTestOk",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"],$_POST["oscommerce_dbuser"]); $mesg.="
"; } else { $mesg ="
".$langs->trans("OSCommerceErrorConnectOkButWrongDatabase",'STORE_NAME',$_POST["oscommerce_db_table_prefix"]."configuration"); $mesg.="
"; } //$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique } elseif ($oscommercedb->connected == 1 && $oscommercedb->database_selected != 1) { $mesg ="
".$langs->trans("OSCommerceTestKo1",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"]); $mesg.="
".$oscommercedb->error(); $mesg.="
"; //$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique } else { $mesg ="
".$langs->trans("OSCommerceTestKo2",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbuser"]); $mesg.="
".$oscommercedb->error(); $mesg.="
"; } //$resql=$db->query("select count(*) from llx_const"); //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n"; } /* * Affichage page */ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("OSCommerceSetup"),$linkback,'setup'); print '
'; $var=true; print '
'; print ""; print ""; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ''; print ""; $var=!$var; print ""; print ""; print ""; print ''; print ""; print "
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")."
".$langs->trans("OSCommerceServer")."global->OSC_DB_HOST) . "\" size=\"30\">localhost"; //print "
__dolibarr_main_db_host__ (".$dolibarr_main_db_host.")" print "
".$langs->trans("OSCommerceDatabaseName")."global->OSC_DB_NAME) . "\" size=\"30\">oscommerce"; //print "
__dolibarr_main_db_name__ (".$dolibarr_main_db_name.")"; print "
".$langs->trans("OSCommercePrefix")."global->DB_TABLE_PREFIX) . "\" size=\"30\">osc_"; print "
".$langs->trans("OSCommerceUser")."global->OSC_DB_USER) . "\" size=\"30\">oscommerceuser"; //print "
__dolibarr_main_db_user__ (".$dolibarr_main_db_user.")"; print "
".$langs->trans("Password")."global->OSC_DB_PASS) . "\" size=\"30\">'; //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; print ' 
".$langs->trans("PasswordRetype")."global->OSC_DB_PASS) ."\" size=\"30\">'; //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; print ' 
"; print '
'; print "trans("TestConnection")."\">"; print "   "; print "trans("Save")."\">"; print "
"; print "
\n"; clearstatcache(); if ($mesg) print "
$mesg
"; print "
"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>