feeme
Usuario (Argentina)
Bueno, es un script que hice script que hice ayer, y les dejo para que lo usen si les gusta. Finalidad: Toma una imagen desde una lista de imagenes y la muestra de forma aleatoria. Forma de uso: simplemente llamamos a al archivo php como si fuera una imagen. [img]ruta.php[/img] <img src="ruta.php"/> Archivo requerido: images.txt. Este archivo debe tener el siguiente formato: URL IMG | Formato IMG. Formatos permitidos: PNG (no hace falta especificar el formato de estos), GIF, JPG. Demo: http://informaticaya.net23.net/randomimage/randimage.php Source Online: http://userscripts.org/scripts/review/87738 randimage.php <?php // ==UserScript== // @name RandomImage // @author feme // @version 1.0 // ==/UserScript== // File that include the urls of the images. This file needs stay in the same folder that the script. // FORMAT of this file: URL | MIME TYPE (It can only GIF, JPEG or PNG) // Ex: www.url.com/image.png | PNG $imagesfile='images.txt'; $fp=@file_get_contents($imagesfile); if(!$fp) { echo '<p>Error al intentar abrir <b>'.$imagesfile.'</b></p>'; } else { $line=explode(chr(10),$fp); for($x=0;$x<count($line);$x++) { $line2[$x]=explode(' | ',$line[$x]); } $amount=count($line2); $x=mt_rand(0,$amount-1); $url=trim($line2[$x][0]); $type=trim(strtolower($line2[$x][1])); if($type=='jpg') { $type='jpeg'; } switch($type) { case 'jpeg': header('Content-Type: image/jpeg'); $image=@imagecreatefromjpeg($url); $color=imagecolorallocate($image,250,250,250); imagestring($image,1,10,110,$url,$color); imagejpeg($image); break; case 'gif': header('Content-Type: image/gif'); $image=@imagecreatefromgif($url); imagegif($image); break; default: header('Content-Type: image/png'); $image=@imagecreatefrompng($url); imagepng($image); } imagedestroy($image); } ?> Ejemplo de images.txt: www.url.com/image.jpg | JPEG www.url.com/image.png | PNG // para este formato no es necesario especificarlo. www.url.com/image.gif | GIF