<?php
chdir('../..');
require_once('api/buyers.php');

$result = false;
$buyers = new Buyers();

if(!$buyers->managers->access('design'))
	return false;

$file_content = $buyers->request->post('file_content');
$subdir = $buyers->request->post('dir', 'string') ? $buyers->request->post('dir')."/" : "";
$module = $buyers->request->post('module');
$filename = $buyers->request->post('filename', 'string');

$file = 'design/'.$buyers->settings->theme.'/'.$module.'/'.$subdir . $filename;
if(is_file($file) && is_writable($file))
{
	file_put_contents($file, $file_content);
    $result = true;
}

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");

print json_encode($result);
