[Mapbender-commits] r8834 - trunk/mapbender/cors_proxy/http
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 8 07:52:35 PDT 2014
Author: armin11
Date: 2014-05-08 07:52:35 -0700 (Thu, 08 May 2014)
New Revision: 8834
Modified:
trunk/mapbender/cors_proxy/http/index.php
Log:
Modified: trunk/mapbender/cors_proxy/http/index.php
===================================================================
--- trunk/mapbender/cors_proxy/http/index.php 2014-05-08 14:46:34 UTC (rev 8833)
+++ trunk/mapbender/cors_proxy/http/index.php 2014-05-08 14:52:35 UTC (rev 8834)
@@ -27,6 +27,7 @@
$width = 400;
$height = 400;
$tmpSession = false;
+$corsAllowedFor = false;
//parse url
$query = new QueryHandler();
$reqParams = $query->getRequestParams();
@@ -71,6 +72,8 @@
$CORS_WHITELIST_array = explode(" ",CORS_WHITELIST);
if (!in_array($originFromHeader,$CORS_WHITELIST_array)) {
throwExceptionXml('','Server not found in whitelist of cors_proxy, please check your configuration!');
+ } else {
+ $corsAllowedFor = $originFromHeader;
}
} else {
throwExceptionXml('','Mapbenders cors_proxy has no whitelist defined, check your configuration!');
@@ -185,10 +188,14 @@
* @param string the original url of the image to send
*/
function getImage($or){
- global $reqParams;
+ global $reqParams, $corsAllowedFor;
header("Content-Type: ".$reqParams['format']);
//set cors header
- header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ if ($corsAllowedFor != false) {
+ header('Access-Control-Allow-Origin: '.$corsAllowedFor);
+ } else {
+ header('Access-Control-Allow-Origin: '."");
+ }
//log the image_requests to database
//log the following to table mb_proxy_log
//timestamp,user_id,getmaprequest,amount pixel,price - but do this only for wms to log - therefor first get log tag out of wms!
@@ -246,10 +253,15 @@
}
function responseImage($im){
- global $reqParams;
+ global $reqParams, $corsAllowedFor;
$format = $reqParams['format'];
$format="image/gif";
- header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ if ($corsAllowedFor != false) {
+ header('Access-Control-Allow-Origin: '.$corsAllowedFor);
+ } else {
+ header('Access-Control-Allow-Origin: '."");
+ }
+
if($format == 'image/png'){header("Content-Type: image/png");}
if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
if($format == 'image/gif'){header("Content-Type: image/gif");}
More information about the Mapbender_commits
mailing list