$update_to_arr['rmbs+'] = $credits3; if ($use_self && $credits3 > 0) $update_from_arr['rmbs-'] = $credits3; } db_update('user', array('uid' => $_thread['uid']), $update_to_arr); if ($use_self) db_update('user', array('uid' => $uid), $update_from_arr); db_insert('reward', array('uid' => $uid, 'time' => $time, 'tid' => $tid, 'credits' => $credits1, 'golds' => $credits2, 'rmbs' => $credits3)); db_insert('user_pay', array('uid' => $uid, 'status' => 1, 'num' => '0', 'type' => 14, 'credit_type' => '1', 'time' => time(), 'code' => $tid .tt_credits_rtn_name($credits1, $credits2, $credits3))); db_insert('user_pay', array('uid' => $_thread['uid'], 'status' => 1, 'num' => '0', 'type' => 15, 'credit_type' => '1', 'time' => time(), 'code' => $tid . tt_credits_rtn_name($credits1, $credits2, $credits3))); message(0, '打赏成功!'); } } elseif($action=='sReward') { $tid = param(2); include _include(APP_PATH . 'plugin/tt_reward/view/htm/tt_reward_list.htm'); return; } // 发表主题帖 | create new thread if($action == 'create') { !ipaccess_check($longip, 'threads') AND message(-1, '您的 IP 今日主题数达到上限。'); !ipaccess_check_seriate_threads() AND message(-1, '您的 IP 今日连续主题数已经达到上限。'); user_login_check(); if($method == 'GET') { $fid = param(2, 0); $forum = $fid ? forum_read($fid) : array(); $forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread'); $forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name')); if(empty($forumlist_allowthread)) { message(-1, lang('user_group_insufficient_privilege')); } $header['title'] = lang('create_thread'); $header['mobile_title'] = $fid ? $forum['name'] : ''; $header['mobile_linke'] = url("forum-$fid"); $content_num = 0; $content_num_type = 1; if($group['allowsell']=="1") { $input['content_num_status'] = form_radio_yes_no('content_num_status', 0); } $offer_num=0; $input['offer_status'] = form_radio_yes_no('offer_status', 0); $pnumber=0; $input['readp_status'] = form_radio_yes_no('readp_status', 0); include _include(APP_PATH.'view/htm/post.htm'); } else { $from_tag = param('fox_tag', ''); !empty($from_tag) AND fox_tag_filter($from_tag, 1); !empty($from_tag) AND fox_tag_words_check($from_tag, $qt_error) AND message('fox_tag', '标签含有敏感词:' . $qt_error); $set = setting_get('tt_credits'); $credits = $set['thread_exp'];$rmbs = $set['thread_rmb'];$golds = $set['thread_gold']; $golds_op = $golds>0?'+':'';$credits_op = $credits>0?'+':'';$rmbs_op = $rmbs>0?'+':''; if(($credits<0&&($user['credits']+$credits<0))||($golds<0&&($user['golds']+$golds<0))||($rmbs<0&&($user['rmbs']+$rmbs<0))) {message(-1,lang('credit_no_enough'));die();} $c_limit =$set['limit'] ; $add_credit=1; if($c_limit!=0) { $todayTime = strtotime(date('Y-m-d',time()))-1; $todayThread = db_count('post',array('create_date' => array('>'=>$todayTime),'uid'=>$uid,'isfirst'=>'1')); if($c_limit<=$todayThread) $add_credit=0; } $fid = param('fid', 0); $forum = forum_read($fid); empty($forum) AND message('fid', lang('forum_not_exists')); $r = forum_access_user($fid, $gid, 'allowthread'); !$r AND message(-1, lang('user_group_insufficient_privilege')); $subject = htmlspecialchars(param('subject', '', FALSE)); empty($subject) AND message('subject', lang('please_input_subject')); xn_strlen($subject) > 128 AND message('subject', lang('subject_length_over_limit', array('maxlength'=>128))); $message = param('message', '', FALSE); empty($message) AND message('message', lang('please_input_message')); $doctype = param('doctype', 0); $doctype > 10 AND message(-1, lang('doc_type_not_supported')); xn_strlen($message) > 2028000 AND message('message', lang('message_too_long')); $thread = array ( 'fid'=>$fid, 'uid'=>$uid, 'sid'=>$sid, 'subject'=>$subject, 'message'=>$message, 'time'=>$time, 'longip'=>$longip, 'doctype'=>$doctype, ); qt_check_sensitive_word($thread['subject'], 'post_sensitive_words', $qt_error) AND message('subject', lang('thread_contain_sensitive_word') . $qt_error); qt_check_sensitive_word($thread['message'], 'post_sensitive_words', $qt_error) AND message('message', lang('post_contain_sensitive_word') . $qt_error);$set_check = setting_get('tt_check'); if($set_check['user_check']=='1' && $user['OK']!= '1') {message(-1, '您需要等待管理员审核后,才能发表帖子!'); die();} $offer_num = intval(param('offer_num')); $offer_status=param('offer_status'); if($offer_num<0){message(-1,'输入数字不合法!不能为负。');die();} if ($offer_status&& $offer_num>0){ $set_offer = setting_get('tt_offer'); if($user[get_credits_name_by_type($set_offer['credits_type'])] - $offer_num <0) { message(-1, '您好,您的余额不足,无法发表该悬赏!点此充值'); die();} } // todo: $tagids = param('tagid', array(0)); $tagcatemap = $forum['tagcatemap']; foreach($forum['tagcatemap'] as $cate) { $defaulttagid = $cate['defaulttagid']; $isforce = $cate['isforce']; $catetags = array_keys($cate['tagmap']); $intersect = array_intersect($catetags, $tagids); // 比较数组交集 // 判断是否强制 if($isforce) { if(empty($intersect)) { message(-1, '请选择'.$cate['name']); } } } $tid = thread_create($thread, $pid); $pid === FALSE AND message(-1, lang('create_post_failed')); $tid === FALSE AND message(-1, lang('create_thread_failed')); $pnumber = param('readp');$pstatus=param('readp_status'); if ($pstatus&& $pnumber>0) {db_update('thread', array('tid' => $tid), array('readp' => $pnumber));} if(!empty($tid)){ $from_tag = param('fox_tag', ''); !empty($from_tag) AND fox_tag_thread_create($tid, $from_tag); } if ($offer_status&& $offer_num>0){ db_update('user',array('uid'=>$uid),array(get_credits_name_by_type($set_offer['credits_type']).'-'=>$offer_num)); db_insert('user_pay',array('uid'=>$uid,'status'=>1,'num'=>$offer_num,'type'=>16,'credit_type'=>$set_offer['credits_type'],'time'=>time(),'code'=>'')); db_update('thread', array('tid' => $tid), array('offerNum' =>$offer_num,'offerStatus'=>0)); } if($tid && $forum['allowSEO']=='1' && $group['allowSEO']=='1') { $set_seo = setting_get('tt_seo'); if ($set_seo['auto'] == '1') seo_auto_push(array($tid),$uid,$set_seo); if ($set_seo['xzh']=='1') seo_xzh_push(array($tid),$uid,$set_seo,'realtime'); if ($set_seo['mip_ping']=='1') seo_auto_push_mip(array($tid),$uid,$set_seo); if ($set_seo['mip_xzh']=='1') seo_xzh_push_mip(array($tid),$uid,$set_seo); } ipaccess_inc($longip, 'threads'); // todo: /* $tag_cate_id_arr = param('tag_cate_id', array(0)); foreach($tag_cate_id_arr as $tag_cate_id => $tagid) { tag_thread_create($tagid, $tid); } */ $tagids = param('tagid', array(0)); $tagcatemap = $forum['tagcatemap']; foreach($forum['tagcatemap'] as $cate) { $defaulttagid = $cate['defaulttagid']; $isforce = $cate['isforce']; $catetags = array_keys($cate['tagmap']); $intersect = array_intersect($catetags, $tagids); // 比较数组交集 // 判断是否强制 if($isforce) { if(empty($intersect)) { message(-1, '请选择'.$cate['name']); } } // 判断是否默认 if($defaulttagid) { if(empty($intersect)) { array_push($tagids, $defaulttagid); } } } foreach($tagids as $tagid) { $tagid AND tag_thread_create($tagid, $tid); } if($group['allowsell']=="1") { $content_num_status = param('content_num_status'); $content_num = param('content_num');//下面添加 if($content_num < 0 ){//判断购买主题货币值小于零 $content_num = 1;//小于零强制写为一 } $content_type = credits_get_content_type_by_name(param('content_type')); if ($content_num_status && $content_num) db_update('thread', array('tid' => $tid), array('content_buy' => $content_num, 'content_buy_type' => $content_type)); } $update_array = array(); if((($add_credit==1)||($add_credit==0&& $credits<0))&&$credits!=0) $update_array['credits+']=$credits; if((($add_credit==1)||($add_credit==0&& $golds<0))&&$golds!=0) $update_array['golds+']=$golds; if((($add_credit==1)||($add_credit==0&& $rmbs<0))&&$rmbs!=0) $update_array['rmbs+']=$rmbs; $uid AND $update_array AND user_update($uid, $update_array); $uid AND $update_array AND $user['gid']>=100 AND user_update_group($uid); $message = ''; isset($update_array['credits+']) AND $message .= lang('credits1').$credits_op.$credits.' ' ; isset($update_array['golds+']) AND $message .= lang('credits2').$golds_op.$golds.' ' ; isset($update_array['rmbs+']) AND $message .= lang('credits3').$rmbs_op.$rmbs ; message(0, lang('create_thread_sucessfully').' '.$message); message(0, lang('create_thread_sucessfully')); } // 帖子详情 | post detail } else { // thread-{tid}-{page}-{keyword}.htm $tid = param(1, 0); $page = param(2, 1); $keyword = param(3); $pagesize = $conf['postlist_pagesize']; //$pagesize = 10; //$page == 1 AND $pagesize++; ipaccess_inc($longip, 'read_thread'); if( ipaccess_check($longip, 'read_thread') === false ) { message(1,'您今日的查看帖子数量已达到上限。'); } $thread = thread_read($tid); empty($thread) AND message(-1, lang('thread_not_exists')); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) AND message(3, lang('forum_not_exists')); $postlist = post_find_by_tid($tid, $page, $pagesize); empty($postlist) AND message(4, lang('post_not_exists')); if($page == 1) { empty($postlist[$thread['firstpid']]) AND message(-1, lang('data_malformation')); $first = $postlist[$thread['firstpid']]; unset($postlist[$thread['firstpid']]); $attachlist = $imagelist = $filelist = array(); // 如果是大站,可以用单独的点击服务,减少 db 压力 // if request is huge, separate it from mysql server thread_inc_views($tid); } else { $first = post_read($thread['firstpid']); } $keywordurl = ''; if($keyword) { $thread['subject'] = post_highlight_keyword($thread['subject'], $keyword); //$first['message'] = post_highlight_keyword($first['subject']); $keywordurl = "-$keyword"; } $allowpost = forum_access_user($fid, $gid, 'allowpost') ? 1 : 0; $allowupdate = forum_access_mod($fid, $gid, 'allowupdate') ? 1 : 0; $allowdelete = forum_access_mod($fid, $gid, 'allowdelete') ? 1 : 0; forum_access_user($fid, $gid, 'allowread') OR message(-1, lang('user_group_insufficient_privilege')); $pagination = pagination(url("thread-$tid-{page}$keywordurl"), $thread['posts'] + 1, $page, $pagesize); $header['title'] = $thread['subject'].'-'.$forum['name'].'-'.$conf['sitename']; //$header['mobile_title'] = lang('thread_detail'); $header['mobile_title'] = $forum['name'];; $header['mobile_link'] = url("forum-$fid"); $header['keywords'] = ''; $header['description'] = $thread['subject']; $_SESSION['fid'] = $fid; if($page == 1 && $first['user']['gid'] == 7){ if($user['gid'] == 1){ $first['message_fmt'] = $first['message_fmt_fox']; } } $header['title'] = $thread['subject'].' - '.$forum['name'].' - '.$conf['sitename']; $header['keywords'] = !empty($thread['keywords']) ? $thread['keywords'] : ''; $header['description'] = $thread['subject']; $haya_post_info_param = array(); if (isset($haya_post_info_config['show_post_sort']) && $haya_post_info_config['show_post_sort'] == 1 ) { $haya_post_info_post_default_sort = isset($haya_post_info_config['post_default_sort']) ? trim($haya_post_info_config['post_default_sort']) : ''; $haya_post_info_orderby = param('sort', $haya_post_info_post_default_sort); if (!empty($haya_post_info_orderby)) { $haya_post_info_param = array_merge($haya_post_info_param, array('sort' => trim($haya_post_info_orderby))); } } if ((isset($haya_post_info_config['show_see_him']) && $haya_post_info_config['show_see_him'] == 1) || (isset($haya_post_info_config['show_see_first_floor']) && $haya_post_info_config['show_see_first_floor'] == 1) ) { $haya_post_info_see_user = param('user', ''); if (!empty($haya_post_info_see_user)) { $haya_post_info_see_user_id = intval($haya_post_info_see_user); $thread['posts'] = post_count(array( 'tid' => $thread['tid'], 'isfirst' => 0, 'uid' => $haya_post_info_see_user_id, )); $haya_post_info_param = array_merge($haya_post_info_param, array('user' => $haya_post_info_see_user_id)); } } if (!empty($haya_post_info_param)) { $pagination = pagination(url("thread-$tid-{page}$keywordurl", $haya_post_info_param), $thread['posts'] + 1, $page, $pagesize); } if (isset($haya_post_like_config['open_post']) && $haya_post_like_config['open_post'] == 1 ) { $hot_like_post_size = intval($haya_post_like_config['hot_like_post_size']) + 1; $hot_like_post_low_count = intval($haya_post_like_config['hot_like_post_low_count']); $haya_post_like_post_ids = array(); if (!empty($postlist)) { foreach ($postlist as $haya_post_like_post) { $haya_post_like_post_ids[] = $haya_post_like_post['pid']; } } $haya_post_like_life_time = isset($haya_post_like_config['hot_like_life_time']) ? intval($haya_post_like_config['hot_like_life_time']) : 86400; $haya_post_like_hot_posts = haya_post_like_find_hot_posts_by_tid_cache($thread['tid'], $hot_like_post_size, $hot_like_post_low_count, $haya_post_like_life_time); if (!empty($haya_post_like_hot_posts)) { if (isset($haya_post_like_config['hot_like_isfirst']) && $haya_post_like_config['hot_like_isfirst'] == 1 ) { $hot_like_isfirst = true; } else { $hot_like_isfirst = false; } $haya_post_like_hot_post_isfirst = false; foreach ($haya_post_like_hot_posts as $haya_post_like_hot_post_key => $haya_post_like_hot_post) { if ($haya_post_like_hot_post['isfirst'] == 1 && !$hot_like_isfirst) { unset($haya_post_like_hot_posts[$haya_post_like_hot_post_key]); $haya_post_like_hot_post_isfirst = true; } else { $haya_post_like_post_ids[] = $haya_post_like_hot_post['pid']; // 移除楼层 $haya_post_like_hot_posts[$haya_post_like_hot_post_key]['floor'] = ''; } } if (!$haya_post_like_hot_post_isfirst && (count($haya_post_like_hot_posts)) >= $hot_like_post_size) { array_pop($haya_post_like_hot_posts); } } $haya_post_like_pids = haya_post_like_find_by_pids_and_uid($haya_post_like_post_ids, $uid, count($haya_post_like_post_ids)); } if($thread['OK']!='1' && $group['see_check']!='1' && $uid!=$thread['uid']) { if($thread['OK']=='-2'){ message(-1, "本帖正在回收站中,您无权查看!"); die(); } } $spay_url = url('thread-sPay-'.$tid); if($thread['content_buy_type']=='3') {$thread['content_buy']/=100.0;} if($route=='mip') $html_pay='您好,本帖需付费查看,请您点击“查看完整版网页”获取!'; else $html_pay=''; $preg_pay = preg_match_all('/\[ttPay\](.*?)\[\/ttPay\]/s',$first['message_fmt'],$array); $first['purchased']='1'; $content_pay = db_find_one('paylist', array('tid' => $tid, 'uid' => $uid, 'type' => 1)); $is_set=0; if($thread['content_buy']){ if($preg_pay){ $array_count = count($array[0]); for($i=0;$i<$array_count;$i++){ $a = $array[0][$i]; $b = ''; if($content_pay||$thread['uid']==$uid) $first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); elseif($uid && setting_get('tt_vip')['no_credits_see']=='1' && vip__isvip($user['vip_end'])==1) $first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); else $first['message_fmt'] = str_replace($a,$is_set==0?$html_pay:'',$first['message_fmt']); $is_set=1;$first['purchased']='0'; } } }else{ $first['message_fmt'] = str_replace('[ttPay]','',$first['message_fmt']); $first['message_fmt'] = str_replace('[/ttPay]','',$first['message_fmt']); } $gid=isset($user['gid'])?$user['gid']:'0'; $my_p=$group['readp']; $target_p=$thread['readp']; $need_refresh=0; $set_vip = setting_get('tt_vip'); if($uid && $set_vip['up_read']!='0' && vip__isvip($user['vip_end'])) $my_p += $set_vip['up_read']; if(($gid!=1)&& $my_p<$target_p ){ message(-1, jump(lang('dear_p'), http_referer(), 2));die();} $preg_login = preg_match_all('/\[ttlogin\](.*?)\[\/ttlogin\]/s',$first['message_fmt'],$array); if($preg_login) { $array_count = count($array[0]); $html_hide=''; for($i=0;$i<$array_count;$i++){ $a = $array[0][$i]; $b = ''; if($uid)$first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); else $first['message_fmt'] = str_replace($a,$html_hide,$first['message_fmt']); } } $preg_reply = preg_match_all('/\[ttreply\](.*?)\[\/ttreply\]/s',$first['message_fmt'],$array); if($preg_reply) { $array_count = count($array[0]); $html_reply =''; if($uid) $replied=db_find_one('post',array('uid'=>$uid,'tid'=>$thread['tid'])); else $replied=array(); for($i=0;$i<$array_count;$i++){ $a = $array[0][$i]; $b = ''; if($uid AND $replied)$first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); if($uid AND isset($gid) AND $gid==1)$first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); elseif($uid && $set_vip['no_reply_see']!='0' && vip__isvip($user['vip_end']) && vip_getlevel($uid)>=$set_vip['no_reply_see']) $first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); else {$first['message_fmt'] = str_replace($a,$html_reply,$first['message_fmt']);$need_refresh=1;} } } $set = setting_get('tt_read'); if($set&& $set['old']==1) { $preg_reply2 = preg_match_all('/\[reply\](.*?)\[\/reply\]/s',$first['message_fmt'],$array2); if($preg_reply2) { $array2_count = count($array2[0]); $html_reply =''; if($uid) $replied=db_find_one('post',array('uid'=>$uid,'tid'=>$thread['tid'])); else $replied=array(); for($i=0;$i<$array2_count;$i++){ $a = $array2[0][$i]; $b = ''; if($uid AND $replied)$first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); elseif($uid && $set_vip['no_reply_see']!='0' && vip__isvip($user['vip_end']) && vip_getlevel($uid)>=$set_vip['no_reply_see']) $first['message_fmt'] = str_replace($a,$b,$first['message_fmt']); else {$first['message_fmt'] = str_replace($a,$html_reply,$first['message_fmt']);$need_refresh=1;} } } } include _include(APP_PATH.'view/htm/thread.htm'); } ?>