ZiNgA BuRgA
Smart Alternative
Posts: 17,022.2988 Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs : 446.1274
Random Image Generator in PHP
Decided to put this up for anyone interested.
NOTE, requires:
A hosting service with PHP support
Images must be uploaded to the same folder as the PHP script
Copy and paste this to make a new .php file:
PHP Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s " ) . " GMT " ) ;
header( "Cache-Control: no-store, no-cache, must-revalidate " ) ;
header( "Cache-Control: post-check=0, pre-check=0 " , false ) ;
header( "Pragma: no-cache " ) ;
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT " ) ;
header( "Content-Type: image " ) ;
$pic = array (
"1.jpg " ,
"2.jpg " ,
"3.jpg "
) ;
$rpic = $pic [ mt_rand( 0 , count( $pic ) - 1 ) ] ;
header( "Content-Length: " . filesize( $rpic ) ) ;
header( "Content-Type: image " ) ;
$fp = fopen( $rpic , 'rb' ) ;
fpassthru( $fp ) ;
fclose( $fp ) ;
?>
Upload this file to your server, and direct people to use this .php file as the image.
I chose to use this method as it works better than a header redirect (which typically gets cached). Also hides the actual files from the user :P
Further reference:
http://endlessparadigm.com/forum/showthread.php?tid=930
(This post was last modified: 01/04/2008 06:09 AM by ZiNgA BuRgA .)
26/03/2007 03:48 AM
S7*
Sweet Dreams
Posts: 16,689.4373 Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs : 383.2309
RE: Random Image Generator in PHP
i CAN'T BELIEVE YOU!
I asked you loads, and you posted it here..
:(
:/
03/04/2007 04:52 AM
Ge64
Former Admin ;)
Posts: 3,163.4170 Threads: 295
Joined: 3rd Feb 2007
Reputation: 0.38918
E-Pigs : 108.4795
RE: Random Image Generator in PHP
lawl. yeah i did something with php and images some time ago, was a status image for a thread on a forum which showed the number of posts/pages in the thread and the last poster etc. turned out pretty cool
ty for sharing
also
http://crimsonomen.imeem.com/music/8-pwm..._has_aids/
03/04/2007 06:16 AM
SXForce
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Posts: 280.3000 Threads: 38
Joined: 20th Feb 2007
Reputation: 1.40616
E-Pigs : 5.6493
RE: Random Image Generator in PHP
03/04/2007 09:46 AM
Necro-Bot
Non-existent
11/04/2009 11:36 AM
Sparker
Super Lame Productions
Posts: 8,165.3369 Threads: 549
Joined: 19th Jan 2007
Reputation: 10.74638
E-Pigs : 187.9012
RE: Random Image Generator in PHP
I should use this sometime
11/04/2009 11:36 AM
RIKKU
Storm Trooper
Posts: 2,380.2478 Threads: 288
Joined: 12th Aug 2007
Reputation: -2.68834
E-Pigs : 69.6099
RE: Random Image Generator in PHP
11/04/2009 09:27 PM
S7*
Sweet Dreams
Posts: 16,689.4373 Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs : 383.2309
RE: Random Image Generator in PHP
oh my god.
this was 2 YEARS AGO!?
Holy spoon.
12/04/2009 08:53 AM
feinicks
One day... we Fly...
Posts: 6,124.6050 Threads: 531
Joined: 27th Mar 2008
Reputation: 2.35695
E-Pigs : 210817.3958
RE: Random Image Generator in PHP
(This post was last modified: 12/04/2009 10:17 AM by S7* .)
12/04/2009 10:16 AM