Помогите в чем ошибка не пойму???

Статус
В этой теме нельзя размещать новые ответы.

Pornocat

Новичок
Помогите в чем ошибка не пойму???

Есть код выводящий 10 случайных предосмотров из подпапок основной папки img
Проблема в том что 10 предосмотров он не выводит а 5 или 6 по разному а хотелось чтобы все 10!!!


<?php

//&#206;&#225;&#249;&#224;&#255; &#228;&#232;&#240;&#229;&#234;&#242;&#238;&#240;&#232;&#255; &#232;&#231;&#238;&#225;&#240;&#224;&#230;&#229;&#237;&#232;&#233;
define ("_IMG_root", "img" );

function img_resize($src, $dest, $width, $height, $rgb = 0xFFFFFF, $quality = 100) {
if (!file_exists($src)) return false;
$size = getimagesize($src);
if ($size === false) return false;
$format = strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
$icfunc = "imagecreatefrom" . $format;
if (!function_exists($icfunc)) return false;
$x_ratio = $width / $size[0];
$y_ratio = $height / $size[1];
$ratio = min ($x_ratio, $y_ratio);
$use_x_ratio = ($x_ratio == $ratio);
$new_width = $use_x_ratio ? $width : floor($size[0] * $ratio);
$new_height = !$use_x_ratio ? $height : floor($size[1] * $ratio);
$new_left = $use_x_ratio ? 0 : floor(($width - $new_width) / 2);
$new_top = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2);
$isrc = $icfunc($src);
$idest = imagecreatetruecolor ($width, $height );
imagefill ($idest, 0, 0, $rgb );
imagecopyresampled ($idest, $isrc, $new_left, $new_top, 0, 0,
$new_width, $new_height, $size[0], $size[1]);
imagejpeg ($idest, $dest, $quality );
imagedestroy ($isrc );
imagedestroy ($idest );
return true;

}


$Open_temp = opendir ("temp");
while ($Read_temp = readdir ($Open_temp)) {
if ($Read_temp == "." ) { continue; }
if ($Read_temp == ".." ) { continue; }
$NEW_TEMP[] = $Read_temp;
}

$Open_scan = opendir (_IMG_root);

for ($xx = 0; $xx < count ($NEW_TEMP); $xx++) {
//&#196;&#232;&#240;&#229;&#234;&#242;&#238;&#240;&#232;&#232; &#232;&#231;&#238;&#225;&#240;&#224;&#230;&#229;&#237;&#232;&#233;
while ($Read_scan = readdir ($Open_scan)) {
if (filetype (_IMG_root."/".$Read_scan) === "dir") {
if ($Read_scan == "." ) { continue; }
if ($Read_scan == "..") { continue; }
$Scan_element[] = $Read_scan;
}
}

$Count_scan_array = count ($Scan_element );
$R_e_l_path = rand (0, $Count_scan_array -1);

//&#195;&#229;&#237;&#229;&#240;&#232;&#240;&#243;&#229;&#236; &#241;&#235;&#243;&#247;&#224;&#233;&#237;&#243;&#254; &#228;&#232;&#240;&#229;&#234;&#242;&#238;&#240;&#232;&#254;
$Open_path_img = opendir (_IMG_root."/".$Scan_element[$R_e_l_path]);

while ($Read_element = readdir ($Open_path_img)) {
$Image_array[] = $Read_element;
}
for ($x = 0; $x < count ($Image_array); $x++) {
if ($Image_array[$x] == "." ) { continue; }
if ($Image_array[$x] == ".." ) { continue; }
if ($Image_array[$x] == "index.html") { continue; }
if ($Image_array[$x] == "index.htm" ) { continue; }

//&#194; &#241;&#235;&#243;&#247;&#224;&#229; &#229;&#241;&#235;&#232; windows &#245;&#238;&#241;&#242;&#232;&#237;&#227;
if ($Image_array[$x] == "Thumbs.db" ) { continue; }
$Convert[] = $Image_array[$x];
$Check = count ($Convert);
}
if (!empty ($Check)) {
//&#207;&#238;&#228;&#247;&#232;&#242;&#251;&#226;&#224;&#229;&#236; &#234;&#238;&#235;&#232;&#247;&#229;&#241;&#242;&#226;&#238; &#253;&#235;&#229;&#236;&#229;&#237;&#242;&#238;&#226; &#236;&#224;&#241;&#241;&#232;&#226;&#224;
$Img_array_count = count ($Convert );
$Rand_image = rand (0, $Img_array_count -1);

//&#195;&#229;&#237;&#229;&#240;&#232;&#240;&#243;&#229;&#236; &#239;&#240;&#238;&#232;&#231;&#226;&#238;&#235;&#252;&#237;&#243;&#254; &#234;&#224;&#240;&#242;&#232;&#237;&#234;&#243;
$Select_element = $Convert[$Rand_image];
$RANOM[] = $Convert[$Rand_image];

$DEARRAY = implode ("-", $RANOM);
if (substr_count ($DEARRAY, $Select_element) > 1) { continue; }
if (img_resize(_IMG_root."/".$Scan_element[$R_e_l_path]."/".$Select_element, "temp/".md5 ("$Select_element").".jpg", 150, 150)) {
print "<a href = "._IMG_root."/".$Scan_element[$R_e_l_path]."/".$Select_element."><img src = \"temp/".md5 ("$Select_element").".jpg"."\" /></a>";
} else {

}

} else {
echo "&#205;&#229;&#242; &#232;&#231;&#238;&#225;&#240;&#224;&#230;&#229;&#237;&#232;&#255;!";
}
if ($xx > 9) { break; }
}


?>
 

Фанат

oncle terrible
Команда форума
Тема закрыта.

Формулируйте вопрос так, чтобы его могли понять не только Вы.
Не пишите больше 10-15 строк кода.
Никто не будет вникать в Ваш код длиной 100 строк.
Правила форума: http://phpclub.ru/talk/announcement.php?s=&forumid=12
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху