<?php include('header.php');
$header_ad_url = '../ads/header.txt';
if (isset($_POST['save_header_ad'])) {
$handle = fopen($header_ad_url,"w");
$edited_code = $_POST['header_ad'];
$fwrite = fwrite($handle,$edited_code);
if ($fwrite === FALSE) {
$message = notification('danger','Error Happened');
} else {
$message = notification('success','All Changes Saved Successfully');	
}
fclose($handle);	
} 
$header_ad = file_get_contents($header_ad_url); 
$sidebar_ad_url = '../ads/side.txt';
if (isset($_POST['save_sidebar_ad'])) {
$handle = fopen($sidebar_ad_url,"w");
$edited_code = $_POST['sidebar_ad'];
$fwrite = fwrite($handle,$edited_code);
if ($fwrite === FALSE) {
$message = notification('danger','Error Happened');
} else {
$message = notification('success','All Changes Saved Successfully');	
}
fclose($handle);	
} 
$sidebar_ad = file_get_contents($sidebar_ad_url); 
$content_ad_url = '../ads/content.txt';
if (isset($_POST['save_content_ad'])) {
$handle = fopen($content_ad_url,"w");
$edited_code = $_POST['content_ad'];
$fwrite = fwrite($handle,$edited_code);
if ($fwrite === FALSE) {
$message = notification('danger','Error Happened');
} else {
$message = notification('success','All Changes Saved Successfully');	
}
fclose($handle);	
} 
$content_ad = file_get_contents($content_ad_url);
?>
        <div class="page-header page-heading">
            <h1><i class="fa fa-picture-o"></i> Ads Spaces</h1>
        </div>
		<?php if (isset($message)) {echo $message;} ?>
		<form role="form" method="POST" action="">
		  <div class="form-group">
			<label for="header_ad">Header Ad Space (Wide Banner)</label>
			<textarea class="form-control" name="header_ad" id="header_ad" rows="10"><?php echo $header_ad; ?></textarea>
		  </div>
		  <button type="submit" name="save_header_ad" class="btn btn-primary">Save</button>
		</form>
		<form role="form" method="POST" action="" style="margin-top:50px;">
		  <div class="form-group">
			<label for="sidebar_ad">Sidebar Ad Space (Square)</label>
			<textarea class="form-control" name="sidebar_ad" id="sidebar_ad" rows="10"><?php echo $sidebar_ad; ?></textarea>
		  </div>
		  <button type="submit" name="save_sidebar_ad" class="btn btn-primary">Save</button>
		</form>
		<form role="form" method="POST" action="" style="margin-top:50px;">
		  <div class="form-group">
			<label for="content_ad">Content Ad Space (Wide Banner)</label>
			<textarea class="form-control" name="content_ad" id="content_ad" rows="10"><?php echo $content_ad; ?></textarea>
		  </div>
		  <button type="submit" name="save_content_ad" class="btn btn-primary">Save</button>
		</form>
<?php include('footer.php'); ?>
 