48 blogs & 60 users

Posts Tagged ‘code’

A major problem fixed

October 11th, 2008

Over the past few days, as I have been increasingly active in “fixing” PersonalLog, I noticed something that’s always been perplexing to me. Our database had been increasing significantly in size, and it was rather odd.

I decided to use phpMyAdmin to take a look. What I found was disturbing. (No screenshots.)

The database had over 4000 records in the options table for many blogs. Looking through some of the records, I quickly ascertained that most of the records were duplicate entries: “kb_robotstxt” and the robots.txt file as the value.

I immediately proceeded to wipe the 4000+ records from the tables, which ended up halving the size of the database after optimization. I then went over to the File Manager for a bit more investigation.

The problem was clearly the “KB Robots.txt” plugin. After checking the plugin’s PHP file, I was shocked to see an ugly piece of code that inserted a database record for the plugin’s options every time it was loaded. Since WordPress plugins are loaded on every page load, this meant that the plugin was inserting a new record into the table for every page load, unnecessarily.

I know I could have changed the plugin so that it only did so upon activation. But I was so disturbed by this piece of bad coding that I proceeded to delete it immediately.

As a result, all blogs depending on the “KB Robots.txt” plugin will no longer have access to it. Instead, I did something that was better; I made a default, search engine optimized robots.txt file identical to what the plugin produced, so all blogs will now benefit from the robots.txt optimization, without the need for an inefficient plugin. :)

Addendum: the database has been further optimized by purging the caches of the various RSS feeds in the dashboard. This means that the first time you log in to your dashboard after these changes, there will be a slight delay (both before and after you load the page) while WordPress fetches the RSS feeds. However, the database is now a fifth of its unoptimized size and will perform significantly more efficiently. :)

Enjoy your blogs on a cleaner, faster database.

Scribd iPaper is now available

September 29th, 2008

I’ve added a new plugin to PersonalLog, built by me, which will allow simple insertion of iPaper documents. It is unlikely that I will ever integrate this into PersonalLog (along with the other video embed codes) because this one requires an additional piece of JavaScript code, and it would be inefficient to load that code on every blog.

Here’s what you do.

1. Upload the document to Scribd, or find a document

Upload to Scribd

2. Go to the document’s page (e.g. http://www.scribd.com/doc/6184541/Minutes-for-September-22-2008).

Scroll down until you see “More Info”. Click on it.

3. Make note of the URL

The URL now contains all the information you need to embed the document.

The all digit portion of the URL (before the question mark) is the document id.

The part starting with “key-” and containing a weird jumble of alphanumeric characters is the access key.

4. Use the [ipaper] embed code

First, make sure that you’ve activated the “Simpler iPaper” plugin. (I’m planning on releasing this as open source.)

Then, use the following syntax:

[ipaper id="document id" accesskey="access key"]

For instance, to embed the document above, I would use:

[ipaper id="6184541" accesskey="key-1krukpl84ovn1aktdcyp"]

I hope this is helping you to embed documents in your blog!

Tip: use height=”a number” and/or width=”a number” to customize the embed!