Posts Tagged ‘PHP’

Zend Framework + Doctrine + ExtJS

Tuesday, January 5th, 2010

I started working on a new project today, which I hope to write about as I work through the different parts and challenges presented. I’m developing the project in PHP using Zend Framework with Doctrine ORM for the database layer. I’ve used ZF for a few projects now and it just keeps getting better and more mature. I’ve been reading about Doctrine ORM and read a few articles about integrating it with ZF and so far it’s been really good, although I’ve just barely scratched the surface.

The frontend of the project is going to just use the Zend Application MVC tool, but for the backend I’m using ExtJS. I’ve been a fan of ExtJS and used it for a few projects now but this time I’m trying something new – I’m using Zend_Json_Server to provide the data directly to ExtJS. I’m still working out how it works, but basically you create the objects on the backend, enable Zend_Json_Server and then your objects and methods are available right within the Ext.Direct and Ext.DataStore objects. Very slick. Once I’ve figured it out more I’ll post some links to the resources that helped me the most.

Also, it seems that everytime I log into WP there is a software update… maybe I need to post more.

Working With Legacy Code – magic_quotes_gpc

Tuesday, July 14th, 2009

Sometimes you have to work with legacy code and you don’t have the budget to refactor it to remove practices that are deprecated. magic_quotes_gpc was a setting that was turned on for a lot of PHP 4 installations but it is now no longer a best practice to have it on. If you aren’t sure what that is, it automatically adds slashes or quotes data that comes in to PHP via cookies or a GET or POST HTTP request.

The PHP website has a good method of stripping out those slashes if you are unable to turn off magic_quotes_gpc (http://ca3.php.net/manual/en/security.magicquotes.disabling.php). But what if you need it on to run your legacy code? Here is the inverse of the solution that is provided on the PHP website:

if (!get_magic_quotes_gpc()) {
	function addslashes_deep($value)
	{
		$value = is_array($value) ?
		array_map('addslashes_deep', $value) :
		addslashes($value);
		return $value;
	}

	$_POST = array_map('addslashes_deep', $_POST);
	$_GET = array_map('addslashes_deep', $_GET);
	$_COOKIE = array_map('addslashes_deep', $_COOKIE);
	$_REQUEST = array_map('addslashes_deep', $_REQUEST);
}

Put that at the beginning of your script and it will add all of the slashes back in. Not ideal, but if you have no other option it will get you going again.