<?php include('header.php');
$ga_code_url = '../analytics/code.txt';
if (isset($_POST['save'])) {
$handle = fopen($ga_code_url,"w");
$edited_code = $_POST['ga_code'];
$fwrite = fwrite($handle,$edited_code);
if ($fwrite === FALSE) {
$message = notification('danger','Error Happened');
} else {
$message = notification('success','All Changes Saved Successfully');	
}
fclose($handle);	
} 
$ga_code = file_get_contents($ga_code_url); 
?>
        <div class="page-header page-heading">
            <h1><i class="fa fa-bar-charts"></i> Google Analytics Code</h1>
        </div>
		<?php if (isset($message)) {echo $message;} ?>
		<form role="form" method="POST" action="">
		  <div class="form-group">
			<textarea class="form-control" name="ga_code" id="ga_code" rows="10"><?php echo $ga_code; ?></textarea>
		  </div>
		  <button type="submit" name="save" class="btn btn-primary">Save</button>
		</form>
<?php include('footer.php'); ?>
 