From 6071ad5264f8f3895ddaa1b4cc50cce899d96bc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sat, 9 Jul 2005 23:31:10 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Proc=E9dure=20de=20test=20connexion=20ba?= =?UTF-8?q?se=20webcalendar=20plus=20bind=E9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/webcalendar.php | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php index a38d493e279..fa4bf7ad1c0 100644 --- a/htdocs/admin/webcalendar.php +++ b/htdocs/admin/webcalendar.php @@ -52,13 +52,13 @@ $phpwebcalendar_user=trim($_POST["phpwebcalendar_user"]); $phpwebcalendar_pass=trim($_POST["phpwebcalendar_pass"]); $phpwebcalendar_pass2=trim($_POST["phpwebcalendar_pass2"]); $phpwebcalendar_syncro=trim($_POST["phpwebcalendar_syncro"]); -$actionsave=$_POST["save"]; $actiontest=$_POST["test"]; +$actionsave=$_POST["save"]; // Test saisie mot de passe if ($phpwebcalendar_pass != $phpwebcalendar_pass2) { - $ok="<font class=\"error\">".$langs->trans("ErrorPasswordDiffers")."</font>"; + $ok="<div class=\"error\">".$langs->trans("ErrorPasswordDiffers")."</div>"; } // Positionne la variable pour le test d'affichage de l'icone elseif ($actionsave) @@ -105,13 +105,16 @@ elseif ($actionsave) } } -if (! $phpwebcalendar_url) { $phpwebcalendar_url=PHPWEBCALENDAR_URL; } -if (! $phpwebcalendar_host) { $phpwebcalendar_host=PHPWEBCALENDAR_HOST; } -if (! $phpwebcalendar_dbname) { $phpwebcalendar_dbname=PHPWEBCALENDAR_DBNAME; } -if (! $phpwebcalendar_user) { $phpwebcalendar_user=PHPWEBCALENDAR_USER; } -if (! $phpwebcalendar_pass) { $phpwebcalendar_pass=PHPWEBCALENDAR_PASS; } -if (! $phpwebcalendar_pass2) { $phpwebcalendar_pass2=PHPWEBCALENDAR_PASS; } -if (! $phpwebcalendar_syncro) { $phpwebcalendar_syncro=PHPWEBCALENDAR_SYNCRO; } +if (! $actiontest && ! $actionsave) +{ + if (! $phpwebcalendar_url) { $phpwebcalendar_url=PHPWEBCALENDAR_URL; } + if (! $phpwebcalendar_host) { $phpwebcalendar_host=PHPWEBCALENDAR_HOST; } + if (! $phpwebcalendar_dbname) { $phpwebcalendar_dbname=PHPWEBCALENDAR_DBNAME; } + if (! $phpwebcalendar_user) { $phpwebcalendar_user=PHPWEBCALENDAR_USER; } + if (! $phpwebcalendar_pass) { $phpwebcalendar_pass=PHPWEBCALENDAR_PASS; } + if (! $phpwebcalendar_pass2) { $phpwebcalendar_pass2=PHPWEBCALENDAR_PASS; } + if (! $phpwebcalendar_syncro) { $phpwebcalendar_syncro=PHPWEBCALENDAR_SYNCRO; } +} /** @@ -167,27 +170,46 @@ print "</form>\n"; clearstatcache(); if ($ok) print "<br>$ok<br>"; - +print "<br>"; // Test de la connection a la database webcalendar if ($actiontest && ($phpwebcalendar_pass == $phpwebcalendar_pass2)) { + // Test connexion $webcal = new DoliDb('',$phpwebcalendar_host,$phpwebcalendar_user,$phpwebcalendar_pass,$phpwebcalendar_dbname); if ($webcal->connected == 1 && $webcal->database_selected == 1) { - print "<br><font class=\"ok\">".$langs->trans("WebCalTestOk",$phpwebcalendar_host,$phpwebcalendar_dbname,$phpwebcalendar_user)."</font><br>"; + // V�rifie si bonne base + $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'"; + $resql=$webcal->query($sql); + if ($resql) { + $mesg ="<div class=\"ok\">".$langs->trans("WebCalTestOk",$phpwebcalendar_host,$phpwebcalendar_dbname,$phpwebcalendar_user); + $mesg.="</div>"; + } + else { + $mesg ="<div class=\"error\">".$langs->trans("ErrorConnectOkButWrongDatabase"); + $mesg.=$webcal->error; + $mesg.="</div>"; + } + $webcal->close(); } - elseif ($webcal->connected == 1) + elseif ($webcal->connected == 1 && $webcal->database_selected != 1) { - print "<br><font class=\"error\">".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname)."</font><br>"; + $mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname); + $mesg.="<br>".$webcal->error; + $mesg.="</div>"; $webcal->close(); } else { - print "<br><font class=\"error\">".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user)."</font><br>"; + $mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user); + $mesg.="<br>".$webcal->error; + $mesg.="</div>"; } + + print $mesg; } -- GitLab