<?php
define('IN_SYS',TRUE);
define('IN_AdminMenu',TRUE);
require './admin_config.php';
require '../config.php';
require '../setup.php';
require("../lib/admin_chk.php");
?>
<?php
$pageTitle="添加网站信息";

$cateTable = "category";
$infoTable = "content";
$_uname = $_SESSION["adminUsr"];
$Type=$_GET["Type"];
$MType = $_GET["MType"];
$Title = $_POST["title"];
$MpType = $_POST["MpType"];
$Mcataid = $_GET["Mcataid"];
$uType = 1;

if($Type=="up"){

	if($Title==""){
		OutErrorBack("信息标题不能够为空!");
	}
	if($MpType == "0"){
		OutErrorBack("请选择信息类别!");
	}
	//stripslashes()反转义
	//为什么用反转义，因为fck编辑器自动的将需要进入数据库的信息转义了一次，所以我们在取图片地址的时候就必须反转义一次才行。
	//echo stripslashes($_POST["d_content"]);
	$Cotent_img=RequestImg(stripslashes($_POST["d_content"]));

	//插入数据
	$rs = array();
	$rs["Type"]=trim($_POST["MpType"]);
	$rs["title"]=$_POST["title"];
	$rs["content"] = addslashes($_POST["d_content"]);
	$rs["aAuthor"]=$_POST["aAuthor"];
	$rs["aFrom"]=$_POST["aFrom"];
	$rs["tColor"]=$_POST["tColor"];
	$rs["pic"]=$_POST["imageUrl"];

	$aIsRecommend=$_POST["isRecommend"];
	if($aIsRecommend == ""){
		$aIsRecommend=0;
	}else{
		$aIsRecommend==$aIsRecommend;
	}
	$rs["isRecommend"]=$aIsRecommend;

	$aIsHot=$_POST["isHot"];
	if($aIsHot == ""){
		$aIsHot=0;
	}else{
		$aIsHot==$aIsHot;
	}
	$rs["isHot"]=$aIsHot;

	$aIsHeadlines=$_POST["isHeadlines"];
	if($aIsHeadlines == ""){
		$aIsHeadlines=0;
	}else{
		$aIsHeadlines==$aIsHeadlines;
	}
	$rs["isHeadlines"]=$aIsHeadlines;

	$aIsSlide=$_POST["isSlide"];
	if($aIsSlide == ""){
		$aIsSlide=0;
	}else{
		$aIsSlide==$aIsSlide;
	}
	$rs["isSlide"]=$aIsSlide;
	$subTitle=$_POST["subTitle"];

	/*$rs["isRecommend"] = isset($_POST["isRecommend"]) ? $_POST["isRecommend"] :  false;*/
	$rs["aKeywords"]=$_POST["aKeywords"];
	$rs["aDescription"]=$_POST["aDescription"];
	$rs["aCount"]=$_POST["aCount"];
	$rs["jumpUrl"]=$_POST["jumpUrl"];
	$rs["adate"]=make_semiangle($_POST["time"]);
	$rs["Content_img"]=$Cotent_img;
	$rs["attachments"]=$_POST["attachments"];
	$aPrice = floatval($_POST["aPrice"]);
	
	$sql = "insert into ".DB_TablePre.$infoTable." (type,title,content,aAuthor,aFrom,tColor,pic,isRecommend,isHot,isHeadlines,isSlide,aKeywords,aDescription,jumpUrl,aCount,adate,Content_img,attachments,subTitle,aPrice) values ('".$rs["Type"]."','".$rs["title"]."','".$rs["content"]."','".$rs["aAuthor"]."','".$rs["aFrom"]."','".$rs["tColor"]."','".$rs["pic"]."','".$rs["isRecommend"]."','".$rs["isHot"]."','".$rs["isHeadlines"]."','".$rs["isSlide"]."','".$rs["aKeywords"]."','".$rs["aDescription"]."','".$rs["jumpUrl"]."','".$rs["aCount"]."','".$rs["adate"]."','".$rs["Content_img"]."','".$rs["attachments"]."','".$subTitle."','".$aPrice."')";
	//echo $sql;

	$conn = new dbo();
	$conn->query($sql);
	$inssql = $conn->res;
	
	if($inssql){
		//echo "写入成功";
		//exit;
	}else{
		echo "写入失败";
		//echo $sql;
		exit;
	}
	
	OutErrorGo("网站信息添加成功!","?Mcataid=".$_POST["MpType"]);
}
?><!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<title><?php echo $pageTitle?><?php echo $sysTitle?></title>
<link href="templates/admin.css" rel="stylesheet" type="text/css">
<link href="js/colorPickerV2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../lib/jquery/jquery.js"></script>
<script type="text/javascript" src="js/controlPanelMenu.js"></script>
<script type="text/javascript" src="js/commmonAdmin.js"></script>
<script type="text/javascript" src="js/colorPickerFunctions.js"></script>
<script type="text/javascript" src="js/colorPickerV2.js"></script>
<script type="text/javascript" src="../apps/_8816a37faf9597de8c595dbf8ff9d628$/ckeditor.js"></script>
<script type="text/javascript" src="../lib/validform/source.js"></script>
<link type="text/css" rel="stylesheet" href="../lib/validform/validform.css">
<link type="text/css" rel="stylesheet" href="../lib/uploadify/uploadify.css">
<script type="text/javascript" src="../lib/uploadify/source.js?ver=<?php echo rand(0,999);?>"></script>
<script type="text/javascript">
function uploadSuccess(file,data,response){
	try{
		var result = jQuery.parseJSON(data);
		$('#imageUrlImg').attr("src",result.FileUrl);$('#imageUrlImg').show();$('#imageUrl').val(result.FileUrl);
	}
	catch(ex){alert("图片上传失败，请重新上传。");return;}
}
$(function(){
	$('#imageUrl_upload').uploadify({
		'formData':{'<?php echo session_name();?>':'<?php echo session_id(); ?>','picw':'1922'},
		'swf': '../lib/uploadify/uploadify.swf',
		'uploader': '../apps/Upload_uploadify.php?upType=thumbUpload',
		'multi':false,
		'buttonText':'选择缩略图',
		'fileTypeDesc':'文件',
		'fileTypeExts':'*.jpg;*.jpeg;*.gif;*.png',
		'onUploadSuccess':uploadSuccess
	});
});

function uploadSuccessAttachments(file,data,response){
	try{
		var result = jQuery.parseJSON(data);
		//$('#imageUrlImg').attr("src",result.FileUrl);$('#imageUrlImg').show();
		$('#attachments').val(result.FileUrl);
	}
	catch(ex){alert("视频上传失败，请重新上传。");return;}
}
$(function(){
	$('#attachmentsUrl_upload').uploadify({
		'formData':{'<?php echo session_name();?>':'<?php echo session_id(); ?>','picw':'1922'},
		'swf': '../lib/uploadify/uploadify.swf',
		'uploader': '../apps/Upload_uploadify.php?upType=attachmentsUpload',
		'multi':false,
		'buttonText':'选择附件',
		'fileTypeDesc':'附件',
		'fileTypeExts':'*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.zip;*.rar;*.pdf',
		'onUploadSuccess':uploadSuccessAttachments
	});
});
</script>
</head>
<body>
<?php
include("./admin_header.php")
?>
<div id="containerAdmin" class="wrapper_m">
<div id="sidebarAdmin">
<?php
include("./admin_controlPanelDir.php")
?>
</div>
<div id="contentbarAdmin">
<div class="tips_2"><?php echo adminPageLocation($pageTitle)?></div>

<form action="?Type=up" method="post" name="formAdmin" target="_parent" id="formAdmin">
<div class="clearfix mt_10">
<ul id="atab1" class="adminTabs_1">
<li class="tabCurrent" onClick="tabsAdminV0(this,0);">常规信息</li> 
<li class="tabNormal" onClick="tabsAdminV0(this,1);">高级设置</li>
</ul>
</div>
<div id="atab1_content0">
<table cellspacing="1" class="adminTableV0">
<tr>
<td class="tw_1">信息主标题：</td>
<td class="tw_2"><input name="title" type="text" id="title" class="moduleBorderA moduleInputA iW_500" datatype="*" nullmsg="请输入标题！" errormsg="标题格式不正确！"></td>
</tr>
<tr>
  <td class="tw_1">副标题：</td>
  <td class="tw_2"><input name="subTitle" type="text" id="subTitle" class="moduleBorderA moduleInputA iW_500" ></td>
</tr>
<tr>
<td class="tw_1">自定义属性：</td>
<td class="tw_2"><label><span class="iW_textTips2"><input name="isRecommend" type="checkbox" id="isRecommend" style="border:none;" value="1">推荐</span></label><label><span class="iW_textTips2"><input name="isHot" type="checkbox" id="isHot" style="border:none;" value="1">热门</span></label><label><span class="iW_textTips2"><input name="isHeadlines" type="checkbox" id="isHeadlines" style="border:none;" value="1">头条</span></label><label><span class="iW_textTips2"><input name="isSlide" type="checkbox" id="isSlide" style="border:none;" value="1">赠品</span></label></td>
</tr>
<tr>
<td class="tw_1">信息所属类别：</td>
<td class="tw_2">
<select name="MpType" id="MpType" size="1" class="moduleBorderSelectA" datatype="zeroMain" nullmsg="请选择类别！" errormsg="类别格式不正确！">
<option value="0">--请选择信息所属类别--</option>
<?php ShowSelect(0,$cateTable,$Mcataid,6,true) ?>
</select></td>
</tr>
<tr>
<td class="tw_1">缩略图上传：</td>
<td class="tw_2"><input id="imageUrl_upload" name="imageUrl_upload" type="file" multiple><input id="imageUrl" name="imageUrl" type="hidden"><img width="100" id="imageUrlImg" name="imageUrlImg" class="none" /></td>
</tr>
<!--<tr>
<td class="tw_1"><span class="iW_textTips">市场零售价：</span></td>
<td class="tw_2"><input name="aPrice" id="aPrice" type="text" class="moduleBorderA moduleInputA iW_100" ></td>
</tr>-->
<tr>
<td class="tw_1">详细内容：</td>
<td class="tw_2"><textarea name="d_content" id="d_content"></textarea></td>
</tr>
<!--
<tr>
<td class="tw_1"><span class="iW_textTips">分页标签：</span></td>
<td class="tw_2"><input name="pageText" id="pageText" type="text" value="$$SplitPage$$" class="moduleBorderA moduleInputA iW_150" readonly></td>
</tr>
-->
<tr>
<td class="tw_1">添加时间：</td>
<td class="tw_2"><input name="time" type="text" id="time" value="<?php echo now()?>" class="moduleBorderA moduleInputA iW_150"><span class="iW_textTips">请写入正确的日期。如：<?php echo date('Y-m-d H:i:s',time());?></span></td>
</tr>
<tr>
<td class="tw_1">附件上传：</td>
<td class="tw_2"><p><input id="attachments" name="attachments" class="moduleBorderA moduleInputA iW_250"><span class="iW_textTips">此处请勿手动输入。格式限制为：doc&nbsp;/&nbsp;docx&nbsp;/&nbsp;xls&nbsp;/&nbsp;xlsx&nbsp;/&nbsp;ppt&nbsp;/&nbsp;pptx&nbsp;/&nbsp;zip&nbsp;/&nbsp;rar&nbsp;/&nbsp;pdf</span></p><p class="mt_5"><input id="attachmentsUrl_upload" name="attachmentsUrl_upload" type="file" multiple></p></td>
</tr>
<tr>
<td colspan="2" class="tw_3"><input name="Submit" type="submit" value="发布" class="btn_2"></td>
</tr>
</table>
</div>
<div id="atab1_content1" class="none">
<table cellspacing="1" class="adminTableV0">
<tr>
<td class="tw_1">关键字：<br>(Keywords)</td>
<td class="tw_2"><input name="aKeywords" type="text" id="aKeywords" class="moduleBorderA moduleInputA iW_400">
<span class="iW_textTips">每个词之间用英文半角逗号 , 隔开</span></td>
</tr>
<tr>
<td class="tw_1">描述：<br>(Description)</td>
<td class="tw_2"><textarea name="aDescription" id="aDescription" rows="6" class="moduleBorderA iW_400"></textarea><span class="iW_textTips">建议不要多于200个汉字</span></td>
</tr>
<tr>
<td class="tw_1">标题文字颜色：</td>
<td class="tw_2"><input type="text" size="0" maxlength="7" name="tColor" id="tColor" class="moduleBorderA moduleInputA iW_100">&nbsp;<input type="button" value="选择颜色" onClick="showColorPicker(this,formAdmin.tColor)" class="btn_4"><span class="iW_textTips">此项仅用于文章列表信息</span></td>
</tr>
<tr>
<td class="tw_1">作者：</td>
<td class="tw_2"><input name="aAuthor" type="text" id="aAuthor" value="<?php echo $_uname?>" class="moduleBorderA moduleInputA iW_100"></td>
</tr>
<tr>
<td class="tw_1">浏览次数：</td>
<td class="tw_2"><input name="aCount" type="text" id="aCount" value="1<?php //echo rand(10,500)?>" class="moduleBorderA moduleInputA iW_100"></td>
</tr>
<tr>
<td class="tw_1">信息来源：</td>
<td class="tw_2"><input name="aFrom" type="text" id="aFrom" value="本站" class="moduleBorderA moduleInputA iW_100"></td>
</tr>
<tr>
<td class="tw_1">跳转网址：</td>
<td class="tw_2"><input name="jumpUrl" type="text" id="jumpUrl" class="moduleBorderA moduleInputA iW_400"></td>
</tr>
<tr>
<td colspan="2" class="tw_3"><input name="Submit" type="submit" value="发布" class="btn_1"></td>
</tr>
</table>
</div>
</form>
</div>
<div class="clearfix"></div>
</div>
<?php
include("./admin_footer.php")
?>
<script type="text/javascript" src="js/init.js"></script>
</body>
</html>