open All Channels
seplocked EVE Forum Experiments
blankseplocked Rotate Sigs
 
This thread is older than 90 days and has been locked due to inactivity.


 
Author Topic

CCP Zymurgist


Gallente
C C P
Posted - 2009.12.21 18:20:00 - [1]
 

With special thanks to Joshua Calvert & Chribba

Step 1)

Gather your collection of sigs.

Step 2)

Put them all in one folder on your webserver.

Step 3)

Cut and paste the below code in tyour favourite text editor:


<?php

*/

$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';


// You don't need to edit anything after this point.


// --------------------- END CONFIGURATION -----------------------

$img = null;

if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}

if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);

if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}

if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}

?>


Save it with whatever name you like with the extension of .php

Step 4)

Point your signature to http://www.yourwebserver.com/rotate.php

And for the ASP way

<%
Randomize
Num = Int((Rnd * 4) + 1)
If Num = 1 Then
Response.Redirect("http://foo.com/image1.jpg")
ElseIf Num = 2 Then
Response.Redirect("http://foo.com/image2.jpg")
ElseIf Num = 3 Then
Response.Redirect("http://foo.com/image3.jpg")
Else
Response.Redirect("http://foo.com/image4.jpg")
End If
%>

CCP Zymurgist


Gallente
C C P
Posted - 2009.12.21 18:21:00 - [2]
 

PHP

Remember that you need to place this script ("rotate.php") within the SAME folder as your sigs and link to the script itself, using the IMG tags:-

e.g. http://www.mysite/sigs/rotate.php

<?php

if ($dir = opendir("."))
{
$list = buildimagearray($dir);
displayrandomimage($list);
}

// This function reads all the files in the current directory and adds all image files to the array $list[]
function buildimagearray($dir)
{
while (false !== ($file = readdir($dir)))
{
if (!is_dir($file) && getimagesize($file))
{
$list[] = $file;
}
}
return $list;
}

// This function selects a random image, determines the mime type, opens the file for reading,
// and then outputs the image
function displayrandomimage($list)
{
srand ((double) microtime() * 10000000);
$sig = array_rand ($list);

$size = getimagesize ($list[$sig]);
$fp = fopen($list[$sig], "rb");

if ($size && $fp)
{
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
}
}
?>



put all your pics in a folder

create a php file called random.php that contains

<?php
$dir = opendir('.');
$files = array();

while($file = readdir($dir)){
if(strpos($file, ".gif") != false || strpos($file, ".jpg")!=false || strpos($file, ".png")!=false){
array_push($files, $file);
}
}
$index = mt_rand(0, count($files)-1);
$filename = $files[$index];
$ext = substr($filename, strrpos($filename, ".")+1);

$file = file_get_contents($files[$index]);
header("content-type: image/".$ext);
echo $file;
?>

make sure it is in the same file as the images.

now, you want to link to it

i.e. http://www.bkoa.us/ef1/images/banner/random.php/1.jpg

that 1.jpg does NOT interfere with the random, but allows the forum to see it as a valid picture format

This method WILL work on other formats as well.

CCP Zymurgist


Gallente
C C P
Posted - 2009.12.21 18:22:00 - [3]
 

ASP

<%
Randomize
Num = Int((Rnd * 4) + 1)
If Num = 1 Then
Response.Redirect("http://foo.com/image1.jpg")
ElseIf Num = 2 Then
Response.Redirect("http://foo.com/image2.jpg")
ElseIf Num = 3 Then
Response.Redirect("http://foo.com/image3.jpg")
Else
Response.Redirect("http://foo.com/image4.jpg")
End If
%>

CCP Zymurgist


Gallente
C C P
Posted - 2009.12.21 18:22:00 - [4]
 

Perl

bytes: 223 (vs original 1404) = 15.9%
lines: 8 (vs original 68) = 11.8%

--file begins--
#!/usr/bin/perl

my $directory="src";
my @files=(glob("$directory/*.jpg"),glob("$directory/*.png"),glob("$directory/*.gif"));
my $file=$files[rand @files];
print "Status: 302 Found\n";
print "Location: $file\n";
print "\n";
--file ends--

file is placed one dir above images dir "src" if $directory is used as above, use $directory "" if in the same dir, use "/absolute/path/from/webroot" or "relative/path/from/script" as needed


 

This thread is older than 90 days and has been locked due to inactivity.


 


The new forums are live

Please adjust your bookmarks to https://forums.eveonline.com

These forums are archived and read-only