Random Images Script

This script will randomize images. Useful for ads or simply a change of scenery. Link capabilities are in this script. Please comment back, I would like to hear everyone’s response.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// Created by Matt Lo, very simple :)
class random_images {
	// store images
	protected $_images = array();
	// no constructor needed
 
	// properties per image, protected, all parameters are strings
	// $location = path/to/image.jpg, REQUIRED
	public function define_image($location, $title=NULL, $link=NULL, $target='_blank') {
		// html code for image with variables
		// removing border, you can edit it out or leave it in
		$image = '<img src="'.$location.'" alt="'.$title.'" style="border: none;" />';
 
		// if link param has value to it...
		if($link != '') {
			$image = '<a href="'.$link.'" target="'.$target.'">'.$image.'</a>';
		}
 
		// array, key index starts at 0
		$this->_images[] = $image;
	}
 
	public function display() {
		// randomize the array by finding max
		$rand_int = mt_rand(0, count($this->_images)-1);
		return $this->_images[$rand_int];
	}
}
 
// Usage
// NOTE: You can put the class into a separate page, then include it
// start
$image = new random_images();
// example 1
$image->define_image("http://cdn.joomla.org/images/logo.png", 'testing j');
// lets add a mix of linked images
$image->define_image("http://drupal.org/sites/all/themes/bluebeach/logos/drupal.org.png", 'drupal', 'http://drupal.org');
// output
echo $image->display();
?>

Example: http://mattloinfo.com/scripts/random_image.php

Updates Part 2

New theme, new plugins (search cloud, twitter), AND updated my wordpress admin area.

So this night I updated everything on my domain since I’ve been pretty lazy posting, added myself to some project site that asks developers/coders to make websites, downloaded CS4 Flash trial, and I cleaned my desktop since I got a million files just sitting there doing nothing.

PHP:
http://mattloinfo.com/pub-code.php/class.coremail.php
Simple little class for Private Messaging, I’ll keep building onto it since its lacking a bunch of stuff but its a start.

CONFICKER is not really a problem for me, since I’m not an idiot (not saying you are).