【php开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了php开源代码-article.php的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
<?php
if(!defined('ROOT') || !isset($php_self) || !preg_match("/[\/\\\\]admincp\.php$/", $php_self)) {
exit('Access Denied');
}
per
mission();
// 鍔犺浇闄勪欢鐩稿叧鍑芥暟
require_once(ROOT.'include/func_attachment.php');
if(isset($_POST['action'])||isset($_GET['action'])){
$action =isset($_POST['action'])?$_POST['action']:$_GET['action'];
}else{
$action ="list";
}
$do= $_POST['do'];
$uquery="";
/////////////////////////////////////
$catedb = array();
$query = $DB->query("SELECT cid,name FROM {$db_prefix}categories ORDER BY displayorder");
while ($cate = $DB->fetch_array($query)) {
$catedb[] = $cate;
}
unset($cate);
$DB->free_result($query);
/////////////////////////////////////
if($_POST['action'] == 'addarticle') {
// 鍙栧煎苟杩囨护閮ㄥ垎
$title = trim($_POST['title']);
$cid = intval($_POST['cid']);
//$description = addslashes($_POST['description']);
$content = addslashes($_POST['content']);
$readpassword = addslashes($_POST['readpassword']);
$keywords = strtolower(addslashes(trim($_POST['keywords'])));
$closecomment = intval($_POST['closecomment']);
$visible = intval($_POST['visible']);
$stick = intval($_POST['stick']);
// 鏃堕棿鍙橀噺
$edittime = intval($_POST['edittime']);
$newyear = intval($_POST['newyear']);
$newmonth = intval($_POST['newmonth']);
$newday = intval($_POST['newday']);
$newhour = intval($_POST['newhour']);
$newmin = intval($_POST['newmin']);
$newsec = intval($_POST['newsec']);
$keywords = str_replace('锛?, ',', $keywords);
$keywords = str_replace(',,', ',', $keywords);
if (substr($keywords, -1) == ',') {
$keywords = substr($keywords, 0, strlen($keywords)-1);
}
// 鏆傛椂鎶婃彁浜ょ殑鏁版嵁淇濆瓨鍒癈OOKIE
$cookietime=$timestamp+2592000;
setcookie('cid',$cid,$cookietime);
setcookie('title',$title,$cookietime);
//setcookie('description',$description,$cookietime);
setcookie('content',$content,$cookietime);
setcookie('keywords',$keywords,$cookietime);
setcookie('closecomment',$closecomment,$cookietime);
setcookie('visible',$visible,$cookietime);
setcookie('stick',$stick,$cookietime);
// 妫鏌ュ彉閲?
$result = '';
$result .= checktitle($title);
$result .= checkcate($cid);
$result .= checkcontent($content);
$result .= checkkeywords($keywords);
if($result) {
redirect($result);
}
$title = char_cv($title);
$query = $DB->query("SELECT articleid FROM {$db_prefix}articles WHERE title='$title' and cid='$cid' and content='$content'");
if($DB->num_rows($query)) {
redirect('鏁版嵁搴撲腑宸插瓨鍦ㄧ浉鍚岀殑鏁版嵁', 'admincp.php?go=article&action=add');
}
// 涓婁紶闄勪欢
require_once('uploadfiles.php');
// 涓婁紶缁撴潫
// 淇敼鏃堕棿
if ($edittime) {
if (checkdate($newmonth, $newday, $newyear)) {
if (substr(PHP_OS, 0, 3) == 'WIN' && $newyear < 1970) {
$posttime = $timestamp;
} else {
$posttime = gmmktime($newhour, $newmin, $newsec, $newmonth, $newday, $newyear) - $timeoffset * 3600;
}
} else {
$posttime = $timestamp;
}
} else {
$posttime = $timestamp;
}
$sql="INSERT INTO {$db_prefix}articles (cid, uid, title, content, keywords, dateline, views, comments, attachments, closecomment, visible, stick) VALUES ('$cid', '1', '$title', '$content', '$keywords', '$posttime', '0', '0', '$attachs', '$closecomment', '$visible', '$stick')";
// 鎻掑叆鏁版嵁閮ㄥ垎
$DB->query("$sql");
$articleid = $DB->insert_id();
$sql1="UPDATE {$db_prefix}users SET articles=articles+1 WHERE userid='$fy_uid'";
echo $sql1;
$DB->unbuffered_query($
sql1);
if($attachmentids){
$DB->unbuffered_query("UPDATE {$db_prefix}attachments SET articleid='$articleid' WHERE attachmentid IN($attachmentids)");
}
// 鎻掑叆/鏇存柊Tags
if ($key
words) {
$tagdb = explode(',', $keywords);
$tagnum = count($tagdb);
for($i=0; $i<$tagnum; $i++) {
$tagdb[$i] = trim($tagdb[$i]);
if ($tagdb[$i]) {
$tag = $DB->fetch_one_array("SELECT tagid,aids FROM {$db_prefix}tags WHERE tag='$tagdb[$i]'");
if(!$tag) {
$DB->query("INSERT INTO {$db_prefix}tags (tag,usenum,aids) VALUES ('$tagdb[$i]', '1', '$articleid')");
$DB->unbuffered_query("UPDATE {$db_prefix}statistics S