svn commit: r900 - trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php

christoph at osgeo.org christoph at osgeo.org
Tue Nov 21 03:57:13 EST 2006


Author: christoph
Date: 2006-11-21 08:57:13+0000
New Revision: 900

Modified:
   trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php

Log:
* added utf8_encoding
* only insert in db if ID and wmc are given


Modified: trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php?view=diff&rev=900&p1=trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php&p2=trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php&r1=899&r2=900
==============================================================================
--- trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php	(original)
+++ trunk/mapbender/http/javascripts/mod_insertWmcIntoDb.php	2006-11-21 08:57:13+0000
@@ -1,5 +1,5 @@
 <?php
-#$Id: mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
 #$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
 # Copyright (C) 2002 CCGIS 
 #
@@ -49,6 +49,16 @@
 </body>
 </html>
 <?php
+
+function mb_utf8_encode ($str) {
+	if(CHARSET=="UTF-8") return utf8_encode($str);
+	return $str;
+}
+function mb_utf8_decode ($str) {
+	if(CHARSET=="UTF-8") return utf8_decode($str);
+	return $str;
+}
+
 if ($_POST["data"]) {
 	$d = explode("____", $_POST["data"]);	
 	// Display WMC 
@@ -58,25 +68,28 @@
 	
 	if ($session) {
 		echo "<script>document.write('<b>saving workspace...</b>');</script>";
-//		$sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&#38;" , html_entity_decode($d[2])) . "', '" . $d[1] . "', '" . time() . "')";
-//		$res = db_query($sql);
-		$_SESSION['mb_wmc'] = str_replace("&", "&#38;" , html_entity_decode($d[2]));
+
+		if (isset($_SESSION['mb_wmc'])) {
+			$_SESSION['mb_wmc'] = stripslashes(str_replace("&", "&#38;" , mb_utf8_encode(html_entity_decode($d[2]))));
+		}
 		echo "<script>function obsolete(){window.close();} window.setTimeout('obsolete()', 1000);</script>";
 	}
 	else {
-		$sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&#38;" , html_entity_decode($d[2])) . "', '" . $d[1] . "', '" . time() . "')";
-		
-		
-		$res = db_query($sql);
-		if ($d[1]) {
-			 $wmc_title = "'" . $d[1] . "' ";
-		}
-		if (db_error()) {
-				 echo "<script>var title = \"" . $wmc_title . "\";alert(\"Error while saving WMC document \" + title + \"!\");</script>";
-		}
-		else {
-			if ($alert) {
-				 echo "<script>var title = \"" . $wmc_title . "\";alert(\"WMC document \" + title + \"has been saved!\")</script>";
+		if ($d[3] && $d[0]) {
+			$sql = "INSERT INTO mb_user_wmc VALUES ('" . $d[3] . "', '" . $d[0] . "', '" . str_replace("&", "&#38;" , mb_utf8_encode(html_entity_decode($d[2]))) . "', '" . $d[1] . "', '" . time() . "')";
+			
+			
+			$res = db_query($sql);
+			if ($d[1]) {
+				 $wmc_title = "'" . $d[1] . "' ";
+			}
+			if (db_error()) {
+					 echo "<script>var title = \"" . $wmc_title . "\";alert(\"Error while saving WMC document \" + title + \"!\");</script>";
+			}
+			else {
+				if ($alert) {
+					 echo "<script>var title = \"" . $wmc_title . "\";alert(\"WMC document \" + title + \"has been saved!\")</script>";
+				}
 			}
 		}
 	}




More information about the Mapbender_commits mailing list