Skip to main content

Posts

Showing posts from June, 2008

Quick Smarty tip - Restricting when the debug console is shown

Another tip for those who have to work on live servers. The debug console is quite handy if you're using the smarty templating engine - but probably not something that should be shown to "real" users. So, an easy fix is to restrict it to be shown to only traffic coming from your IP address, like so: {if $smarty.server.REMOTE_ADDR == "[your ip address]"} {debug} {/if}

What is up with gibberish spam?

Every now and then you'll run across this - spammers dumping large amounts of apparentl gibberish in to comments, forums, etc. It's very strange - it's not code, and there's no links or anything else of apparent use to the spammer. So why do they bother? I have a couple theories. One possibility is that it is a malfunctioning bot. That's kind of fun to imagine, but seems unlikely. Thinking about how a spam bot would be coded, I'd think it more likely to leave empty comments if something was wrong then long strings of gibberish. The other possibility is that the bot is actually leaving a "fingerprint" in the form of a unique text string. The spammer can then check his work later by just doing a google search for this text. If the spam comes up it tells him several useful things: His bot worked and left a message The message was not deleted/moderated The page that was spammed is indexed by google It'd be possible to have a second automated bot do t...

Updating on the fly

I thought this was a moderately clever solution to a problem, so I thought I'd share it here. A client wanted to add thumbnails for every entry on their huge movable-type powered blog site. They already had full-size pics for most posts, they just wanted a preview thumbnail version associated with each post for use in the xml feed, search results, etc. This is a static movable type powered site with thousands of entries. The standard solution would be to create a new field using RightFields and store the filename of an image their, and then somehow go through all those thousands of entries and create thumbnails, then save the thumb filename in the new field. And do a full rebuild of the site. This would work, but it was going to take forever ! The first thing to figure out was how to automatically create those thumbs. I knew that the first image in each post was the one to use, so it was pretty easy to set up a little php script that would find that image tag in the entry body, and...

Making live changes on large high-traffic sites

Somehow I seem to often be in the position where I need to make changes to large, complex, high-traffic sites - changes to the live site that is... Yes, they should have dev/staging servers, but they don't, and I'm not in a position to make them set it up... So changes must be made with a minimum of disruption to the site. Usually the best way to do this is to make a test copy of the page that's going to change and work with that - so that if you break something it doesn't affect the live page. But in some cases this isn't feasible - for one large site a change will involve a cascading set of php files and smarty templates - and I'd have to make copies of all of those, plus change the includes in the right place etc. to make it all work. Then undo all that to make the changes live... Not the best way to set up a system, but that's a topic for another day. So how to minimize disruption? One way I've alluded to before - take advantage of Firebug by putt...