Signature Rotation Code

Status
Not open for further replies.
nope. it'll be 3 that i've posted so far. and then i can just change them around if i make a new one that i like.

i've also got a library of close to 100 sigs on my computer that i might draw from.
 
Code:
<?php

$pic = array (
	'http://link-to-image.jpg',
	'http://link-to-image2.jpg',
	'http://link-to-image3.jpg',
	'http://link-to-image4.jpg',
	);

$i = rand(0,count($pic)-1);

$currPic = $pic[$i];

function getExt($img='')
{
	$pos = strrpos($img,'.');

	$ext = substr($img,$pos+1,strlen($img));

	if ($ext === 'jpeg') {
		$ext = 'jpg';
	}

	return strtolower ($ext);
}

function errorImg($pic='')
{
	$img = imagecreatetruecolor (150,30);
	$bgc = imagecolorallocate ($img,255,255,255);
	$tc  = imagecolorallocate ($img,0,0,0);

	imagefilledrectangle ($img,0,0,150,30,$bgc);

	imagestring ($img,1,5,5,'Error Loading '.$pic,$tc);

	return $img;
}

$ext = getExt($currPic);

if ($ext == 'jpg') {
	if (! ($img = @imagecreatefromjpeg ($currPic))) {
		$img = errorImg($currPic);
	}

	header ('Content-Type: image/jpeg');

	imagejpeg ($img);
} elseif ($ext == 'gif') {
	if (! ($img = @imagecreatefromgif ($currPic))) {
		$img = errorImg($currPic);
	}

	header ('Content-Type: image/gif');

	imagegif ($img);
} elseif ($ext == 'png') {
	if (! ($img = @imagecreatefrompng ($currPic))) {
		$img = errorImg($currPic);
	}

	header ('Content-Type: image/png');

	imagepng ($img);
}

imagedestroy ($img);

?>

Save this as whatever you want .php

Find a free webhost, or use a real webhost if you have one. Then, add your pictures here:

Code:
$pic = array (
	'http://link-to-image.jpg',
	'http://link-to-image2.jpg',
	'http://link-to-image3.jpg',
	'http://link-to-image4.jpg',
	);

Using the format that I have. Single quotes around each link, followed by a comma. Just copy what I have and you're set. You can have an unlimited amount of pictures. They must be saved as .jpg, .jpeg, .gif, or .png.

Then, for the sig, just do this:

Code:
[img ]http://url-to-where-the-php-script-is.php[/img ]

Should work. Try it.
 
ok. so where do i plop the long script? does that go in my apache index page? or does that go somewhere else.

and then the shorter one with the image links directly into it, that goes into the apache page.

correct?
 
The shorter code is part of the bigger code, you'll see it at the top of the long code. I was just showing where you'd set your links in the long code. That sounds really confusing, whoas. o_O

If you plan to host it on your own pc, then you need to have Apache (or IIS) and PHP installed and configured, as well as the GD library. Once you have that, just save the script as, say, pics.php (with any text editor, doesn't matter) and then put it in your Apache document root folder (as defined in the httpd.conf).

Then you need to open port 80 in your router, and hope that you have a static IP, and hope that your ISP doesn't block port 80 (otherwise you need to use a different port).
 
The shorter code is part of the bigger code, you'll see it at the top of the long code. I was just showing where you'd set your links in the long code. That sounds really confusing, whoas. o_O

If you plan to host it on your own pc, then you need to have Apache (or IIS) and PHP installed and configured, as well as the GD library. Once you have that, just save the script as, say, pics.php (with any text editor, doesn't matter) and then put it in your Apache document root folder (as defined in the httpd.conf).

Then you need to open port 80 in your router, and hope that you have a static IP, and hope that your ISP doesn't block port 80 (otherwise you need to use a different port).

And dyndns ;)

This is your best bet, I doubt your connection could cope with the load anyhow...

100WebSpace: Free Web Hosting Plan

Tkey
 
You don't necessarily need dyndns. Only if you don't have a static IP do you need that.

But, I agree... just go with a free web host that supports PHP and GD.

If you really need to, I can throw it on my hosting.
 
aite so i registered my stuff on the 100webspace thing and got that all done. i enabled php 5 (don't know differences between 4,5 and 6...) and then i uploaded the .php file to the ftp. when i put in the link to where the script is located nothing pops up in my sig. Thing is I don't know how to enable GD. ideas?
 
Run the following script, it will tell you if GD is supported or not.

Code:
<?php

/* Displays details of GD support on your server */

echo '<div style="margin: 10px;">';

echo '<p style="color: #444444; font-size: 130%;">GD is ';

if (function_exists("gd_info")) {

	echo '<span style="color: #00AA00; font-weight: bold;">supported</span> by your server!</p>';

	$gd = gd_info();
        
	foreach ($gd as $k => $v) {

		echo '<div style="width: 340px; border-bottom: 1px solid #DDDDDD; padding: 2px;">';
		echo '<span style="float: left;width: 300px;">' . $k . '</span> ';

		if ($v)
			echo '<span style="color: #00AA00; font-weight: bold;">Yes</span>';
		else
			echo '<span style="color: #EE0000; font-weight: bold;">No</span>';

		echo '<div style="clear:both;"><!-- --></div></div>';
	}

} else {

	echo '<span style="color: #EE0000; font-weight: bold;">not supported</span> by your server!</p>';

}

echo '<p>by <a href="http://www.dagondesign.com">dagondesign.com</a></p>';

echo '</div>';

?>
 
Status
Not open for further replies.
Back
Top Bottom