<?require ("global.php");?>
<?php

if (isset($_GET['ID']))
{
  $ID = $_GET["ID"];

  $query = "SELECT fullname, stageID FROM pics WHERE ID = $ID LIMIT 1";
  $result = mysql_query($query, $db);
  if ($result)
    {
      if ($r = mysql_fetch_array($result))
	{
	  $fullname = $r['fullname'];
	  $stageID = $r['stageID'];
	  unlink("$DOCUMENT_ROOT/tick/images/gallery/${fullname}");
	  unlink("$DOCUMENT_ROOT/tick/images/gallery/t_${fullname}");
	}
    }

  $query = "DELETE FROM pics WHERE ID = $ID LIMIT 1";
  $result = mysql_query($query, $db);
  staticify($stageID);
}

header("Location: /tick/pics.php");

?>
