Няколко грешки в галерия

ReXTaN

Registered
Здравейте,
Скрипта си работи перфектно по принцип, но като я сложа в сайта ми изкарва тия грешки:
Код:
Notice: Undefined index: kat in /www/1gb.bg/s/p/a/space/htdocs/pictures.php on line 159

Notice: Undefined index: kat in /www/1gb.bg/s/p/a/space/htdocs/pictures.php on line 219

Notice: Undefined index: page in /www/1gb.bg/s/p/a/space/htdocs/pictures.php on line 228

Ето го и кода:

Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Web Site</title>
	<meta name="keywords" content="web">
	<meta name="description" content="Web site">
	<meta http-equiv="content-language" content="bg">
	<meta name="author" content="ReXTaN">
	<meta name="distribution" content="global">
	<meta name="robots" content="follow, index">
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
	<link rel="stylesheet" type="text/css" href="style.css">
	<link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />
	<script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.lightbox-0.5.js"></script>
	<script type="text/javascript">
    $(function() {
        $('#gallery a').lightBox();
    });
    </script>
	<style type="text/css">
	
	</style>
</head>
<body>
    <div id="All">
        <div class="logo"></div>
		<div class="header"></div>
		
		<div id="content" style="clear:both;">
        <div class="menu">
			<a href="#" title="#" target="_self">Home</a>
			<a href="#" title="#" target="_self">Home</a>
			<a href="#" title="#" target="_self">Home</a>
		</div>
		
        <div class="left">
            <div class="name_l"></div>
            <div class="box">
				<ul>
					<li><a href="#" title="#">Начало</a></li>
					<li><a href="#" title="#">Начало</a></li>
					<li><a href="#" title="#">Начало</a></li>
					<li><a href="#" title="#">Начало</a></li>
					<li><a href="#" title="#">Начало</a></li>
					<li><a href="#" title="#">Начало</a></li>
				</ul>
            </div>
        </div>
		
        <div class="center">
            <div class="name_r"></div>
            <div class="box_r">
               <?php

				// КОНФИГУРАЦИЯ //

				$pics_folder = "pics"; // в коя папка са картинките и категориите
				$max_width = 150; // максимална широчина
				$max_height = 150; // максимална височина
				$pics_per_page = 9; // по колко картинки на страница
				$pics_ex = array('jpg','jpeg','gif','png'); // кои файлове да зачита като картинки

				// КРАЙ НА КОНФИГУРАЦИЯТА //

				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_pic;
							$height = $width / $ratio;
						}
						elseif ($width < $height)
						{
							$height = $max_height_pic;
							$width = $height * $ratio;
						}
						elseif ($width == $height)
						{
							$width = $max_width_pic;
							$height = $max_height_pic;
						}
					}
					$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;
					 
				}



				echo"<table  border='0' cellpadding='20px' cellspacing='0'><tr><td>";

				$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++;
					}
				echo "<h3>Категории:</h3><br><b>".$title[0];	
				for ($k=1;$k<count($title);$k++){
				$savp=0;
				for ($m=0;$m<$k;$m++){
				if($title[$m]==$title[$k]){
				$savp=1;
				}
				}
				if($savp==0){echo  $title[$k];}
				}

				echo"</b></td><td>";
				if($_GET['kat']){
				echo "<h3 class='m'>".$_GET['kat']."</h3>";
				}
				else{echo "<h3 class='m'>Всички</h3>";}
				$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 = 1;
				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 align='center'><div id='picviewb' style='height: ".$resize['height']."; width: ".$resize['width'].";'><a href=\"{$pic}\" title=\"{$pic}\"><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 = 1; echo "</tr><tr>\n"; } else { $red++; }
				}
				echo "</tr>
				</table></span>";

				echo "<p class='m'>Страници: ";
				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>";
				?>
            </div>
        </div>
		</div>
        <div class="footer">Всички права запазени - 2009 :)</div>
      </div>
   </body>
</html>
 
Код:
error_reporting(E_ALL^E_NOTICE);
Сложи това в началото на страниците си и ще се махне това съобщение :?:
 
miro_94 каза:
Код:
error_reporting(E_ALL^E_NOTICE);
Сложи това в началото на страниците си и ще се махне това съобщение :?:

Вие дадохте една точка за support на miro_94 .
Натиснете тук за да се върнете в темата.
 
имаш $_GET['page'] и $_GET['kat'] които не са подадени към скрипта поради което ти се появяват забележките. което са ти написали по-горе ще ги скрие, но ще си по-добре ако проверяваш дали тези променливи съществуват преди да ги ползваш вместо

if($_GET['kat'])
прави
Код:
if(isset($_GET['kat']))
 

Горе