<?php
session_start();
$w=file("ac/sess");
$id="";
foreach($w as $line)
 {
   $expl=explode("*",$line);
   $line=trim($line);
   if(session_id()==$expl[1])
      {
        $id=$expl[2];
        $name=$expl[3];
        break;
      }
 }
if($id=="")
  {
    echo "<meta http-equiv=refresh content='0; url=index.php'>";
    exit();
  }

 if(!isset($_GET['id']))
   {
   	 echo "<meta http-equiv=refresh content='0; url=admin3.php?sel3=selected'>";
     exit();
   }

 if(!file_exists("cons/$_GET[id]"))
   {
   	 echo "<meta http-equiv=refresh content='0; url=admin3.php?sel3=selected'>";
     exit();
   }

//Фото, если есть
$foto=array();
 $d=opendir("foto");
   while(($e=readdir($d))!=false)
     {
       if($e =="." || $e ==".." || $e==".htaccess" ) continue;
       $foto[]=$e;
     }
  closedir($d);

foreach($foto as $line)
 {
 	 $expl=explode(".",$line);
 	 if($expl[0]==$_GET['id'])
 	    {
 	      unlink("foto/$line");
 	      break;
 	    }
 }

 echo "<meta http-equiv=refresh content='0; url=admin3.php?sel3=selected'>";
 exit();



?>