Archive for the 'Programming' Category

htaccess to deny access, except for includes

It's usually a bad idea to allow php include files to be directly accessed. My general method is to either declare a constant in the index.php and check for that constant in the included file or make sure that the included file doesn't match $_SERVER['REQUEST_URI'].
Sure, either of those work. But I [...]

Dynamically link to CSS with JavaScript

Needed a way to add a CSS file with JavaScript, so I went out a-Googling like I normally do.  Problem is everything I found either worked in Internet Explorer and not in FireFox or the other way around.  Nothing I found worked in both.  So I hacked together a function of my own.  Should have [...]

phpMailer – Could not instantiate mail function

Had a client getting this error when trying to send emails last week and have now spent several hours on Google trying to find a solution.
Biggest catch is that other scripts were able to send mail, so it seemed unlikely that it was the host. So I took the phpMailer class and uploaded it [...]

bit.ly and PHP

Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me.
David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link.
Link: http://davidwalsh.name/bitly-php
Just put the [...]

Quick PHP wrapper for print_r

Working on web apps I find myself using the print_r command a lot, and I mean a lot. It helps trace out what data is going where, and more often what's not going where it's supposed to.
A few months ago I realized that I type this same bit of code way too often.
PLAIN TEXT
PHP:

echo [...]

Safari, scriptaculous, and non-clickable links

For the better part of the last couple of days I've been trying to figure out why Safari was not allowing me to click on links. Aside from an annoyance, it's not good to have clients complaining...

Prototype.js, setStyle, and IE not working together

Sometimes IE just irritates me. Ok, pretty much anytime I'm working on a web site. Especially when it involves Javascript or DOM.
For the past couple of hours I've been scouring the internet looking for a solution to the prototype method setStyle not working in IE8. I was getting an 'Object [...]

Curved corners script for Photoshop

I've been looking for an excuse to play around with scripting in Photoshop. Today I found one. I came across a series of actions that rounded off the corners of an image to get it ready for uploading to a web site. The problem is that it was a series of actions. [...]

Event tracking with JavaScript

A while back Google added event tracking to Analytics so you could keep track of Javascript and Flash events.  Pretty cool feature.
Being the stat junkie that I wanted to use this to keep track of outgoing clicks on a photography forum of mine.  But I didn't want to have to go through every link prior [...]

How to wrap a SMF forum in WordPress

After spending the better part of yesterday getting a forum setup with the same layout as its parent WordPress site I thought I'd share a couple of tips along the way.
And I picked a less efficient way, including wp-blog-header.php in the forum code, because it was far easier. At some point I may go back [...]