24,923
社区成员
发帖
与我相关
我的任务
分享
<?php
error_reporting(7);
include("../include/connection.php");
include("../include/admin.inc.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户添加</title>
<link href="admin.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../FCKeditor/fckeditor.js"></script>
<script type="text/javascript" src="../inc/jscookies.js"></script>
<script type="text/javascript" src="../inc/checkformat.js"></script>
<script language="JavaScript" src="../JS/jsCalendar.js"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
//function Validate()
//{
// document.form1.submit();
//}
function Validate()
{
if(!checknull("form1.Column","所属栏目")) return false;
if(!checknull("form1.Title","文章标题")) return false;
if(!checkstrlen(form1.Title.value,200))
{
alert("标题不能超过200个字符或者100个汉字");
form1.Title.focus();
return false;
}
if(form1.Visitcount.value!="" && !checknum(form1.Visitcount.value))
{
alert("点击数一栏填写不正确");
form1.Visitcount.focus();
return false;
}
if(form1.Issuetime.value!="" && !checkdate(form1.Issuetime.value))
{
alert("发布时间一栏填写不正确");
form1.Issuetime.focus();
return false;
}
form1.submit();
}
//删除Cookie
delCookie("TitlePic");
//-->
</SCRIPT>
</head>
<body>
<?php
if (!checkVisitPurview('S12,')) {
showMsg("error","<li>对不起,您没有操作该页面的权限。</li>\n<li><a href=\"javascript:history.go(-1)\">返回。</a></li>");
}
$Action = trim($_REQUEST["Action"]);
if ($Action=="Add"){
ManageData();
} else {
MainData();
}
function MainData(){
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="25" class="tableBorder"><a href="Admin_ArticleList.php">文章首页</a> | <a href="Admin_ArticleList.php?Ifpass=1">已审核文章</a> | <a href="Admin_ArticleList.php?Ifpass=0">未审核文章</a> | <a href="Admin_ArticleAdd.php">添加文章</a></th>
</tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#F5F5F5" class="tableBorder">
<form method="post" name="form1" action="?Action=Add">
<tr align="center">
<th height="20" colspan="5">添加文章 </tr>
<tr bgcolor="#F6F6F6">
<td width="20%" height="23" align="left" bgcolor="#FFFFFF">所属栏目:
</td>
<td width="30%" height="23" align="left" bgcolor="#FFFFFF"><?php echo makeMenuList("Column","",2);?></td>
<td width="20%" height="23" align="left" bgcolor="#FFFFFF"></td>
<td width="30%" height="23" align="left" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">文章标题:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Title" type="text" id="Title" size="80"><span class="redtxt">*</span></td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">文章副标题:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Ftitle" type="text" id="Ftitle" size="80"></td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="23" align="left" bgcolor="#FFFFFF">关 键 字:</td>
<td height="25" colspan="3" bgcolor="#FFFFFF"><input name="Keyword" type="text" id="Keyword" size="60">(多个关键字请用“,”隔开)</td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">文章作者:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"> <input name="Author" type="text" id="Author" size="30"></td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">文章来源:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Source" type="text" id="Source" size="30" value="本站编辑"></td>
</tr>
<tr>
<td height="23" colspan="4" align="center" bgcolor="#FFFFFF">
<script type="text/javascript">
<!--
//var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('admin')) ;
var oFCKeditor = new FCKeditor( 'Content' ) ;
oFCKeditor.BasePath = "../fckeditor/";
oFCKeditor.Height = 500 ;
oFCKeditor.Value = '' ;
oFCKeditor.Create() ;
//-->
</script> </td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="23" align="left" bgcolor="#FFFFFF">包含图片:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Ifpic" type="checkbox" id="Ifpic" value="1">
是 <span class="style2">(如果选中的话会在标题前面显示[图文]) </span></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="23" align="left" bgcolor="#FFFFFF">标题图片:</td>
<td height="23" colspan="3" bgcolor="#FFFFFF"><input name="Titlepic" type="text" id="Titlepic" size="60" onFocus="pic_focus()"></td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="23" align="left" bgcolor="#FFFFFF">文章审核:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Ifpass" type="checkbox" id="Ifpass" value="1" checked>
是<span class="style2"> (如果选中的话将直接发布) </span></td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">文章性质:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Ifhot" type="checkbox" id="Ifhot" value="1">
热点文章
<input name="Iftuijian" type="checkbox" id="Iftuijian" value="1">
推荐文章</td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="23" align="left" bgcolor="#FFFFFF">点 击 数:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Visitcount" type="text" id="Visitcount" value="0" size="10"></td>
</tr>
<tr>
<td height="23" align="left" bgcolor="#FFFFFF">发布时间:</td>
<td height="23" colspan="3" align="left" bgcolor="#FFFFFF"><input name="Issuetime" type="text" id="Issuetime" value="<? echo getDateTime();?>" size="20" readOnly></td>
</tr>
</form>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="25" background="images/rr.gif"><img src="images/b_ok.jpg" width="60" height="25" onClick="return Validate()" style="cursor:hand"><img src="images/b_back.jpg" width="60" height="25" onClick="javascript:history.go(-1)" style="cursor:hand"></td>
</tr>
</table>
<?php
}
function ManageData(){
global $conn;
$get_Columnid=intval($_POST["Column"]);
$get_Specialid=intval($_POST["Specialid"]);
$get_Title=trim($_POST["Title"]);
$get_Ftitle = trim($_POST["Ftitle"]);
$get_Keyword=trim($_POST["Keyword"]);
$get_Author=trim($_POST["Author"]);
$get_Source=trim($_POST["Source"]);
$get_Template_Articleid=intval($_POST["Template_Articleid"]);
$get_Content=trim($_POST["Content"]);
$get_Ifpic=trim($_POST["Ifpic"]);
if($get_Ifpic=="") $get_Ifpic="0";
$get_Titlepic=trim($_POST["Titlepic"]);
$get_Ifpass=trim($_POST["Ifpass"]);
if($get_Ifpass=="") $get_Ifpass="0";
$get_Ifhot=trim($_POST["Ifhot"]);
if($get_Ifhot=="") $get_Ifhot="0";
$get_Iftuijian=trim($_POST["Iftuijian"]);
if($get_Iftuijian=="") $get_Iftuijian="0";
$get_Visitcount=intval(trim($_POST["Visitcount"]));
$get_Issuetime=trim($_POST["Issuetime"]);
if ($get_Issuetime=="") $get_Issuetime = null;
$get_Ifcommend=trim($_POST["Ifcommend"]);
if($get_Ifcommend=="") $get_Ifcommend="0";
$get_Ip=$_SERVER['REMOTE_ADDR'];
if (!checkVisitPurview(trim($_POST["Column"]).'1,')) {
showMsg("error","<li>对不起,您没有添加该栏目文章的权限。</li>\n<li><a href=\"javascript:history.go(-1)\">返回。</a></li>");
exit;
} else {
if ($get_Ifpass=="1") {
if (!checkVisitPurview(trim($_POST["Column"]).'2,')) {
$message = "<li>没有通过审核,您没有审核该栏目文章的权限。</li>\n";
$get_Ifpass="0";
}
}
}
try {
$sql="insert into table_article(Columnid,Specialid,Title,Ftitle,Keyword,Author,Source,Template_Articleid,Content,Ifpic,Titlepic,Ifpass,Ifhot,Iftuijian,Visitcount,Issuetime,Ifcommend,Ip) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
/* $sql="insert into table_article(Columnid,Specialid,Title,Keyword,Author,Source,Template_Articleid,Content,Ifpic,Titlepic,Ifpass,Ifhot,Iftuijian,Visitcount,Issuetime,Ifcommend,Ip)
values($get_Columnid,$get_Specialid,'$get_Title','$get_Keyword','$get_Author','$get_Source',$get_Template_Articleid,
'$get_Content','$get_Ifpic','$get_Titlepic','$get_Ifpass','$get_Ifhot','$get_Iftuijian',$get_Visitcount,
$get_Issuetime,'$get_Ifcommend','$get_Ip')";
echo $sql;*/
$stmt = $conn->prepare($sql);
$stmt->bindParam(1, $get_Columnid);
$stmt->bindParam(2, $get_Specialid);
$stmt->bindParam(3, adjustSql($get_Title));
$stmt->bindParam(4, adjustSql($get_Ftitle));
$stmt->bindParam(5, adjustSql($get_Keyword));
$stmt->bindParam(6, adjustSql($get_Author));
$stmt->bindParam(7, adjustSql($get_Source));
$stmt->bindParam(8, $get_Template_Articleid);
$stmt->bindParam(9, $get_Content);
$stmt->bindParam(10, $get_Ifpic);
$stmt->bindParam(11, adjustSql($get_Titlepic));
$stmt->bindParam(12, $get_Ifpass);
$stmt->bindParam(13, $get_Ifhot);
$stmt->bindParam(14, $get_Iftuijian);
$stmt->bindParam(15, $get_Visitcount);
$stmt->bindParam(16, $get_Issuetime);
$stmt->bindParam(17, $get_Ifcommend);
$stmt->bindParam(18, $get_Ip);
$conn->beginTransaction();
$stmt->execute();
$conn->commit();
showMsg("success",
"<li>恭喜您,文章添加成功。</li>\n
".$message."
<li><a href=\"Admin_ArticleList.php\">返回管理界面。</a></li>\n
<li><a href=\"javascript:history.go(-1)\">返回。</a></li>
");
} catch (Exception $e) {
$conn->rollBack();
showMsg("error",
"<li>对不起,添加文章出错。</li>\n
<li>".$e->getMessage()."</li>\n
<li><a href=\"javascript:history.go(-1)\">返回。</a></li>
");
}
}
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
function pic_focus(){
var picvalue = getCookie("TitlePic");
if (picvalue==null) picvalue = "";
if ((form1.Titlepic.value=="") || (picvalue!="" && picvalue!=form1.Titlepic.value)){
form1.Titlepic.value = picvalue;
}
}
//-->
</SCRIPT>
</body>
</html>