<?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){
	   echo '<div class="tip">模块名称和代码内容均不能为空</div>';
	   }else{
	$time = date("Y-m-d");
	$content = $_POST['content']; 
	$article="INSERT INTO html(title,userid,bz,gro,content,time,siteid)VALUES
	('{$_POST["title"]}','{$id}','{$_POST["bz"]}','{$_POST['gro']}','{$content}','{$time}','{$wapid}')";
	$article = mysql_query($article);
    if($article && mysql_affected_rows()>0){
	echo "<div class=\"tip\">";
    echo "已经成功上传了！";
	echo "请阅读检查";
	echo "</div>";
	}else{
	echo "上传失败!请重试或者联系网站管理员！";
		}
	}
    echo "<br>";
	echo "<a href=\"add.php?class=".$_GET['cid']."\">返回添加HTML</a><br>";
	}else{
    echo "
	<div class=\"title\">HTML代码自写</div><div class=\"content\">
    <form method=\"post\" enctype=\"multipart/form-data\" action=\"add.php?class=".$_GET['cid']."&type=add&add=y\">      
    <br><input type=\"text\" name=\"title\"  value=\"HTML标题\">
    <br><input type=\"text\" name=\"bz\"  value=\"备注\"><br>
    栏目分类
    <br>";
	
	echo "<select name=\"gro\" >";
    $sql="SELECT cid,xuhao,cn,gro,q,url FROM class WHERE url='".get_mkid('html/list.php')."' AND siteid='{$wapid}' ORDER BY xuhao";
	/*执行数据查询语句*/  
	$result = mysql_query($sql);
	/*处理结果集*/
	if($result && mysql_num_rows($result)>0){
    while(list($cid,$number,$cn,$class,$lmq,$urld)=mysql_fetch_row($result)){
	if($_GET['cid'] == $cid){
		$cek = ' selected="selected" ';
	}
	echo "<option value=\"".$cid."\" ".$cek." >".$cid."_".$cn."</option>";
	    }
	}
	
    echo "</select><br>
   HTML内容
    <br>
    <textarea name=\"content\"  style=\"height:400px;\"></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);
?>