Archive for May, 2006

Cookie-based PHP image rotator(non-random)

Posted on by Alex in Randomness

As a reply to a post on the x10Hosting.com Forums, I made a simple little script that rotates images using PHP. I searched online for a script that did it, but could only find ones that rotated images randomly… which isn’t really rotating them at all.

I did find a snippet of code which generated a random image other that the one that was shown previously (eliminating displaying of duplicate images). I realized this wouldn’t be a bad way to store the last image displayed for the next time the script was run.

In my code, you specify the array of images you wish to display and store them in their desired order. Whenever the file is called, it will read a cookie on the client’s computer as to which image was displayed last. If the cookie isn’t present, it is created. Then it simply displays the next image in the array of images. Don’t worry about overflowing out of the bounds of the array, when the last image is shown, the next one up is the first image.

Go here to view the code: http://alex.elementfx.com/_scripts/rotator.php

Comments Off

Wordplay

Posted on by Alex in Interesting Links, Site updates

Being home from school and not having started my job yet, I find myself with a lot of time on my hands. Obviously this is something that I definitely didn’t have while at school; projects, homework, female-obligations (Hey, I’m not complaining!). You get the idea. But since I’ve been home I’ve started playing around with WordPress, my blog software. I found that it has some pretty spiffy features…

Plugins: Now, WordPress is notorious for it’s plugin support, and this isn’t news to me. I’ve had several different plugins installed from day 1, but I’ve recently found some cool new ones. Particularly akismet, a spam control plugin, Counterize, a stats plugin, and most of all, Widgets. Wigets are pretty sweet, more on that later.

Akismet is a pretty big plugin to control spam in the comments. I’ve been getting a lot of bot-spam on the site lately. Some days, I would get 2 or 3 notifications about comments posted to the site. Invariably, I knew they were all spam, but I would have to visit the site to delete them. Bummer. While akismet is included with the WordPress install, I never activated it. I’m glad I did though. It has caught everything so far.

Counterize is a tiny plugin which keeps track of visitor statistics. You know… hits, pages viewed and referrers. The usual stuff. I had tried to get an AWStats plugin working, but because of the way this host is setup, I couldn’t get it working. Oh well… I like Counterize because it incorporates with WordPress very nicely, and I can see all the site stats from the Admin panel.

Widgets: These things are really cool. By recoding my sidebar slightly, and enabling the Widgets, I can now move the sidebar sections around super-easy. There is an interface in the admin panel which lets me drag-and-drop the sections where ever I want. I can also modify their contents on the fly, add new sections and incorporate cool WordPress features I didn’t know existed.

Needless to say, I’ve been making slight improvements to the site over the past few days. I also created a “Projects” section. This will be home to information about the Java projects I have worked on for class. They were pretty big, so I want to be able to document them online.

Comments Off