PHP FPM Errors After Upgrade

Recently I noticed a few of my servers had stopped serving my sites, with  502 errors being to visitors. I took a look at my site logs and noticed that they were full of the “Permission Denied” errors below: 2014/06/09 09:45:17 [crit] 11453#0: *22 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream A little more investigation and I found that a privilege escalation issue in the PHP default fpm configuration had been found. This had consequently been fixed in the latest releases. But unless a systems administrator is paying attention and knows that changes to the config are required, upgrading the PHP instance leads to a broken web server. […]

By |June 10th, 2014|PHP, Security, Sysadmin|0 Comments

Tracing Email Sending PHP Scripts On Servers

It happens sometimes, a server you are responsible for seems to be sending out spammy emails, and its normally caused by legacy or insecure code. The mail log indicates there are plenty of potential spam messages going out that are originating locally but most Linux servers host a lot of sites. So the question then becomes, how do I find the script thats responsible for sending all of the emails? […]

By |July 9th, 2013|Linux, PHP|0 Comments

Executing PHP Code Server Side In .html Files

On a recent project we needed to provide a client our contribution to the site code base as static .html files. To make the development process easier though a number of the developers wanted to include some of the global page assets such as the header and footer using PHP includes in their development environments. This of course normally does not work as the server never passes the page content to the PHP engine to process as it doesn’t have a .php or .phtml extension. […]

By |November 26th, 2012|PHP, Sysadmin, web development|0 Comments

Easy PHP File Extensions With PathInfo

The other day I was building some file handling functionality into a project I was working on when i came to thinking about the best way to retrieve the extension of a filename with PHP. The first approach that came to mind was using explode statement to split the string at the full stop giving the extension of the file in the last array element. The second was using substr and strrchr in combination similar to below: […]

By |August 15th, 2012|PHP|0 Comments

PHP CGI 504 Gateway Timed Out Errors With Nginx

Recently I noticed that the nginx error log for a site I was working with was filling up with timeout messages similar to below: 2012/07/06 17:21:01 [error] 23897#0: *8870 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: “GET /jobs/update HTTP/1.0”, upstream: “fastcgi://”, host: “” 2012/07/06 17:41:01 [error] 23897#0: *8960 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: “GET /jobs/update HTTP/1.0”, upstream: “fastcgi://”, host: “” The script in question is normally called via a cron job, pulling alot of information from external sources and then storing for later reference to a local database. Loading the location in a browser resulted in the page working for awhile and then returning with a 504 Gateway timed out error page. So things obviously wern’t happening quick enough for the liking of nginx and it was recording the problem as a timeout error in the log file. […]

By |August 3rd, 2012|Linux, PHP|0 Comments

Currency Conversion With Google Calculator

Working on a recent project I found myself in the market for a way to simply calculate what one currency is worth in relation to another. After some looking around I was surprised to find currency conversion can be performed quickly and simply using the Google Calculator API. To use you need only make a request to the API similar to this: […]

By |July 25th, 2012|PHP|0 Comments

Magic Quotes In PHP

The Symptoms Recently I was trying to debug a piece of code it worked fine in the development and staging environments. But when the code was uploaded to the production server it would break! Looking at the JSON data it appeared the production web server was adding back slashes to the data in the JSON [...]

By |June 30th, 2012|PHP|0 Comments

Using The Panoramio Wrapper Class

Ever been working on a project that was area specific and wanted nearby local images? I did recently, and knew after seeing images over layed onto Google maps that it must be possible. Looking around I found a few pieces of code that did what I wanted using the Panoramio API but they were all written in Javascript and I wanted to do some server side processing and caching before presenting them. This prompted me to create a Panoramio wrapper class. Simply instantiate and provide your chosen location via its longitude and latitude and the class will return a PHP object containing images from the surrounding area. The project show up in github as being written in Javascript although this is wrong the main code is PHP, the inclusion of jQuery and a few other javascript libraries with the documentation seem to have thrown its language detection off. […]

By |June 15th, 2012|Open Source, PHP|0 Comments

Magic constant not working with require_once

Its funny when a new feature is added to your language of choice how quickly it gets embraced and used within your code. Today upon uploading some code to a clients shared hosting environment I was greeted by the following error: Uploading a file to display phpinfo() I was able to ascertain the server was [...]

By |March 14th, 2012|PHP|0 Comments

Anonymizing CURL Scripts With TOR & Polipo

Last week I received a typical run of the mill phishing email littered with the usual bad Engrish making the instructions far from believable but being bored I decided to take a look at the link they were pushing. They had created a believable enough looking Paypal form asking clueless punters to enter their credit card details in order to avoid having their account being suspended. After playing around with the form for awhile in Firebug I decided to create a quick script to poison their data by submitting a new fake 16 digit VISA number along with random card holder name, CVV number and expiry date every couple of seconds. After running this script for half an hour I decided that the script while it did the job would be a lot better if the posted data was coming from an anonymous IP address. Here I will run you through the process of setting up TOR & Polipo on a machine to add an element of anonymity to the data being sent and received by your CURL based script using. […]

By |August 10th, 2011|Linux, PHP|0 Comments