[Mapbender-commits] r8840 - in trunk/mapbender: conf cors_proxy/http http/javascripts http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon May 12 02:41:39 PDT 2014
Author: armin11
Date: 2014-05-12 02:41:39 -0700 (Mon, 12 May 2014)
New Revision: 8840
Modified:
trunk/mapbender/conf/mapbender.conf-dist
trunk/mapbender/cors_proxy/http/index.php
trunk/mapbender/http/javascripts/initWmcObj.php
trunk/mapbender/http/php/mod_savewmc_server.php
Log:
Bugfix for cors proxy and possibility to store mapbenders temporal wmc alternativly to apc cache via class_cache.php.
Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist 2014-05-12 08:56:28 UTC (rev 8839)
+++ trunk/mapbender/conf/mapbender.conf-dist 2014-05-12 09:41:39 UTC (rev 8840)
@@ -255,12 +255,19 @@
#define("MAPBENDER_VARIABLE_CACHE", false);
#define("MAPBENDER_CACHE_TYPE", "apc");
+# --------------------------------------------
# define memcached server connections, if memcached ist used for session storing
# lib/class_Mapbender_session.php
#
#define("MEMCACHED_IP", "localhost");
#define("MEMCACHED_PORT", "11211");
+# --------------------------------------------
+# define where to store temporary wmc documents (client configurations) when switching between applications. Needed if mb is integrated as iframe in external applications
+# --------------------------------------------
+define("TMP_WMC_SAVE_STORAGE", "file"); #memcached, memcache, #session - not yet implemented, file, cache (apc - thru class_cache.php - there is no possibility to delete those elements when using apc)
+define("TMP_WMC_MAX_AGE", "2400"); # Max age in seconds for temporal wmc before it will be deleted by e.g. a cronjob or by memcached itself
+
#---------------------------------------------
# HOSTNAME WHITELIST
# The whitelist is used for some modules who generate urls from a given hostName GET parameter. In such a case it is usefull to give a whitelist for security reasons! If no hostName is given, the parameter $_SERVER['HTTP_HOST'] is used for the urls!
Modified: trunk/mapbender/cors_proxy/http/index.php
===================================================================
--- trunk/mapbender/cors_proxy/http/index.php 2014-05-12 08:56:28 UTC (rev 8839)
+++ trunk/mapbender/cors_proxy/http/index.php 2014-05-12 09:41:39 UTC (rev 8840)
@@ -78,6 +78,8 @@
} else {
throwExceptionXml('','Mapbenders cors_proxy has no whitelist defined, check your configuration!');
}
+//check if wms has open data licence!
+//TODO
$n = new administration();
//get authentication infos if they are available in wms table! if not $auth = false
$auth = $n->getAuthInfoOfWMS($wmsId);
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2014-05-12 08:56:28 UTC (rev 8839)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2014-05-12 09:41:39 UTC (rev 8840)
@@ -13,6 +13,7 @@
require_once(dirname(__FILE__) . "/../classes/class_tou.php");
require_once(dirname(__FILE__)."/../classes/class_connector.php");
require_once(dirname(__FILE__)."/../classes/class_owsConstraints.php");
+require_once(dirname(__FILE__)."/../classes/class_cache.php");
function getConfiguration ($key) {
//check if key param can be found in SESSION,
@@ -44,7 +45,7 @@
//use standard options
$memcache_obj->connect('localhost', 11211);
}
- new mb_notice("wmc sessions stored via memcache");
+ new mb_notice("wmc sessions load via memcache");
$wmc = $memcache_obj->get($filename);
$memcache_obj->close();
return $wmc;
@@ -57,11 +58,20 @@
//use standard options
$memcached_obj->addServer('localhost', 11211);
}
- new mb_notice("wmc stored via memcacheD");
+ new mb_notice("wmc load via memcacheD");
$wmc = $memcached_obj->get($filename);
//$memcached_obj->quit();
return $wmc;
break;
+ case "cache":
+ $cache = new Cache();
+ if ($cache->isActive && $cache->cachedVariableExists($filename)) {
+ $wmc = $cache->cachedVariableFetch($filename);
+ return $wmc;
+ } else {
+ return false;
+ }
+ break;
case "file":
$wmc = file_get_contents($filename);
return $wmc;
@@ -113,7 +123,7 @@
$wmcDocSession = getWmcFromStorage($wmc_filename);
$time_end = microtime();
$timediff = $time_end - $time_start;
- $e = new mb_exception('initWmcObj.php: time to load wmc from storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
+ $e = new mb_notice('initWmcObj.php: time to load wmc from storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
}
try {
$loadFromSession = new ElementVar($app, "loadwmc", "loadFromSession");
Modified: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php 2014-05-12 08:56:28 UTC (rev 8839)
+++ trunk/mapbender/http/php/mod_savewmc_server.php 2014-05-12 09:41:39 UTC (rev 8840)
@@ -12,6 +12,7 @@
require_once(dirname(__FILE__)."/../classes/class_wmc.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
require_once(dirname(__FILE__)."/../classes/class_lzw_decompress.php");
+require_once(dirname(__FILE__)."/../classes/class_cache.php");
function putWmcToStorage($filename, $xml) {
switch (TMP_WMC_SAVE_STORAGE) {
@@ -41,6 +42,18 @@
//$memcached_obj->quit();
return true;
break;
+ case "cache":
+ $cache = new Cache();
+ if ($cache->isActive) {
+ if ($cache->cachedVariableExists($filename)) {
+ $cache->cachedVariableDelete($filename);
+ }
+ return $cache->cachedVariableAdd($filename,$xml);
+ new mb_notice("wmc stored via cache");
+ } else {
+ return false;
+ }
+ break;
case "file":
file_put_contents($filename, $xml);
break;
@@ -50,10 +63,6 @@
}
}
-
-
-
-
$ajaxResponse = new AjaxResponse($_POST);
if($ajaxResponse->getMethod() != "saveWMC") {
$ajaxResponse->setSuccess(false);
@@ -74,24 +83,18 @@
$overwrite = $ajaxResponse->getParameter('overwrite');
$overwrite = $overwrite == "1" ? true : false;
//for debugging, write mapObject to file
-
if ($lzwCompressed == 'true') {
//$e = new mb_exception('mod_savewmc_server.php: mapObject: '.implode(',',$mapObject));
$mapObject = lzw_decompress($mapObject);
-
//$e = new mb_exception('mod_savewmc_server.php: mapObject uncompressed: '.$mapObject);
//$filename = TMPDIR."/formerly_compressed_json.txt";//will be set to new one cause ?
} else {
//$filename = TMPDIR."/formerly_uncompressed_json.txt";//will be set to new one cause ?
}
//file_put_contents($filename, $mapObject);
-
-
//$e = new mb_exception('mod_savewmc_server.php: mapObject is here ;-)');
$mapObject = $json->decode($mapObject);
-
$e = new mb_notice('mod_savewmc_server.php: mapObject has been decoded from json');
-
// create WMC object
$wmc = new wmc();
if($overwrite) {
@@ -116,10 +119,7 @@
putWmcToStorage($filename, $wmc->xml);
$time_end = microtime();
$timediff = $time_end - $time_start;
- $e = new mb_exception('mod_savewmc_server.php: time to save wmc to storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
-
- //file_put_contents($filename, $wmc->xml);
- //put filename into session
+ $e = new mb_notice('mod_savewmc_server.php: time to save wmc to storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
Mapbender::session()->set("mb_wmc",$filename);
$epsgString = $wmc->mainMap->extentToJavascript();
// get epsg code from jquery string
More information about the Mapbender_commits
mailing list