Exemplo n.º 1
0
function updatetopic($topic = '')
{
    global $_G;
    $topicid = empty($topic) ? '' : $topic['topicid'];
    include_once libfile('function/home');
    $_POST['title'] = getstr(trim($_POST['title']), 255, 1, 1);
    $_POST['name'] = getstr(trim($_POST['name']), 255, 1, 1);
    $_POST['domain'] = getstr(trim($_POST['domain']), 255, 1, 1);
    if (empty($_POST['title'])) {
        return 'topic_title_cannot_be_empty';
    }
    if (empty($_POST['name'])) {
        $_POST['name'] = $_POST['title'];
    }
    if (!$topicid || $_POST['name'] != $topic['name']) {
        $value = DB::fetch_first('SELECT * FROM ' . DB::table('portal_topic') . " WHERE name = '{$_POST['name']}' LIMIT 1");
        if ($value) {
            return 'topic_name_duplicated';
        }
    }
    if ($topicid && !empty($topic['domain'])) {
        require_once libfile('function/delete');
        deletedomain($topicid, 'topic');
    }
    if (!empty($_POST['domain'])) {
        require_once libfile('function/domain');
        domaincheck($_POST['domain'], $_G['setting']['domain']['root']['topic'], 1);
    }
    $setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'domain' => $_POST['domain'], 'summary' => getstr($_POST['summary'], '', 1, 1), 'keyword' => getstr($_POST['keyword'], '', 1, 1), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0', 'allowcomment' => $_POST['allowcomment'] ? 1 : 0, 'closed' => $_POST['closed'] ? 0 : 1);
    if ($_POST['deletecover'] && $topic['cover']) {
        if ($topic['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
        }
        $setarr['cover'] = '';
    } else {
        if ($_FILES['cover']['tmp_name']) {
            if ($topic['cover'] && $topic['picflag'] != '0') {
                pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
            }
            $pic = pic_upload($_FILES['cover'], 'portal');
            if ($pic) {
                $setarr['cover'] = 'portal/' . $pic['pic'];
                $setarr['picflag'] = $pic['remote'] ? '2' : '1';
            }
        } else {
            if (!empty($_POST['cover']) && $_POST['cover'] != $topic['cover']) {
                if ($topic['cover'] && $topic['picflag'] != '0') {
                    pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
                }
                $setarr['cover'] = $_POST['cover'];
                $setarr['picflag'] = '0';
            }
        }
    }
    $primaltplname = '';
    if (empty($topicid) || empty($topic['primaltplname']) || $topic['primaltplname'] && $topic['primaltplname'] != 'portal/' . $_POST['primaltplname']) {
        $primaltplname = 'portal/' . $_POST['primaltplname'];
        $checktpl = checkprimaltpl($primaltplname);
        if ($checktpl !== true) {
            return $checktpl;
        }
        $setarr['primaltplname'] = $primaltplname;
    }
    if ($topicid) {
        DB::update('portal_topic', $setarr, array('topicid' => $topicid));
        DB::update('common_diy_data', array('name' => $setarr['title']), array('targettplname' => 'portal/portal_topic_content_' . $topicid));
    } else {
        $setarr['uid'] = $_G['uid'];
        $setarr['username'] = $_G['username'];
        $setarr['dateline'] = $_G['timestamp'];
        $setarr['closed'] = '1';
        $topicid = addtopic($setarr);
        if (!$topicid) {
            return 'topic_created_failed';
        }
    }
    if (!empty($_POST['domain'])) {
        DB::insert('common_domain', array('domain' => $_POST['domain'], 'domainroot' => addslashes($_G['setting']['domain']['root']['topic']), 'id' => $topicid, 'idtype' => 'topic'));
    }
    if ($topic['primaltplname'] != $primaltplname) {
        $targettplname = 'portal/portal_topic_content_' . $topicid;
        DB::update('common_diy_data', array('primaltplname' => $primaltplname), array('targettplname' => $targettplname));
        updatediytemplate($targettplname);
    }
    if ($primaltplname && empty($topic['primaltplname'])) {
        $content = file_get_contents(DISCUZ_ROOT . './template/default/' . $primaltplname . '.htm');
        $tplfile = DISCUZ_ROOT . './data/diy/portal/portal_topic_content_' . $topicid . '.htm';
        $tplpath = dirname($tplfile);
        if (!is_dir($tplpath)) {
            dmkdir($tplpath);
        }
        file_put_contents($tplfile, $content);
    }
    include_once libfile('function/cache');
    updatecache(array('diytemplatename', 'setting'));
    return $topicid;
}
Exemplo n.º 2
0
function updatetopic($topic = '')
{
    global $_G;
    $topicid = empty($topic) ? '' : $topic['topicid'];
    include_once libfile('function/home');
    $_POST['title'] = getstr(trim($_POST['title']), 255);
    $_POST['name'] = getstr(trim($_POST['name']), 255);
    $_POST['domain'] = getstr(trim($_POST['domain']), 255);
    if (empty($_POST['title'])) {
        return 'topic_title_cannot_be_empty';
    }
    if (empty($_POST['name'])) {
        $_POST['name'] = $_POST['title'];
    }
    if (!$topicid || $_POST['name'] != $topic['name']) {
        if ($value = C::t('portal_topic')->fetch_by_name($_POST['name'])) {
            return 'topic_name_duplicated';
        }
    }
    if ($topicid && !empty($topic['domain'])) {
        require_once libfile('function/delete');
        deletedomain($topicid, 'topic');
    }
    if (!empty($_POST['domain'])) {
        require_once libfile('function/domain');
        domaincheck($_POST['domain'], $_G['setting']['domain']['root']['topic'], 1);
    }
    $setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'domain' => $_POST['domain'], 'summary' => getstr($_POST['summary']), 'keyword' => getstr($_POST['keyword']), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0', 'allowcomment' => $_POST['allowcomment'] ? 1 : 0, 'closed' => $_POST['closed'] ? 0 : 1);
    if ($_POST['deletecover'] && $topic['cover']) {
        if ($topic['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
        }
        $setarr['cover'] = '';
    } else {
        if ($_FILES['cover']['tmp_name']) {
            if ($topic['cover'] && $topic['picflag'] != '0') {
                pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
            }
            $pic = pic_upload($_FILES['cover'], 'portal');
            if ($pic) {
                $setarr['cover'] = 'portal/' . $pic['pic'];
                $setarr['picflag'] = $pic['remote'] ? '2' : '1';
            }
        } else {
            if (!empty($_POST['cover']) && $_POST['cover'] != $topic['cover']) {
                if ($topic['cover'] && $topic['picflag'] != '0') {
                    pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
                }
                $setarr['cover'] = $_POST['cover'];
                $setarr['picflag'] = '0';
            }
        }
    }
    $primaltplname = '';
    if (empty($topicid) || empty($topic['primaltplname']) || $topic['primaltplname'] && $topic['primaltplname'] != $_POST['primaltplname']) {
        $primaltplname = $_POST['primaltplname'];
        if (!isset($_POST['signs'][dsign($primaltplname)])) {
            return 'diy_sign_invalid';
        }
        $checktpl = checkprimaltpl($primaltplname);
        if ($checktpl !== true) {
            return $checktpl;
        }
        $setarr['primaltplname'] = $primaltplname;
    }
    if ($topicid) {
        C::t('portal_topic')->update($topicid, $setarr);
        C::t('common_diy_data')->update('portal/portal_topic_content_' . $topicid, getdiydirectory($topic['primaltplname']), array('name' => $setarr['title']));
    } else {
        $setarr['uid'] = $_G['uid'];
        $setarr['username'] = $_G['username'];
        $setarr['dateline'] = $_G['timestamp'];
        $setarr['closed'] = '1';
        $topicid = addtopic($setarr);
        if (!$topicid) {
            return 'topic_created_failed';
        }
    }
    if (!empty($_POST['domain'])) {
        C::t('common_domain')->insert(array('domain' => $_POST['domain'], 'domainroot' => $_G['setting']['domain']['root']['topic'], 'id' => $topicid, 'idtype' => 'topic'));
    }
    $tpldirectory = '';
    if ($primaltplname && $topic['primaltplname'] != $primaltplname) {
        $targettplname = 'portal/portal_topic_content_' . $topicid;
        if (strpos($primaltplname, ':') !== false) {
            list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
        }
        C::t('common_diy_data')->update($targettplname, getdiydirectory($topic['primaltplname']), array('primaltplname' => $primaltplname, 'tpldirectory' => $tpldirectory));
        updatediytemplate($targettplname);
    }
    if ($primaltplname && empty($topic['primaltplname'])) {
        $tpldirectory = $tpldirectory ? $tpldirectory : $_G['cache']['style_default']['tpldir'];
        $content = file_get_contents(DISCUZ_ROOT . $tpldirectory . '/' . $primaltplname . '.htm');
        $tplfile = DISCUZ_ROOT . './data/diy/' . $tpldirectory . '/portal/portal_topic_content_' . $topicid . '.htm';
        $tplpath = dirname($tplfile);
        if (!is_dir($tplpath)) {
            dmkdir($tplpath);
        }
        file_put_contents($tplfile, $content);
    }
    include_once libfile('function/cache');
    updatecache(array('diytemplatename', 'setting'));
    return $topicid;
}
Exemplo n.º 3
0
     cpmsg('topic_choose_at_least_one_topic', 'action=topic', 'error');
 }
 if ($_POST['optype'] == 'delete') {
     $targettplname = array();
     foreach ($_POST['ids'] as $key => $value) {
         $targettplname[] = 'portal/portal_topic_content_' . $value;
     }
     DB::delete('common_diy_data', "targettplname IN (" . dimplode($targettplname) . ")", 0, true);
     DB::query('DELETE FROM ' . DB::table('common_block') . ' WHERE bid IN (SELECT bid FROM ' . DB::table('common_template_block') . ' WHERE targettplname IN (' . dimplode($targettplname) . '))', 'UNBUFFERED');
     DB::delete('common_template_block', 'targettplname IN (' . dimplode($targettplname) . ')', 0, true);
     require_once libfile('function/home');
     $picids = array();
     $query = DB::query('SELECT * FROM ' . DB::table('portal_topic_pic') . ' WHERE topicid IN (' . dimplode($_POST['ids']) . ')');
     while ($value = DB::fetch($query)) {
         $picids[] = $value['picid'];
         pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
     }
     if (!empty($picids)) {
         DB::delete('portal_topic_pic', 'picid IN (' . dimplode($picids) . ')', 0, true);
     }
     foreach ($targettplname as $key => $value) {
         @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm');
         @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm.bak');
     }
     DB::delete('portal_topic', 'topicid IN (' . dimplode($_POST['ids']) . ')', 0, true);
     cpmsg('topic_delete_succeed', 'action=topic', 'succeed');
 } elseif ($_POST['optype'] == 'close') {
     DB::query('UPDATE ' . DB::table('portal_topic') . " SET closed = '1' WHERE topicid IN (" . dimplode($_POST['ids']) . ")");
     cpmsg('topic_close_succeed', 'action=topic', 'succeed');
 } elseif ($_POST['optype'] == 'open') {
     DB::query('UPDATE ' . DB::table('portal_topic') . " SET closed = '0' WHERE topicid IN (" . dimplode($_POST['ids']) . ")");
Exemplo n.º 4
0
function deleteportaltopic($dels)
{
    if (empty($dels)) {
        return false;
    }
    $targettplname = array();
    foreach ((array) $dels as $key => $value) {
        $targettplname[] = 'portal/portal_topic_content_' . $value;
    }
    C::t('common_diy_data')->delete($targettplname, null);
    require_once libfile('class/blockpermission');
    $tplpermission =& template_permission::instance();
    $templates = array();
    $tplpermission->delete_allperm_by_tplname($targettplname);
    deletedomain($dels, 'topic');
    C::t('common_template_block')->delete_by_targettplname($targettplname);
    require_once libfile('function/home');
    $picids = array();
    foreach (C::t('portal_topic')->fetch_all($dels) as $value) {
        if ($value['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $value['cover']), 'portal', 0, $value['picflag'] == '2' ? '1' : '0');
        }
    }
    $picids = array();
    foreach (C::t('portal_topic_pic')->fetch_all($dels) as $value) {
        $picids[] = $value['picid'];
        pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
    }
    if (!empty($picids)) {
        C::t('portal_topic_pic')->delete($picids, true);
    }
    C::t('portal_topic')->delete($dels);
    C::t('portal_comment')->delete_by_id_idtype($dels, 'topicid');
    C::t('common_moderate')->delete($dels, 'topicid_cid');
    include_once libfile('function/block');
    block_clear();
    include_once libfile('function/cache');
    updatecache('diytemplatename');
}
Exemplo n.º 5
0
function deleteportaltopic($dels)
{
    if (empty($dels)) {
        return false;
    }
    $targettplname = array();
    foreach ((array) $dels as $key => $value) {
        $targettplname[] = 'portal/portal_topic_content_' . $value;
    }
    DB::delete('common_diy_data', "targettplname IN (" . dimplode($targettplname) . ")", 0, true);
    require_once libfile('class/blockpermission');
    $tplpermission =& template_permission::instance();
    $templates = array();
    $tplpermission->delete_allperm_by_tplname($targettplname);
    deletedomain($dels, 'topic');
    DB::delete('common_template_block', 'targettplname IN (' . dimplode($targettplname) . ')', 0, true);
    require_once libfile('function/home');
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        if ($value['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $value['cover']), 'portal', 0, $value['picflag'] == '2' ? '1' : '0');
        }
    }
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic_pic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        $picids[] = $value['picid'];
        pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
    }
    if (!empty($picids)) {
        DB::delete('portal_topic_pic', 'picid IN (' . dimplode($picids) . ')', 0, true);
    }
    foreach ($targettplname as $key => $value) {
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm');
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm.bak');
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '_preview.htm');
    }
    DB::delete('portal_topic', 'topicid IN (' . dimplode($dels) . ')');
    DB::delete('portal_comment', "id IN(" . dimplode($dels) . ") AND idtype='topicid'");
    DB::delete('common_moderate', "id IN (" . dimplode($dels) . ") AND idtype='topicid_cid'");
    include_once libfile('function/block');
    block_clear();
    include_once libfile('function/cache');
    updatecache('diytemplatename');
}
Exemplo n.º 6
0
$operation = $_GET['op'] ? $_GET['op'] : '';
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
$aid = empty($_GET['aid']) ? '' : intval($_GET['aid']);
$attach = C::t('portal_attachment')->fetch($id);
if (empty($attach)) {
    showmessage('portal_attachment_noexist');
}
if ($operation == 'delete') {
    if (!$_G['group']['allowmanagearticle'] && $_G['uid'] != $attach['uid']) {
        showmessage('portal_attachment_nopermission_delete');
    }
    if ($aid) {
        C::t('portal_article_title')->update($aid, array('pic' => ''));
    }
    C::t('portal_attachment')->delete($id);
    pic_delete($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
    showmessage('portal_image_noexist');
} elseif ($operation == 'getattach') {
    require_once libfile('function/attachment');
    if ($attach['isimage']) {
        require_once libfile('function/home');
        $smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
        $bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']);
        $coverstr = addslashes(serialize(array('pic' => 'portal/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'])));
    }
    $attach['filetype'] = attachtype($attach['filetype'] . "\t" . $attach['filetype']);
    $attach['filesize'] = sizecount($attach['filesize']);
    include template('portal/portal_attachment');
    exit;
} else {
    $filename = $_G['setting']['attachdir'] . '/portal/' . $attach['attachment'];
Exemplo n.º 7
0
 $_G['gp_author'] = dhtmlspecialchars($_G['gp_author']);
 $_G['gp_from'] = dhtmlspecialchars($_G['gp_from']);
 $_G['gp_fromurl'] = dhtmlspecialchars($_G['gp_fromurl']);
 $_G['gp_shorttitle'] = getstr(trim(dhtmlspecialchars($_G['gp_shorttitle'])), 80, 1, 1, 1);
 $setarr = array('title' => $_POST['title'], 'shorttitle' => $_G['gp_shorttitle'], 'author' => $_G['gp_author'], 'from' => $_G['gp_from'], 'fromurl' => $_G['gp_fromurl'], 'url' => $_POST['url'], 'summary' => $summary, 'prename' => $prename, 'preurl' => $_POST['preurl'], 'catid' => intval($_POST['catid']));
 if (empty($setarr['catid'])) {
     showmessage('article_choose_system_category');
 }
 if ($_FILES['pic']) {
     if ($files = pic_upload($_FILES['pic'], 'portal', 300, 300, 2)) {
         $setarr['pic'] = $files['pic'];
         $setarr['thumb'] = $files['thumb'];
         $setarr['remote'] = $files['remote'];
     }
     if ($setarr['pic'] && $article['pic']) {
         pic_delete($article['pic'], 'portal', $article['thumb'], $article['remote']);
     }
 }
 if (empty($article)) {
     $setarr['uid'] = $_G['uid'];
     $setarr['username'] = $_G['username'];
     $setarr['dateline'] = $_G['timestamp'];
     $setarr['id'] = intval($_POST['id']);
     if ($setarr['id']) {
         $setarr['idtype'] = $_POST['idtype'] == 'blogid' ? 'blogid' : 'tid';
     }
     $aid = DB::insert('portal_article_title', $setarr, 1);
     DB::query('UPDATE ' . DB::table('portal_category') . " SET articles=articles+1 WHERE catid = '{$setarr['catid']}'");
 } else {
     DB::update('portal_article_title', $setarr, array('aid' => $aid));
 }
Exemplo n.º 8
0
function deletearticlerelated($dels)
{
    DB::query('DELETE FROM ' . DB::table('portal_article_count') . " WHERE aid IN(" . dimplode($dels) . ")", 'UNBUFFERED');
    DB::query('DELETE FROM ' . DB::table('portal_article_content') . " WHERE aid IN(" . dimplode($dels) . ")", 'UNBUFFERED');
    $query = DB::query("SELECT * FROM " . DB::table('portal_attachment') . " WHERE aid IN (" . dimplode($dels) . ")");
    while ($value = DB::fetch($query)) {
        $attachment[] = $value;
        $attachdel[] = $value['attachid'];
    }
    foreach ($attachment as $value) {
        pic_delete($value['attachment'], 'portal', $value['thumb'], $value['remote']);
    }
    DB::query("DELETE FROM " . DB::table('portal_attachment') . " WHERE aid IN (" . dimplode($dels) . ")", 'UNBUFFERED');
    DB::query('DELETE FROM ' . DB::table('portal_comment') . " WHERE aid IN(" . dimplode($dels) . ")", 'UNBUFFERED');
    DB::query('DELETE FROM ' . DB::table('portal_article_related') . " WHERE aid IN(" . dimplode($dels) . ")", 'UNBUFFERED');
}
Exemplo n.º 9
0
function mydeletepics($picids)
{
    global $_G;
    $albumids = $sizes = $pics = $newids = array();
    $allowmanage = checkperm('managealbum');
    $haveforumpic = false;
    $query = C::t('#sanree_brand#sanree_brand_album')->fetch_all($picids);
    foreach ($query as $value) {
        if ($allowmanage || $value['uid'] == $_G['uid']) {
            $pics[] = $value;
            $newids[] = $value['albumid'];
            $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size'];
            $albumids[$value['albumid']] = $value['albumid'];
            if (!$haveforumpic && $value['remote'] > 1) {
                $haveforumpic = true;
            }
        }
    }
    if (empty($pics)) {
        return array();
    }
    C::t('#sanree_brand#sanree_brand_album')->delete($newids);
    $remotes = array();
    include_once libfile('function/home');
    foreach ($pics as $pic) {
        pic_delete($pic['pic'], 'album', $pic['thumb'], $pic['remote']);
    }
}
Exemplo n.º 10
0
function deleteportaltopic($dels)
{
    if (empty($dels)) {
        return false;
    }
    $targettplname = array();
    foreach ((array) $dels as $key => $value) {
        $targettplname[] = 'portal/portal_topic_content_' . $value;
    }
    DB::delete('common_diy_data', "targettplname IN (" . dimplode($targettplname) . ")", 0, true);
    deletedomain($dels, 'topic');
    DB::delete('common_template_permission', "targettplname IN (" . dimplode($targettplname) . ")", 0, true);
    $bids = array();
    $query = DB::query('SELECT bid FROM ' . DB::table('common_template_block') . ' WHERE targettplname IN (' . dimplode($targettplname) . ')');
    while ($value = DB::fetch($query)) {
        $bids[] = $value['bid'];
    }
    $bids = dimplode($bids);
    if (!empty($bids)) {
        DB::query('DELETE FROM ' . DB::table('common_block') . ' WHERE bid IN (' . $bids . ')', 'UNBUFFERED');
        DB::query('DELETE FROM ' . DB::table('common_block_permission') . ' WHERE bid IN (' . $bids . ')', 'UNBUFFERED');
    }
    DB::delete('common_template_block', 'targettplname IN (' . dimplode($targettplname) . ')', 0, true);
    require_once libfile('function/home');
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        if ($value['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $value['cover']), 'portal', 0, $value['picflag'] == '2' ? '1' : '0');
        }
    }
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic_pic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        $picids[] = $value['picid'];
        pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
    }
    if (!empty($picids)) {
        DB::delete('portal_topic_pic', 'picid IN (' . dimplode($picids) . ')', 0, true);
    }
    foreach ($targettplname as $key => $value) {
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm');
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm.bak');
    }
    DB::delete('portal_topic', 'topicid IN (' . dimplode($dels) . ')', 0, true);
    include_once libfile('function/cache');
    updatecache('diytemplatename');
}
Exemplo n.º 11
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;
}