<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/19/2014	ELL
	
	include ("check_session.php");

	$file_name = $_POST['file_name'];
	$folder = $_POST["folder"];
	
	if (strpos($file_name, "/") === 0)
		$file_name = substr($file_name, 1);
	
	$document_root = $_SERVER['DOCUMENT_ROOT'];
	$path = $document_root . "/" . $folder . "/";
	
	$save_file_path = $path . "." . $file_name . "_save";
	if (file_exists($save_file_path))
		unlink($save_file_path);
	else	{
		echo "No draft found";
	}
	
	$file_path = $path . $file_name;
	
	if (!($fh = fopen($file_path, 'r'))) {
		echo "Error opening file";
		exit;
	}
	$contents = (fread($fh, filesize($file_path)));
	fclose($fh);

	echo $contents;
?>