d); } $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配置 // 新增:判断是否为VIP用户(从user_vip表查询,确保精准) $is_vip = false; if ($uid > 0) { $vip_info = db_find_one('user_vip', array('uid' => $uid)); $is_vip = !empty($vip_info) && $vip_info['level'] >= 1 && $vip_info['end'] > time(); } $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 = ''; // 修复:判断是否回帖,需检查查询结果是否存在(新增 isset($replied['pid']) ) $replied = $uid ? db_find_one('post', array('uid' => $uid, 'tid' => $thread['tid'])) : array(); $has_replied = $uid && !empty($replied) && isset($replied['pid']); for ($i = 0; $i < $array_count; $i++) { $a = $array[0][$i]; // 关键修改:将内容框与VIP提示合并为一个div,共用边框和样式 $content = $array[1][$i]; $b = ''; // 闭合内容框,提示与内容共用一个边框 // VIP用户直接显示融合后的内容 if ($is_vip) { $first['message_fmt'] = str_replace($a, $b, $first['message_fmt']); } // 已回复用户/管理员可见(使用修复后的回帖判断) else if ($has_replied) { $first['message_fmt'] = str_replace($a, '', $first['message_fmt']); } else if ($uid && isset($gid) && $gid == 1) { $first['message_fmt'] = str_replace($a, '', $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 = ''; // 修复:判断是否回帖,需检查查询结果是否存在(新增 isset($replied2['pid']) ) $replied2 = $uid ? db_find_one('post', array('uid' => $uid, 'tid' => $thread['tid'])) : array(); $has_replied2 = $uid && !empty($replied2) && isset($replied2['pid']); for ($i = 0; $i < $array2_count; $i++) { $a = $array2[0][$i]; $content = $array2[1][$i]; $b = ''; // VIP用户直接显示融合后的内容 if ($is_vip) { $first['message_fmt'] = str_replace($a, $b, $first['message_fmt']); } // 已回复用户可见(使用修复后的回帖判断) else if ($has_replied2) { $first['message_fmt'] = str_replace($a, '', $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'); } ?>