Example #1
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;
}
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;
}
Example #3
0
 $start = ($page - 1) * $perpage;
 $url = 'forum.php?mod=group&action=manage&op=' . $_G['gp_op'] . '&fid=' . $_G['fid'];
 if ($_G['gp_op'] == 'group') {
     $domainlength = checkperm('domainlength');
     if (submitcheck('groupmanage')) {
         $forumarr = array();
         if (isset($_G['gp_domain']) && $_G['forum']['domain'] != $_G['gp_domain']) {
             $domain = strtolower(trim($_G['gp_domain']));
             if ($_G['setting']['allowgroupdomain'] && !empty($_G['setting']['domain']['root']['group']) && $domainlength) {
                 checklowerlimit('modifydomain');
             }
             if (empty($domainlength) || empty($domain)) {
                 $domain = '';
             } else {
                 require_once libfile('function/domain');
                 if (domaincheck($domain, $_G['setting']['domain']['root']['group'], $domainlength)) {
                     require_once libfile('function/delete');
                     deletedomain($_G['fid'], 'group');
                     DB::insert('common_domain', array('domain' => $domain, 'domainroot' => addslashes($_G['setting']['domain']['root']['group']), 'id' => $_G['fid'], 'idtype' => 'group'));
                 }
             }
             $forumarr['domain'] = $domain;
             updatecreditbyaction('modifydomain');
         }
         if ($_G['gp_name'] && !empty($specialswitch['allowchangename']) || $_G['gp_fup'] && !empty($specialswitch['allowchangetype'])) {
             if ($_G['uid'] != $_G['forum']['founderuid'] && $_G['adminid'] != 1) {
                 showmessage('group_edit_only_founder');
             }
             if (isset($_G['gp_name'])) {
                 $_G['gp_name'] = censor(addslashes(dhtmlspecialchars(cutstr(stripslashes(trim($_G['gp_name'])), 20, ''))));
                 if (empty($_G['gp_name'])) {
Example #4
0
     $moderators = implode("\t", $members);
     C::t('forum_forumfield')->update($fid, array('moderators' => $moderators));
 }
 $allowpostspecialtrade = intval($_GET['allowpostspecialnew'][2]);
 $_GET['allowpostspecialnew'] = bindec(intval($_GET['allowpostspecialnew'][6]) . intval($_GET['allowpostspecialnew'][5]) . intval($_GET['allowpostspecialnew'][4]) . intval($_GET['allowpostspecialnew'][3]) . intval($_GET['allowpostspecialnew'][2]) . intval($_GET['allowpostspecialnew'][1]));
 $allowspecialonlynew = $_GET['allowpostspecialnew'] || $_G['setting']['threadplugins'] && $_GET['threadpluginnew'] ? $_GET['allowspecialonlynew'] : 0;
 $forumcolumnsnew = $_GET['forumcolumnsnew'] > 1 ? intval($_GET['forumcolumnsnew']) : 0;
 $threadcachesnew = max(0, min(100, intval($_GET['threadcachesnew'])));
 $subforumsindexnew = $_GET['subforumsindexnew'] == -1 ? 0 : ($_GET['subforumsindexnew'] == 0 ? 2 : 1);
 $_GET['simplenew'] = isset($_GET['simplenew']) ? $_GET['simplenew'] : 0;
 $simplenew = bindec(sprintf('%02d', decbin($_GET['defaultorderfieldnew'])) . $_GET['defaultordernew'] . sprintf('%02d', decbin($subforumsindexnew)) . '00' . $_GET['simplenew']);
 $allowglobalsticknew = $_GET['allowglobalsticknew'] ? 1 : 0;
 if (!empty($_G['setting']['domain']['root']['forum'])) {
     deletedomain($fid, 'forum');
     if (!empty($domain)) {
         domaincheck($domain, $_G['setting']['domain']['root']['forum'], 1, 0);
         C::t('common_domain')->insert(array('domain' => $domain, 'domainroot' => $_G['setting']['domain']['root']['forum'], 'id' => $fid, 'idtype' => 'forum'));
     }
 }
 $forumdata = array_merge($forumdata, array('status' => $_GET['statusnew'], 'name' => $_GET['namenew'], 'styleid' => $_GET['styleidnew'], 'alloweditpost' => $_GET['alloweditpostnew'], 'allowpostspecial' => $_GET['allowpostspecialnew'], 'allowspecialonly' => $allowspecialonlynew, 'allowhtml' => $_GET['allowhtmlnew'], 'allowbbcode' => $_GET['allowbbcodenew'], 'allowimgcode' => $_GET['allowimgcodenew'], 'allowmediacode' => $_GET['allowmediacodenew'], 'allowsmilies' => $_GET['allowsmiliesnew'], 'alloweditrules' => $_GET['alloweditrulesnew'], 'allowside' => $_GET['allowsidenew'], 'disablecollect' => $_GET['disablecollectnew'], 'modnewposts' => $_GET['modnewpostsnew'], 'recyclebin' => $_GET['recyclebinnew'], 'jammer' => $_GET['jammernew'], 'allowanonymous' => $_GET['allowanonymousnew'], 'forumcolumns' => $forumcolumnsnew, 'catforumcolumns' => $catforumcolumnsnew, 'threadcaches' => $threadcachesnew, 'simple' => $simplenew, 'allowglobalstick' => $allowglobalsticknew, 'disablethumb' => $_GET['disablethumbnew'], 'disablewatermark' => $_GET['disablewatermarknew'], 'autoclose' => intval($_GET['autoclosenew'] * $_GET['autoclosetimenew']), 'allowfeed' => $_GET['allowfeednew'], 'domain' => $domain));
 C::t('forum_forum')->update($fid, $forumdata);
 if (!C::t('forum_forumfield')->fetch($fid)) {
     C::t('forum_forumfield')->insert(array('fid' => $fid));
 }
 if (!$multiset) {
     $creditspolicynew = array();
     $creditspolicy = $forum['creditspolicy'] ? dunserialize($forum['creditspolicy']) : array();
     foreach ($_GET['creditnew'] as $rid => $rule) {
         $creditspolicynew[$rules[$rid]['action']] = isset($creditspolicy[$rules[$rid]['action']]) ? $creditspolicy[$rules[$rid]['action']] : $rules[$rid];
         $usedefault = $_GET['usecustom'][$rid] ? false : true;
         if (!$usedefault) {
 $domain = $_GET['domain'] ? $_GET['domain'] : '';
 $_GET['closed'] = intval($_GET['closed']) ? 0 : 1;
 $_GET['catname'] = trim($_GET['catname']);
 $foldername = trim($_GET['foldername']);
 $oldsetindex = !empty($_G['setting']['defaultindex']) && $_G['setting']['defaultindex'] == $cate['caturl'] ? 1 : 0;
 $perpage = intval($_GET['perpage']);
 $maxpages = intval($_GET['maxpages']);
 $perpage = empty($perpage) ? 15 : $perpage;
 $maxpages = empty($maxpages) ? 1000 : $maxpages;
 if ($_GET['catid'] && !empty($cate['domain'])) {
     require_once libfile('function/delete');
     deletedomain($_GET['catid'], 'channel');
 }
 if (!empty($domain)) {
     require_once libfile('function/domain');
     domaincheck($domain, $_G['setting']['domain']['root']['channel'], 1);
 }
 $updatecategoryfile = array();
 $editcat = array('catname' => $_GET['catname'], 'allowcomment' => $_GET['allowcomment'], 'url' => $_GET['url'], 'closed' => $_GET['closed'], 'seotitle' => $_GET['seotitle'], 'keyword' => $_GET['keyword'], 'description' => $_GET['description'], 'displayorder' => intval($_GET['displayorder']), 'notinheritedarticle' => $_GET['inheritancearticle'] ? '0' : '1', 'notinheritedblock' => $_GET['inheritanceblock'] ? '0' : '1', 'disallowpublish' => $_GET['allowpublish'] ? '0' : '1', 'notshowarticlesummay' => $_GET['notshowarticlesummay'] ? '0' : '1', 'perpage' => $perpage, 'maxpages' => $maxpages, 'noantitheft' => intval($_GET['noantitheft']));
 $dir = '';
 if (!empty($foldername)) {
     $oldfoldername = empty($_GET['catid']) ? '' : $portalcategory[$_GET['catid']]['foldername'];
     preg_match_all('/[^\\w\\d\\_]/', $foldername, $re);
     if (!empty($re[0])) {
         cpmsg(cplang('portalcategory_foldername_rename_error') . ',' . cplang('return'), NULL, 'error');
     }
     $parentdir = getportalcategoryfulldir($cate['upid']);
     if ($parentdir === false) {
         cpmsg(cplang('portalcategory_parentfoldername_empty') . ',' . cplang('return'), NULL, 'error');
     }
     if ($foldername == $oldfoldername) {
}
$domainlength = checkperm('domainlength');
if ($_G['setting']['allowspacedomain'] && !empty($_G['setting']['domain']['root']['home']) && $domainlength) {
    checklowerlimit('modifydomain');
} else {
    showmessage('no_privilege_spacedomain');
}
if (submitcheck('domainsubmit')) {
    $setarr = array();
    $_POST['domain'] = strtolower(trim($_POST['domain']));
    if ($_POST['domain'] != $space['domain']) {
        if (empty($domainlength) || empty($_POST['domain'])) {
            $setarr['domain'] = '';
        } else {
            require_once libfile('function/domain');
            if (domaincheck($_POST['domain'], $_G['setting']['domain']['root']['home'], $domainlength)) {
                $setarr['domain'] = $_POST['domain'];
            }
        }
    }
    if ($setarr) {
        updatecreditbyaction('modifydomain');
        DB::update('common_member_field_home', $setarr, array('uid' => $_G['uid']));
        require_once libfile('function/delete');
        deletedomain($_G['uid'], 'home');
        if (!empty($setarr['domain'])) {
            DB::insert('common_domain', array('domain' => $setarr['domain'], 'domainroot' => addslashes($_G['setting']['domain']['root']['home']), 'id' => $_G['uid'], 'idtype' => 'home'));
        }
    }
    showmessage('domain_succeed', 'home.php?mod=spacecp&ac=domain');
}