[fusion-commits] r1408 - in trunk: MapGuide/php MapServer/php
common/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu May 15 16:16:20 EDT 2008
Author: madair
Date: 2008-05-15 16:16:20 -0400 (Thu, 15 May 2008)
New Revision: 1408
Modified:
trunk/MapGuide/php/CreateSession.php
trunk/MapServer/php/CreateSession.php
trunk/common/php/Utilities.php
Log:
re #66: added loadFusionConfig to set the config file in the session
Modified: trunk/MapGuide/php/CreateSession.php
===================================================================
--- trunk/MapGuide/php/CreateSession.php 2008-05-14 19:14:55 UTC (rev 1407)
+++ trunk/MapGuide/php/CreateSession.php 2008-05-15 20:16:20 UTC (rev 1408)
@@ -44,8 +44,10 @@
echo var2json($result);
/* start a php session in the web tier as well, using same session id */
- session_start($sessionId);
+ session_id(str_replace('_', '-', $sessionId));
+ session_start();
$_SESSION['username'] = $username;
+ loadFusionConfig();
} catch (MgException $e) {
echo "ERROR: " . $e->GetMessage() . "n";
Modified: trunk/MapServer/php/CreateSession.php
===================================================================
--- trunk/MapServer/php/CreateSession.php 2008-05-14 19:14:55 UTC (rev 1407)
+++ trunk/MapServer/php/CreateSession.php 2008-05-15 20:16:20 UTC (rev 1408)
@@ -34,6 +34,7 @@
initializeSession( "sid", "", "" );
$sessionId = session_id();
+loadFusionConfig();
header('Content-type: text/x-json');
header('X-JSON: true');
Modified: trunk/common/php/Utilities.php
===================================================================
--- trunk/common/php/Utilities.php 2008-05-14 19:14:55 UTC (rev 1407)
+++ trunk/common/php/Utilities.php 2008-05-15 20:16:20 UTC (rev 1408)
@@ -260,4 +260,27 @@
return $_ARG;
}
+function loadFusionConfig() {
+ if (function_exists('json_decode')) {
+ $configFile = realpath(dirname(__FILE__)."/../../config.json");
+ if (file_exists($configFile)) {
+ $configStr = file_get_contents($configFile);
+ /* replace single quotes with double quotes */
+ $configStr = str_replace("'", '"', $configStr);
+ /* get rid of new lines, it just complicates things */
+ $configStr = str_replace("\n", '', $configStr);
+ /* get rid of embedded comments */
+ $configStr = preg_replace("/\/\*.*\*\//U", "", $configStr);
+ /* the regex after this one can't handle http: as a value, so mangle it. */
+ $configStr = preg_replace("/http:/U", "http_", $configStr);
+ /* quote unquoted attribute names */
+ $configStr = preg_replace("/[^\"]{1}(\w*):/U", "\"$1\":", $configStr);
+ /* decode the whole thing */
+ $_SESSION['fusionConfig'] = json_decode($configStr, false);
+ } else {
+ echo "config file not found";
+ }
+ }
+}
+
?>
\ No newline at end of file
More information about the fusion-commits
mailing list