Jump to content

Recommended Posts

Posted

Boas!

Estou com uma dificuldade.

Tenho a seguinte tag

<img height='90' src='files/fotos/gerais/rid.php?pic=random'>

O ficheiro rid.php mostra fotos aleatorias, mas o que eu pretendia era saber o que esse script processa exactamente, do genero "files/fotos/gerais/foto.jpg", para poder trabalhar melhor com a foto...

Isto porque ao fazer view image, processa novamente o php, mostrando assim outra foto aleatória, em vez de mostrar a mesma... É que ao fazer Properties à foto, tudo o que aparece é que a path da foto é files/fotos/gerais/rid.php?pic=random 😁

Alguma dica?

obrigado 😁

Posted

Já agora, o ficheiro rid.php contém:

<?php 
//read folder
$folder=opendir("."); 
while ($file = readdir($folder)) 
$names[count($names)] = $file; 
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar=0;
for ($i=0;$names[$i];$i++){
$ext=strtolower(substr($names[$i],-4));
if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;}
}
//random
srand ((double) microtime() * 10000000);
$rand_keys = array_rand ($names1, 2);
//random image from array
$slika=$names1[$rand_keys[0]]; 
//image dimensions
$dimensions = GetImageSize($slika); 
if (isset($HTTP_GET_VARS["pic"])){header ("Location: $slika");}
else {echo "<img src=\"$slika\" $dimensions[3]>";}
?>

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.