
<?php
  //инициализируем переменные
  $File = $_GET['file'];
  $Time = $_GET['time'];
  $FileName = "../txt/".$File;
  $IpFile = "../txt/ip".$Time;
  $PswdFile  = "../txt/pswd".$Time;
  $PswdsFile = "../txt/pswds".$Time;
  $EachPassd_Letter = "../txt/eachpassd_letter".$Time;
  $OnePassd_EmailAddr = "../txt/onepassd_emailaddr".$Time;
  $OnePassd_Letter = "../txt/onepassd_letter".$Time;
  $TypeFile = "../txt/type".$Time;
  $Total = $_GET['total'];
	$PollArr = file($FileName);
  $EndPos = count($PollArr) - 1;
  if(strpos($File, 'cp') !== false)
    $PageTmp = 'currentpoll'; else $PageTmp = 'pollarchive';
  //Выводим диалог с подтверждением
  if($_GET['DeleteConf'] != true)
  {
    //выбираем вопрос
    $Question = StripBBCode($PollArr[0]);
    //выводим диалог
    print "<br><br>";
    print "<div align=center>";
    print "{$Cpt_DelQuest} <b>{$Question}</b><br>";
    print "{$Cpt_di_Total} {$Total}<br><br>";
    print "<a href = index.php?page=deleteitem&file={$File}&time={$Time}&DeleteConf=1>{$Cpt_Yes}</a>&nbsp;&nbsp;&nbsp;<a href = index.php?page={$PageTmp}>{$Cpt_No}</a>";
    print "</div>";
  }
  if($_GET['DeleteConf'] == 1)
  {
	  //Удаляем файлы, где хранятся IP и пароли
	  if(file_exists($IpFile))
	    unlink($IpFile);
	  if(file_exists($PswdFile))
	    unlink($PswdFile);
	  if(file_exists($PswdsFile))
	    unlink($PswdsFile);
    if(file_exists($EachPassd_Letter))
	    unlink($EachPassd_Letter);
    if(file_exists($OnePassd_EmailAddr))
	    unlink($OnePassd_EmailAddr);
    if(file_exists($OnePassd_Letter))
	    unlink($OnePassd_Letter);
    if(file_exists($TypeFile))
	    unlink($TypeFile);
    //print "{$IpFile}{$PswdFile}{$PswdsFile}";
	  $ToDeleteStr = @implode("", $PollArr)."\n\n";
	  SaveStringInFile($File_DeletedPolls, $ToDeleteStr, 'a');
	    unlink($FileName);
    //удаляем изображения
    if(file_exists('../pictures/jpgraph_bar1'.$Time.'.jpg'))
	    unlink('../pictures/jpgraph_bar1'.$Time.'.jpg');
    if(file_exists('../pictures/jpgraph_bar2'.$Time.'.jpg'))
	    unlink('../pictures/jpgraph_bar2'.$Time.'.jpg');
    if(file_exists('../pictures/pie'.$Time.'.jpg'))
	    unlink('../pictures/pie'.$Time.'.jpg');
    if(file_exists('../pictures/pieplot3d'.$Time.'.jpg'))
	    unlink('../pictures/pieplot3d'.$Time.'.jpg');
    if(file_exists('../pictures/scatterplot'.$Time.'.jpg'))
	    unlink('../pictures/scatterplot'.$Time.'.jpg');

    //определяем страницу перехода
    if(strpos($FileName, 'arch') === true)
      $PageTmp = 'pollarchive'; else $PageTmp = 'currentpoll';
    Refresh($PageTmp);
  }
?>