Thank you, Cherokee! It would've taken me much longer to see that little trick, and I'm sure I would've implemented it in a slightly more roundabout (read "stupid and inefficient") method. Anyways, I have done exactly what Mini Franki is attempting, so I hope he's subscribed to this topic months later or has since found a similar solution. Do what Cherokee Red describes, except use PHP's built-in readfile() function to implement it instead of echo; you don't want to return a text string to the page like in a regular HTML file, you want to instead return an image itself, and you can do that in only one line if you have access to a PHP-enabled Web host. So, take that array you made, but instead of using $imgs inside an echo statement, use it inside a readfile() statement after you send the proper header to the calling page:
Code: Select all
// all of the stuff you had from above up until the echo statement
This code, when placed in the file created using Cherokee's suggestion, will allow your random image to work perfectly in your signature; don't forget to change the MIME type to fit your image format. However, BBCode / phpBB doesn't even recognize that you're asking it to point to a .php file instead of an image file. (Actually, you can even bypass the built-in signature image size limits, if you first apply your signature while using a small image before you make it choose from the array. It checks only when you submit the signature, not when it is included into the forum's page.) Oh, and by the way, you shouldn't need the srand function in there unless you've got a VERY backwards version of PHP on the server... usually the random number generator is already seeded, and subsequent seeds actually make the results less random rather than more. I hope this helps; it certainly did a lot for me!