* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent * * 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 3 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, see . * */ /** * \file htdocs/boutique/admin/boutique.php * \ingroup boutique * \brief Page d'administration/configuration du module OsCommerce */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); $langs->load("oscommerce"); if (!$user->admin) accessforbidden(); /* * Actions */ if (GETPOST('save','alpha')) { $db->begin(); $i=0; $i+=dolibarr_set_const($db,'OSC_DB_HOST',trim(GETPOST('oscommerce_dbhost','alpha')),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'OSC_DB_NAME',trim(GETPOST('oscommerce_dbname','alpha')),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'OSC_DB_USER',trim(GETPOST('oscommerce_dbuser','alpha')),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'OSC_DB_PASS',trim(GETPOST('oscommerce_dbpass','alpha')),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'OSC_DB_TABLE_PREFIX',trim(GETPOST('oscommerce_db_table_prefix','alpha')),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'OSC_LANGUAGE_ID',1,'chaine',0,'',$conf->entity); if ($i >= 4) { $db->commit(); $mesg = "".$langs->trans("OSCommerceSetupSaved").""; } else { $db->rollback(); header("Location: ".$_SERVER["PHP_SELF"]); exit; } } elseif (GETPOST('test','alpha')) { //$resql=$db->query("select count(*) from ".MAIN_DB_PREFIX."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=GETPOST('oscommerce_dbhost','alpha'); $conf->oscommerce->db->port=GETPOST('oscommerce_dbport','alpha'); $conf->oscommerce->db->name=GETPOST('oscommerce_dbname','alpha'); $conf->oscommerce->db->user=GETPOST('oscommerce_dbuser','alpha'); $conf->oscommerce->db->pass=GETPOST('oscommerce_dbpass','alpha'); $oscommercedb=getDoliDBInstance($conf->oscommerce->db->type,$conf->oscommerce->db->host,$conf->oscommerce->db->user,$conf->oscommerce->db->pass,$conf->oscommerce->db->name,$conf->oscommerce->db->port); if ($oscommercedb->connected == 1 && $oscommercedb->database_selected == 1) { // Verifie 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",GETPOST('oscommerce_dbhost','alpha'),GETPOST('oscommerce_dbname','alpha'),GETPOST('oscommerce_dbuser','alpha')); $mesg.="
"; } else { $mesg ="
".$langs->trans("OSCommerceErrorConnectOkButWrongDatabase",'STORE_NAME',GETPOST('oscommerce_db_table_prefix','alpha')."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",GETPOST('oscommerce_dbhost','alpha'),GETPOST('oscommerce_dbname','alpha')); $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",GETPOST('oscommerce_dbhost','alpha'),GETPOST('oscommerce_dbuser','alpha')); $mesg.="
".$oscommercedb->error(); $mesg.="
"; } //$resql=$db->query("select count(*) from ".MAIN_DB_PREFIX."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 ""; 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__ ('.preg_replace('/./i','*',$dolibarr_main_db_pass).')'; print ' 
".$langs->trans("PasswordRetype")."global->OSC_DB_PASS) ."\" size=\"30\">'; //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.preg_replace('/./i','*',$dolibarr_main_db_pass).')'; print ' 
"; print '
'; print "trans("TestConnection")."\">"; print "   "; print "trans("Save")."\">"; print "
"; print "
\n"; dol_htmloutput_mesg($mesg); $db->close(); llxFooter(); ?>