• 0

PHP Random sig image


Question

Recommended Posts

  • 0

i think keldyn is right

and here u go;)

<?

$URL1="sigs/sig1.jpg";

$URL2="sigs/sig2.jpg";

$URL3="sigs/sig3.jpg";

srand((double) microtime() * 1000000);

$random = rand(1,3);

if($random == 1)

@header ("Location: $URL1");

elseif ($random == 2)

@header ("Location: $URL2");

elseif ($random == 3)

@header ("Location: $URL3");

?>

  • 0

The majority of people use php files, thats what I used. I warn you though, if you intend on using this, make sure you have a lot of bandwidth because these eat it up for breakfast.

Just for reference, here's the coding I had in my "sig.php":



<?

$URL1="sig/Real.jpg";

$URL2="sig/Lust.jpg";

$URL3="sig/Fate.jpg";

$URL4="sig/Love.jpg";

$URL5="sig/Hate.jpg";

$URL6="sig/Pure.jpg";

$URL7="sig/Hope.jpg";

$URL8="sig/True.jpg";

$URL9="sig/Luck.jpg";



srand((double) microtime() * 1000000);

$random = rand(1,9);



if($random == 1)

@header ("Location: $URL1");

elseif ($random == 2)

@header ("Location: $URL2");

elseif ($random == 3)

@header ("Location: $URL3");

elseif ($random == 4)

@header ("Location: $URL4");

elseif ($random == 5)

@header ("Location: $URL5");

elseif ($random == 6)

@header ("Location: $URL6");

elseif ($random == 7)

@header ("Location: $URL7");

elseif ($random == 8)

@header ("Location: $URL8");

elseif ($random == 9)

@header ("Location: $URL9");

?>[/PHP]

This was for 9 random sigs, the sigs are called "real.jpg", "Lust.jpg" etc. They are placed in a folder called "Sig".

I'm real crap at explaining this so you'd probably be better off searching in the forums, because I know there was a good thread dedicated to this.

Edit: Damn, you beat me to it... :evil:

  • 0
  Quote
Originally posted by prasanth16

Dazzla im a lil fast:P

yeah I suppose, but mine's in nice pretty PHP tags and That extra minute was spent trying to explain it (poorly I admit :D ), so :lick:

Disclaimer: for people who lack a sense of humour, this is called sarcasm

  • 0

Here's a random image script in perl, it chooses a random file from a directory you specify.

&lt;pre&gt;

#!/usr/bin/perl

$IMAGE_DIRECTORY = "INSERT ABSOLUTE PATH TO DIRECTORY";

my $line = "";

my $file1= "";

my $x=0;

opendir (DIR,"$IMAGE_DIRECTORY");

while ($fileName = readdir(DIR)) {

        next if (-d $IMAGE_DIRECTORY . $fileName);

	next if ($fileName !~ /w/);

	$ls[$x] = $fileName;

	$x+=1;

}

closedir(DIR);

srand();

$file1 = int(rand(@ls));

print ("Pragma: no-cachen");

if ($ls[$file1] =~ /.gif$/i) {

	print ("Content-type: image/gifnn");

} elsif ($ls[$file1] =~ /.jpg$|.jpeg$/i) {

	print ("Content-type: image/jpgnn");

} else {

	exit(0);

}

open (INPUT, $IMAGE_DIRECTORY . $ls[$file1]);

while ($line = &lt;INPUT&gt;) {

	print ($line);

}

close(INPUT);

exit(0);

&lt;/pre&gt;

You would call it as if it were a normal image..."random.cgi"

  • 0

HOW TO DO IT!

&lt;?

$URL1="addressofsig1";

$URL2="addressofsig2";

$URL3="addressofsig3";

$URL4="addressofsig4";

$URL5="addressofsig5";

$URL6="addressofsig6";

$URL7="addressofsig7";

$URL8="addressofsig8";

$URL9="addressofsig9";



srand((double) microtime() * 1000000);

$random = rand(1,9);



if($random == 1)

    @header ("Location: $URL1");

elseif ($random == 2)

    @header ("Location: $URL2");

elseif ($random == 3)

    @header ("Location: $URL3");

elseif ($random == 4)

    @header ("Location: $URL4");

elseif ($random == 5)

    @header ("Location: $URL5");

elseif ($random == 6)

    @header ("Location: $URL6");

elseif ($random == 7)

    @header ("Location: $URL7");

elseif ($random == 8)

    @header ("Location: $URL8");

elseif ($random == 9)

    @header ("Location: $URL9");

?&gt;



open notepad. copy paste that info above into it. where it says addressofsig1 - thats the address of your first signature file - e.g. http://www.geocities.com/neowinuser/sig1.jpg . that would be what you put in there. The second one would be were ever it is, and os and so on. if 9 is too many then remove one - dont forget to remove one of the

elseif ($random == 9)

@header ("Location: $URL9");

at the bottom.

any quezzies?!

  • 0

If you're going to do it in php there is an easier way:

<?php 



/* Declare variables. */

$path = "./";

$arr = array ();



/* Open Directory */

if ($dir = @opendir($path)) {

while ($file = readdir($dir))

{

if ((is_file($file)) && (eregi("(.gif|.jpg|.png)",$file))) {

/* Verify that the file is an image. */

$arr[] = $file;

}

}

closedir($dir);

}



/* print a random sig. */

header ('Location: ' . $arr[rand (0, count ($arr)-1)]);



?>[/PHP]

Just change the $path variable to whatever folder you want.

  • 0

Another easy way

&lt;pre&gt;&lt;?php



header("Location: [url]http://www.bla.net/blaavatars/sig[/url]".rand(1,40).".gif");





?&gt;&lt;/pre&gt;

Obviously the location has to lead to your pictures, and ure pictures have to begin with "sig" followed by a number. For example i would have sig1, sig2, and sig3. You can change the random range to whatever number of pics you have, and you can change .gif to .jpg or .png...maybe it is a little bit complicated, but at least the code is shorter :p

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • ...so more bloat is added (that naturally is always running in the background, using resources) that will report that you have a lot of bloat (and also a few more ads were also added but that has nothing to do with anything, right...).
    • Thank you for replying! Is MP600 also good? Where I'm looking they don't have MP700. I was also looking at Corsair T500, that comes with heatsink.
    • As someone who was born in 1980, I’m feeling this.
    • Amazon Deal: This Vifa Stockholm 2.0 is one of the best sounding bluetooth speakers by Sayan Sen A few days back we covered some great JBL bluetooth speaker deals across several of its popular models. The discounts are still live and you can check them out in this dedicated piece. Meanwhile for those who prefer more powerful home cinema sound systems, Nakamichi and Samsung are offering the Dragon and Shockwafe models, and the Q-series models, respectively, at their best ever prices. However, if you are someone who is looking for a bit of both, the portability of a bluetooth speaker and the fidelity of a good sounding hi-fi system then the Vifa Stockholm 2.0 Bluetooth Soundbar is something you should look at as it's currently a nice deal (purchase link under the specs table below). While you are not getting a subwoofer with the Vifa Stockholm as it is a 2.0 system, Vifa promises lows down to 42 Hz at +3dB and that should be pretty good for a device lacking a dedicated bass unit; it does pack passive radiators to help with the bass. The Stockholm 2.0 is praised for its sound quality (SQ) and one of the reasons behind it is becasue it has three-way drivers. The technical specifications of the Vifa Stockholm 2.0 Bluetooth Soundbar are given below: Specification Frequency Response 42 Hz – 20 kHz @ ±3 dB Materials Frame: One-piece die-cast aluminium; Enclosure: ABS reinforced; Grills: Kvadrat textile Connectivity Bluetooth® Qualcomm aptX™ HD audio; Wi-Fi Direct & networked (2.4 GHz); Wired optical or analog (3.5 mm mini-jack); USB-disk; Vifa®HOME, Vifa®LINK, Vifa®PLAY Driver Units Tweeter: 2 × 28 mm soft-dome drivers; Midrange: 2 × 80 mm aluminium-cone drivers; Woofer: 4 × 100 mm flat sandwich-cone drivers (force-balanced, backed by 4 passive radiators) Other Features Apple AirPlay & DLNA streaming; DSP signal processing; 6-channel high-performance power amplifier Get it at the link below: Vifa Stockholm 2.0 Bluetooth Soundbar, Nordic Design Soundbar, Smart APP Multi-Room System (Slate Black): $1156.99 (Sold and Shipped by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • Explzh 9.81 by Razvan Serea Explzh is a free Windows archive manager for creating, extracting and managing archives. The program supports many different types of archives, including zip, 7z, rar, tar, ace, lzh, arj, cab, iso, img, msi, sfx and more. Apart from archive creation and extraction, you will also be able to verify compressed data for errors, initiate repair routines, split data into multiple items, and more. It additionally allows you to password protect your data and attach digital signatures to files. Key features of Explzh: Explorer-like GUI and operability. LHA, ZIP (ZIPX), JAR, CAB, RAR, TAR, TAR.XXX, 7z, ARJ, WIM, CHM, PE, HFS, NSIS Format Installer, ISO, InstallShield, MSI, and several other formats... Support for more archive formats by introducing the integrated archiver DLL. Self-extracting archive creation function that can create high-performance automatic installers. Digital signature addition function to created self-extracting archive. Office 2007 or later document compression / image optimization re-archiving function. Supports compression and decompression of Unicode file names. Supports compression and expansion exceeding 4GB. AES encryption function. You can create a robust secure ZIP encryption archive. Thumbnail function of image file. In-library file search function. . Equipped with archive file conversion function. File split function. The split file has a self-consolidation function, and can concatenate files larger than 4GB. (No need for batch file or connection software) UU (XX) Encode, Base64 decode function. FTP upload function Supports Windows 11 shell integration extended context menu. Explzh 9.81 changelog: Improved to send update notifications to the shell when making changes such as additional compression to existing zip and 7-zip files. This also updates the Explorer view of the open file in real time. (If the drop target feature is enabled, you can easily create an encrypted ZIP by dragging and dropping onto the ZIP icon while holding down the Ctrl key.) When the zip drop target setting is enabled, the "Compressed (zipped) Folder" item will be added to the "New" shell context menu if it does not already exist. Password manager bug fix: Fixed a bug that caused the app to crash when reading password.dat (password data) when changing authentication method. Updated to Visual Studio 2022 v.17.14.9. Download: Explzh 64-bit | Explzh 32-bit | ~6.0 MB (Freeware) Download: Explzh ARM64 | 5.9 MB View: Explzh Home Page | Screenshot | Themes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Popular Contributors

    1. 1
      +primortal
      611
    2. 2
      Michael Scrip
      199
    3. 3
      ATLien_0
      190
    4. 4
      +FloatingFatMan
      138
    5. 5
      Xenon
      125
  • Tell a friend

    Love Neowin? Tell a friend!