black
read my profile
sign my guestbook

Message: message me


Member Since: 1/1/2001

SubscriptionsSites I Read

Posting Calendar

|<< oldest | newest >>|
view all weblog archives

Get Involved!

Suggest a link

Recommend to friend

Create a site


Monday, January 01, 2001

For all you perl heads, here is a random script to change your head image around in xanga or anywhere else:



#!/usr/bin/perl
#
#
# Random Image - non-ssi
#########################
# Install:
# Set the 2 variables below.
# Upload to your server.
# CHMOD it to 755
# Call the script in your image tag:
# http://www.yoursite.com/cgi-bin/ranimage_nssi.cgi
# OR call directly from your browser:
# http://www.yourdomain.com/your cig-bin/ranimage_nssi.cgi
#
# All non-image files are weeded out, so you can use this to
# randomize images in any dir.
#
#
########################################
# E D I T V A R I A B L E S


# The UNIX dir of your images.
$IMG_DIR = "img/";


# The URL of $IMG_DIR
$VIRTUAL_DIR = "http://www.yourdomain.com/random_img/img;


# E N D V A R I A B L E S
#######################################################


opendir(DOT,"$IMG_DIR")|| &error ("Cannot Open $IMG_DIR");
foreach (sort readdir(DOT))
{
$file = $_;
if (($file =~ /.gif/) || ($file =~ /.tif/) || ($file =~ /.jpg/) || ($file =~ /.GIF/) || ($file =~ /.TIF/) || ($file =~ /.JPG/))
{ push (@dir_list, "$file");}
}
closedir(DOT);



srand(time ^ $$);
$IMG_NUM =rand(@dir_list);


print "Location: $VIRTUAL_DIR/$dir_list[$IMG_NUM]\n\n";


################
# ERROR HANDLING
################
sub error
{

print "Content-type: text/html\n\n";
print "<BOLD><FONT size=+1>Error:<FONT COLOR=\"#FF0000\"> <B>$_[0]</B></FONT></FONT><BR>";
exit;
}