()))-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 = param('subject'); 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, ); $jp=param('jp');$sj=param('sj');$xnjp=param('xnjp');$prizecount=param('prizecount'); $arrlist = db_find_one('thread',array('subject'=>$subject)); if(!empty($arrlist)) { message(-1, '此标题已被使用,请换一个试试吧!'); }$set_check = setting_get('tt_check'); if($set_check['user_check']=='1' && $user['OK']!= '1') {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));}$cjid = setting_get('cjid'); if($uid==$cjid){ db_update('thread',array('tid'=>$tid),array('jp'=>$jp,'sj'=>$sj,'xnjp'=>$xnjp,'prize'=>1,'prizecount'=>$prizecount));}$client_type = 'android_web'; // 默认值是 web $ua = strtolower($_SERVER['HTTP_USER_AGENT']); // 获取并转换为小写 if (strpos($ua, 'iphone') !== false || strpos($ua, 'ipad') !== false) { $client_type = 'iphone_web'; // 苹果手机网页端 } elseif (strpos($ua, 'android') !== false && strpos($ua, 'mobile') !== false) { $client_type = 'android_web'; // 安卓手机网页端 } elseif (strpos($ua, 'windows nt') !== false || strpos($ua, 'macintosh') !== false) { $client_type = 'pc_web'; // 电脑网页端 } else { $client_type = 'unknown'; // 未知设备 } thread_update($tid, array('client_type_t'=>$client_type)); if (!isset($till_rss_setting)) { $till_rss_setting = setting_get('till_rss_setting'); } if ($till_rss_setting['update_on_thread_create']) { if (!isset($forumlist_for_rss)) { $forumlist = forum_list_cache(); $forumlist_for_rss = forum_list_access_filter($forumlist, 0); } till_rss_generate_homepage($forumlist_for_rss, $till_rss_setting['rss_items'], $till_rss_setting['summary_length'], true); till_rss_generate_forums([$forum], $till_rss_setting['rss_items'], $till_rss_setting['summary_length'], true); }$isviponly=param('VIPonly');$isviponlyA=param('VIPonlyA'); if ($isviponly) db_update('thread', array('tid' => $tid), array('VIPonly' => $isviponly)); if ($isviponlyA) db_update('thread', array('tid' => $tid), array('VIPonlyA' => $isviponlyA));$pconfig = kv_get('xiuno_top_viewsrand'); $open_plugin= $pconfig['open_plugin']; $view_min = $pconfig['view_min']; $view_max = $pconfig['view_max']; $view_rand=rand($view_min,$view_max); db_update('thread', array('tid'=>$tid), array('views'=>$view_rand)); // 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); } $tagids_str = implode(',', array_diff($tagids, array(0))); thread_update($tid, array('tagids'=>$tagids_str, 'tagids_time'=>$time)); 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++; $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; $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']=='0') message(-1, "本帖正在审核中,您无权查看!"); elseif($thread['OK']=='-1') message(-1, "本帖未审核通过,您无权查看!"); elseif($thread['OK']=='-2') message(-1, "本帖正在回收站中,您无权查看!"); die(); } $spay_url = url('thread-sPay-'.$tid); if ($thread['content_buy_type'] == '3') { $thread['content_buy'] /= 1; } // 检查VIP状态和权限 $is_vip_free = false; if(function_exists('vip_isvip') && function_exists('vip_getlevel')) { $set_vip = setting_get('wiki_vip'); // 检查用户是否为VIP且满足免费查看付费内容的等级要求 if(!empty($user) && !empty($set_vip['no_credits_see']) && $set_vip['no_credits_see'] != '0') { $user_is_vip = vip_isvip($uid); $user_vip_level = vip_getlevel($uid); $required_level = intval($set_vip['no_credits_see']); if($user_is_vip && $user_vip_level >= $required_level) { $is_vip_free = true; } } } if ($route == 'mip') { $html_pay = '您好,本帖含有付费内容,请您点击下方"查看完整版网页"获取!'; } else { $vip_hint = ''; if(function_exists('vip_isvip') && !$is_vip_free) { $set_vip = setting_get('wiki_vip'); if(!empty($set_vip['no_credits_see']) && $set_vip['no_credits_see'] != '0') { $required_level = intval($set_vip['no_credits_see']); $vip_hint = '
VIP'.$required_level.'级以上用户可免费查看付费内容
'; } } $html_pay = '
'.$conf['sitename'].' - '.lang("purchase").'
'.lang("have_pay").' '.$thread['content_buy'].lang('credits'.$thread['content_buy_type']).' '.lang("after_see").'
'.$vip_hint.'
'; } $preg_pay = preg_match_all('/\[ttPay\](.*?)\[\/ttPay\]/is', $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 = '
'.$conf['sitename'].' - '.lang("see_paid").'
查看购买记录

'.$array[1][$i].'
'; if ($content_pay || $thread['uid'] == $uid || $is_vip_free) { // 如果是VIP用户免费查看,添加特殊标识 if($is_vip_free && !$content_pay && $thread['uid'] != $uid) { $vip_notice = '
VIP专享:您正在免费查看付费内容
'; $b = str_replace('
', $vip_notice.'
', $b); } $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'; $group = isset($group) ? $group : array('readp' => 0); $my_p = $group['readp']; $thread = isset($thread) ? $thread : array('readp' => 0, 'tid' => 0); $target_p = $thread['readp']; $need_refresh = 0; $uid = isset($uid) ? $uid : 0; $first = isset($first) ? $first : array('message_fmt' => ''); $set_vip = isset($set_vip) ? $set_vip : array('no_reply_see' => 0); // 初始化VIP配置 $set_vip = setting_get('wiki_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) { // 兼容框架函数,避免未定义导致页面崩溃 if (function_exists('message') && function_exists('jump') && function_exists('lang') && function_exists('http_referer')) { message(-1, jump(lang('dear_p'), http_referer(), 2)); } else { echo '权限不足,即将返回'; header("Refresh:2;url=" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/')); } die(); } // 处理[ttlogin]标签(保留原逻辑,确保图标正常) $preg_login = preg_match_all('/\[ttlogin\](.*?)\[\/ttlogin\]/i', $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 = ''; $first['message_fmt'] = $uid ? str_replace($a, $b, $first['message_fmt']) : str_replace($a, $html_hide, $first['message_fmt']); } } // 处理[ttreply]标签(添加VIP提示,保留原权限逻辑) $preg_reply = preg_match_all('/\[ttreply\](.*?)\[\/ttreply\]/i', $first['message_fmt'], $array); if ($preg_reply) { $array_count = count($array[0]); // 构建VIP提示内容(按需求添加在dear_reply后,带换行和样式) $vipHtml = '
VIP ' . $set_vip['no_reply_see'] . '级及以上用户可免回复查看 '; if ($uid > 0) { $modalUrl = function_exists('url') ? url('my-wiki_vip_open') : '/my-wiki_vip_open'; $vipHtml .= ''; } else { $loginUrl = function_exists('url') ? url('user-login') : '/user-login'; $vipHtml .= ' 开通会员 '; } $vipHtml .= ''; // 拼接原提示与VIP内容 $html_reply = ''; $replied = $uid ? db_find_one('post', array('uid' => $uid, 'tid' => $thread['tid'])) : array(); for ($i = 0; $i < $array_count; $i++) { $a = $array[0][$i]; $b = ''; // 保留原双重判断逻辑(已回复/管理员可见) if ($uid && $replied) { $first['message_fmt'] = str_replace($a, $b, $first['message_fmt']); } if ($uid && isset($gid) && $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; } } } // 处理旧版[reply]标签(同步添加VIP提示,保留原逻辑) $set = function_exists('setting_get') ? setting_get('tt_read') : array(); if ($set && $set['old'] == 1) { $preg_reply2 = preg_match_all('/\[reply\](.*?)\[\/reply\]/i', $first['message_fmt'], $array2); if ($preg_reply2) { $array2_count = count($array2[0]); // 同ttreply标签的VIP提示内容 $vipHtml2 = '
VIP ' . $set_vip['no_reply_see'] . '级及以上用户可免回复查看 '; if ($uid > 0) { $modalUrl2 = function_exists('url') ? url('my-wiki_vip_open') : '/my-wiki_vip_open'; $vipHtml2 .= ''; } else { $loginUrl2 = function_exists('url') ? url('user-login') : '/user-login'; $vipHtml2 .= ' 开通会员 '; } $vipHtml2 .= ''; $html_reply2 = ''; $replied2 = $uid ? db_find_one('post', array('uid' => $uid, 'tid' => $thread['tid'])) : array(); for ($i = 0; $i < $array2_count; $i++) { $a = $array2[0][$i]; $b = ''; if ($uid && $replied2) { $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_reply2, $first['message_fmt']); $need_refresh = 1; } } } } if($thread['VIPonly']) { if (empty($user)) { message(-1, jump("您好,请先登录!", url('my-credits'), 5)); die(); } if ($user['gid'] != 1 && !(vip__isvip($user['vip_end']))) { message(-1, jump("您好,本帖为VIP专属帖子,仅限VIP用户查看,请您开通VIP后查看!", url('my-credits'), 5)); die(); } } if($page == 1 && $first['user']['gid'] == 7){ if($user['gid'] == 1){ $first['message_fmt'] = $first['message_fmt_wiki']; } } // 插入访客信息 if($user['uid']) { $logid = db_find_one('zz_iqismart_viewlog', array('uid' => $user['uid'], 'tid' => $tid)); if($logid) { db_update('zz_iqismart_viewlog', array('uid' => $user['uid'], 'tid' => $tid), array('dateline' => $time)); } else { db_insert('zz_iqismart_viewlog', array('uid' => $user['uid'], 'username' => $user['username'], 'tid' => $tid, 'dateline' => $time)); } } $viewlog = kv_get('zz_iqismart_viewlog'); if($viewlog['days']) { $deletetime = $time - $viewlog['days'] * 86400; $tablepre = $db->tablepre; db_exec('delete from '.$tablepre.'zz_iqismart_viewlog where dateline <='.$deletetime); } $logs = db_find('zz_iqismart_viewlog', array('tid' => $tid), array('dateline' => -1), 1, $viewlog['maxnum']); $logs_count = db_count('zz_iqismart_viewlog', array('tid' => $tid)); include _include(APP_PATH.'view/htm/thread.htm'); } ?>