ET tag_count=tag_count+1");
} else {
$aids = $tag['aids'].','.$articleid;
$DB->unbuffered_query("UPDATE {$db_prefix}tags SET usenum=usenum+1, aids='$aids' WHERE tag='$tagdb[$i]'");
}
}
unset($aids);
}
}
// 鏇存柊鍒嗙被鏂囩珷鏁伴噺
$DB->unbuffered_query("UPDATE {$db_prefix}categories SET articles=articles+1 WHERE cid='$cid'");
$DB->unbuffered_query("UPDATE {$db_prefix}statistics SET article_count=article_count+1");
$DB->unbuffered_query("UPDATE {$db_prefix}statistics SET attachment_count=attachment_count+".$attachment_count);
// 娓呴櫎涓存椂鏁版嵁
setcookie('cid','');
setcookie('title','');
//setcookie('description','');
setcookie('content','');
setcookie('keywords','');
setcookie('closecomment','');
setcookie('visible','');
setcookie('stick','');
redirect('娣诲姞鏂囩珷鎴愬姛', 'admincp.php?go=article&action=add');
}
//淇敼鏂囩珷
if($_POST['action'] == 'modarticle') {
$title = trim($_POST['title']);
$articleid = intval($_POST['articleid']);
$cid = intval($_POST['cid']);
$content = addslashes($_POST['content']);
$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);
}
$result = '';
$result .= checktitle($title);
$result .= checkcate($cid);
$result .= checkcontent($content);
$result .= checkkeywords($keywords);
if($result) {
redirect($result);
}
$title = char_cv($title);
$article = $DB->fetch_one_array("SELECT uid,attachments,cid,visible FROM {$db_prefix}articles WHERE articleid='$articleid'");
// 淇敼闄勪欢
$oldattach=array();
$aid = $article['attachments'];
if ($aid){
$oldattach = unserialize(stripslashes_array($aid));
$nokeep = array();
foreach ($oldattach AS $id => $value){
if (!@in_array($id,$_POST['keep'])){
$nokeep[$id]['filepath'] = $value['filepath'];
$nokeep[$id]['thumb_filepath'] = $value['thumb_filepath'];
unset($oldattach[$id]);
}
}
removeattachment($nokeep);
}
require_once('uploadfiles.php');
if ($attachs){
$attachs=unserialize(stripslashes_array($attachs));
foreach ($attachs as $key=>$value){
$oldattach[$key]=$value;
}
}
if ($oldattach){
$oldattach=addslashes(serialize($oldattach));
} else {
$oldattach='';
}
if($attachmentids){
$DB->unbuffered_query("UPDATE {$db_prefix}attachments SET articleid='$articleid' WHERE attachmentid IN($attachmentids)");
}
// 淇敼闄勪欢缁撴潫
//***************** 澶勭悊tags鍙婅鏁?*****************//
$oldtags = $_POST['oldtags'] ? strtolower(addslashes($_POST['oldtags'])) : '';
updatetags($articleid, $keywords, $oldtags);
//***************** 澶勭悊tags鍙婅鏁扮粨鏉?*************//
// 淇敼鏃堕棿
$edittimesql = '';
if ($edittime) {
if (checkdate($newmonth, $newday, $newyear)) {
if (substr(
PHP_OS, 0, 3) == 'WIN' && $newyear < 1970) {
$edittimesql = '';
} else {
$posttime = gmmktime($newhour, $newmin, $newsec, $newmonth, $newday, $newyear) - $timeoffset * 3600;
$edittimesql = ", dateline='$posttime'";
}
}
}
$query="UPDATE {$db_prefix}articles SET cid='$cid', title='$title', content='$content', attachments='$oldattach', keywords='$keywords', closecomment='$closecomment', visible='$visible', stick='$stick' $edittimesql WHERE articleid='$articleid'";
//echo $query;
$DB->unbuffered_query($query);
$DB->unbuffered_query("UPDATE {$db_prefix}statistics SET attachment_count=attachment_count+".$attachment_count);
if ($article['cid'] != $cid) {
$DB->unbuffered_query("UPDATE {$db_prefix}categories SET articles=articles-1 WHERE cid='".$article['ci