PHP

PHP FPM Errors After Upgrade

6obj0w9nop

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? Continue reading “Tracing Email Sending PHP Scripts On Servers” »

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. Continue reading “Executing PHP Code Server Side In .html Files” »

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: Continue reading “Easy PHP File Extensions With PathInfo” »

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: 173.25.1.129, server: project.com, request: “GET /jobs/update HTTP/1.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “project.com” 2012/07/06 17:41:01 [error] 23897#0: *8960 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 173.25.1.129, server: project.com, request: “GET /jobs/update HTTP/1.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “project.com” 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. Continue reading “PHP CGI 504 Gateway Timed Out Errors With Nginx” »

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: http://www.google.com/ig/calculator?hl=en&q=1AUD=?USD Continue reading “Currency Conversion With Google Calculator” »

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. Continue reading “Using The Panoramio Wrapper Class” »

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. Continue reading “Anonymizing CURL Scripts With TOR & Polipo” »

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