Exemple #1
0
function article_move_portal($arr, $old_arr)
{
    global $_G;
    require_once libfile('function/home');
    require_once libfile('function/portalcp');
    $arr['title'] = getstr(trim($arr['title']), 80, 1, 1);
    if ($arr['check']) {
        $subject = daddslashes($arr['title']);
        if (!strlen($subject)) {
            return FALSE;
        }
        $num = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('portal_article_title') . " WHERE title='{$subject}'");
        if ($num) {
            return FALSE;
        }
    }
    $arr['catid'] = $arr['portal_cid'] ? intval($arr['portal_cid']) : intval($_GET['portal']);
    //print_r($arr);
    if ($article_arr['contents'] > 1 && $arr['is_page_public'] == 1) {
        //是否决定合并内容
        if ($arr['content_arr']) {
            $arr['content'] = content_merge($arr['content_arr']);
        }
    } else {
        $contents = count($article_arr['content_arr']);
    }
    if (empty($arr['summary'])) {
        $arr['summary'] = portalcp_get_summary(stripslashes($arr['content']));
    }
    //print_r($arr);exit();
    $arr['dateline'] = !empty($arr['public_time']) ? $arr['public_time'] : TIMESTAMP;
    $arr['pic'] = $arr['pic'] ? $_thumb . addslashes($arr['pic']) : '';
    $arr['thumb'] = 0;
    $arr['remote'] = 0;
    $article_status = 0;
    $arr['summary'] = dstripslashes($arr['summary']);
    $setarr = array('title' => $arr['title'], 'author' => $arr['author'], 'from' => $arr['from'], 'catid' => $arr['catid'], 'pic' => $arr['pic'], 'thumb' => $arr['thumb'], 'remote' => $arr['remote'], 'fromurl' => $arr['fromurl'], 'dateline' => intval($arr['dateline']), 'url' => $arr['url'], 'allowcomment' => !empty($arr['forbidcomment']) ? '0' : '1', 'summary' => $arr['summary'], 'tag' => $arr['tag'], 'status' => $article_status, 'highlight' => $style, 'showinnernav' => empty($arr['showinnernav']) ? '0' : '1', 'uid' => $arr['uid'], 'username' => $arr['username'], 'contents' => $contents);
    $setarr['id'] = intval($arr['id']);
    //var_dump($old_arr);
    if ($old_arr['portal_id']) {
        //检查文章被放进回收站或者删除
        $info = DB::fetch_first("SELECT catid,aid FROM " . DB::table('portal_article_title') . " WHERE aid='" . $old_arr['portal_id'] . "'");
        //删除附件
        pic_delete($info['pic'], 'portal', $info['thumb'], $info['remote']);
        $query = DB::query("SELECT * FROM " . DB::table('portal_attachment') . " WHERE aid='{$old_arr['portal_id']}' ORDER BY attachid DESC");
        while ($value = DB::fetch($query)) {
            pic_delete($value['attachment'], 'portal', $value['thumb'], $value['remote']);
        }
        DB::query('DELETE FROM ' . DB::table('portal_attachment') . " WHERE aid='{$old_arr['portal_id']}'");
        //删除目前的数据再更新
    }
    if (!$info['aid']) {
        //旧文章已经不在
        if (DISCUZ_VERSION != 'X2') {
            //2.5版本
            $setarr = dstripslashes($setarr);
        } else {
            $setarr = daddslashes($setarr);
        }
        $aid = DB::insert('portal_article_title', $setarr, 1);
        DB::update('common_member_status', array('lastpost' => $arr['dateline']), array('uid' => $arr['uid']));
        //DB::insert('portal_article_count', array('aid'=>$aid, 'catid'=>$setarr['catid'], 'dateline'=>$setarr['dateline'],'viewnum'=>1));
    } else {
        DB::update('portal_article_title', $setarr, array('aid' => $old_arr['portal_id']));
        DB::query('UPDATE ' . DB::table('portal_category') . " SET articles=articles-1 WHERE catid='" . $info['catid'] . "'");
        $aid = $old_arr['portal_id'];
    }
    //文章点击率更新
    $count_setarr = array('viewnum' => $arr['view_num'], 'dateline' => $arr['dateline']);
    if (DISCUZ_VERSION != 'X2') {
        //2.5版本
        unset($count_setarr['dateline']);
    }
    $view_check = DB::fetch_first("SELECT aid FROM " . DB::table('portal_article_count') . " WHERE aid='" . $aid . "'");
    if ($view_check) {
        DB::update('portal_article_count', $count_setarr, array('aid' => $aid));
    } else {
        $count_setarr['aid'] = $aid;
        DB::insert('portal_article_count', $count_setarr);
    }
    //相关文章
    $relatedarr = $arr['relatedarr'];
    DB::query('DELETE FROM ' . DB::table('portal_article_related') . " WHERE aid='{$aid}'");
    //删除目前的数据再更新
    DB::query('DELETE FROM ' . DB::table('portal_article_related') . " WHERE raid='{$aid}'");
    //删除目前的数据再更新
    if ($relatedarr) {
        $query = DB::query("SELECT * FROM " . DB::table('portal_article_title') . " WHERE aid IN (" . dimplode($relatedarr) . ")");
        $list = array();
        while ($value = DB::fetch($query)) {
            $list[$value['aid']] = $value;
        }
        $replaces = array();
        $displayorder = 0;
        foreach ($relatedarr as $relate) {
            if ($value = $list[$relate]) {
                if ($value['aid'] != $aid) {
                    $replaces[] = "('{$aid}', '{$value['aid']}', '{$displayorder}')";
                    $replaces[] = "('{$value['aid']}', '{$aid}', '0')";
                    $displayorder++;
                }
            }
        }
        if ($replaces) {
            DB::query("REPLACE INTO " . DB::table('portal_article_related') . " (aid,raid,displayorder) VALUES " . implode(',', $replaces));
        }
    }
    DB::query('UPDATE ' . DB::table('portal_category') . " SET articles=articles+1 WHERE catid='" . $setarr['catid'] . "'");
    return $aid;
}
Exemple #2
0
         }
         $article['title'] = getstr($blog['subject'], 0);
         $article['summary'] = portalcp_get_summary($blog['message']);
         $article['fromurl'] = 'home.php?mod=space&uid=' . $blog[uid] . '&do=blog&id=' . $blog[blogid];
         $article['author'] = $blog['username'];
         $article_content['content'] = dhtmlspecialchars($blog['message']);
     }
     break;
 default:
     $posttable = getposttablebytid($_GET['from_id']);
     $thread = C::t('forum_thread')->fetch($_GET['from_id']);
     $thread = array_merge($thread, C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['from_id']));
     if ($thread) {
         $article['title'] = $thread['subject'];
         $thread['message'] = portalcp_get_postmessage($thread, $_GET['getauthorall']);
         $article['summary'] = portalcp_get_summary($thread['message']);
         $article['fromurl'] = 'forum.php?mod=viewthread&tid=' . $thread['tid'];
         $article['author'] = $thread['author'];
         $article_content['content'] = dhtmlspecialchars($thread['message']);
         $article['attach_image'] = $article['attach_file'] = '';
         foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $thread['tid'], 'pid', $thread['pid'], 'aid DESC') as $attach) {
             $attachcode = '[attach]' . $attach['aid'] . '[/attach]';
             if (!strexists($article_content['content'], $attachcode)) {
                 $article_content['content'] .= '<br /><br />' . $attachcode;
             }
             if ($attach['isimage']) {
                 if ($article['pic']) {
                     $attach['pic'] = $article['pic'];
                 }
             } else {
             }
Exemple #3
0
 function create_page_article($article_info_arr)
 {
     global $_G;
     $arr = $this->page_article_format($article_info_arr);
     $this->get_pick_status(1);
     $now = '-' . ($this->i - 1) . time();
     $show_args = array_merge($this->msg_args, array('li_no_end' => 1, 'no_border' => 1, 'now' => $now));
     show_pick_info(array(milu_lang('article'), $arr['title']), 'left', $show_args);
     $this->msg_args['now'] = $now;
     if ($this->p_arr['is_auto_public'] == 1 && $this->p_arr['public_class'][0]) {
         //自动发布文章
         $public_aid = $this->article_public($arr);
         if ($public_aid < 0) {
             show_pick_info(milu_lang('article_publiced'), 'err', $this->msg_args);
             $this->v_a++;
             $this->pick_cache_data['v_a'] = $this->v_a;
             return FALSE;
         }
         if ($this->p_arr['public_type'] == 1) {
             $setarr['portal_id'] = $public_aid;
         } else {
             if ($this->p_arr['public_type'] == 2) {
                 $setarr['forum_id'] = $public_aid;
             } else {
                 if ($this->p_arr['public_type'] == 3) {
                     $setarr['blog_id'] = $public_aid;
                 }
             }
         }
         $setarr['status'] = $this->temp_arr['article_status'] ? $this->temp_arr['article_status'] : 0;
     }
     if ($public_aid && $this->p_arr['is_public_del'] == 1) {
         //不入库,直接发布
         $this->public_info['insert_aid'] = $public_aid;
         if ($public_aid) {
             show_pick_info(milu_lang('public_data'), 'success', $this->msg_args);
         }
         return;
     }
     //标题表
     $setarr['pid'] = $this->pid;
     $setarr['url'] = $this->now_url;
     $setarr['pic'] = $arr['pic'];
     $setarr['title'] = daddslashes($arr['title']);
     $setarr['contents'] = $arr['contents'];
     $setarr['summary'] = portalcp_get_summary($arr['content']);
     $setarr['summary'] = daddslashes($setarr['summary']);
     $setarr['dateline'] = $_G['timestamp'];
     $setarr['url_hash'] = md5($setarr['url']);
     unset($arr['other']);
     $this->aid = DB::insert('strayer_article_title', $setarr, TRUE);
     $this->article_timing_update($this->aid, $this->temp_arr['timing_id']);
     //更新定时发布
     $setarr = array();
     //内容表
     foreach ($arr['content_arr'] as $k => $v) {
         $setarr['aid'] = $this->aid;
         $setarr['content'] = daddslashes($v['content']);
         $setarr['pageorder'] = $v['page'];
         $setarr['dateline'] = $_G['timestamp'];
         $insert_id = DB::insert('strayer_article_content', $setarr, TRUE);
     }
     if ($this->aid) {
         show_pick_info(milu_lang('add_data'), 'success', $this->msg_args);
     }
 }