$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'); } ?>