<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Zendcasts Forum / ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
		<link>http://www.zendcasts.com/forum/viewtopic.php?id=87</link>
		<description><![CDATA[The most recent posts in ZC35 – Protecting Assets with Zend Controller Plugins.]]></description>
		<lastBuildDate>Tue, 11 May 2010 09:38:12 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=850#p850</link>
			<description><![CDATA[<p>Hello everyone,<br />i didn&#039;t know that there was already a discussion about those point, i came just for put my solution of extending this excellent assets grabber.( I have also implemented several function to use it with auth, acl and cahce but it&#039;s not the point)<br />The usefull tweak are as jon says on comment 4 a mime-type detection :<br />first thing it&#039;s better to use $this-&gt;_response instead of the echo.<br />with this function you could set a lot of usefull header, i first use an auto-detect mime-type<br /></p><div class="codebox"><pre><code>$this-&gt;_response-&gt;setHeader(&#039;Content-Type&#039;,mime_content_type($file_path));    
$this-&gt;_response-&gt;setBody(file_get_contents($file_path));
$this-&gt;_response-&gt;sendResponse(); 
// where $file_path is your file path...</code></pre></div><p>To make some streaming-like it&#039;s a bit harder the response must look something like that :<br /></p><div class="codebox"><pre><code>        $this-&gt;_response-&gt;setHeader(&#039;Content-Type&#039;,mime_content_type($file_path));
    $this-&gt;_response-&gt;setHeader(&#039;Connection&#039;,&#039;Keep-Alive&#039;);
    $this-&gt;_response-&gt;setHttpResponseCode(206);
    $this-&gt;_response-&gt;setHeader(&#039;Keep_Alive&#039;,&#039;timeout=15, max=98&#039;);
    $this-&gt;_response-&gt;setHeader(&#039;Content-Length&#039;,filesize($file_path));
    $this-&gt;_response-&gt;setBody(file_get_contents($file_path));
    $this-&gt;_response-&gt;sendResponse();</code></pre></div><p>To make real streaming you have to use the stream_context_create() option of file_get_contents and to accept header request to grab the offset of the file and passing it to the context.</p><p>Note that in php 5.3 you have better method based on PECL to check mime-type and other info for your file. And lastely having a function that check if the file exists and if it is readable is always a good idea.</p><p>That&#039;s it for my little contribution, hope it could be usefull for someone.</p>]]></description>
			<author><![CDATA[dummy@example.com (T_bo)]]></author>
			<pubDate>Tue, 11 May 2010 09:38:12 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=850#p850</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=593#p593</link>
			<description><![CDATA[<p>hey Kuzma, you&#039;ll probably need a two-part solution, with a view helper that generates the right url, which in turn hits the plugin with the necessary parameters to return the video file and the necessary mimetype.</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Sun, 31 Jan 2010 18:34:16 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=593#p593</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=592#p592</link>
			<description><![CDATA[<p>Hello!<br />Firstly I&#039;d thank you for this tutorial!<br />I&#039;ve a question:<br />On a secured page I&#039;d to display secured links pointing to video files.<br />Video player must grab them and play <img src="http://www.zendcasts.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />Video files are stored in Application/uploads directory.How I can form links with your plugin and send them into a view template as &lt;a href..&gt; tags that video player might play them? <br />Thank you!</p>]]></description>
			<author><![CDATA[dummy@example.com (01Kuzma)]]></author>
			<pubDate>Sat, 30 Jan 2010 14:42:52 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=592#p592</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=340#p340</link>
			<description><![CDATA[<p>That&#039;s where CSS Sprites becomes handy. You can reduce GET requests pretty easily.</p>]]></description>
			<author><![CDATA[dummy@example.com (Manuel)]]></author>
			<pubDate>Tue, 10 Nov 2009 15:29:15 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=340#p340</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=330#p330</link>
			<description><![CDATA[<p>that&#039;s a good point. If they&#039;re thumbnails, you could make those requests run straight through Apache and make asynchronous calls for the session-required assets.</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Tue, 03 Nov 2009 18:57:11 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=330#p330</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=329#p329</link>
			<description><![CDATA[<p>Cache is a must for this kind of operations. But I&#039;m wondering what will happen if I will try to display hundreds of files on one page? After all some part of routing is still on and php interpreter is running. Well, I&#039;ll give it a try.</p>]]></description>
			<author><![CDATA[dummy@example.com (batman)]]></author>
			<pubDate>Mon, 02 Nov 2009 19:46:22 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=329#p329</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=328#p328</link>
			<description><![CDATA[<p>hmmm... I think it&#039;s fast in the sense that you&#039;re essentially stopping the rest of the MVC architecture to load. You could use the parameters that are routed (like I did with the filename) to help you find the right file. Another option would be store a lookup in Zend_Cache to cut down on the I/O operations on a per-request basis.</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Mon, 02 Nov 2009 16:53:46 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=328#p328</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=326#p326</link>
			<description><![CDATA[<p>Hello,</p><p>Nice idea protecting files with plugins, but there is only one thing that bothers me. Is it fast? What if I would like to check 100 or even 1000 files in one action?</p>]]></description>
			<author><![CDATA[dummy@example.com (batman)]]></author>
			<pubDate>Mon, 02 Nov 2009 15:48:55 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=326#p326</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=324#p324</link>
			<description><![CDATA[<p>Thanks.. :-P<br />It works now.</p>]]></description>
			<author><![CDATA[dummy@example.com (beregu)]]></author>
			<pubDate>Mon, 02 Nov 2009 03:18:30 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=324#p324</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=322#p322</link>
			<description><![CDATA[<p>good call tomas.</p><p>in production code, you would set the Content-Type in the header.</p><p>something like header(&#039;Content-Type: image/jpg&#039;); in the AssetGrabber plugin. </p><p>if we were building generic component, then it would probably involved detecting the mimetype of the file we were grabbing and setting the headers appropriately.</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Sun, 01 Nov 2009 21:17:51 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=322#p322</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=320#p320</link>
			<description><![CDATA[<p>You should send appropriate headers (=Content-Type).</p>]]></description>
			<author><![CDATA[dummy@example.com (tomas.fejfar)]]></author>
			<pubDate>Sat, 31 Oct 2009 17:22:15 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=320#p320</guid>
		</item>
		<item>
			<title><![CDATA[Re: ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=318#p318</link>
			<description><![CDATA[<p>Hello Jon,</p><p>It is very good to hear that you are getting back into a weekly posting. Your new tutorial was really amazing. Unfortunately, the code you attached with your video seems not working properly on my computer.</p><p>After I got authenticated, http://localhost/assets/image.jpg gives me long long strings of something like:</p><p>============<br />ÿØÿàJFIFÿâXICC_PROFILEHLinomntrRGB XYZ Î&#160; &#160; 1acspMSFTIEC sRGBöÖÓ-HP cprtP3desc„lwtptðbkptrXYZgXYZ,bXYZ@dmndTpdmddÄˆvuedL†viewÔ$lumiømeas$tech0rTRC&lt;gTRC&lt;bTRC&lt;textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ óQÌXYZ XYZ o¢8õXYZ b™·…<br />============</p><p>Also, without authentication, the AssestGrabber Plugin doesn&#039;t redirect me to the index.</p><p>I&#039;m on Windows, WampServer 2.0h (not supports PHP5.3) with its installation default plus Apache mod_rewrite enabled.</p><p>Should I check if some special PHP or Apache extensions are enabled? If so, please advice me what to check. :-D</p><p>Thank you Jon.</p>]]></description>
			<author><![CDATA[dummy@example.com (beregu)]]></author>
			<pubDate>Sat, 31 Oct 2009 12:05:19 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=318#p318</guid>
		</item>
		<item>
			<title><![CDATA[ZC35 – Protecting Assets with Zend Controller Plugins]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=317#p317</link>
			<description><![CDATA[<p>I had to take a little hiatus the last few weeks, however I&#039;m hoping to get back into a weekly posting schedule.</p><p>This video is an introduction in how to effectively use Zend Controller Plugins. The Zend Documentation refers to Zend Controller plugins being part of the Action Stack which is a simple data structure that can be filled with a bunch of plugins which will run in succession. </p><p>We&#039;ll create a simple asset protection script using the Zend Framework&#039;s built in Zend Controller Plugin architecture. </p><p>Grab a <a href="http://zendcasts.googlecode.com/svn/trunk/zc35-protecting-assets-with-zend-controller-plugins/zc35-protecting-assets-with-zend-controller-plugins.zip">copy of the project</a> or <a href="http://code.google.com/p/zendcasts/source/browse/#svn/trunk/zc35-protecting-assets-with-zend-controller-plugins/application">browse the repository</a>.</p><p>zend_controller, plugin, zend_controller_plugin, zend_session,action stack</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Sat, 31 Oct 2009 02:07:49 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=317#p317</guid>
		</item>
	</channel>
</rss>

