Friday, December 18, 2009

PHPProxifier. PHP Proxy script.

Intro:

Recently team i'm currently working in received a task to make a proxy script that supports GET, POST, PUT, DELETE HTTP methods. All scripts we've found in network aren't supporting PUT and DELETE methods.
IMPORTANT this script has no fully-featured demo, sample etc. If you are don't know PHP please read PHP manuals before.

Idea:

  • Proxy should be as simple as possible.
  • Proxy should proxy one domain.
Proxy is a script that receives headers, data and pass it to proxied host. Then returns returned headers and data back

Steps of development:

First of all i remember my experience with Snoopy PHP library. It has really good functionality, but old code and code-style, and as we're have agile project with PHPUnderControl that checks it, we've decided that rewriting Snoopy library will consume a lot of time. Anyway i've rewritten it :) and soon it will be available.

Our project based on CodeIgniter has no such things also, but i remembered i saw REST service in Zend Framework and research/work begins.

First of all we don't want to use all of Zend Framework and i stripped out only classes we need:
  • Zend_Controller_Request*
  • Zend_Http_Client*
  • Zend_Http_Cookie
  • Zend_Http_CookieJar
  • Zend_Http_Response
  • Zend_Uri*
  • Zend_Validate_Hostname*
  • Zend_Validate_Ip

Second step was writing a proxy script. You need have php-cURL installed to use this script from scratch. All you need to run it in example mode: download from it's GIT repository

git@github.com:biozshock/PHPProxifier.git

if you are have what to proxy through this script please change $proxyingUrl variable. To enter in debug mode that shows headers, server variables, etc. you need to change $debug variable.

Third thing: to demonstrate feature is working i write script client.php to check all things are working nice. Also this script shows how to implement a page that will call proxy script. To use it you need to change $uri variable to point script to server.php script.
As i don't want to write fully-featured page with all HTTP methods as selector i've just commented out methods you are need to call to get responce.

Conclusion

If you are familiar with PHP and do not know Zend Framework you will easily read code and find out it's simple. If no - please go and read other PHP manuals please.

Thursday, August 20, 2009

Ubuntu Wine keyboard shortcuts

I was googling very long time to get answer for a question: why in apps, games under Ubuntu and Wine keyboard is getting "lost"? It's happening after a small period of time or few shortcuts. Seems today i found a solution to do so:

env XMODIFIERS="" WINEPREFIX="/home/biozshock/.wine" wine "C:\Program Files\notepad\notepad++.exe"


Here you need to change WINEPREFIX to your wine directory and C:\Program Files\notepad\notepad++.exe to application you want to call.

Tested with notepad++, Warcraft III.