Simmons Consulting, the Website of Toby Simmons

Integrating WP in external PHP pages

24
Jun

I have several external pages that use the WP theme engine to wrap the content. I use the method found here, which worked great under WordPress 2.9.2. After upgrading to WP 3.0, these pages no longer worked as expected but instead generated 404s; it turns out the fix is rather simple.

(more…)

HOWTO: Upgrade Ubuntu LTS 8.04 server to PHP 5.2.8

08
Mar

I recently had to upgrade an Ubuntu server to the latest version of PHP (at the time, 5.2.8) … the problem was the server was running Ubuntu 8.04 and the latest version of PHP available through the normal update channels is 5.2.4. The server is running 8.04 because that is the “long term support” version of Ubuntu.

Thanks to Tom Liu and launchpad.net, there is a binary build of PHP 5.2.8 for this version of Ubuntu. I know that real Linux studs would just compile their own, but I didn’t want to go through the build and fail, build and fail process and needed a quick fix. Here are the steps I followed to update my Hardy Heron to PHP 5.2.8.

(more…)

PHP class function for screen scraping

10
Jan

I’ve updated my simple PHP function (the one to replace fopen()) for grabbing URLs using cURL. I’ve added some features and made it a class instead of a straight PHP function. One improvement is the ability to normalize URLs so you can use relative URLs. It also has more error checking and uses a standard user-agent by default.

The syntax is a little different from the previous version. To use it, you create an instance of the object then call the proper method:

  1. $urlScoop = new UrlGrabber;
  2. $rawhtml=$urlScoop->_get($urlScoop->_normalize("https://www.simmonsconsulting.com/"));

Fetching a relative url would look like this:

  1. $urlScoop = new UrlGrabber;
  2. $rawhtml=$urlScoop->_get($urlScoop->_normalize("../../Photos/"));

The function is included in the jump.
(more…)

Connecting PHP 4 to MySQL 5

20
Aug

I recently upgraded one of our MySQL servers from 4.1.22 to 5.1.26. In the process of upgrading, I dumped all the databases, uninstalled MySQL then installed a clean copy of 5.1.26. Then I manually created all the users and schemas by hand, then restored our backups to the new install. Everything went smoothly and all the servers that had PHP 5.x installed could connect with no problems (because they used the latest version of the MySQL client API.)
(more…)

Running a WordPress blog in site root using IIS

21
Apr

Up until recently, I had never been able to setup a WordPress blog as the root of a web site under IIS. But I have discovered the secret and have recently changed my own site so that my content no longer shows up under a “/wordpress” directory but instead in the root.
(more…)