Wednesday, June 15th 2011


Fixing TimThumb for PHP 5.3
posted @ 8:01 am in [ Fixing Things -PHP -WordPress ]

The latest version of PHP 5.3 deprecates the ‘ereg’ function, which generates errors that break programs such as TimThumb, the automatic image thumbnail generator.

To fix this, replace the existing ‘ereg’ expressions with alternative functions as per below:

Replace:

if (ereg(‘http://’, $src) == true) {

With:

if (strpos (strtolower ($src), ‘http://’) !== false || strpos (strtolower ($src), ‘https://’) !== false) {

Replace:

if (ereg($site, $url_info[‘host’]) == true) {

With:

if (strpos (strtolower ($url_info[‘host’]), $site) !== false) {

and you are all good to go :->

References:

http://code.google.com/p/timthumb/
http://devthought.com/2009/06/09/fix-ereg-is-deprecated-errors-in-php-53/




Tuesday, August 24th 2010


WordPress – PHP Fatal error: Call to undefined function get_option() in admin
posted @ 8:51 am in [ Fixing Things -Web Design -WordPress ]

For us, this was a strange problem in FreeBSD where even with a vanilla latest version of WordPress the error still occurred and we got a white screen trying to login to our admin area.

It seems to be caused by FreeBSD incorrectly thinking that the required files have been included as asked for in PHP using a require_once function.

So to fix it we manually added the wp-includes/functions.php file and change the existing require_once for wp-load.php in ‘wp-admin/admin.php’ to be:

[modified wp-admin/admin.php lines 20 and new line 21]

require(dirname(dirname(__FILE__)) . ‘/wp-load.php’);
require(dirname(dirname(__FILE__)) . ‘/wp-includes/functions.php’);

[original for reference line 20]

require_once(dirname(dirname(__FILE__)) . ‘/wp-load.php’);

Problem solved!