- <?php
- /*
- [DISCUZ!] include/newthread.inc.php - starting new thread for post module
- This is NOT a freeware, use is subject to license terms
- Version: 4.0.0
- Web: http://www.comsenz.com
- Copyright: 2001-2005 Comsenz Technology Ltd.
- Last Modified: 2005-3-7 16:15
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- $discuz_action = 11;
- //Music Heartland (音乐厅) By oytktk(靖飒)
- @require DISCUZ_ROOT.'./forumdata/cache/plugin_mymusic.php';
- $mucfg = $_DPLUGIN['mymusic']['vars'];
- $musicfid=$mucfg['musicfid'];
- foreach( explode(',', $musicfid) as $fids ){
- if ($fid == $fids) {$readonly = "readonly"; break;}
- }
- //Music Heartland (音乐厅) By oytktk(靖飒) end...
- if(empty($forum['fid']) || $forum['type'] == 'group') {
- showmessage('forum_nonexistence');
- }
- if(!$discuz_uid && !((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])))) {
- showmessage('group_nopermission', NULL, 'NOPERM');
- } elseif(empty($forum['allowpost'])) {
- if(!$forum['postperm'] && !$allowpost) {
- showmessage('group_nopermission', NULL, 'NOPERM');
- } elseif($forum['postperm'] && !forumperm($forum['postperm'])) {
- showmessage('post_forum_newthread_nopermission', NULL, 'HALTED');
- }
- }
- $isblog = empty($isblog) ? '' : 'yes';
- if($isblog && (!$allowuseblog || !$forum['allowblog'])) {
- showmessage('post_newthread_blog_invalid', NULL, 'HALT');
- }
- checklowerlimit($postcredits);
- if(!submitcheck('topicsubmit', 0, $seccodecheck)) {
- $typeselect = typeselect($typeid);
- $icons = '';
- if(is_array($_DCACHE['icons'])) {
- $key = 1;
- foreach($_DCACHE['icons'] as $id => $icon) {
- $icons .= ' <input type="radio" name="iconid" value="'.$id.'"><img src="'.SMDIR.'/'.$icon.'">';
- $icons .= !(++$key % 10) ? '<br>' : '';
- }
- }
- include template('post_newthread');
- } else {if($readonly && ($mp3_name == '' || $mp3_artist == '') && (!$upload && !$mp3_m_r == '')) {
- showmessage("对不起, 您没有输入音乐必选参数!");
- }
- if($subject == '' || $message == '') {
- showmessage('post_sm_isnull');
- }
- if($post_invalid = checkpost()) {
- showmessage($post_invalid);
- }
- if(checkflood()) {
- showmessage('post_flood_ctrl');
- }
- if(!empty($_FILES['attach'])) {
- checklowerlimit($creditspolicy['postattach']);
- }
- $typeid = isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0;
- $iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $iconid : 0;
- $displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0);
- $digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1 : 0;
- $blog = $allowuseblog && $forum['allowblog'] && !empty($addtoblog) ? 1 : 0;
- $readperm = $allowsetreadperm ? $readperm : 0;
- $price = $maxprice ? ($price <= $maxprice ? $price : $maxprice) : 0;
- if(!$typeid && $forum['threadtypes']['required']) {
- showmessage('post_type_isnull');
- }
- if($price > 0 && floor($price * (1 - $creditstax)) == 0) {
- showmessage('post_net_price_iszero');
- }
- if(isset($poll) && $allowpostpoll && trim($polloptions)) {
- $poll = 1;
- $pollarray = array();
- $polloptions = explode("\n", $polloptions);
- if(count($polloptions) > $maxpolloptions) {
- showmessage('post_poll_option_toomany');
- }
- foreach($polloptions as $polloption) {
- $polloption = trim($polloption);
- if($polloption) {
- $pollarray['options'][] = array($polloption, 0);
- }
- }
- $pollarray['multiple'] = !empty($multiplepoll);
- $pollarray['voters'] = array();
- $pollopts = addslashes(serialize($pollarray));
- } elseif(isset($trade) && $allowposttrade && !empty($seller) && !empty($item_name) && !empty($item_price)) {
- include language('misc');
- $message = "[b]$language[post_trade_seller]:[/b] $seller\r\n\r\n".
- "[b]$language[post_trade_name]:[/b] $item_name\r\n\r\n".
- "[b]$language[post_trade_price]:[/b] $item_price $language[post_trade_yuan]\r\n\r\n".
- (!empty($item_quality) ? "[b]$language[post_trade_quality]:[/b] $item_quality\r\n\r\n" : '').
- (!empty($item_locus) ? "[b]$language[post_trade_locus]:[/b] $item_locus\r\n\r\n" : '').
- "[b]$language[post_trade_postage]:[/b] ".(empty($postage_mail) && empty($postage_express) ? $language['post_trade_postage_seller'] : $language['post_trade_postage_buyer']).(!empty($postage_mail) ? ", $language[post_trade_postage_mail] $postage_mail $language[post_trade_yuan]" : '').(!empty($postage_express) ? ", $language[post_trade_postage_express] $postage_express $language[post_trade_yuan]" : '')."\r\n\r\n".
- "[b]$language[post_trade_description]:[/b]\r\n\r\n".
- "[payto]\r\n".
- "(seller)$seller(/seller)\r\n".
- "(subject)$item_name(/subject)\r\n".
- "(body)".cutstr($message, 400)."(/body)\r\n".
- "(price)$item_price(/price)\r\n".
- "(ordinary_fee)$postage_mail(/ordinary_fee)\r\n".
- "(express_fee)$postage_express(/express_fee)\r\n".
- "[/payto]\r\n\r\n".
- $message;
- $iconid = 25;
- } else {
- $poll = 0;
- $pollopts = '';
- }
- $moderated = $digest || $displayorder > 0 ? 1 : 0;
- $attachment = ($allowpostattach && $attachments = attach_upload()) ? 1 : 0;
- $db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, mp3_type, blog, poll, attachment, moderated)
- VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$discuz_user', '$displayorder', '$digest', '$mp3_m_r', '$blog', '$poll', '$attachment', '$moderated')");
- $tid = $db->insert_id();
- if($moderated) {
- updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG'));
- }
- if($poll) {
- $db->query("INSERT INTO {$tablepre}polls (tid, pollopts)
- VALUES ('$tid', '$pollopts')");
- }
- $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
- $smileyoff = checksmilies($message, !empty($smileyoff));
- $parseurloff = !empty($parseurloff);
- $htmlon = $allowhtml && !empty($htmlon) ? 1 : 0;
- $pinvisible = $modnewthreads ? -2 : 0;
- $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, usesig, htmlon, bbcodeoff, mp3_url, smileyoff, parseurloff, attachment)
- VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$message', '$onlineip', '$pinvisible', '$usesig', '$htmlon', '$bbcodeoff', '$mp3_url', '$smileyoff', '$parseurloff', '$attachment')");
- $pid = $db->insert_id();
- if($attachment) {
- foreach($attachments as $attach) {
- $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
- VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
- }
- updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
- }
- if($modnewthreads) {
- $allowuseblog && $isblog && $blog ? showmessage('post_newthread_mod_blog_succeed', "blog.php?uid=$discuz_uid") :
- showmessage('post_newthread_mod_succeed', "forumdisplay.php?fid=$fid");
- } else {
- if($digest) {
- foreach($creditspolicy['digest'] as $id => $addcredits) {
- $forum['postcredits'][$id] = (isset($forum['postcredits'][$id]) ? $forum['postcredits'][$id] : 0) + $addcredits;
- }
- }
- updatepostcredits('+', $discuz_uid, $postcredits);
- $lastpost = "$tid\t$subject\t$timestamp\t$discuz_user";
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=".todayposts()." WHERE fid='$fid'", 'UNBUFFERED');
- if($forum['type'] == 'sub') {
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
- }
- if(!empty($emailnotify) && $discuz_uid) {
- $query = $db->query("SELECT tid FROM {$tablepre}subscriptions WHERE uid='$discuz_uid' AND tid='$tid'");
- if(!$db->result($query, 0)) {
- $db->query("INSERT INTO {$tablepre}subscriptions (uid, email, tid)
- VALUES ('$discuz_uid', '$email', '$tid')", 'UNBUFFERED');
- }
- }
- $allowuseblog && $isblog && $blog ? showmessage('post_newthread_blog_succeed', "blog.php?tid=$tid") :
- showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra");
- }
复制代码 |