Ejemplo 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);
    $_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;
}
Ejemplo 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, 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;
}
Ejemplo n.º 3
0
 }
 if (empty($_POST['summary'])) {
     $_POST['summary'] = preg_replace("/(\\s|###NextPage###)+/", ' ', $_POST['content']);
 }
 $summary = portalcp_get_summary($_POST['summary']);
 $prename = getstr(dhtmlspecialchars($_POST['prename']), 255, 1, 1, 1);
 $_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';
Ejemplo n.º 4
0
 foreach ($thestyle['fields'] as $fieldname) {
     $showfields[$fieldname] = "1";
 }
 if (submitcheck('itemsubmit') || submitcheck('recommendsubmit') || submitcheck('verifydatasubmit') || submitcheck('managedatasubmit')) {
     $item['bid'] = $block['bid'];
     $item['displayorder'] = intval($_POST['displayorder']);
     $item['startdate'] = !empty($_POST['startdate']) ? strtotime($_POST['startdate']) : 0;
     $item['enddate'] = !empty($_POST['enddate']) ? strtotime($_POST['enddate']) : 0;
     $item['itemtype'] = !empty($_POST['locked']) ? '1' : '2';
     $item['title'] = dhtmlspecialchars($_POST['title']);
     $item['url'] = $_POST['url'];
     $block['param']['summarylength'] = empty($block['param']['summarylength']) ? 80 : $block['param']['summarylength'];
     $block['param']['titlelength'] = empty($block['param']['titlelength']) ? 40 : $block['param']['titlelength'];
     $item['summary'] = cutstr($_POST['summary'], $block['param']['summarylength'], '');
     if ($_FILES['pic']['tmp_name']) {
         $result = pic_upload($_FILES['pic'], 'portal');
         $item['pic'] = 'portal/' . $result['pic'];
         $item['picflag'] = $result['remote'] ? '2' : '1';
         $item['makethumb'] = 0;
         $item['thumbpath'] = '';
         $thumbdata = array('bid' => $block['bid'], 'itemid' => $item['itemid'], 'pic' => $item['pic'], 'picflag' => $result['remote'], 'type' => '1');
         C::t('common_block_pic')->insert($thumbdata);
     } elseif ($_POST['pic']) {
         $pic = dhtmlspecialchars($_POST['pic']);
         $urls = parse_url($pic);
         if (!empty($urls['scheme']) && !empty($urls['host'])) {
             $item['picflag'] = '0';
             $item['thumbpath'] = '';
         } else {
             $item['picflag'] = intval($_POST['picflag']);
         }
Ejemplo n.º 5
0
 if (empty($_POST['title'])) {
     showmessage('topictitle_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) {
         showmessage('topic_name_duplicated');
     }
 }
 $setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'summary' => getstr($_POST['summary'], '', 1, 1, 1), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0');
 if ($_FILES['cover']['tmp_name']) {
     include_once libfile('function/home');
     $pic = pic_upload($_FILES['cover'], 'portal');
     if ($pic) {
         $setarr['cover'] = 'portal/' . $pic['pic'];
         $setarr['picflag'] = $pic['remote'] ? '2' : '1';
     }
 } elseif (!empty($_POST['cover'])) {
     $setarr['cover'] = $_POST['cover'];
     $setarr['picflag'] = '0';
 }
 if ($topicid) {
     DB::update('portal_topic', $setarr, array('topicid' => $topicid));
 } else {
     $primaltplname = $_POST['primaltplname'];
     if (!$primaltplname || preg_match("/(\\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\\.|\$)/i", $primaltplname)) {
         showmessage('filename_invalid');
     }