Main menu:

Site search



Archive for 'PHP'

How to convert a text URL into a hyperlink

May sound easy, change the HTML…. but there are time when you cannot directly change the HTML.  For instance if your content is database driven, and you don’t want to edit the database source. well, a little PHP code can do the trick $str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str); for example This will take a a [...]

How to bulk replace strings in a file on linux

Ever find that you need to do a bulk/mass replacement of strings in a file on a linux server?  I ran into a situation where I needed to change a website from using persistent connections to mysql to normal.  This involved changing mysql_pconnect to mysql_connect.  Using grep, There were about 5 files to change. Of [...]

Error with file_get_contents(), is there a work around?

Alternative for file_get_contents() I was trying to use file_get_contents to work the other day and was getting an error message. Turns out the function was disabled in the php config. There is a way around this which I found on see below for an example. Instead of: < ?php $file_contents = file_get_contents(‘’); // display [...]

How to solve the PHP Error Warning: Cannot modify header information

That message is the bane of anyone that used the header function to forward to a new Location. Any output from PHP before that command will cause it to fail with a Warning: Cannot modify header information – headers already sent by… Things to check… Look at the :number in the message “headers already sent [...]

How to install Zend in cpanel/whm

pretty darn simple to do… To install Zend Optimizer: 1. Login to your server via SSH 2. Run: /scripts/installzendopt 3. Follow the instructions on the screen to install Zend Optimizer

What the ????? upgrade to php 5.1 and I get broken PNG… gd-png: fatal libpng error: zlib error in

So I did an upgrade from php 4.2.2 to 5.1.something… and now my PNG that are dynamically created on the fly are all broken… I found the solution. After looking in the error logs for apache and finding the following gd-png: fatal libpng error: zlib error in I went and check the manual for imagepng. [...]

Upgrading PHP in cpanel from version 4 to 5

One thing to be aware of when doing the upgrade of cpanel via the WHM control panel, is that when you select your new version for the apache build, it unselects the check box for including PHP in the build. When the Build is complete running, you will have a PHP dead version of apache…. [...]

adsense earnings script

Looking for a way to automatically login to adsense and get a report of your earnings? here is a windows based script that can do just that

ROOT_PATH vulnerabilities.

In PHP there is a vulnerability involving the ROOT_PATH include. It bascially allows via poor coding and a well constructed querystring to pass a file to PHP from a remote server and execute the code. As an example the included file could be used to send spam or phishing email be routing it internally through [...]