Dreamhost php-cgi use different php.ini per directory

The popular gallery webapp still uses dated short PHP open tags <?, this makes it difficult to deploy in a subdirectory of a site that uses XHTML which requires short_open_tag=off to use &lt?xml… headers, leading to the following error. Parse error: syntax error, unexpected T_STRING in /home/foo/example.com/index.php on line 3 This problem is further complicated… Continue reading Dreamhost php-cgi use different php.ini per directory

Reverse geocode using PHP

function getPostcode($lat, $lng) { $returnValue = NULL; $ch = curl_init(); $url = “http://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&sensor=false”; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); $json = json_decode($result, TRUE); if (isset($json[‘results’])) { foreach ($json[‘results’] as $result) { foreach ($result[‘address_components’] as $address_component) { $types = $address_component[‘types’]; if (in_array(‘postal_code’, $types) && sizeof($types) == 1) { $returnValue = $address_component[‘short_name’]; } }… Continue reading Reverse geocode using PHP

Enabling PHP system calls

If you’re struggling to enable any of the functions (system, exec, popen etc) by disabling safe mode, then you’re going down the wrong path. You need to change the disabled_functions key in php.ini instead. ; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names.… Continue reading Enabling PHP system calls

Published
Categorized as geek Tagged

LAMP hello world

Quick start/refresher cheat-sheet on setup of fresh LAMP test server on Ubuntu 9.10. Intended for local development only, no security concerns addressed. Installation apt-get install apache2 libapache2-mod-php5 php5 mysql-server php5-mysql Login as root user to create a dedicated user and database. mysql –user root –password mysql> USE mysql; mysql> CREATE DATABASE testdb; mysql> CREATE USER… Continue reading LAMP hello world

PHP with apache on Mac OS X

Enable apache server with System Preferences -> Sharing -> Web Sharing -> Enable sudo emacs /etc/apache2/httpd.conf # Comment in the following lines #LoadModule php5_module libexec/apache2/libphp5.so #LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so # Restart apache to pickup config changes sudo /usr/sbin/apachectl restart By default two sites are setup. http://localhost/ which maps onto /Library/WebServer/Documents/ and http://localhost/~user which map onto /Users/username/Sites/.

Published
Categorized as geek Tagged ,