<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rahul Vaidya's Blog &#187; php</title>
	<atom:link href="http://www.rvaidya.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rvaidya.com/blog</link>
	<description>Development, Tech, Whatever.</description>
	<lastBuildDate>Wed, 16 Sep 2009 00:33:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Google Maps Flex API: Refresh TileLayer without refreshing map</title>
		<link>http://www.rvaidya.com/blog/gis/2009/02/27/google-maps-flex-api-refresh-tilelayer-without-refreshing-map/</link>
		<comments>http://www.rvaidya.com/blog/gis/2009/02/27/google-maps-flex-api-refresh-tilelayer-without-refreshing-map/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 06:18:20 +0000</pubDate>
		<dc:creator>Rahul</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[Tile]]></category>

		<guid isPermaLink="false">http://www.rvaidya.com/blog/?p=43</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>This submission is in response to <a href="http://code.google.com/p/gmaps-api-issues/issues/detail?id=503" target="_blank">this gmaps-api-flex feature request</a>.  This is a hack that provides functionality like what was requested here.</p>
<p>So you&#8217;ve added a custom tile layer to your Google Maps app in Flex, which lets you show all your pretty spatial features.  Fantastic!  If you want to make this tile layer dynamic, however, you run into a few problems.  The Google Maps Flex API caches tiles that it has loaded from a specific Tile Overlay, so if your data changes, the changes won&#8217;t be reflected on your map immediately.  There have been various hacks that force a refresh of the map, but they don&#8217;t completely meet the requirements set in this feature request.  The attached code here is a hack that tries to mimic the requested functionality, without refreshing the entire map.</p>
<p>After exploring a little, I saw that one way the Flex API differentiates overlays is by the request URL.  If you create an overlay, add it to the map, remove it, create a new overlay with the same URL, and add the new overlay, it will load the tiles from the internal cache.  Now, this functionality can be nice if you&#8217;re switching between two different overlays, and there haven&#8217;t been any changes in the data.  For instance, if an app requests tiles from the following URLs in order:</p>
<p>mapserver.php?X=0&amp;Y=0&amp;Z=0&amp;LAYERS=calicounties</p>
<p>mapserver.php?X=0&amp;Y=0&amp;Z=0&amp;LAYERS=oregcounties</p>
<p>it will load both of these layers properly, and cache them both.  If you then load the calicounties layer, using the same URL string, it&#8217;ll give you back the cached version.</p>
<p>However, if the data has changed, you&#8217;d want to reload the entire layer.  To do this, I have appended a garbage GET variable to the URL.  The requests will now look like:</p>
<p>mapserver.php?X=0&amp;Y=0&amp;Z=0&amp;LAYERS=calicounties&amp;GARBAGE=SDK34K</p>
<p>mapserver.php?X=0&amp;Y=0&amp;Z=0&amp;LAYERS=oregcounties&amp;GARBAGE=SDK34K</p>
<p>Simply change the GARBAGE variable when loading calicounties again and it&#8217;ll load from the source.</p>
<p>The included code implements four events that are dispatched to/listened from the map object:</p>
<ul>
<li>TileLayerRefresh
<ul>
<li>Tell the Tile Layer to refresh (do not change the GARBAGE variable)</li>
</ul>
</li>
<li>TileLayerReload
<ul>
<li>Tell the Tile Layer to reload (change the GARBAGE variable)</li>
</ul>
</li>
<li>TileLayerRefreshed
<ul>
<li>Refresh/Reload completed successfully (all tiles loaded)</li>
<li>Implemented by incrementing a counter whenever Loader instances are created, and decrementing the counter whenever they complete/fail.</li>
</ul>
</li>
<li>TileLayerRefreshError
<ul>
<li>If any loading errors occurred.</li>
</ul>
</li>
</ul>
<p>Note: You need to pass the TileLayer both the TileOverlay that holds it and the Map object, so it can handle refreshing and event dispatch by itself.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li></li><li><span style="color: #000000; font-weight: bold;">var</span> tileLayer:MapServerTileLayer = <span style="color: #000000; font-weight: bold;">new</span> MapServerTileLayer<span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#41;</span>;</li><li><span style="color: #000000; font-weight: bold;">var</span> tileLayerOverlay:TileLayerOverlay = <span style="color: #000000; font-weight: bold;">new</span> TileLayerOverlay<span style="color: #66cc66;">&#40;</span>tileLayer<span style="color: #66cc66;">&#41;</span>;</li><li>tileLayer.<span style="color: #006600;">setOverlay</span><span style="color: #66cc66;">&#40;</span>tileLayerOverlay<span style="color: #66cc66;">&#41;</span>;</li><li>map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>tileLayerOverlay<span style="color: #66cc66;">&#41;</span>;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>For an example on using MapServer/PHP MapScript with Google Maps, go to <a href="http://www.rvaidya.com/blog/gis/2009/02/12/mapserver-using-google-maps-with-php-mapscript/" target="_blank">this blog post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rvaidya.com/blog/gis/2009/02/27/google-maps-flex-api-refresh-tilelayer-without-refreshing-map/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get request headers sent by client in PHP</title>
		<link>http://www.rvaidya.com/blog/php/2009/02/25/get-request-headers-sent-by-client-in-php/</link>
		<comments>http://www.rvaidya.com/blog/php/2009/02/25/get-request-headers-sent-by-client-in-php/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 08:56:31 +0000</pubDate>
		<dc:creator>Rahul</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[request]]></category>

		<guid isPermaLink="false">http://www.rvaidya.com/blog/?p=36</guid>
		<description><![CDATA[A nice little function I found posted by &#8220;lazynitwit&#8221; on BlueHost forums: function getHeaders&#40;&#41;&#123;&#160;&#160;&#160;&#160;$headers = array&#40;&#41;;&#160;&#160;&#160;&#160;foreach &#40;$_SERVER as $k =&#62; $v&#41;&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if &#40;substr&#40;$k, 0, 5&#41; == &#34;HTTP_&#34;&#41;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$k = str_replace&#40;'_', ' ', substr&#40;$k, 5&#41;&#41;;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$k = str_replace&#40;' ', '-', ucwords&#40;strtolower&#40;$k&#41;&#41;&#41;;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$headers&#91;$k&#93; = $v;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;return $headers;&#125;&#160;&#160; The PHP function getallheaders() only works on Apache, and only if Apache has been installed [...]]]></description>
			<content:encoded><![CDATA[<p>A nice little function I found posted by &#8220;lazynitwit&#8221; on BlueHost forums:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">function</span> getHeaders<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;HTTP_&quot;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #339933;">,</span> 5<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$headers</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$headers</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span>&nbsp;&nbsp;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>The PHP function getallheaders() only works on Apache, and only if Apache has been installed as a module.</p>
<p>It turns out that this information is within the $_SERVER global variable, and can be parsed out.</p>
<p>This code is useful if, for instance, you want to differentiate between user browser requests and requests made through AJAX.  Some of the JavaScript frameworks (jQuery, Prototype, YUI, MooTools) send a special header,</p>
<p>X-Requested-With: XMLHttpRequest</p>
<p>whenever a request is made.  I have put this to use in my <a href="http://www.rvaidya.com/chat?channels=test">phpFreeChat chat box</a> to allow channels to be specified in the URL as GET parameters.</p>
<p>via <a href="http://www.bluehostforum.com/showthread.php?t=1453">request headers  php  &#8211; bluehostforum.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rvaidya.com/blog/php/2009/02/25/get-request-headers-sent-by-client-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
