<?php
//Set up the system
require('config.include.php');
//Auth stuff
require('auth.include.php');
//Save data if given
$saved=false;
//Path to the css file
$cssfile='../'.THEMEFOLDER.'/'.THEME.'/'.THEME.'.css';
if(isset($_POST['cssCode'])) {
	$tmpFile=@fopen($cssfile,'w+');
	if($tmpFile===false)
		die('Could not open "'.$cssfile.'" for writing, please check the file permissions.');
	fwrite($tmpFile,fetch::unescapePostVar($_POST['cssCode']));
	fclose($tmpFile);
	$saved=true;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit CSS</title>
<link rel="stylesheet" href="admin.css" />
</head>

<body>
<div id="wrapper">
	<div id="header">
    	<?php echo('<a href="../" class="breadcrumb">'.SITE_TITLE.'</a> &raquo; <a href="dashboard.php" class="breadcrumb">Dashboard</a> &raquo; <a href="setcss.php" class="breadcrumb">Edit CSS</a>'); ?>
    </div>
    <div id="sidebar">
<?php
	require('nav.include.php');
?>
    </div>
    <div id="content">
        <div class="contentblock">
		<h2>Update Template CSS</h2>
		<form action="setcss.php" method="post">
			<textarea name="cssCode" class="full" cols="60" rows="30"><?php echo(htmlentities(file_get_contents($cssfile),ENT_QUOTES,"UTF-8")); ?></textarea>
			<br />
			<input type="submit" value="Save"/>
		</form>
		<?php
		if($saved)
			echo('Changes saved.');
		?>
		</div>
    </div>
    <div id="footer">
    </div>
</div>
</body>
</html>