<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/18//2014	ELL

	include ("check_session.php");

	$file_content = $_POST['file_content'];
	$file_name = $_POST['file_name'];
	$r_file_name = strrev($file_name);
	$file_name_parts = explode(".", $r_file_name);
	$ext = $file_name_parts[0];
	$ext = strrev($ext);
	
	$document_root = $_SERVER['DOCUMENT_ROOT'];
	$website = $http . $_SERVER['SERVER_NAME'];
	if ((BWB_BASE_DIR == '') && (BWB_WEBPAGE_DIR == ''))	{
		$path = $document_root;
		$web_path = $website;
	}
	elseif (BWB_BASE_DIR == '')	{
		$path = $document_root . "/" . BWB_WEBPAGE_DIR;
		$web_path = $website . "/" . BWB_WEBPAGE_DIR;
	}
	else	{
		$path = $document_root . "/" . BWB_BASE_DIR . "/" . BWB_WEBPAGE_DIR;
		$web_path = $website . "/" . BWB_BASE_DIR . "/" . BWB_WEBPAGE_DIR;
	}
		
	$file_path = $path . "/pREVIEW." . $ext;
	$fh = fopen($file_path, 'w') or die("Can't create $file_path: $php_errormsg");
	$result = (fputs($fh, $file_content));
	fclose($fh) or die($php_errormsg);
	@chmod($file_path, 0644);
	
	echo $web_path . "@@@@@" . $ext;
?>