function convert_article_table($_prefix) { global $zbp; $list = array("`ID`" => "log_ID", "`post_title`" => "log_Title", "unix_timestamp(`post_date`)" => "log_PostTime", "`post_excerpt`" => "log_Intro", "`post_content`" => "log_Content", "`post_name`" => "log_Alias", "`post_author`" => "log_AuthorID", '0' => "log_CateID", 'IF(`post_type` = "post", 0, 1 )' => "log_Type", "0" => "log_ViewNums", "`comment_count`" => "log_CommNums", '0' => "log_IsTop", 'IF(`post_status` = "publish", 0, 1 )' => "log_Status", '""' => "log_Meta"); $ary1 = array(); $ary2 = array(); foreach ($list as $name => $value) { $ary1[] = $value; $ary2[] = $name . ' AS ' . $value; } $sql = build_sql('Post', $_prefix . 'posts', $ary1, $ary2, ' WHERE (((`post_type`="page") OR (`post_type`="post")) AND (`post_status`<>"auto-draft"))'); $zbp->db->QueryMulit($sql); $array = $zbp->GetArticleList(null, null, null, null, null, false); foreach ($array as $a) { if ($a->Intro == '') { if (strpos($a->Content, '<!--more-->') !== false) { $a->Intro = GetValueInArray(explode('<!--more-->', $a->Content), 0); } else { if ($a->Intro == '') { $a->Intro = SubStrUTF8($a->Content, $zbp->option['ZC_ARTICLE_EXCERPT_MAX']); if (strpos($a->Intro, '<') !== false) { $a->Intro = CloseTags($a->Intro); } } } } $a->Save(); } return; }
function PostArticle() { global $zbp; if (!isset($_POST['ID'])) { return; } if (isset($_POST['Tag'])) { $_POST['Tag'] = TransferHTML($_POST['Tag'], '[noscript]'); $_POST['Tag'] = PostArticle_CheckTagAndConvertIDtoString($_POST['Tag']); } if (isset($_POST['Content'])) { $_POST['Content'] = str_replace('<hr class="more" />', '<!--more-->', $_POST['Content']); $_POST['Content'] = str_replace('<hr class="more"/>', '<!--more-->', $_POST['Content']); if (strpos($_POST['Content'], '<!--more-->') !== false) { if (isset($_POST['Intro'])) { $_POST['Intro'] = GetValueInArray(explode('<!--more-->', $_POST['Content']), 0); } } else { if (isset($_POST['Intro'])) { if ($_POST['Intro'] == '') { $_POST['Intro'] = SubStrUTF8($_POST['Content'], $zbp->option['ZC_ARTICLE_EXCERPT_MAX']); if (strpos($_POST['Intro'], '<') !== false) { $_POST['Intro'] = CloseTags($_POST['Intro']); } } } } } if (!isset($_POST['AuthorID'])) { $_POST['AuthorID'] = $zbp->user->ID; } else { if ($_POST['AuthorID'] != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) { $_POST['AuthorID'] = $zbp->user->ID; } if ($_POST['AuthorID'] == 0) { $_POST['AuthorID'] = $zbp->user->ID; } } if (isset($_POST['Alias'])) { $_POST['Alias'] = TransferHTML($_POST['Alias'], '[noscript]'); } if (isset($_POST['PostTime'])) { $_POST['PostTime'] = strtotime($_POST['PostTime']); } if (!$zbp->CheckRights('ArticleAll')) { unset($_POST['IsTop']); } $article = new Post(); $pre_author = null; $pre_tag = null; $pre_category = null; if (GetVars('ID', 'POST') == 0) { if (!$zbp->CheckRights('ArticlePub')) { $_POST['Status'] = ZC_POST_STATUS_AUDITING; } } else { $article->LoadInfoByID(GetVars('ID', 'POST')); if ($article->AuthorID != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) { $zbp->ShowError(6); } if (!$zbp->CheckRights('ArticlePub') && $article->Status == ZC_POST_STATUS_AUDITING) { $_POST['Status'] = ZC_POST_STATUS_AUDITING; } $pre_author = $article->AuthorID; $pre_tag = $article->Tag; $pre_category = $article->CateID; } foreach ($zbp->datainfo['Post'] as $key => $value) { if ($key == 'ID') { continue; } if ($key == 'Meta') { continue; } if (isset($_POST[$key])) { $article->{$key} = GetVars($key, 'POST'); } } $article->Type = ZC_POST_TYPE_ARTICLE; foreach ($GLOBALS['Filter_Plugin_PostArticle_Core'] as $fpname => &$fpsignal) { $fpname($article); } FilterPost($article); FilterMeta($article); $article->Save(); CountTagArrayString($pre_tag . $article->Tag); CountMemberArray(array($pre_author, $article->AuthorID)); CountCategoryArray(array($pre_category, $article->CateID)); CountPostArray(array($article->ID)); CountNormalArticleNums(); $zbp->AddBuildModule('previous'); $zbp->AddBuildModule('calendar'); $zbp->AddBuildModule('comments'); $zbp->AddBuildModule('archives'); $zbp->AddBuildModule('tags'); $zbp->AddBuildModule('authors'); foreach ($GLOBALS['Filter_Plugin_PostArticle_Succeed'] as $fpname => &$fpsignal) { $fpname($article); } return true; }
/** * 提交文章数据 * @api Filter_Plugin_PostArticle_Core * @api Filter_Plugin_PostArticle_Succeed * @return bool */ function PostArticle() { global $zbp; if (!isset($_POST['ID'])) { return; } if (isset($_COOKIE['timezone'])) { $tz = GetVars('timezone', 'COOKIE'); if (is_numeric($tz)) { date_default_timezone_set('Etc/GMT' . sprintf('%+d', -$tz)); } unset($tz); } if (isset($_POST['Tag'])) { $_POST['Tag'] = TransferHTML($_POST['Tag'], '[noscript]'); $_POST['Tag'] = PostArticle_CheckTagAndConvertIDtoString($_POST['Tag']); } if (isset($_POST['Content'])) { $_POST['Content'] = str_replace('<hr class="more" />', '<!--more-->', $_POST['Content']); $_POST['Content'] = str_replace('<hr class="more"/>', '<!--more-->', $_POST['Content']); if (strpos($_POST['Content'], '<!--more-->') !== false) { if (isset($_POST['Intro'])) { $_POST['Intro'] = GetValueInArray(explode('<!--more-->', $_POST['Content']), 0); } } else { if (isset($_POST['Intro'])) { if ($_POST['Intro'] == '') { $_POST['Intro'] = SubStrUTF8($_POST['Content'], $zbp->option['ZC_ARTICLE_EXCERPT_MAX']); $_POST['Intro'] .= '<!--autointro-->'; } $_POST['Intro'] = CloseTags($_POST['Intro']); } } } if (!isset($_POST['AuthorID'])) { $_POST['AuthorID'] = $zbp->user->ID; } else { if ($_POST['AuthorID'] != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) { $_POST['AuthorID'] = $zbp->user->ID; } if ($_POST['AuthorID'] == 0) { $_POST['AuthorID'] = $zbp->user->ID; } } if (isset($_POST['Alias'])) { $_POST['Alias'] = TransferHTML($_POST['Alias'], '[noscript]'); } if (isset($_POST['PostTime'])) { $_POST['PostTime'] = strtotime($_POST['PostTime']); } if (!$zbp->CheckRights('ArticleAll')) { unset($_POST['IsTop']); } $article = new Post(); $pre_author = null; $pre_tag = null; $pre_category = null; $pre_istop = null; $pre_status = null; $orig_id = 0; if (GetVars('ID', 'POST') == 0) { if (!$zbp->CheckRights('ArticlePub')) { $_POST['Status'] = ZC_POST_STATUS_AUDITING; } } else { $article->LoadInfoByID(GetVars('ID', 'POST')); if ($article->AuthorID != $zbp->user->ID && !$zbp->CheckRights('ArticleAll')) { $zbp->ShowError(6, __FILE__, __LINE__); } if (!$zbp->CheckRights('ArticlePub') && $article->Status == ZC_POST_STATUS_AUDITING) { $_POST['Status'] = ZC_POST_STATUS_AUDITING; } $orig_id = $article->ID; $pre_author = $article->AuthorID; $pre_tag = $article->Tag; $pre_category = $article->CateID; $pre_istop = $article->IsTop; $pre_status = $article->Status; } foreach ($zbp->datainfo['Post'] as $key => $value) { if ($key == 'ID' || $key == 'Meta') { continue; } if (isset($_POST[$key])) { $article->{$key} = GetVars($key, 'POST'); } } $article->Type = ZC_POST_TYPE_ARTICLE; if (isset($_POST['IsTop'])) { if (1 == $_POST['IsTop']) { $article->TopType = $_POST['IstopType']; } if (0 == $_POST['IsTop']) { $article->TopType = null; } } foreach ($GLOBALS['Filter_Plugin_PostArticle_Core'] as $fpname => &$fpsignal) { $fpname($article); } FilterPost($article); FilterMeta($article); $article->Save(); //更新统计信息 $pre_arrayTag = $zbp->LoadTagsByIDString($pre_tag); $now_arrayTag = $zbp->LoadTagsByIDString($article->Tag); $pre_array = $now_array = array(); foreach ($pre_arrayTag as $tag) { $pre_array[] = $tag->ID; } foreach ($now_arrayTag as $tag) { $now_array[] = $tag->ID; } $del_array = array_diff($pre_array, $now_array); $add_array = array_diff($now_array, $pre_array); $del_string = $zbp->ConvertTagIDtoString($del_array); $add_string = $zbp->ConvertTagIDtoString($add_array); if ($del_string) { CountTagArrayString($del_string, -1, $article->ID); } if ($add_string) { CountTagArrayString($add_string, +1, $article->ID); } if ($pre_author != $article->AuthorID) { if ($pre_author > 0) { CountMemberArray(array($pre_author), array(-1, 0, 0, 0)); } CountMemberArray(array($article->AuthorID), array(+1, 0, 0, 0)); } if ($pre_category != $article->CateID) { if ($pre_category > 0) { CountCategoryArray(array($pre_category), -1); } CountCategoryArray(array($article->CateID), +1); } if ($zbp->option['ZC_LARGE_DATA'] == false) { CountPostArray(array($article->ID)); } if ($orig_id == 0 && $article->IsTop == 0 && $article->Status == ZC_POST_STATUS_PUBLIC) { CountNormalArticleNums(+1); } elseif ($orig_id > 0) { if ($pre_istop == 0 && $pre_status == 0 && ($article->IsTop != 0 || $article->Status != 0)) { CountNormalArticleNums(-1); } if (($pre_istop != 0 || $pre_status != 0) && ($article->IsTop == 0 && $article->Status == 0)) { CountNormalArticleNums(+1); } } if ($article->IsTop == true && $article->Status == ZC_POST_STATUS_PUBLIC) { CountTopArticle($article->ID, null); } else { CountTopArticle(null, $article->ID); } $zbp->AddBuildModule('previous'); $zbp->AddBuildModule('calendar'); $zbp->AddBuildModule('comments'); $zbp->AddBuildModule('archives'); $zbp->AddBuildModule('tags'); $zbp->AddBuildModule('authors'); foreach ($GLOBALS['Filter_Plugin_PostArticle_Succeed'] as $fpname => &$fpsignal) { $fpname($article); } return true; }