diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php
index cb3695d23da..54b4c8f4325 100644
--- a/htdocs/admin/webcalendar.php
+++ b/htdocs/admin/webcalendar.php
@@ -33,7 +33,7 @@
require("./pre.inc.php");
if (!$user->admin)
-accessforbidden();
+ accessforbidden();
llxHeader();
@@ -43,128 +43,101 @@ print '
';
$def = array();
-$phpwebcalendar_url=$_POST["phpwebcalendar_url"];
-$phpwebcalendar_host=$_POST["phpwebcalendar_host"];
-$phpwebcalendar_dbname=$_POST["phpwebcalendar_dbname"];
-$phpwebcalendar_user=$_POST["phpwebcalendar_user"];
-$phpwebcalendar_pass=$_POST["phpwebcalendar_pass"];
-$phpwebcalendar_pass2=$_POST["phpwebcalendar_pass2"];
+$phpwebcalendar_url=trim($_POST["phpwebcalendar_url"]);
+$phpwebcalendar_host=trim($_POST["phpwebcalendar_host"]);
+$phpwebcalendar_dbname=trim($_POST["phpwebcalendar_dbname"]);
+$phpwebcalendar_user=trim($_POST["phpwebcalendar_user"]);
+$phpwebcalendar_pass=trim($_POST["phpwebcalendar_pass"]);
+$phpwebcalendar_pass2=trim($_POST["phpwebcalendar_pass2"]);
$actionsave=$_POST["save"];
$actiontest=$_POST["test"];
// Positionne la variable pour le test d'affichage de l'icone
if ($actionsave)
{
- if (trim($phpwebcalendar_pass) == trim($phpwebcalendar_pass2))
+ if ($phpwebcalendar_pass == $phpwebcalendar_pass2)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_URL';";
-
- $db->query($sql);
-
- $sql='';
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
- ('PHPWEBCALENDAR_URL','".$phpwebcalendar_url."',0);";
-
- $db->query($sql);
-
- $sql='';
-
- $sql1 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_HOST';";
-
- $db->query($sql1);
-
- $sql1 = '';
-
- $sql1 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_HOST','".$phpwebcalendar_host."',0);";
+ $db->query($sql);
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_URL','".$phpwebcalendar_url."',0);";
+ $result=$db->query($sql);
+
+ $sql1 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_HOST';";
+ $db->query($sql1);
+
+ $sql1 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_HOST','".$phpwebcalendar_host."',0);";
+ $result1=$db->query($sql1);
+
+ $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_DBNAME';";
+ $db->query($sql2);
+
+ $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_DBNAME','".$phpwebcalendar_dbname."',0);";
+ $result2=$db->query($sql2);
+
+ $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_USER' ;";
+ $db->query($sql3);
+
+ $sql3 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_USER','".$phpwebcalendar_user."',0);";
+ $result3=$db->query($sql3);
+
+ $sql4 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_PASS';";
+ $db->query($sql4);
+
+ $sql4 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_PASS','".$phpwebcalendar_pass."',0);";
+ $result4=$db->query($sql4);
- $db->query($sql1);
-
- $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_DBNAME';";
-
- $db->query($sql2);
-
- $sql2='';
-
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
- ('PHPWEBCALENDAR_DBNAME','".$phpwebcalendar_dbname."',0);";
-
- $db->query($sql2);
-
- $sql2='';
-
- $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_USER' ;";
-
- $db->query($sql3);
-
- $sql3='';
-
- $sql3 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
- ('PHPWEBCALENDAR_USER','".$phpwebcalendar_user."',0);";
-
- $sql4 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_PASS';";
-
- $db->query($sql4);
-
- $sql4='';
-
- $sql4 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
- ('PHPWEBCALENDAR_PASS','".$phpwebcalendar_pass."',0);";
-
- $db->query($sql4);
-
- if ($db->query($sql) && $db->query($sql1) && $db->query($sql2) && $db->query($sql3) && $db->query($sql4))
+ if ($result && $result1 && $result2 && $result3 && $result4)
{
- // la constante qui a été lue en avant du nouveau set
- // on passe donc par une variable pour avoir un affichage cohérent
- define("PHPWEBCALENDAR_URL", $phpwebcalendar_url);
- define("PHPWEBCALENDAR_HOST", $phpwebcalendar_host);
- define("PHPWEBCALENDAR_DBNAME",$phpwebcalendar_dbname);
- define("PHPWEBCALENDAR_USER", $phpwebcalendar_user);
- define("PHPWEBCALENDAR_PASS", $phpwebcalendar_pass);
- $ok = "
Les identifiants webcalendar ont été sauvegardés.
"; + $ok = "Le mot de passe n'est pas identique, veuillez le saisir à nouveau