Bueno, les dejo este pequeñito script que lo hice ayer.
Finalidad del script: mostrar una imagen del monton de forma aleatoria.
FOROS
[img=http://www.url-de-tu-host.com/randimage.php]
HTML (no recomendado)
Archivo randimage.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
// For show an image just write for forums: [img=http://www.url.com/randimage.php]
// For html: .
$imagesfile='images.txt';
$fp=@file_get_contents($imagesfile);
if(!$fp)
{
echo '
Error al intentar abrir '.$imagesfile.'';
}
else
{
$line=explode(chr(10),$fp);
for($x=0;$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);
}
?>
Las URLs de las imagenes tienen que estar en un archivo de texto en la misma carpeta y se debe llamar images.txt.
El formato del archivo de texto debe ser el siguiente: URL | FORMATO.
No hace falta especificar el formato si se trata de una imagen PNG. Solo se aceptan imagenes JPG, GIF y PNG.
Archivo images.txt:
www.web.com/image.jpg | JPEG
www.web.com/image.png | PNG
www.web.com/image.gif | GIFCódigo ONLINE: http://userscripts.org/scripts/review/87738
RESULTADO: