[Mapbender-commits] r9217 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Jun 19 04:42:41 PDT 2015
Author: armin11
Date: 2015-06-19 04:42:40 -0700 (Fri, 19 Jun 2015)
New Revision: 9217
Modified:
trunk/mapbender/http/php/mod_callMetadata.php
trunk/mapbender/http/php/mod_savewmc_server.php
Log:
store wmc to apc on demand
Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php 2015-06-19 11:42:20 UTC (rev 9216)
+++ trunk/mapbender/http/php/mod_callMetadata.php 2015-06-19 11:42:40 UTC (rev 9217)
@@ -48,8 +48,12 @@
$preDefinedMaxResults = array(5,10,15,20,25,30);
$searchEPSG = "EPSG:31466";
$classJSON = new Mapbender_JSON;
-#$tempFolder = "/tmp";
-$tempFolder = TMPDIR;
+
+if (defined('ABSOLUTE_TMPDIR')){
+ $tempFolder = ABSOLUTE_TMPDIR;
+} else {
+ $tempFolder = TMPDIR;
+}
$orderBy = "rank"; //rank or title or id or date
$hostName = $_SERVER['HTTP_HOST'];
$headers = apache_request_headers();
@@ -894,7 +898,9 @@
}
if ($resultTarget == 'file' or $resultTarget == 'webclient') {
$filename = $tempFolder."/".$searchId."_filter.json";
- if (file_exists($filename)) {
+ $admin = new administration();
+ $admin->putToStorage($filename, $queryFilter, TMP_SEARCH_RESULT_STORAGE, TMP_SEARCH_RESULT_MAX_AGE);
+ /*if (file_exists($filename)) {
$e = new mb_notice("php/callMetdata.php: The file $filename exists - it will not be overwritten!");
} else {
@@ -905,7 +911,7 @@
} else {
$e = new mb_notice("php/callMetdata.php: cannot create filter_file!");
}
- }
+ }*/
}
//function to transpose a matrix - sometimes needed to do an array search
@@ -979,7 +985,7 @@
//call class_metadata - in case of file for all requested resources, in case of web only for one resource - cause there are different result files
if ($resultTarget == 'file') {
for($i=0; $i<count($searchResources);$i++){
- $str = "nohup php5 /data/mapbender/http/php/mod_metadataWrite.php ";
+ /*$str = "nohup php5 /data/mapbender/http/php/mod_metadataWrite.php ";
$str .= "'".$userId."' ";
$str .= "'".$searchId."' ";
$str .= "'".$searchText."' ";
@@ -1008,7 +1014,8 @@
$str .= "'".$restrictToOpenData."' ";
$str .= " & ";
$e = new mb_notice($str);
- exec($str);
+ exec($str);*/
+ $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[$i], $searchPages[$i], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader);
}
}
if ($resultTarget == 'web' or $resultTarget == 'debug' or $resultTarget == 'webclient') {
Modified: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php 2015-06-19 11:42:20 UTC (rev 9216)
+++ trunk/mapbender/http/php/mod_savewmc_server.php 2015-06-19 11:42:40 UTC (rev 9217)
@@ -12,57 +12,9 @@
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");
+//require_once(dirname(__FILE__)."/../classes/class_cache.php");
+$admin = new administration();
-function putWmcToStorage($filename, $xml) {
- switch (TMP_WMC_SAVE_STORAGE) {
- case "memcache":
- $memcache_obj = new Memcache;
- if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
- $memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
- } else {
- //use standard options
- $memcache_obj->connect('localhost', 11211);
- }
- new mb_notice("wmc sessions stored via memcache");
- $memcache_obj->set($filename, $xml, 0, TMP_WMC_MAX_AGE);
- $memcache_obj->close();
- return true;
- break;
- case "memcached":
- $memcached_obj = new Memcached;
- if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
- $memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
- } else {
- //use standard options
- $memcached_obj->addServer('localhost', 11211);
- }
- new mb_notice("wmc stored via memcacheD");
- return $memcached_obj->set($filename, $xml, TMP_WMC_MAX_AGE);
- //$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;
- default:
- file_put_contents($filename, $xml);
- break;
- }
-}
-
$ajaxResponse = new AjaxResponse($_POST);
if($ajaxResponse->getMethod() != "saveWMC") {
$ajaxResponse->setSuccess(false);
@@ -116,7 +68,8 @@
}
//
$time_start = microtime();
- putWmcToStorage($filename, $wmc->xml);
+ $wmcXml = $wmc->xml;
+ $admin->putToStorage($filename, $wmcXml, TMP_WMC_SAVE_STORAGE, TMP_WMC_MAX_AGE);
$time_end = microtime();
$timediff = $time_end - $time_start;
$e = new mb_notice('mod_savewmc_server.php: time to save wmc to storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
@@ -160,14 +113,14 @@
$wmc->wmc_srs = $map->epsg;
}
// make a keyword array here
- $kwds = explode(",",$attributes->keywords);
- $wmckwds = $wmc->keyword;
- if(is_array($wmckwds)) {
- foreach ($wmckwds as &$val) {
- $val = trim($val);
- }
- }
- $wmc->keyword = $wmckwds;
+ $kwds = explode(",",$attributes->keywords);
+ $wmckwds = $wmc->keyword;
+ if(is_array($wmckwds)) {
+ foreach ($wmckwds as &$val) {
+ $val = trim($val);
+ }
+ }
+ $wmc->keyword = $wmckwds;
$wmc->wmc_keyword = $kwds;
$wmc->wmc_abstract = $attributes->abstract;
More information about the Mapbender_commits
mailing list