![]() |
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. |
Re: a different sig each time
PHP Code:
|
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. |
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. |
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... |
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 if($num == 1) {$im = imagecreatefrompng("pic1.png"); if)$num == 2) ($im = imagecreatefrompng("pic2.png"); etc... |
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 :) |
Re: a different sig each time
Code:
<?php Like that perhaps. :) |
Re: a different sig each time
nice work.
|
Re: a different sig each time
I was to post about the same thing :D
PHP Code:
|
Re: a different sig each time
glad i could return a favor, you've helped me many a time PM.
|
Re: a different sig each time
does it have to be a png file.. can i change that. im not very good at php.. i getting help from someone who dont know much but know more then me..
|
Re: a different sig each time
No, you can use one of the many image format PHP supports (provided PHP has been installed on your server with the right image lib extensions).
Have a look at www.php.net and search for the image capabilities of PHP. Everything is explained. |
Re: a different sig each time
k. thanks..
|
Re: a different sig each time
Quote:
|
Re: a different sig each time
Another (possibly slightly hackier, but still does the same) way to do this only with out the GD libs, would be something like this:
PHP Code:
The only main differences between this and the GD version are (like i said), this doesnt require GD, and it can be generated faster, thru not having to create a seperate image. |
Re: a different sig each time
testing...
wahey it works!! Thanks Frosty! That's true, I prefer this method ! :) |
Re: a different sig each time
glad i could help :)
|
Re: a different sig each time
i've got a slightly more 'interesting' method here, which will open a dir, read all the images in it, (doesnt matter about filenames, so long as they have valid extentions), then pick one of them at random, and display it if you want it. Would be easier for 'organising' sigs :p
|
Re: a different sig each time
do you mind giving out the source?.. or something that is easy to change so it fits or another.. i would be pretty happy if you did..
its not very importent to me.. just a cool thing to have.. must add im complete noob when it comes to php coding.. |
Re: a different sig each time
oh yeah, I'm interested as well :)
that's teh way I'm learning PHP: by reading at other ppl's code... |
Re: a different sig each time
once i was using crontab :D
then i used php genrated image then the .php links were forbidden because it could return dangerouns output so i changed it to writ the .jpg file a diff file (well more like crontab script in fact) now i use static jpg cause i got used to it - easier to find my own posts |
Re: a different sig each time
ok, here we go then :)
This script is much longer than the others, but does what its told :) PHP Code:
If you have any questions, gimme a shout :) |
Re: a different sig each time
hehe w00t thanks
I've made it a lil bit shorter :) don't forget to close the directory handle in your code btw... Code:
<?php |
Re: a different sig each time
how in the world could a simple Joe like me get this one going? i like that kind of stuff!
|
Re: a different sig each time
Well, just copy what's inside the code tags and paste it in your notepad, then save the file and name it "sig.php" or whatever. Then upload it to your server in the directory where you put your signatures, and instead of using [ img]http://soulfathermaps.de/images/mysig.jpg[ /img] use [ img]http://soulfathermaps.de/images/sig.php[ /img]
That should be enough Ensure the directory where your sig is has read access allowed to anybody. |
Re: a different sig each time
sounds real easy :)
and how do i make it select 4 pics designed just for this purpose? and not the whole bank of pics? |
Re: a different sig each time
to my understanding (php is one of my things in the the things to learn list :()
if u upload the 4 photo's\images and the sig in the same folder to the server and link upto that sig.php script it will automatically choose from that 4 becoz there is no other in that folder |
Re: a different sig each time
Quote:
Quote:
Mine was designed to be more customisable, rather than 'just work', so you could select the folder easily, and simple add , "ext" to add an extention to the list.. What i've done here, is taken the speed of yours, and the customisability of mine, and combined them, and got the following :p PHP Code:
|
Re: a different sig each time
@Frosty: About the "rand (0, $file_count - 1)", I suppose the array indexing works just like in C ?
Let's say we have an array of 3 elements (hence $file_count = 3) we have array[0] -> first element array[1] -> second element array[2] -> third element (and no array[3], which is out of bounds) is that right ? so if I want to pick a random number between 0 and 2 inclusively, I call rand (0, $file_list - 1)... well that's how I see things, but you know PHP better than me so... ???:( @SF: with this script you have to arrange your pics into subdirectories, because it takes the whole image list. If you want a script that would output only a selected set of images randomly, you can write something like this: Code:
<?php |
Re: a different sig each time
hmm, thinking about it, i'm not sure..
aah, right you are, soz i'm in a VERY adjitated mood tonight (someone decided they didnt like a script i was working on, so MASACARED it (all for google ratings) now i have a messed up Webserver, as well as a non-functioning script which i spend 3 solid days coding..) so my heads not screwed on right :p so yea, you are right, my bad, soz :/ |
Re: a different sig each time
ill just throw them in a separate folder :) thanks
|
Re: a different sig each time
oh.. great.. a explaination how to use it too..
|
Re: a different sig each time
ok, with my 'latest' script..
Make a Directory, give it a name (probably images).. chuck all your images in there, then edit the following: $target = getcwd() . "/images"; replace "/images" with your folder name. If you want to use an extention which isnt in the list, change the following line Array("PNG", "JPG", "GIF"); to Array("PNG", "JPG", "GIF", "EXT", "EXT2", "ETC"); then just call the php file in a browser, and each time you refresh, you should get a new random image. Then use the BBCode IMG tag, and point the URL to where your php script is, or use an <img src='http://your.domain/path/to/something.php'> (something.php being the script filename) and it should work.. (If you wernt being sarcastic about the explanation thing, i appologise ;)) |
Re: a different sig each time
As a note, if you can use .htaccess you can 'force' a file to a php script, so rename your php file to something.jpg (replace something with whatever you want), and add this to your .htaccess
<Files something.jpg> ForceType application/x-httpd-php </Files> I just tested that, and it seems to work :) |
Re: a different sig each time
i have that php saved in my folder and i looked at it just now and it says mysig.php.txt :(
|
Re: a different sig each time
Open a Windows Explorer window
Click on Tools -> Folder Options... Switch to the 2nd tab Uncheck the "Hide known file extensions" checkbox Click OK && try again Your file was just named .txt instead of .php by notepad, as long as you don't tell windows to show the file extensions it won't allow you to name a file the way you want. |
Re: a different sig each time
Windows is evil like that :)
|
Re: a different sig each time
hopefully longhorn will skip annoying things from earlier releases.. big plus for being based on unix..
|
Re: a different sig each time
being based on Unix ??? wtf ???
where do you take this from ? ???:( |
All times are GMT +2. The time now is 20:47. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.