[Help] Редактиране на скрипт

Gam3*BoY

Active Member
Joined
Dec 5, 2008
Messages
497
Reaction score
89
Здравейте ...
Ще помоля някой, който му се занимава да редактира този скрипт ... Проблема, който показва хоста е "Warning: Invalid argument supplied for foreach()" .. Не съм на ясно с Personal Home Page надявам се някой да помогне ....

PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<LINK REL="SHORTCUT ICON" HREF="images/favicon.ico">
	<title>Gallery</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="JS/jquery.js"></script>
    <script type="text/javascript" src="JS/jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="JS/jquery.lightbox-0.5.css" media="screen" />
    
    <script type="text/javascript">
    $(function() {
        $('#gallery a').lightBox();
    });
 </script>
<script language="JavaScript" type="text/javascript">
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// --> 
</script>
</head>
<link href="css/style.css" rel="stylesheet" type="text/css">

<? require("configs/config.php"); ?>
<?PHP

function resize($pic)
{
    global $max_width, $max_height;
    $max_width_pic = $max_width;
    $max_height_pic = $max_height;
    list($width,$height) = getimagesize($pic);
    $ratio = $width / $height;
    
    if ($width > $max_width_pic || $height > $max_height_pic)
    {
        if ($width > $height)
        {
            $width = $max_width;
            $height = $max_height;
        }
        elseif ($width < $height)
        {
            $height = $max_width;
            $width = $max_height;
        }
        elseif ($width == $height)
        {
            $width = $max_width;
            $height = $max_height;
        }
    }
    $width = intval($width);
    $height = intval($height);
    return array("width" => $width, "height" => $height);
}

$pics_folder = preg_replace('/[\/]+/', '/', preg_replace('/^[\/]+/', '', $pics_folder).'/');

function all_images()
{
    global $pics_folder, $pics_ex;
    $folders = array($pics_folder);
    $out_files = array();
    while (count($folders))
    {
        foreach ($folders as $folder)
        {
            array_shift($folders);
            $dir = opendir($folder);
            while ($file = readdir($dir))
            {
                if ($file != '.' && $file != '..')
                {
                    if (is_file($folder.$file) && in_array(strtolower(end(explode(".", $file))), $pics_ex))
                    {
                        $out_files[] = $folder.$file;
                    }
                    elseif (is_dir($folder.$file))
                    {
                        $folders[] = $folder.$file.'/';
                    }
                }
            }
        }
    }
    return $out_files;
}

$all_images = all_images();

$category = false;
if (preg_match('/^[^\/\\\:\*\?\"\<\>\|]+((->)[^\/\\\:\*\?\"\<\>\|]+)*$/i', $_GET['kat']))
{
    $category = (is_dir($pics_folder.str_replace('->', '/', $_GET['kat']))) ? str_replace('->', '\/', $_GET['kat']) : false;
}
    
$out_images = array();
$out_images1 = array();
foreach ($all_images as $image)
{
    $raz = explode("/", $image);
    for ($n=1;$n<=(substr_count($pics_folder, "/"));$n++) array_shift($raz);
    array_pop($raz);
    $out_images1[] = $image;    
    if ($category && !preg_match("/^$category/", implode("/", $raz))) continue;
    $out_images[] = $image;
	 
}





$title=Array();
$k=0;
$br=count($out_images1);
$masiv = @array_chunk($out_images1, $br, true);
foreach ($masiv[0] as $pic)
{
    $razp = explode("/", $pic);
    for ($n=1;$n<=(substr_count($pics_folder, "/"));$n++) array_shift($razp);
    array_pop($razp);

    $kat = array();
    $kat[] = '<a href="?" class="f">Всички</a>';
    for ($i=0;$i<count($razp);$i++)
    {
        $url = array();
        for($i2=0;$i2<=$i;$i2++)
        {
            $url[] = $razp[$i2];
        }
        $kat[] = '<a href="?kat='.implode("->", $url).'">'.$razp[$i].'</a>';
    }
    
$title[$k]="<br ><br >".implode(" -> ", $kat);

$k++;
	}

	
require("configs/menu.php");


$masiv = @array_chunk($out_images, $pics_per_page, true);

$stranici = floor(count($out_images) / $pics_per_page);
if ((count($out_images) % $pics_per_page) > 0) { $stranici++; }

if (is_numeric($_GET['page']) && $_GET['page'] <= $stranici) {
    $page = $_GET['page'];
} else {
    $page = 1;
}

$red = 0;
echo "<span id=\"gallery\"><table border=\"0\">
<tr>\n";
foreach ($masiv[($page - 1)] as $pic)
{
    $resize = resize($pic);
    $razp = explode("/", $pic);
    for ($n=1;$n<=(substr_count($pics_folder, "/"));$n++) array_shift($razp);
    array_pop($razp);
 
    $kat = array();
    $kat[] = '<a href="?">Главна</a>';
    for ($i=0;$i<count($razp);$i++)
    {
        $url = array();
        for($i2=0;$i2<=$i;$i2++)
        {
            $url[] = $razp[$i2];
        }
        $kat[] = '<a href="?kat='.implode("->", $url).'">'.$razp[$i].'</a>';
    }
    
	echo "<td aligan='right'><div id='picviewb' style='height: ".$resize['height']."; width: ".$resize['width'].";'><a href=\"{$pic}\" title=\"{upname()}\"><img src=\"{$pic}\" width=\"".$resize['width']."\" height=\"".$resize['height']."\" border=\"0\" id=\"picview1b\"></a></div></td>\n";
    if ($red == floor(sqrt($pics_per_page))) { $red = 0; echo "</tr><tr>\n"; } else { $red++; }
}
echo "</tr>
</table></span>";

echo "<p class='m'>Page: ";
for ($i=1;$i<=$stranici;$i++) {
    if ($page != $i) {
        echo "<a href=\"?page=$i".(($category) ? '&kat='.$_GET['kat'] : '')."\">$i</a> ";
    } else {
        echo "<span class='f'>$i </span>";
    }
}
echo"</p>";


echo"</td>";
echo"</tr></table>";
?>
</body>
</html>
 
Показва warning, но работи ли нормално скрипта ?