Welcome aboard Visitor...

Daily Screenshot

Server Costs Target


84% of target met.

Latest Topics

- so i talked with Massi »
- See Commands »
- Now the fun begins »
- Qand answers have returned »
- Call to Arms »
- All Species 8572 Report in »
- hi there »
- Anyone still playing from a decade ago or longer? »
- Game still active. NICE! »
- help me »

Development Blog

- Roadmap »
- Hello strangers, it’s been a while... »
- State of DarkSpace Development »
- Potential planetary interdictor changes! »
- The Silent Cartographer »

Combat Kills

Combat kills in last 24 hours:
No kills today... yet.

Upcoming Events

- Weekly DarkSpace
11/23/24 +20.7 Hours

Search

Anniversaries

No anniversaries today.

Social Media

Why not join us on Discord for a chat, or follow us on Twitter or Facebook for more information and fan updates?

Network

DarkSpace
DarkSpace - Beta
Palestar

[FAQ
Forum Index » » English (General) » » How to make a PHP random image signature.
 Author How to make a PHP random image signature.
JBud
Marshal

Joined: February 26, 2008
Posts: 1900
From: Behind you.
Posted: 2008-10-14 08:58   
This will select a random image from a directory of any amount of images(signatures)


first thing you need is a directory if you are using an ftp just create a folder and add your signatures (jpg jpeg png gif) into the folder

open notepad.exe

copy paste this script

/*---------------------------------------------------------------/
/ This program is free software; you can redistribute it and/or /
/ modify it under the terms of the GNU General Public License /
/ as published by the Free Software Foundation; either version 2 /
/ of the License, or (at your option) any later version. /
/---------------------------------------------------------------*/

//
// Configuration

// Change this to the pathname of the directory where the random images reside. If for example your page is at
// http://www.website.com/random.php and all the random images are in the directory http://www.website.com/random/ you
// should leave this as-is. All files with a .gif (boo UNISYS!), .jpg, .jpeg or .png extension in this directory
// will be added to the rotation
$path = './random/';

$files=array();
if ($handle=opendir("$path")) {
while(false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
substr($file,-3)=='gif';
substr($file,-3)=='jpg';
substr($file,-3)=='jpeg';
substr($file,-3)=='png';
$files[count($files)] = $file;
}
}
}
closedir($handle);

$random=rand(0,count($files)-1);
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='jpeg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");
readfile("$path/$files[$random]");
?>
save as index.php
Place index.php in '(path)/rotate/'
Place Images in '(path)/rotate/random/'
set your signature in your profile to

[img](path)/rotate/[/img]

your done thats all u have to do!
(NOTE:make sure all of your signatures in the directory are less than 500x200 50kb)

[small][ This Message was edited by: JBud on 2009-04-12 17:48 ][/small]
[small][ This Message was edited by: JBud on 2009-04-12 17:49 ][/small]
[ This Message was edited by: JBud on 2009-04-12 17:58 ]
_________________
[-Point Jumper-][-Privateer Elite-][-Summus Dux-][-Praeclarae-]
[img(RIP MY SIGNATURE DELETED AFTER 7 YEARS/img]
''Insisto Rector - Suivez le Guide - Tempus hostium est''

  Email JBud   Goto the website of JBud
BackSlash
Marshal
Galactic Navy


Joined: March 23, 2003
Posts: 11183
From: Bristol, England
Posted: 2008-10-14 09:04   
Bit overly complicated, but it'll work.

Also bare in mind that you need a PHP enabled host for this to work...
_________________


Eledore Massis [R33]
Grand Admiral
Templar Knights


Joined: May 26, 2002
Posts: 2695
From: tsohlacoLocalhost
Posted: 2008-10-14 12:09   
p.s. smart people save it as index.php and don't include the php file definition at the end of your link. e.g; http://ds.37542.nl/pictures/signature/eledore/
Ok not giving the php file can cause problems for people are still using IE4 or below. but who the heck would still use IE4.


Quote:
On 2008-10-14 12:12, JBud[ADM] wrote:
that link is dead

Ok forgive me for using a backdoor to the servers.
Corrected URL.
[ This Message was edited by: Eledore[NL] on 2008-10-14 12:53 ]
_________________
DS Discordion

JBud
Marshal

Joined: February 26, 2008
Posts: 1900
From: Behind you.
Posted: 2008-10-14 12:12   
.
[ This Message was edited by: JBud[ADM] on 2008-10-15 03:11 ]
_________________
[-Point Jumper-][-Privateer Elite-][-Summus Dux-][-Praeclarae-]
[img(RIP MY SIGNATURE DELETED AFTER 7 YEARS/img]
''Insisto Rector - Suivez le Guide - Tempus hostium est''

  Email JBud   Goto the website of JBud
Eledore Massis [R33]
Grand Admiral
Templar Knights


Joined: May 26, 2002
Posts: 2695
From: tsohlacoLocalhost
Posted: 2009-04-12 16:49   
Nice of you to take my php script but if i recall it had some more lines..
This is the whole code..


  • /*---------------------------------------------------------------/
    / This program is free software; you can redistribute it and/or /
    / modify it under the terms of the GNU General Public License /
    / as published by the Free Software Foundation; either version 2 /
    / of the License, or (at your option) any later version. /
    /---------------------------------------------------------------*/

    //
    // Configuration

    // Change this to the pathname of the directory where the random images reside. If for example your page is at
    // http://www.website.com/random.php and all the random images are in the directory http://www.website.com/random/ you
    // should leave this as-is. All files with a .gif (boo UNISYS!), .jpg, .jpeg or .png extension in this directory
    // will be added to the rotation
    $path = './random/';

    $files=array();
    if ($handle=opendir("$path")) {
    while(false !== ($file = readdir($handle))) {
    if ($file != "." && $file != "..") {
    substr($file,-3)=='gif';
    substr($file,-3)=='jpg';
    substr($file,-3)=='jpeg';
    substr($file,-3)=='png';
    $files[count($files)] = $file;
    }
    }
    }
    closedir($handle);

    $random=rand(0,count($files)-1);
    if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
    elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
    elseif(substr($files[$random],-3)=='jpeg') header("Content-type: image/jpeg");
    elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");
    readfile("$path/$files[$random]");
    ?>
Quote:

On 2008-10-14 08:58, JBud wrote:
substr($file,-3)=='gif jpg jpeg png';
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
[ This Message was edited by: JBud on 2009-04-11 21:41 ]


+ that explains why it won't properly work on your server, i only gave you a copy of my own random.
Mine only has GIF in the substr.. you just added all those extra statements to a single substr... pure failage.

[edit] Forgot the [code] doesn't work here.

[ This Message was edited by: Eledore ICC Massis [R33] on 2009-04-12 16:54 ]
_________________
DS Discordion

Sens [R33]
Admiral

Joined: September 27, 2008
Posts: 1020
From: Edge of th...
Posted: 2009-04-12 17:26   
rofl, comments are good too...
_________________
Proud member of the Order of the Gaifen
Founder and former Club chair of the Shigernafy Fan Club
Co-founder of the Doran Judication Comittee


  Email Sens [R33]
JBud
Marshal

Joined: February 26, 2008
Posts: 1900
From: Behind you.
Posted: 2009-04-12 17:43   
yea I had deleted them out when I put in my site, and when I put it here I just copied what I had on there, and yea, fail. Thanks for the fix

[ This Message was edited by: JBud on 2009-04-12 17:47 ]
_________________
[-Point Jumper-][-Privateer Elite-][-Summus Dux-][-Praeclarae-]
[img(RIP MY SIGNATURE DELETED AFTER 7 YEARS/img]
''Insisto Rector - Suivez le Guide - Tempus hostium est''

  Email JBud   Goto the website of JBud
Supertrooper
Marshal
Pitch Black


Joined: March 18, 2004
Posts: 1895
From: Maryland, U.S.A
Posted: 2009-04-12 20:04   
Er, so you stole his work and didn't credit him? Nice one.


And this is more of a 'Here, have a free PHP Random Image Signature' rather than 'How to Make' one.
_________________


  Email Supertrooper
JBud
Marshal

Joined: February 26, 2008
Posts: 1900
From: Behind you.
Posted: 2009-04-12 20:26   
this thread is half a year old
_________________
[-Point Jumper-][-Privateer Elite-][-Summus Dux-][-Praeclarae-]
[img(RIP MY SIGNATURE DELETED AFTER 7 YEARS/img]
''Insisto Rector - Suivez le Guide - Tempus hostium est''

  Email JBud   Goto the website of JBud
Pakhos[+R]
Chief Marshal
Pitch Black


Joined: May 31, 2002
Posts: 1352
From: Clean room lab
Posted: 2009-04-12 21:36   
Quote:

On 2009-04-12 20:04, Crim [R33] wrote:
Er, so you stole his work and didn't credit him? Nice one.


And this is more of a 'Here, have a free PHP Random Image Signature' rather than 'How to Make' one.




chill, he is our next dev.
_________________
* Josef hands [PB]Quantium the Golden GothThug award for best melodrama in a miniseries...
[-GTN-]BackSlash: "Azreal is a master of showing me what is horribly broken in the game."

JBud
Marshal

Joined: February 26, 2008
Posts: 1900
From: Behind you.
Posted: 2009-04-12 21:55   
Quote:

On 2009-04-12 21:36, Pakhos wrote:
Quote:

On 2009-04-12 20:04, Crim [R33] wrote:
Er, so you stole his work and didn't credit him? Nice one.


And this is more of a 'Here, have a free PHP Random Image Signature' rather than 'How to Make' one.




chill, he is our next dev.


lolwut? you know somethin' I don't?
_________________
[-Point Jumper-][-Privateer Elite-][-Summus Dux-][-Praeclarae-]
[img(RIP MY SIGNATURE DELETED AFTER 7 YEARS/img]
''Insisto Rector - Suivez le Guide - Tempus hostium est''

  Email JBud   Goto the website of JBud
Pegasus
Grand Admiral
Pitch Black


Joined: August 02, 2005
Posts: 434
From: Eleventh galaxy on the right!
Posted: 2009-04-13 02:53   
Quote:

On 2009-04-12 21:36, Pakhos wrote:
Quote:

On 2009-04-12 20:04, Crim [R33] wrote:
Er, so you stole his work and didn't credit him? Nice one.


And this is more of a 'Here, have a free PHP Random Image Signature' rather than 'How to Make' one.




chill, he is our next dev.




God help us!
_________________
Retired K'luth Combateer


Sens [R33]
Admiral

Joined: September 27, 2008
Posts: 1020
From: Edge of th...
Posted: 2009-04-13 15:16   
Quote:

On 2009-04-13 02:53, Pegasus™ wrote:
Quote:

On 2009-04-12 21:36, Pakhos wrote:
Quote:

On 2009-04-12 20:04, Crim [R33] wrote:
Er, so you stole his work and didn't credit him? Nice one.


And this is more of a 'Here, have a free PHP Random Image Signature' rather than 'How to Make' one.




chill, he is our next dev.




God help us!



_________________
Proud member of the Order of the Gaifen
Founder and former Club chair of the Shigernafy Fan Club
Co-founder of the Doran Judication Comittee


  Email Sens [R33]
Page created in 0.016880 seconds.


Copyright © 2000 - 2024 Palestar Inc. All rights reserved worldwide.
Terms of use - DarkSpace is a Registered Trademark of PALESTAR