<?
require_once('../connect/connect.php');
$papka = '../tmp_file/'.ip2long($_SERVER['REMOTE_ADDR']);

if(file_exists($papka))
	{
	if($_GET['del']) 
		{
		$_GET['del']=intval($_GET['del']);
		$small = $papka.'/'.$_GET['del'].'_s_.jpg';
		$big = $papka.'/'.$_GET['del'].'_b_.jpg';
		if(file_exists($small) && is_file($small)) unlink($small);
		if(file_exists($big) && is_file($big)) unlink($big);
		}
	
	$dir = opendir($papka);
	while(($file = readdir($dir)))
		{
		if (is_file ($papka."/".$file))
			{
			$f=explode('_', $file);
			if($f[1]=='s') $arr_foto[]=$f[0];
			}
		}
	closedir ($dir);
				
	if($arr_foto && is_array($arr_foto))
		{
		sort($arr_foto);
		$i=0;
		$j=0;
		echo '<table cellpadding="3" cellspacing="3" >';
		foreach($arr_foto as $af)
			{
			$j++;
			if(!$i) echo '<tr>';
			echo '<td valign="top" align=center>';
			echo '<img src="'.$papka.'/'.$af.'_s_.jpg" border=0 height=80> ';
			echo '<br><a href="javascript:dels('.$af.')"><font color=red>X</font></a>';
			$i++;
			if($i==4) $i=0;
			}
		echo '</table>';
		}
	}
	
if($j < $rru['limit_foto'])
	{
	?>
	<script type="text/javascript">
	document.getElementById('foto').disabled=0;
	</script>
	<?
	}
else
	{
	?>
	<script type="text/javascript">
	document.getElementById('foto').disabled=1;
	</script>
	<?
	}
?>