2004-10-19 20:58:50 +02:00
|
|
|
|
<?php
|
2003-03-13 19:28:27 +01:00
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-09-01 23:23:20 +02:00
|
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
2006-03-23 17:02:52 +01:00
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
|
|
|
|
|
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-03-13 19:28:27 +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$
|
|
|
|
|
|
*/
|
2004-08-29 14:01:58 +02:00
|
|
|
|
|
2006-03-23 17:02:52 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/admin/boutique.php
|
2004-08-29 14:01:58 +02:00
|
|
|
|
\ingroup boutique
|
2006-03-23 17:02:52 +01:00
|
|
|
|
\brief Page d'administration/configuration du module OsCommerce
|
2004-08-29 14:01:58 +02:00
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-03-13 19:28:27 +01:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
|
2004-08-29 14:01:58 +02:00
|
|
|
|
$langs->load("admin");
|
2006-08-04 03:44:29 +02:00
|
|
|
|
$langs->load("oscommerce");
|
2004-08-29 14:01:58 +02:00
|
|
|
|
|
|
|
|
|
|
if (!$user->admin)
|
|
|
|
|
|
accessforbidden();
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-04 03:44:29 +02:00
|
|
|
|
|
2006-03-23 17:02:52 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
2003-03-13 19:28:27 +01:00
|
|
|
|
|
2006-08-04 03:44:29 +02:00
|
|
|
|
if ($_POST["save"])
|
2003-03-13 19:28:27 +01:00
|
|
|
|
{
|
2006-08-04 03:44:29 +02:00
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
|
|
if ($i >= 4)
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->commit();
|
|
|
|
|
|
$mesg = "<font class=\"ok\">".$langs->trans("OSCommerceSetupSaved")."</font>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$db->rollback();
|
|
|
|
|
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
2003-03-13 19:28:27 +01:00
|
|
|
|
}
|
2006-08-04 03:44:29 +02:00
|
|
|
|
elseif ($_POST["test"])
|
2003-03-13 19:28:27 +01:00
|
|
|
|
{
|
2006-08-04 03:44:29 +02:00
|
|
|
|
//$resql=$db->query("select count(*) from llx_const");
|
|
|
|
|
|
//print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n";
|
|
|
|
|
|
|
|
|
|
|
|
// Test de la connection a la database webcalendar
|
|
|
|
|
|
$conf->oscommerce->db->type=$dolibarr_main_db_type;
|
|
|
|
|
|
$conf->oscommerce->db->host=$_POST["oscommerce_dbhost"];
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
|
|
//print "D ".$db." - ".$db->db."<br>\n";
|
|
|
|
|
|
//print "W ".$oscommercedb." - ".$oscommercedb->db."<br>\n";
|
|
|
|
|
|
|
|
|
|
|
|
if ($oscommercedb->connected == 1 && $oscommercedb->database_selected == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
// V<>rifie si bonne base par requete sur une table OSCommerce
|
2006-09-03 15:57:44 +02:00
|
|
|
|
$sql ="SELECT configuration_value";
|
|
|
|
|
|
$sql.=" FROM configuration";
|
|
|
|
|
|
$sql.=" WHERE configuration_key='STORE_NAME'";
|
2006-08-04 03:44:29 +02:00
|
|
|
|
$resql=$oscommercedb->query($sql);
|
|
|
|
|
|
if ($resql) {
|
|
|
|
|
|
$mesg ="<div class=\"ok\">".$langs->trans("OSCommerceTestOk",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"],$_POST["oscommerce_dbuser"]);
|
|
|
|
|
|
$mesg.="</div>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
2006-09-03 15:57:44 +02:00
|
|
|
|
$mesg ="<div class=\"error\">".$langs->trans("OSCommerceErrorConnectOkButWrongDatabase");
|
2006-08-04 03:44:29 +02:00
|
|
|
|
$mesg.="</div>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//$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 ="<div class=\"error\">".$langs->trans("OSCommerceTestKo1",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"]);
|
|
|
|
|
|
$mesg.="<br>".$oscommercedb->error();
|
|
|
|
|
|
$mesg.="</div>";
|
|
|
|
|
|
//$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$mesg ="<div class=\"error\">".$langs->trans("OSCommerceTestKo2",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbuser"]);
|
|
|
|
|
|
$mesg.="<br>".$oscommercedb->error();
|
|
|
|
|
|
$mesg.="</div>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//$resql=$db->query("select count(*) from llx_const");
|
|
|
|
|
|
//print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n";
|
2003-03-13 19:28:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-03-23 17:02:52 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Affichage page
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
llxHeader();
|
2003-03-13 19:28:27 +01:00
|
|
|
|
|
2006-08-12 17:32:57 +02:00
|
|
|
|
print_fiche_titre($langs->trans("OSCommerceSetup"),'','setup');
|
2003-03-13 19:28:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
2006-08-04 03:44:29 +02:00
|
|
|
|
|
|
|
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
$var=true;
|
|
|
|
|
|
print '<form name="oscommerceconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
|
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
|
|
|
|
|
print "<tr class=\"liste_titre\">";
|
|
|
|
|
|
print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
|
|
|
|
|
|
print "<td>".$langs->trans("Value")."</td>";
|
|
|
|
|
|
print "<td>".$langs->trans("Examples")."</td>";
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr ".$bc[$var].">";
|
|
|
|
|
|
print "<td>".$langs->trans("OSCOmmerceServer")."</td>";
|
|
|
|
|
|
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbhost\" value=\"". ($_POST["oscommerce_dbhost"]?$_POST["oscommerce_dbhost"]:$conf->global->OSC_DB_HOST) . "\" size=\"30\"></td>";
|
|
|
|
|
|
print "<td>localhost";
|
|
|
|
|
|
//print "<br>__dolibarr_main_db_host__ <i>(".$dolibarr_main_db_host.")</i>"
|
|
|
|
|
|
print "</td>";
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr ".$bc[$var].">";
|
|
|
|
|
|
print "<td>".$langs->trans("OSCOmmerceDatabaseName")."</td>";
|
|
|
|
|
|
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbname\" value=\"". ($_POST["oscommerce_dbname"]?$_POST["oscommerce_dbname"]:$conf->global->OSC_DB_NAME) . "\" size=\"30\"></td>";
|
|
|
|
|
|
print "<td>oscommerce";
|
|
|
|
|
|
//print "<br>__dolibarr_main_db_name__ <i>(".$dolibarr_main_db_name.")</i>";
|
|
|
|
|
|
print "</td>";
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr ".$bc[$var].">";
|
|
|
|
|
|
print "<td>".$langs->trans("OSCOmmerceUser")."</td>";
|
|
|
|
|
|
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbuser\" value=\"". ($_POST["oscommerce_dbuser"]?$_POST["oscommerce_dbuser"]:$conf->global->OSC_DB_USER) . "\" size=\"30\"></td>";
|
|
|
|
|
|
print "<td>oscommerceuser";
|
|
|
|
|
|
//print "<br>__dolibarr_main_db_user__ <i>(".$dolibarr_main_db_user.")</i>";
|
|
|
|
|
|
print "</td>";
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr ".$bc[$var].">";
|
|
|
|
|
|
print "<td>".$langs->trans("Password")."</td>";
|
|
|
|
|
|
print "<td><input type=\"password\" class=\"flat\" name=\"oscommerce_dbpass\" value=\"" . ($_POST["oscommerce_dbpass"]?$_POST["oscommerce_dbpass"]:$conf->global->OSC_DB_PASS) . "\" size=\"30\"></td>";
|
|
|
|
|
|
print '<td>';
|
|
|
|
|
|
//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>';
|
|
|
|
|
|
print ' </td>';
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr ".$bc[$var].">";
|
|
|
|
|
|
print "<td>".$langs->trans("PasswordRetype")."</td>";
|
|
|
|
|
|
print "<td><input type=\"password\" class=\"flat\" name=\"oscommerce_dbpass2\" value=\"" . ($_POST["oscommerce_dbpass2"]?$_POST["oscommerce_dbpass2"]:$conf->global->OSC_DB_PASS) ."\" size=\"30\"></td>";
|
|
|
|
|
|
print '<td>';
|
|
|
|
|
|
//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>';
|
|
|
|
|
|
print ' </td>';
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<br><center>';
|
|
|
|
|
|
print "<input type=\"submit\" name=\"test\" class=\"button\" value=\"".$langs->trans("TestConnection")."\">";
|
|
|
|
|
|
print " ";
|
|
|
|
|
|
print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
|
|
|
|
|
|
print "</center>";
|
|
|
|
|
|
|
|
|
|
|
|
print "</form>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clearstatcache();
|
|
|
|
|
|
|
|
|
|
|
|
if ($mesg) print "<br>$mesg<br>";
|
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
|
2006-03-23 17:02:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
2003-03-13 19:28:27 +01:00
|
|
|
|
?>
|