<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/class.php");
include("../class/user.php");
include("../class/MemberLevel.php");
include("../class/q_functions.php");
include("../class/qinfofun.php");
$link=db_connect();
$empire=new mysqlquery();
if($public_r['addnews_ok'])//关闭投稿
{
	printerror("NotOpenCQInfo","",1);
}
$classid=(int)$_GET['classid'];
$mid=(int)$_GET['mid'];
if(empty($classid)||empty($mid))
{
	printerror("EmptyQinfoCid","",1);
}
$enews=$_GET['enews'];
if(empty($enews))
{
	$enews="MAddInfo";
}
$muserid=(int)getcvar('mluserid');
$musername=getcvar('mlusername');
$mrnd=getcvar('mlrnd');
$showkey="";
$r['newstext']="";
//增加
if($enews=="MAddInfo")
{
	$cr=DoQCheckAddLevel($classid,$muserid,$musername,$mrnd,0,1);
	$mr=$empire->fetch1("select qenter,qmname,tobrf from {$dbtbpre}enewsmod where mid='$cr[modid]'");
	if(empty($mr['qenter']))
	{
		printerror("NotOpenCQInfo","history.go(-1)",1);
	}
	$word="提交信息";
	$ecmsfirstpost=1;
	$rechangeclass="&nbsp;[<a href='ChangeClass.php?mid=".$cr['modid']."'>重新选择</a>]";
	//验证码
	if($cr['qaddshowkey'])
	{
		$showkey="<tr bgcolor=\"#FFFFFF\">
      <td width=\"11%\" height=\"25\">验证码</td>
      <td height=\"25\"><input name=\"key\" type=\"text\" size=\"6\">
        <img src=\"../ShowKey/?ecms\"></td></tr>";
	}
	//图片
	$imgwidth=0;
	$imgheight=0;
	//图片集模型
	if(strstr($mr['qenter'],"morepic<"))
	{
		$morepicnum=3;
		$morepicpath="<table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
		<tr> 
			<td width='7%'><div align=center>1</div></td>
			<td width='33%'><div align=center>
			<input name=msmallpic[] type=text id=msmallpic[] size=28>
			</div></td>
			<td width='30%'><div align=center>
			<input name=mbigpic[] type=text id=mbigpic[] size=28>
			</div></td>
			<td width='30%'><div align=center>
			<input name=mpicname[] type=text id=mpicname[]>
			</div></td>
		</tr>
		<tr> 
			<td><div align=center>2</div></td>
			<td><div align=center>
			<input name=msmallpic[] type=text id=msmallpic[] size=28>
			</div></td>
			<td><div align=center>
			<input name=mbigpic[] type=text id=mbigpic[] size=28>
			</div></td>
			<td><div align=center>
			<input name=mpicname[] type=text id=mpicname[]>
			</div></td>
		</tr>
		<tr> 
			<td><div align=center>3</div></td>
			<td><div align=center>
			<input name=msmallpic[] type=text id=msmallpic[] size=28>
			</div></td>
			<td><div align=center>
			<input name=mbigpic[] type=text id=mbigpic[] size=28>
			</div></td>
			<td><div align=center>
			<input name=mpicname[] type=text id=mpicname[]>
			</div></td>
		</tr></table>";
	}
	//文件验证码
	$filepass=time();
}
else
{
	$word="修改信息";
	$ecmsfirstpost=0;
	$id=(int)$_GET['id'];
	if(empty($id))
	{
		printerror("EmptyQinfoCid","",1);
	}
	$cr=DoQCheckAddLevel($classid,$muserid,$musername,$mrnd,1,0);
	$mr=$empire->fetch1("select qenter,qmname,tobrf from {$dbtbpre}enewsmod where mid='$cr[modid]'");
	if(empty($mr['qenter']))
	{
		printerror("NotOpenCQInfo","history.go(-1)",1);
	}
	$r=CheckQdoinfo($classid,$id,$muserid,$cr['tbname'],$cr['adminqinfo'],1);
	//图片
	$imgwidth=170;
	$imgheight=120;
	//图片集系统模型
	$morepicpath="";
	if(strstr($mr['qenter'],"morepic<"))
	{
		$morepicnum=0;
		if($r[morepic])
		{
			$r[morepic]=stripSlashes($r[morepic]);
			//地址
			$j=0;
			$pd_record=explode("\r\n",$r[morepic]);
			for($i=0;$i<count($pd_record);$i++)
			{
				$j=$i+1;
				$pd_field=explode("::::::",$pd_record[$i]);
				$morepicpath.="<tr> 
	<td width='7%'><div align=center>".$j."</div></td>
    <td width='33%'><div align=center>
        <input name=msmallpic[] type=text value='".$pd_field[0]."' size=28>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mbigpic[] type=text value='".$pd_field[1]."' size=28>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mpicid[] value=".$j."><input type=checkbox name=mdelpicid[] value=".$j.">删
      </div></td></tr>";
			}
			$morepicnum=$j;
			$morepicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$morepicpath."</table>";
		}
	}
	//文件验证码
	$filepass=$id;
}
$tbname=$cr['tbname'];
esetcookie("qeditinfo","dgcms");
//栏目
$classurl=sys_ReturnBqClassname($cr,9);
$postclass="<a href='".$classurl."' target='_blank'>".$class_r[$classid]['classname']."</a>".$rechangeclass;
if($cr['bclassid'])
{
	$bcr['classid']=$cr['bclassid'];
	$bclassurl=sys_ReturnBqClassname($bcr,9);
	$postclass="<a href='".$bclassurl."' target=_blank>".$class_r[$cr['bclassid']]['classname']."</a>&nbsp;>&nbsp;".$postclass;
}
$url="<a href='../../'>首页</a>&nbsp;>&nbsp;<a href='../member/cp'>控制面板</a>&nbsp;>&nbsp;<a href='ListInfo.php?mid=".$cr['modid']."'>管理信息</a>&nbsp;>&nbsp;".$word."&nbsp;(".$mr[qmname].")";
//html编辑器
if(strstr($mr['qenter'],"newstext<"))
{
	$htmlareacode="<script type=\"text/javascript\">
      _editor_url = \"../data/htmlarea\";
      _editor_lang = \"en\";
	</script>
	<script type=\"text/javascript\" src=\"../data/htmlarea/htmlarea.php?userid=$muserid&username=$musername&rnd=$mrnd&classid=$classid&filepass=$filepass\"></script>
	<script type=\"text/javascript\" src=\"../data/htmlarea/plugins/FullPage/full-page.js\"></script>
	<script type=\"text/javascript\" src=\"../data/htmlarea/plugins/FullPage/lang/en.js\"></script>
	<script type=\"text/javascript\">
	//HTMLArea.loadPlugin(\"FullPage\");
	var editor = null;
	function initEditor() {
		editor = new HTMLArea(\"newstext\");
		editor.registerPlugin(FullPage);
		editor.generate();
		document.all['title'].focus();
		return false;
	}
	function InsertFile(html){
		editor.insertHTML(html);
	}
    </script>";
	$onload="<script>initEditor();</script>";
}
if(empty($musername))
{
	$musername="游客";
}
$modfile="../data/html/q".$cr['modid'].".php";
include("../data/template/cp_1.php");
?>
<?=$htmlareacode?>
<script src="../data/html/setday.js"></script>
<script>
function bs(){
	var f=document.add
	if(f.title.value.length==0){alert("标题还没写");f.title.focus();return false;}
	if(f.classid.value==0){alert("请选择栏目");f.classid.focus();return false;}
}
function foreColor(){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) document.add.titlecolor.value=arr;
  else document.add.titlecolor.focus();
}
function FieldChangeColor(obj){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) obj.value=arr;
  else obj.focus();
}
</script><noscript>
<iframe src=*.htm></iframe>
</noscript>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="17%" valign="top"> 
    <?
	//输出可管理的模型
	$modsql=$empire->query("select mid,qmname from {$dbtbpre}enewsmod where qenter<>'' order by mid");
	while($modr=$empire->fetch($modsql))
	{
		$fontb="";
		$fontb1="";
		if($modr['mid']==$mid)
		{
			$fontb="<b>";
			$fontb1="</b>";
		}
	?>
      <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableborder">
        <tr class="header"> 
          <td height="23">
            <?=$modr[qmname]?>管理</td>
        </tr>
        <tr> 
          <td height="23" bgcolor="#FFFFFF"><img src="../data/images/msgnav.gif" width="5" height="5">&nbsp;<a href="ChangeClass.php?mid=<?=$modr[mid]?>"><?=$fontb?>增加<?=$modr[qmname]?>
            <?=$fontb1?></a></td>
        </tr>
        <tr> 
          <td height="23" bgcolor="#FFFFFF"><img src="../data/images/msgnav.gif" width="5" height="5">&nbsp;<a href="ListInfo.php?mid=<?=$modr[mid]?>"><?=$fontb?>管理<?=$modr[qmname]?>
            <?=$fontb1?></a></td>
        </tr>
      </table>
      <br> 
      <?
	  }
	  ?>
    </td>
    <td width="1%" valign="top">&nbsp;</td>
    <td width="82%" valign="top"> 
      <form name="add" method="POST" enctype="multipart/form-data" action="ecms.php">
        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
          <tr class="header"> 
            <td height="25" colspan="2"> 
              <?=$word?>
              <input type=hidden value=<?=$enews?> name=enews> <input type=hidden value=<?=$classid?> name=classid> 
              <input name=id type=hidden id="id" value=<?=$id?>> <input type=hidden value="<?=$filepass?>" name=filepass> 
              <input name=mid type=hidden id="mid" value=<?=$mid?>></td>
          </tr>
          <tr bgcolor="#FFFFFF">
            <td>提交者</td>
            <td><b>
              <?=$musername?>
              </b></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td width="16%">栏目</td>
            <td>
              <?=$postclass?>
            </td>
          </tr>
        </table>
  <?
  @include($modfile);
  ?>
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  	<?=$showkey?>
    <tr class="header"> 
      <td width="16%">&nbsp;</td>
      <td><input type="submit" name="addnews" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
  </form>
	</td>
  </tr>
</table>
<?
db_close();
$empire=null;
include("../data/template/cp_2.php");
?>
<?=$onload?>
