[fusion-commits] r1392 - in trunk: MapGuide MapGuide/php lib widgets/Print

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue May 6 15:21:00 EDT 2008


Author: madair
Date: 2008-05-06 15:21:00 -0400 (Tue, 06 May 2008)
New Revision: 1392

Modified:
   trunk/MapGuide/MapGuide.js
   trunk/MapGuide/php/Common.php
   trunk/lib/MGBroker.js
   trunk/widgets/Print/printablepage.templ
Log:
closes #55: patch applied to trunk

Modified: trunk/MapGuide/MapGuide.js
===================================================================
--- trunk/MapGuide/MapGuide.js	2008-05-06 19:15:55 UTC (rev 1391)
+++ trunk/MapGuide/MapGuide.js	2008-05-06 19:21:00 UTC (rev 1392)
@@ -50,6 +50,8 @@
 
     //the resource id of the current MapDefinition
     _sResourceId: null,
+
+    clientAgent: 'Fusion Viewer',
     
     initialize : function(map, mapTag, isMapWidgetLayer) {
         // console.log('MapGuide.initialize');
@@ -490,7 +492,8 @@
       if ( bSingleTile ) {
         params = {        //single tile params
           session : this.getSessionID(),
-          mapName : this._sMapname
+          mapname : this._sMapname,
+          clientagent : this.clientAgent
         };
         params.showLayers = this.aShowLayers.length > 0 ? this.aShowLayers.toString() : null;
         params.hideLayers = this.aHideLayers.length > 0 ? this.aHideLayers.toString() : null;
@@ -504,7 +507,8 @@
       } else {
         params = {      //tiled version
           mapdefinition: this._sResourceId,
-          basemaplayergroupname: this.groupName  //assumes only one group for now
+          basemaplayergroupname: this.groupName,  //assumes only one group for now
+          clientagent : this.clientAgent
         };
       }
 
@@ -1180,6 +1184,7 @@
 */
 
 Fusion.Maps.MapGuide.StyleItem = OpenLayers.Class({
+    clientAgent: 'Fusion Viewer',
     initialize: function(o, staticIcon) {
         this.legendLabel = o.legendLabel;
         this.filter = o.filter;
@@ -1195,6 +1200,6 @@
     },
     getLegendImageURL: function(fScale, layer) {
         var url = Fusion.getConfigurationItem('mapguide', 'mapAgentUrl');
-        return url + "OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID() + "&VERSION=1.0.0&SCALE=" + fScale + "&LAYERDEFINITION=" + encodeURIComponent(layer.resourceId) + "&THEMECATEGORY=" + this.categoryIndex + "&TYPE=" + this.geometryType;
+        return url + "OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID() + "&VERSION=1.0.0&SCALE=" + fScale + "&LAYERDEFINITION=" + encodeURIComponent(layer.resourceId) + "&THEMECATEGORY=" + this.categoryIndex + "&TYPE=" + this.geometryType + "&CLIENTAGENT=" + encodeURIComponent(this.clientAgent);
     }
 });

Modified: trunk/MapGuide/php/Common.php
===================================================================
--- trunk/MapGuide/php/Common.php	2008-05-06 19:15:55 UTC (rev 1391)
+++ trunk/MapGuide/php/Common.php	2008-05-06 19:21:00 UTC (rev 1392)
@@ -74,6 +74,8 @@
         $username = isset($_REQUEST['username']) ? $_REQUEST['username'] : 'Anonymous';
         $password = isset($_REQUEST['password']) ? $_REQUEST['password'] : '';
         $user = new MgUserInformation($username, $password);
+        $user->SetClientIp(GetClientIp());
+        $user->SetClientAgent(GetClientAgent());
         $siteConnection = new MgSiteConnection();
         $siteConnection->Open($user);
     } else {
@@ -90,9 +92,13 @@
         /* current user is re-authenticating or not? */
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             $user = new MgUserInformation($_REQUEST['username'], $_REQUEST['password']);
+            $user->SetClientIp(GetClientIp());
+            $user->SetClientAgent(GetClientAgent());
             $user->SetMgSessionId($sessionID);
         } else {
             $user = new MgUserInformation($sessionID);
+            $user->SetClientIp(GetClientIp());
+            $user->SetClientAgent(GetClientAgent());
         }
 
         /* open a connection to the site.  This will generate exceptions if the user
@@ -255,5 +261,29 @@
     return $numberString;
 }
 
+function GetClientIp()
+{
+    $clientIp = '';
+    if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)
+        && strcasecmp($_SERVER['HTTP_CLIENT_IP'], 'unknown') != 0)
+    {
+        $clientIp = $_SERVER['HTTP_CLIENT_IP'];
+    }
+    else if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
+        && strcasecmp($_SERVER['HTTP_X_FORWARDED_FOR'], 'unknown') != 0)
+    {
+        $clientIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
+    }
+    else if (array_key_exists('REMOTE_ADDR', $_SERVER))
+    {
+        $clientIp = $_SERVER['REMOTE_ADDR'];
+    }
+    return $clientIp;
+}
 
+function GetClientAgent()
+{
+    return "Fusion Viewer";
+}
+
 ?>

Modified: trunk/lib/MGBroker.js
===================================================================
--- trunk/lib/MGBroker.js	2008-05-06 19:15:55 UTC (rev 1391)
+++ trunk/lib/MGBroker.js	2008-05-06 19:21:00 UTC (rev 1392)
@@ -142,7 +142,7 @@
      */
     initializeRequest : function() {
         this.options = { method:'post' };
-        this.parameters = { version : '1.0.0', locale : Fusion.locale };
+        this.parameters = { version : '1.0.0', locale : Fusion.locale, clientagent : 'Fusion Viewer' };
     },
     
     /**

Modified: trunk/widgets/Print/printablepage.templ
===================================================================
--- trunk/widgets/Print/printablepage.templ	2008-05-06 19:15:55 UTC (rev 1391)
+++ trunk/widgets/Print/printablepage.templ	2008-05-06 19:21:00 UTC (rev 1392)
@@ -15,6 +15,7 @@
     var msie = agent.indexOf("msie") != -1;
     var safari = agent.indexOf("safari") != -1;
     var firefox = agent.indexOf("firefox") != -1;
+    var clientAgent = "Fusion Viewer";
     
     var webAgent = '%s';
     var scale = %s;
@@ -38,7 +39,7 @@
         {
             var legendElt = document.getElementById("Legend");
             legendElt.style.width = "180px";
-            legendElt.innerHTML = "<img id=\"legendImage\" width=\"180\" height=\"" + mapHeight + "\" src=\"" + webAgent + "?OPERATION=GETMAPLEGENDIMAGE&VERSION=1.0.0&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&WIDTH=180&HEIGHT=" + mapHeight + "&FORMAT=PNG\" style=\"visibility: hidden\" onload=\"OnImageLoaded('legendImage');\">";
+            legendElt.innerHTML = "<img id=\"legendImage\" width=\"180\" height=\"" + mapHeight + "\" src=\"" + webAgent + "?OPERATION=GETMAPLEGENDIMAGE&VERSION=1.0.0&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&CLIENTAGENT=" + encodeURIComponent(clientAgent) + "&WIDTH=180&HEIGHT=" + mapHeight + "&FORMAT=PNG\" style=\"visibility: hidden\" onload=\"OnImageLoaded('legendImage');\">";
         }
         else
             mapWidth += 180;
@@ -49,7 +50,7 @@
             document.getElementById("ScaleAndArrow").style.height = "0px";
         }
         
-        var imgReq = webAgent + "?OPERATION=GETMAPIMAGE&VERSION=1.0.0&FORMAT=PNG&LOCALE="+locale+"&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&SETDISPLAYWIDTH=" + mapWidth + "&SETDISPLAYHEIGHT=" + mapHeight + "&SETDISPLAYDPI=" + dpi + "&SETVIEWSCALE=" + scale + "&SETVIEWCENTERX=" + centerX + "&SETVIEWCENTERY=" + centerY + "&SEQ=" + Math.random();
+        var imgReq = webAgent + "?OPERATION=GETMAPIMAGE&VERSION=1.0.0&FORMAT=PNG&LOCALE="+locale+"&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&SETDISPLAYWIDTH=" + mapWidth + "&SETDISPLAYHEIGHT=" + mapHeight + "&SETDISPLAYDPI=" + dpi + "&SETVIEWSCALE=" + scale + "&SETVIEWCENTERX=" + centerX + "&SETVIEWCENTERY=" + centerY + "&SEQ=" + Math.random() + "&CLIENTAGENT=" + encodeURIComponent(clientAgent);
         
         var mapElt = document.getElementById("Map");
         mapElt.style.width = mapWidth + "px";



More information about the fusion-commits mailing list