.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   a different sig each time (http://forums.bots-united.com/showthread.php?t=146)

Pierre-Marie Baty 02-01-2004 02:00

a different sig each time
 
While we're at it here's something that should be fun to do, however I'm quite clueless on how to do it.

I figured out at some point that a certain user on a certain forum had turned its signature in a way such as when you hit the "reload" button on your browser, the image displayed in his signature at the bottom of each of his posts was changing each time.

Do you know how he might have done it ?
All I can say is that I believe there's some PHP involved.

raiden 02-01-2004 16:10

Re: a different sig each time
 
PHP Code:

$randomnumber gmp_random(10); //generates a number between 0 and 10

echo "<img src=\"http://yourwebspace.de/".$randomnumber.".jpg\">"

I think that should work if you got webspace with 1.jpg till 10.jpg :>

Pierre-Marie Baty 02-01-2004 18:39

Re: a different sig each time
 
the problem is that forum softwares don't allow PHP in the users' signatures :)
I believe the guy used something like this:
<IMG src="http://hisdomain.com/image.jpg">
but the JPG image was in fact a PHP file, that would open a file at random in the directory and directly send its content over the network. I don't konw if this is feasible, though.

BAStumm 02-01-2004 23:15

Re: a different sig each time
 
php can generate random images so put the phpcode on YOUR php enabled server then put the image tags here pointing to a image.php file stead of image.jpg

Might be better to generate the image on the fly rather then the example above, see the php image() function.

BAStumm 03-01-2004 00:06

Re: a different sig each time
 
lets see if this works... Heres a graph bar I use on my site.


http://bs-linux.com/stats/loadgraph....th=25&avg=0.25
http://bs-linux.com/stats/loadgraph....th=58&avg=0.58

http://bs-linux.com/stats/loadgraph.php
If this works note that both images are the same php file with different ?width settings...

ok so a .php file is ok just can't have any ?blah=blah stuff at the end... If you click the links you will see that the image changes based on my width setting. You can use the image() function to make your sig random looks like. Just do a image from jpg in your php and then randomly use one of the 2 or more images you wish from your site.

http://php.net/image for more info on this...

BAStumm 03-01-2004 00:21

Re: a different sig each time
 
btw the other suggestion prolly wont work. Reason is it outputs html whereas using the image function outputs actual image header info for png, jpg, gif or whatever type you tell the php code to dynamically generate.

take this sample code from the php.net link I gave before...

Code:

<?php
  header("Content-type: image/png");
  $string = $_GET['text'];
  $im        = imagecreatefrompng("images/button1.png");
  $orange = imagecolorallocate($im, 220, 210, 60);
  $px        = (imagesx($im) - 7.5 * strlen($string)) / 2;
  imagestring($im, 3, $px, 9, $string, $orange);
  imagepng($im);
  imagedestroy($im);
?>

Now modify that with some random number generation to do a

if($num == 1) {$im = imagecreatefrompng("pic1.png");
if)$num == 2) ($im = imagecreatefrompng("pic2.png");
etc...

Pierre-Marie Baty 03-01-2004 00:25

Re: a different sig each time
 
hey thanks a lot! how could I forget the trusty php.net resource center :)

that's exactly what I need :)

BAStumm 03-01-2004 00:31

Re: a different sig each time
 
Code:

<?php
//image headers
header("Content-type: image/png");
// random number 1-9
$num = RAND(1,9);
// generate image name
$myimage = "pic".$num.".png";
//create image
$im = imagecreatefrompng($myimage);
// output the image binary       
imagepng($im);
//destroy image
imagedestroy($im);
?>

http://spokaneteamfortress.com/randimg.php

Like that perhaps. :)

rob 03-01-2004 00:53

Re: a different sig each time
 
nice work.

Pierre-Marie Baty 03-01-2004 01:01

Re: a different sig each time
 
I was to post about the same thing :D
PHP Code:

<?php
$filename 
sprintf ("sig%d.png"rand (09));
 
$image imagecreatefrompng ($filename);
 
header ("Content-type: image/png");
imagepng ($image);
imagedestroy ($image);
 
?>

creditz to you Brian, of course :)


All times are GMT +2. The time now is 04:21.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.