<?php 
    require "../../Run.php";
	require "../../include/getmkurl.fun.php";
    echo head('添加代码模块');
	if($login == 1){              /*如果用户已经登录*/
	if($admin == 1 ||$admin == 2){ 
    if($_GET['add'] == 'y'){
	if($_POST['title'] == NULL || $_POST['content'] == NULL){
		ehtml('<div class="tip">模块名称和代码内容均不能为空</div>');
		exit();
	}
	$mysql = new D('dd_html');
	$back = $mysql ->where(array('title'=>$_POST['title'],'siteid'=>WAPID))->find();
	if($back != FALSE){
		ehtml("标签名称重复了，更换一个吧！");
		exit();
	}
	$time = date("Y-m-d"); 
	$_POST['userid'] = $id;
	$_POST['time']   = time();
	$_POST['siteid'] = WAPID;
	if($mysql->insert())
	{
		echo "<div class=\"tip\">";
		echo "已经成功上传了！";
		echo "请阅读检查";
		echo "</div>";
	}else{
		echo "上传失败!请重试或者联系网站管理员！";
	}
    echo "<br>";
	echo "<a href=\"add.php?class=".$_GET['cid']."\">返回添加标签</a><br>";
	}else{
    echo "
	<div class=\"title\">标签管理</div><div class=\"content\">
    <form method=\"post\" enctype=\"multipart/form-data\" action=\"add.php?class=".$_GET['cid']."&type=add&add=y\">      
    <br>标签题目<br><input type=\"text\" name=\"title\"  value=\"\">
    <br><input type=\"text\" name=\"bz\"  value=\"说明\"><br>
	标签内容(支持html)
    <br>
    <textarea name=\"content\"></textarea><br>
    <br> <input type=\"submit\" value=\"保存标签\"><br></form></div>";
	}
	echo "<div class=\"mylink\"><a href=\"list.php?cid=\"".$_GET['cid']."\">返回上级</a><a href=\"../../index.php?\">网站首页</a></div>";
			
	  
    }else{
		echo "您无权进入此页面，请联系管理员！";
		}
	}else{
		echo "您好，您尚未登录！";
		}
	echo footer(1);
?>