WackoWiki: Вам запрещён доступDev/PatchesHacks/RandomImage ...

Home Page | Изменения | Новые Комменты | Пользователи | Каталог | Регистрация | Вход:  Пароль:  

Action: Random Image


{{randomimage imgpath="files/"}}


/actions/randomimage.php

<?php

# $path="files/";
# $path="files/perpage/";
$path="$imgpath";

if (!
$path)
    echo
"<i>Please specify a path with the parameter imgpath, e.g. {{randomimage imgpath=\"files/\"}}.</i><br />";

else
  {
  
$folder=opendir($path);
  while (
$file = readdir($folder))
    
$names[count($names)] = $file;
    
closedir($folder);
    
sort($names);
    
$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++;}
    }
    
srand ((double) microtime() * 10000000);
    
$rand_keys = array_rand ($names1, 2);
    
$xmImg=$path.$names1[$rand_keys[0]];
    
$dimensions = GetImageSize($xmImg);
    if (isset(
$pic)){header ("Location: $xmImg");}
    else {echo
"<img src=\"$xmImg\" $dimensions[3]>";}
  }
?>

To Do


 
Файлов нет. [Показать файлы/форму]
Комментариев нет. [Показать комментарии/форму]
Donate
Время работы: 5.371 s
Использовано памяти: 2.822 Mb