<?php
	require '../../Run.php';
	if($admin !=1 &&$admin !=2){
		ehtml("权限不足！");
		exit();
	}
	echo head("修改论坛栏目CSS");
	echo '<div class="title">论坛CSS自定义</div>';
	$filename = root_path.'/lib/bbs/'.WAPID.'_css.txt';
	if(!is_dir(root_path.'/lib/bbs')){
		mkdir(root_path.'/lib/bbs');
	}
	if(!is_file($filename)){
		file_put_contents($filename, htmlspecialchars('<link rel="stylesheet" type="text/css" href="/style/css/bbs_view.css">'));
	}
	if($_GET['type'] == 'mod'){
		if(file_put_contents($filename,$_POST['css'])){
			echo '<div class="tip">修改成功</div>';
		}else{
			echo '<div class="tip">修改失败</div>';
		}
		echo '<div class="mylink"><a href="?">返回修改</a><a href="http://'.HTTP_HOST.'/admin/wap_admin.php?">管理后台</a></div>';
	}else{
	$this_css = file_get_contents($filename);
	echo '<div class="content">';
	echo '<form method="POST" action="?type=mod">';
	echo '<br>您的CSS样式<br>';
	echo '<textarea name="css">'.$this_css.'</textarea><br>';
	echo '<input value="保存修改" type="submit">';
	echo '</form>';
	echo '</div>';
	echo '<div class="mylink"><a href="http://'.HTTP_HOST.'/admin/wap_admin.php?">管理后台</a></div>';
	}