<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Revised: 1/7/2016	ELL
//

	include ("check_session.php");
	
	$image = $_REQUEST['image'];
	
	$rslt = 1;
		
	$query = "DELETE FROM gallery_titles WHERE image = '$image'";
	$cnt = $bwb_dbh->exec($query);
	
	$doc_root = getenv('DOCUMENT_ROOT');
	if (BWB_BASE_DIR == '')
		$userfiles = '';
	else
		$userfiles = "/" . BWB_BASE_DIR;
		
	if (!file_exists($doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/bkup"))
		mkdir($doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/bkup");
		
	$orig_image_path = $doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/orig/" . $image;
	$fs_image_path = $doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/fs/" . $image;
	$tn_image_path = $doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/tn/" . $image;
	
	copy($orig_image_path, $doc_root . $userfiles . "/" . BWB_IMAGE_DIR . "/gallery/bkup/" . $image);
	unlink($orig_image_path);
	unlink($fs_image_path);
	unlink($tn_image_path);
	
	print $rslt;
?>
