<?php
$site_url = "http://mysite.ru/";
$file_path = "/hsphere/local/home/user/mysite.ru/"; //поменяй на свой путь
$dir_name = "photos/"; //путь к папке с фото
$open_dir = opendir($file_path.$dir_name);
$all_photos = array(1000);
while (false !== ($value = readdir ($open_dir))) {
if (($value!=".") || ($value!="..")) $all_photos[]=$value;
}
closedir($open_dir);
shuffle($all_photos);
$size = array(7);
$size = getimagesize("photos/".$all_photos[0]);
$filesize = filesize("photos/".$all_photos[0]);
$width = $size[0];
$height = $size[1];
$MAX_WIDTH = 150;
$MAX_HEIGHT = 200;
$scale = min($MAX_WIDTH/$width, $MAX_HEIGHT/$height);
if ($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$width = $new_width;
$height = $new_height;
}
echo "<a href=\"".$site_url.$dir_name.$all_photos[0]."\"><img src=\"".$site_url.$dir_name.$all_photos[0]."\" border=\"0\" height=\"$height\" width=\"$width\"></a>";
unset($dir_name);
unset($all_photos);
unset($value);
unset($open_dir);
?>
<br>
<table border=0>
<tr>
<td height='10' width='<?php echo $width; ?>' align="center">
<FONT size=1>
<?php
echo $size[0]."x".$size[1]." (".$filesize." ".$byte.")";
?>
</FONT>
</td>
</tr>
</table>