<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2528094175272198145</id><updated>2011-11-27T17:37:30.173-08:00</updated><category term='php php5 proxy reverseproxy curl'/><category term='oop'/><category term='proxy'/><category term='framework'/><category term='f3'/><category term='webdev'/><category term='reverseproxy'/><category term='curl'/><category term='sso'/><category term='php'/><category term='fatfree'/><title type='text'>TechZinger</title><subtitle type='html'>Zingers on Technology.  It's funny stuff, really...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2528094175272198145.post-7347340199087973799</id><published>2011-08-10T21:34:00.000-07:00</published><updated>2011-08-10T21:34:04.203-07:00</updated><title type='text'>Apple OSX Lion Search Domains FIX</title><content type='html'>So I finally broke down and installed OSX Lion. Not a lot to hoot about though I like the OpenGL performance and the new Mail app. We'll see how long I am satisfied, but for $30 I am not complaining too much.&lt;br /&gt;&lt;br /&gt;A huge problem I ran into was DNS resolution. At my work we use a lot of internal subdomains for our systems. I usually work in 1 and sometimes in the second. Here's an example:&lt;br /&gt;&lt;br /&gt;loc1.example.com&lt;br /&gt;loc2.example.com&lt;br /&gt;&lt;br /&gt;I usually work in loc1, so I set up the following search domains:&lt;br /&gt;&lt;br /&gt;loc1.example.com&lt;br /&gt;example.com&lt;br /&gt;&lt;br /&gt;This means if I am looking for &lt;i&gt;host1&lt;/i&gt; it will try &lt;b&gt;host1&lt;/b&gt;.loc1.example.com then &lt;b&gt;host1&lt;/b&gt;.example.com. This works as expected. The problem is that I used to be able to look up &lt;i&gt;host1.loc2&lt;/i&gt; and it would do the right thing. This is not the case in OSX Lion.&amp;nbsp;My guess is that it wouldn't append the search domain if the host your specified had a dot (.) in it.&lt;br /&gt;&lt;br /&gt;Doing a google search lots of people have ran into the same problem, but the solutions all required a reboot. The best description was on &lt;a href="http://forums.macrumors.com/showthread.php?p=13035618#post13035618"&gt;this post on MacRumors&lt;/a&gt;. This got me there but I didn't want to reboot, so I tried to load up launchctl and restart com.apple.mDNSResponder with no luck. So I goofed around for a bit and found the following to work (&lt;i&gt;after implementing the fix in the MacRumors post above -- go there first!&lt;/i&gt;):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ sudo launchctl&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;launchd% unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;launchd% load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;then check with:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;ps aux | grep -i mdns&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;_mdnsresponder &amp;nbsp;2560 &amp;nbsp; 0.3 &amp;nbsp;0.0 &amp;nbsp;2481092 &amp;nbsp; 2832 &amp;nbsp; ?? &amp;nbsp;Ss &amp;nbsp; &amp;nbsp;9:20PM &amp;nbsp; 0:00.04 /usr/sbin/mDNSResponder -launchd &lt;b&gt;-AlwaysAppendSearchDomains&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Vola! Now all my DNS resolution works! Hope this helps anyone else having issues.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528094175272198145-7347340199087973799?l=techzinger.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/7347340199087973799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techzinger.blogspot.com/2011/08/apple-osx-lion-search-domains-fix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/7347340199087973799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/7347340199087973799'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/2011/08/apple-osx-lion-search-domains-fix.html' title='Apple OSX Lion Search Domains FIX'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528094175272198145.post-3950935083792760814</id><published>2011-04-21T12:12:00.000-07:00</published><updated>2011-04-21T12:12:28.840-07:00</updated><title type='text'>Short update...</title><content type='html'>I'm tired. I am so tired of things coming so close to what I want but being unable to deliver on the basics. Now, I am at an impasse; I can either continue to use a software that is under a license I can't release my changed under (because I disgaree with the GPLv3) or write my own. These are my absolute must-haves from a web framework, which I have yet to find:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PHP 5.3&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Namespaced (yes, I want my own class named "core" or "request")&lt;/li&gt;&lt;li&gt;Can be used with SPL autoloader&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Sensible routing like F3 (which is all I use F3 for right now)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Don't load every class I put into the route definitions (F3::map() I'm talking to you)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;If you must, make it a debug setting I can turn off. I don't need every mapped class autoloaded just to check if my map isn't sane. That can be done in QA/debugging/etc&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;Let me use Smarty 3&lt;/li&gt;&lt;ul&gt;&lt;li&gt;It's an awesome library, still needs namespacing per SPL&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="background-color: black; color: red; font-size: x-large;"&gt;&lt;b&gt;&lt;u&gt;This Just In: HOLY GOD!&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;And as I write these complaints... I find &lt;a href="https://github.com/Respect"&gt;Respect&lt;/a&gt;&amp;nbsp;-- my prayers may have been answered. Testing will commence tonight!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528094175272198145-3950935083792760814?l=techzinger.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/3950935083792760814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techzinger.blogspot.com/2011/04/short-update.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/3950935083792760814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/3950935083792760814'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/2011/04/short-update.html' title='Short update...'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528094175272198145.post-3847976136022140094</id><published>2011-02-09T10:09:00.000-08:00</published><updated>2011-02-09T12:34:28.764-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f3'/><category scheme='http://www.blogger.com/atom/ns#' term='framework'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='fatfree'/><category scheme='http://www.blogger.com/atom/ns#' term='webdev'/><category scheme='http://www.blogger.com/atom/ns#' term='oop'/><title type='text'>Fat-Free Framework for PHP</title><content type='html'>&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5571760649531712450" src="http://1.bp.blogspot.com/_OEp93Yr81OA/TVLeylDWY8I/AAAAAAAAAVA/4EW86a5XkQY/s320/F3.png" style="cursor: hand; cursor: pointer; float: left; height: 120px; margin: 0 10px 10px 0; width: 300px;" /&gt;&lt;br /&gt;One thing I enjoy is when a technology just works. I personally find that most PHP frameworks try and extend themselves too far into complete solutions, trying to solve the problems few people have at the expense of complexity. This is why I have written my own frameworks over and over. Each time iterating over the model and trying to improve the performance and sensibility of the system. Even though I am pretty proud of my efforts, late last year I stumbled onto a framework that really caught my attention, the &lt;a href="http://fatfree.sourceforge.net/"&gt;PHP Fat-Free Framework&lt;/a&gt;. It has the elements of simplicity I feel really allow a developer to push out code quickly. It's very well thought out and feels very tornado-like in it's design style. One problem I have always had with PHP frameworks were their lack of a good routing solution.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I like &lt;a href="http://python.org/"&gt;python&lt;/a&gt;, however, one issue I have with the general attitude of pythons core development is it's inability to accept that it too has flaws, even with some of it's core libraries. These are often dismissed when discussed as something you just need to work around and I find it hard to swallow the pill that just because it's more structured than PHP, the problems with the core (anyone who has used &lt;a href="http://docs.python.org/library/datetime.html"&gt;datetime&lt;/a&gt; and had to deal with &lt;a href="http://groups.google.com/group/mongodb-user/browse_thread/thread/3e87431a758cd3d4/?pli=1"&gt;timezones and mongodb&lt;/a&gt; cannot say there are no flaws in python) are not acknowledged well enough, or even documented well enough, to make coding as pleasant as I feel it could be. That being said, I did enjoy using twisted as a web framework. It had the simplicity in it's design I was looking for. It also is very powerful, and is probably the default framework I will go with for any python-based project I work on.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With all that in mind, I am a PHP developer, and I found Fat-Free to be a breath of fresh air. I finally feel I don't need to write a new framework and really have a place to begin all my future projects.  Fat-Free &lt;a href="http://www.php.net/manual/en/migration53.new-features.php"&gt;PHP 5.3+&lt;/a&gt;, which is what I try to write everything in now. I like namespaces, even if the syntax is a little annoying, I understand the intention and the reasons we have to go with ye olde backspace. I also feel that web page rendering and routing fits very well with OOP and having a stronger OOP core in 5.3 is key. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fat-Free, to me, feels very similar to &lt;a href="http://www.tornadoweb.org/"&gt;tornado&lt;/a&gt; in it's framework design. You define your routing in the main file and it's all handled by included classes. The automatic importing of your classes is very easy to understand, and the routing is extremely simple yet powerful. The ORM tools provided are at least good enough to do anything you really need to, however, if it's not to your liking you just don't use it. I love that about F3. Nothing but the core is required. I like &lt;a href="http://www.smarty.net/"&gt;Smarty&lt;/a&gt;, especially &lt;a href="http://www.smarty.net/v3_overview"&gt;V3&lt;/a&gt;, and I use it whenever I can. Even though the built-in templating supports a lot of the same features, I can do everything I need to do in Smarty, and I am more comfortable with extending it and it's syntax. As with the ORM libraries, you simply don't use f3 and you're off and running with whatever you want to use for rendering your pages.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So check it out. I would like to see your feedback and hear your feelings on the overall state of PHP frameworks.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528094175272198145-3847976136022140094?l=techzinger.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/3847976136022140094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techzinger.blogspot.com/2011/02/fat-free-framework-for.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/3847976136022140094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/3847976136022140094'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/2011/02/fat-free-framework-for.html' title='Fat-Free Framework for PHP'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_OEp93Yr81OA/TVLeylDWY8I/AAAAAAAAAVA/4EW86a5XkQY/s72-c/F3.png' height='72' width='72'/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528094175272198145.post-2508156310874559481</id><published>2007-07-23T14:22:00.000-07:00</published><updated>2007-07-23T15:41:25.179-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php php5 proxy reverseproxy curl'/><title type='text'>Reverse Proxy in PHP5, Rev2</title><content type='html'>It's gotten a bit more complex; The proxy handler didn't pass all the client headers to the proxy server. This caused problems with having the wrong client type, no Etag caching, cookie passing, etc. Here's the current rev, which solves a lot of these issues.&lt;br /&gt;&lt;br /&gt;The cookie handling was broken because I wasn't using cookies on my back-end app. My SSO implementation was caching the cookies to the back-end server in the session.&lt;br /&gt;&lt;br /&gt;So, here you go!&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;class &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;ProxyHandler&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;{&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_host&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_proto&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$translated_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$curl_handler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$cache_control&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$pragma&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    private &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$client_headers&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=array();&lt;br /&gt;&lt;br /&gt;    function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;__construct&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Strip the trailing '/' from the URLs so they are the same.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;preg_replace&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;',/$,'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;proxy_url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;preg_replace&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;',/$,'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Parse all the parameters for the URL&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;if (isset(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'PATH_INFO'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]))&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;.= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'PATH_INFO'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;];&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Add the '/' at the end&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;.= &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'/'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'QUERY_STRING'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;] !== &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;.= &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"?{$_SERVER['QUERY_STRING']}"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;translated_url &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$proxy_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_handler &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_init&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;translated_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Set various options&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_RETURNTRANSFER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_BINARYTRANSFER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;); &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// For images, etc.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_USERAGENT&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'HTTP_USER_AGENT'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_WRITEFUNCTION&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, array(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'readResponse'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_HEADERFUNCTION&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, array(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'readHeaders'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Process post data.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;count&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_POST&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;))&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Empty the post data&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$post&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=array();&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Set the post data&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_POST&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Encode and form the post data&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;foreach(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_POST &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;as &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$key&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$post&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[] = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;urlencode&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$key&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;).&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"="&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;urlencode&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_POSTFIELDS&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;implode&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'&amp;'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$post&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;            unset(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$post&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        }&lt;br /&gt;        elseif (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'REQUEST_METHOD'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;] !== &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'GET'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;) &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Default request method is 'get'&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;{&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Set the request method&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_CUSTOMREQUEST&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_SERVER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'REQUEST_METHOD'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Handle the client headers.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;handleClientHeaders&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setClientHeader&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;client_headers&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[] = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Executes the proxy.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;public function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;execute&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;CURLOPT_HTTPHEADER&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;client_headers&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_exec&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_handler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Get the information about the request.&lt;br /&gt;    // Should not be called before exec.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;public function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;getCurlInfo&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;()&lt;br /&gt;    {&lt;br /&gt;        return &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_getinfo&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_handler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Sets a curl option.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;public function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setCurlOption&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$option&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_setopt&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;curl_handler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$option&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;readHeaders&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&amp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$cu&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$length &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;strlen&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;preg_match&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;',^Location:,'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;))&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;str_replace&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;proxy_url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;url&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        }&lt;br /&gt;        elseif(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;preg_match&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;',^Cache-Control:,'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;))&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;cache_control &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        }&lt;br /&gt;        elseif(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;preg_match&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;',^Pragma:,'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;))&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;pragma &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        }&lt;br /&gt;        if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;header &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;!== &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"\r\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;rtrim&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        return &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$length&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    protected function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;handleClientHeaders&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$headers &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;apache_request_headers&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;();&lt;br /&gt;&lt;br /&gt;        foreach (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$headers &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;as &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$header &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;) {&lt;br /&gt;            switch(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;            {&lt;br /&gt;                case &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'Host'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;:&lt;br /&gt;                    break;&lt;br /&gt;                default:&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;setClientHeader&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;sprintf&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'%s: %s'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$value&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;                    break;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;readResponse&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&amp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$cu&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;    {&lt;br /&gt;        static &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$headersParsed &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// Clear the Cache-Control and Pragma headers&lt;br /&gt;        // if they aren't passed from the proxy application.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$headersParsed &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=== &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;        {&lt;br /&gt;            if (!&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;cache_control&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'Cache-Control: '&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;            }&lt;br /&gt;            if (!&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$this&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;pragma&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;header&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'Pragma: '&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$headersParsed &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        }&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$length &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;strlen&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;        echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$string&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;        return &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$length&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Update: Added a google code project for php5rp at &lt;a href="http://php5rp.googlecode.com/"&gt;Google Code&lt;/a&gt; and here's the &lt;a href="http://php5rp.googlecode.com/svn/"&gt;Subversion Link&lt;/a&gt; for downloading.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528094175272198145-2508156310874559481?l=techzinger.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/2508156310874559481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techzinger.blogspot.com/2007/07/reverse-proxy-in-php5-rev2.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/2508156310874559481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/2508156310874559481'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/2007/07/reverse-proxy-in-php5-rev2.html' title='Reverse Proxy in PHP5, Rev2'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528094175272198145.post-7320012626547743639</id><published>2007-07-17T22:37:00.000-07:00</published><updated>2007-07-18T01:10:24.839-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='curl'/><category scheme='http://www.blogger.com/atom/ns#' term='sso'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='reverseproxy'/><category scheme='http://www.blogger.com/atom/ns#' term='proxy'/><title type='text'>Writing A Reverse Proxy in PHP5</title><content type='html'>So I have been working on a little class to run a reverse proxy from &lt;a href="http://www.php.net/"&gt;PHP&lt;/a&gt; using &lt;a href="http://us.php.net/curl"&gt;cURL&lt;/a&gt;. I have extended this class for my own purposes (single-sign-on) to handle some special request parameters, but here it is. It has some warts, but it's a good starting point. I would appreciate any pointers anyone has to offer.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;class ProxyHandler&lt;br /&gt;{&lt;br /&gt;    private $url;&lt;br /&gt;    private $translated_url;&lt;br /&gt;    private $curl_handler;&lt;br /&gt;&lt;br /&gt;    function __construct($url, $proxy_url)&lt;br /&gt;    {   &lt;br /&gt;        $this-&gt;url = $url;&lt;br /&gt;        $this-&gt;proxy_url = $proxy_url;&lt;br /&gt;&lt;br /&gt;        // Parse all the parameters for the URL&lt;br /&gt;        if (isset($_SERVER['PATH_INFO']))&lt;br /&gt;        {   &lt;br /&gt;            $proxy_url .= $_SERVER['PATH_INFO'];&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {   &lt;br /&gt;            $proxy_url .= '/';&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if ($_SERVER['QUERY_STRING'] !== '')&lt;br /&gt;        {   &lt;br /&gt;            $proxy_url .= "?{$_SERVER['QUERY_STRING']}";&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $this-&gt;translated_url = $proxy_url;&lt;br /&gt;&lt;br /&gt;        $this-&gt;curl_handler = curl_init($proxy_url);&lt;br /&gt;&lt;br /&gt;        // Set various options&lt;br /&gt;        $this-&gt;setCurlOption(CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;        $this-&gt;setCurlOption(CURLOPT_BINARYTRANSFER, true); // For images, etc.&lt;br /&gt;        $this-&gt;setCurlOption(CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);&lt;br /&gt;        $this-&gt;setCurlOption(CURLOPT_WRITEFUNCTION, array($this,'readResponse'));&lt;br /&gt;        $this-&gt;setCurlOption(CURLOPT_HEADERFUNCTION, array($this,'readHeaders'));&lt;br /&gt;&lt;br /&gt;        // Process post data.&lt;br /&gt;        if (count($_POST))&lt;br /&gt;        {   &lt;br /&gt;            // Empty the post data&lt;br /&gt;            $post=array();&lt;br /&gt;&lt;br /&gt;            // Set the post data&lt;br /&gt;            $this-&gt;setCurlOption(CURLOPT_POST, true);&lt;br /&gt;&lt;br /&gt;            // Encode and form the post data&lt;br /&gt;            foreach($_POST as $key=&gt;$value)&lt;br /&gt;            {   &lt;br /&gt;                $post[] = urlencode($key)."=".urlencode($value);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            $this-&gt;setCurlOption(CURLOPT_POSTFIELDS, implode('&amp;',$post));&lt;br /&gt;&lt;br /&gt;            unset($post);&lt;br /&gt;        }&lt;br /&gt;        elseif ($_SERVER['REQUEST_METHOD'] !== 'GET') // Default request method is 'get'&lt;br /&gt;        {   &lt;br /&gt;            // Set the request method&lt;br /&gt;            $this-&gt;setCurlOption(CURLOPT_CUSTOMREQUEST, $_SERVER['REQUEST_METHOD']);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Executes the proxy.&lt;br /&gt;    public function execute()&lt;br /&gt;    {&lt;br /&gt;        curl_exec($this-&gt;curl_handler);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Get the information about the request.&lt;br /&gt;    // Should not be called before exec.&lt;br /&gt;    public function getCurlInfo()&lt;br /&gt;    {&lt;br /&gt;        return curl_getinfo($this-&gt;curl_handler);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Sets a curl option.&lt;br /&gt;    public function setCurlOption($option, $value)&lt;br /&gt;    {&lt;br /&gt;        curl_setopt($this-&gt;curl_handler, $option, $value);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected function readHeaders(&amp;$cu, $string)&lt;br /&gt;    {&lt;br /&gt;        $length = strlen($string);&lt;br /&gt;        if (preg_match(',^Location:,', $string))&lt;br /&gt;        {&lt;br /&gt;            $string = str_replace($this-&gt;proxy_url, $this-&gt;url, $string);&lt;br /&gt;        }&lt;br /&gt;        header($string);&lt;br /&gt;        return $length;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected function readResponse(&amp;$cu, $string)&lt;br /&gt;    {&lt;br /&gt;        $length = strlen($string);&lt;br /&gt;        echo $string;&lt;br /&gt;        return $length;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here's an example .htaccess file:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;RewriteEngine On&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f [NC]&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-d [NC]&lt;br /&gt;RewriteCond %{REQUEST_URI} !^/index.php&lt;br /&gt;RewriteRule ^(.+)$ index.php/$1 [QSA]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And an example usage:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$proxy = new ProxyHandler('http://publicsite.example.com','http://privatesite.example.com');&lt;br /&gt;$proxy-&gt;execute();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Cheers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528094175272198145-7320012626547743639?l=techzinger.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techzinger.blogspot.com/feeds/7320012626547743639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techzinger.blogspot.com/2007/07/writing-reverse-proxy-in-php5.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/7320012626547743639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528094175272198145/posts/default/7320012626547743639'/><link rel='alternate' type='text/html' href='http://techzinger.blogspot.com/2007/07/writing-reverse-proxy-in-php5.html' title='Writing A Reverse Proxy in PHP5'/><author><name>b</name><uri>http://www.blogger.com/profile/09307924836487251305</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry></feed>
