[Chameleon] parameter substitution using mapscript
John Pulles
john.pulles at geodan.nl
Tue Jan 16 07:57:40 EST 2007
Hi list,
In a Chameleon site where parameter substition was needed, the
chameleon-2.4.1-20060906 code was tweaked to allow parameter
substitution by replacing the parameter strings in the session map file
(see the attached patch file).
Since probably more people are/were having this problem, I was wondering
if a more standard solution using Chameleon is available? That would be
preferable to patching the chameleon code.
Regards,
John.
--
John Pulles
-------------------------------------
Geodan IT b.v.
Buitenhaven 27-A
5211TP 's-Hertogenbosch
-------------------------------------
Tel: +31 (0)73 - 692 5151
Fax: +31 (0)73 - 692 5150
-------------------------------------
Postadres / mailing address
President Kennedylaan 1
1079MB Amsterdam
-------------------------------------
E-mail: john.pulles at geodan.nl
Website: http://www.geodan.nl
-------------------------------------
-------------- next part --------------
Index: map_session.php
===================================================================
--- map_session.php (revision 2)
+++ map_session.php (working copy)
@@ -292,7 +292,32 @@
}
else
{
- $this->oMap->save( $szMapFile );
+ $this->oMap->save( $szMapFile );
+
+ /** begin of parameter subsitution hack ***/
+ // after generated save: rewrite hack (post_processor ;-))
+
+ if (!$handle = fopen($szMapFile, 'r'))
+ {
+ $this->error( 0, "Cannot open file ($szMapFile)" );
+ }
+ $str = fread($handle, filesize($szMapFile));
+ $str = ereg_replace ("%dbname%",$_SESSION["userinfo"]["dbname"], $str);
+ $str = ereg_replace ("%username%",$_SESSION["userinfo"]["username"], $str);
+ fclose($handle);
+
+ if (!$handle = fopen($szMapFile, 'w')) {
+ $bResult = false;
+ $this->error( 0, "$szMapFile is not writeable" );
+ }
+
+ if (fwrite($handle, $str) === FALSE)
+ {
+ $this->error( 0, "$szMapFile is not writeable" );
+ $bResult = false;
+ }
+ fclose($handle);
+ /** end of parameter subsitution hack ***/
}
}
// log successful save
More information about the Chameleon
mailing list