www.gusucode.com > ShopEx481 & PHPWind 整合版码程序 > bbs/read.php
<?php define('SCR','read'); require_once('global.php'); require_once(R_P.'require/forum.php'); require_once(R_P.'require/bbscode.php'); include_once(D_P.'data/bbscache/cache_read.php'); $fieldadd = $tablaadd = $sqladd = $fastpost = $special = $ifmagic = $urladd = ''; if (is_array($customfield)) { foreach ($customfield as $key => $value) { $fieldadd .= ',mb.field_'.(int)$value['id']; } } if ($db_union) { $db_union = explode("\t",stripslashes($db_union)); $db_union[0] && $db_hackdb = array_merge((array)$db_hackdb,(array)unserialize($db_union[0])); } $showfield = array(); $custominfo = $db_union[7] ? (array)unserialize($db_union[7]) : array(); foreach ($custominfo as $key=>$val) { if (substr($val[3],2,1)=='1') { $showfield[] = $key; } } if (!empty($showfield)) { $fieldadd .= ",mb.customdata"; } $fieldadd && $tablaadd = "LEFT JOIN pw_memberinfo mb ON mb.uid=t.authorid"; InitGP(array('fpage','page','uid','toread')); if ($page>1) { $S_sql = $J_sql = ''; } else { $page<1 && $page!='e' && $page=1; $start_limit = 0; $pw_tmsgs = GetTtable($tid); $S_sql = ',tm.*,m.uid,m.username,m.gender,m.oicq,m.groupid,m.memberid,m.icon AS micon ,m.hack,m.honor,m.signature,m.showsign,m.regdate,m.signchange,m.medals,m.payemail,md.postnum,md.digests,md.rvrc,md.money,md.credit,md.currency,md.thisvisit,md.lastvisit,md.onlinetime,md.starttime'; $J_sql = "LEFT JOIN $pw_tmsgs tm ON t.tid=tm.tid LEFT JOIN pw_members m ON m.uid=t.authorid LEFT JOIN pw_memberdata md ON md.uid=t.authorid"; } $read = $db->get_one("SELECT t.* $S_sql $fieldadd FROM pw_threads t $J_sql $tablaadd WHERE t.tid='$tid'"); !$read && Showmsg('illegal_tid'); if ($read['ifmagic'] && $db_windmagic) { $ifmagic = 1; list($magicid,$magicname) = explode("\t",$read['magic']); } $fpage = (int)$fpage; $fid = $read['fid']; $ptable = $read['ptable']; $ifcheck = $read['ifcheck']; $pw_posts = GetPtable($ptable); $advertdb = AdvertInit(SCR,$fid); if (is_array($advertdb['header'])) { $header_ad = $advertdb['header'][array_rand($advertdb['header'])]['code']; } if (is_array($advertdb['footer'])) { $footer_ad = $advertdb['footer'][array_rand($advertdb['footer'])]['code'].'<br />'; } list($db_moneyname,$db_moneyunit,$db_rvrcname,$db_rvrcunit,$db_creditname,$db_creditunit)=explode("\t",$db_credits); $foruminfo = $db->get_one("SELECT * FROM pw_forums f LEFT JOIN pw_forumsextra fe USING(fid) WHERE f.fid='$fid'"); !$foruminfo && Showmsg('data_error'); $forumset = unserialize($foruminfo['forumset']); wind_forumcheck($foruminfo); $subject = $read['subject']; $authorid = $read['authorid']; list(,,$downloadmoney,$downloadimg) = explode("\t",$forumset['uploadset']); if (!$foruminfo['allowvisit'] && $gp_allowread==0 && $_COOKIE) { Showmsg('read_group_right'); } unset($advertdb['header'],$advertdb['footer'],$db_advertdb,$S_sql,$J_sql,$foruminfo['forumset']); $rewardtype = null; /*** 悬赏 ***/ if (CkInArray($windid,$manager) || admincheck($foruminfo['forumadmin'],$foruminfo['fupadmin'],$windid)) { $admincheck = 1; } else { $admincheck = 0; } !$windid && $admincheck=0; if ($foruminfo['allowread'] && !$admincheck && !allowcheck($foruminfo['allowread'],$groupid,$winddb['groups'])) { Showmsg('forum_read_right'); } if ($groupid != 3 && !$admincheck && !$foruminfo['allowvisit']) { forum_creditcheck(); } if ($groupid != 3 && !$admincheck && $forumset['forumsell']) { forum_sell($fid); } if ($read['ifcheck']==0 && !$admincheck && !$SYSTEM['viewcheck'] && $windid!=$read['author']) { Showmsg('read_check'); } if ($read['locked']%3==2 && !$admincheck && !$SYSTEM['viewclose']) { Showmsg('read_locked'); } if ($winddb['p_num']) { $db_readperpage = $winddb['p_num']; } elseif ($forumset['readnum']) { $db_readperpage = $forumset['readnum']; } if (is_numeric($uid) && $read['replies']>0) { $rt = $db->get_one("SELECT COUNT(*) AS n FROM $pw_posts WHERE tid='$tid' AND authorid='$uid' AND anonymous='0' AND ifcheck='1'"); $read['replies'] = $rt['n']; $sqladd = "AND authorid='$uid' AND anonymous='0'"; $urladd = "&uid=$uid"; } $count = $read['replies']+1; $numofpage = ceil($count/$db_readperpage); if ($page=='e' || $page>$numofpage) { $numofpage==1 && $page>1 && ObHeader("read.php?tid=$tid&page=1&toread=$toread"); $page=$numofpage; } list($guidename,$forumtitle) = getforumtitle(forumindex($foruminfo['fup'])); $guidename .= " » <a href=\"read.php?tid=$tid\">$subject</a>"; $forumtitle = "|$forumtitle"; $db_metakeyword = "$subject".str_replace(array('|',' - '),',',$forumtitle).'phpwind'; $read['content'] && $db_metadescrip = substrs(strip_tags(str_replace('"','"',$read['content'])),50);//提取内容描述 require_once(R_P.'require/header.php'); require_once(R_P.'require/showimg.php'); Update_ol(); $readdb = array(); $authorids = $tpc_ifview = ''; /*** 控制隐藏帖次数 ***/ if ($read['special']==1 && ($foruminfo['allowtype'] & 2) && ($page==1 || $numofpage==1)) { require_once(R_P.'require/readvote.php'); } elseif ($read['special']==2 && ($foruminfo['allowtype'] & 4) && ($page==1 || $numofpage==1)) { require_once(R_P.'require/readact.php'); } elseif ($read['special']==3 && ($foruminfo['allowtype'] & 8)) { require_once(R_P.'require/readrew.php'); } if ($db_replysitemail && $read['authorid']==$winduid && $read['ifmail']==4) { $rt = $db->get_one("SELECT replyinfo FROM pw_memberinfo WHERE uid='$winduid'"); $rt['replyinfo'] = str_replace(",$tid,",',',$rt['replyinfo']); if ($rt['replyinfo'] == ',') { $winddb['newrp'] && $db->update("UPDATE pw_members SET newrp=0 WHERE uid='$winduid'"); $rt['replyinfo'] = ''; } $db->update("UPDATE pw_memberinfo SET replyinfo='$rt[replyinfo]' WHERE uid='$winduid'"); $db->update("UPDATE pw_threads SET ifmail='2' WHERE tid='$tid'"); } if ($page == 1) { if ($foruminfo['allowhtm'] == 1) { $htmurl = $db_htmdir.'/'.$fid.'/'.date('ym',$read['postdate']).'/'.$read['tid'].'.html'; } if ($foruminfo['allowhtm']==1 && !$foruminfo['cms'] && !$toread && file_exists(R_P.$htmurl)) { ObHeader("$R_url/$htmurl"); } $read['pid'] = 'tpc'; $readdb[] = viewread($read,0); $authorids = $read['authorid']; } $pages = numofpage($count,$page,$numofpage,"read.php?tid=$tid&fpage=$fpage&toread=$toread{$urladd}&"); $tpc_locked = $read['locked']%3<>0 ? 1 : 0; if (!$db_hithour) { $db->update("UPDATE pw_threads SET hits=hits+1 WHERE tid='$tid'"); } else { writeover(D_P."data/bbscache/hits.txt",$tid."\t",'ab'); } /*** 帖子浏览记录 ***/ $readlog = str_replace(",$tid,",',',GetCookie('readlog')); $readlog.= ($readlog ? '' : ',').$tid.','; substr_count($readlog,',')>11 && $readlog = preg_replace("/[\d]+\,/i",'',$readlog,3); Cookie('readlog',$readlog); $favortitle= str_replace(array("'","'","\"","\\"),array("‘","\\'","\\\"","\\\\"),$subject); list($msg_guide,$forumlist) = headguide($guidename); unset($fourm,$guidename); $db_bbsname_a = addslashes($db_bbsname);//模版内用到 if ($read['replies']>0) { $readnum = $db_readperpage; $pageinverse = $page>20 && $page>ceil($numofpage/2) ? true : false; if ($pageinverse) { $start_limit = $count-$page*$db_readperpage; $order = $rewardtype != null ? "ifreward ASC,postdate DESC" : "postdate DESC"; } else { $start_limit = ($page-1)*$db_readperpage-1; $order = $rewardtype != null ? "ifreward DESC,postdate" : "postdate"; } if ($start_limit < 0) { $readnum += $start_limit; $start_limit = 0; } $query = $db->query("SELECT t.*,m.uid,m.username,m.gender,m.oicq,m.groupid,m.memberid,m.icon AS micon,m.hack,m.honor,m.signature,m.regdate,m.signchange,m.medals,m.showsign,m.payemail,md.postnum,md.digests,md.rvrc,md.money,md.credit,md.currency,md.thisvisit,md.lastvisit,md.onlinetime,md.starttime $fieldadd FROM $pw_posts t LEFT JOIN pw_members m ON m.uid=t.authorid LEFT JOIN pw_memberdata md ON md.uid=t.authorid $tablaadd WHERE t.tid='$tid' AND t.ifcheck='1' $sqladd ORDER BY $order LIMIT $start_limit, $readnum"); $pageinverse && $start_limit = $count-$start_limit; $fbpid = array(); while ($read = $db->fetch_array($query)) { $pageinverse ? $start_limit-- : $start_limit++; $readdb[] = viewread($read,$start_limit); $authorids .= $authorids ? ','.$read['authorid'] : $read['authorid']; } $db->free_result($query); $pageinverse && $readdb = array_reverse($readdb); foreach ($fbpid as $key=>$val) { $sqladd = strpos($val,',')!==false ? "IN($val)" : "='$val'"; $db->update("UPDATE $pw_posts SET ifwordsfb='$key' WHERE pid $sqladd"); } } unset($sign,$ltitle,$lpic,$lneed,$gp_right,$_MEDALDB,$fieldadd,$tablaadd,$read,$order,$readnum,$pageinverse); if ($db_showcolony && $authorids) { $colonydb = array(); $query = $db->query("SELECT c.uid,cy.id,cy.cname FROM pw_cmembers c LEFT JOIN pw_colonys cy ON cy.id=c.colonyid WHERE c.uid IN($authorids) AND c.ifadmin!='-1'"); while ($rt = $db->fetch_array($query)) { if (!$colonydb[$rt['uid']]) { $colonydb[$rt['uid']] = $rt; } } $db->free_result($query); } if ($db_showcustom && $authorids) { $customdb = array(); $cids = $add = ''; foreach ($_CREDITDB as $key=>$value) { if (strpos($db_showcustom,",$key,")!==false) { $cids .= $add.$key; !$add && $add = ','; } } if ($cids) { $query = $db->query("SELECT uid,cid,value FROM pw_membercredit WHERE uid IN($authorids) AND cid IN($cids)"); while ($rt = $db->fetch_array($query)) { $customdb[$rt['uid']][$rt['cid']] = $rt['value']; } $db->free_result($query); } } if ($groupid!='guest' && !$tpc_locked) { $psot_sta = 'reply';//control the faster reply $titletop1= substrs('Re:'.str_replace(' ',' ',$subject),$db_titlemax-2); $fastpost = 'fastpost'; $db_forcetype = 0; } $db_menuinit .= ",'td_post' : 'menu_post','td_post1' : 'menu_post'"; //allowtype onoff if ($foruminfo['allowtype'] && (($foruminfo['allowtype'] & 1) || ($foruminfo['allowtype'] & 2 && $gp_allownewvote) || ($foruminfo['allowtype'] & 4 && $gp_allowactive) || ($foruminfo['allowtype'] & 8 && $_G['allowreward'])|| ($foruminfo['allowtype'] & 16))) { $N_allowtypeopen = true; } else { $N_allowtypeopen = false; } require_once(PrintEot('read'));footer(); function viewread($read,$start_limit) { global $SYSTEM,$_G,$groupid,$admincheck,$attach_url,$winduid,$tablecolor,$tpc_author,$tpc_buy,$tpc_pid,$tpc_tag,$tpc_att,$count,$timestamp,$db_onlinetime,$attachdir,$attachpath,$gp_allowloadrvrc,$readcolorone,$readcolortwo,$lpic,$ltitle,$imgpath,$db_ipfrom,$db_showonline,$stylepath,$db_windpost,$db_windpic,$db_signwindcode,$fid,$tid,$pid,$attachments,$aids,$md_ifopen,$_MEDALDB,$rewardtype,$db_shield,$gp_allowdownload,$db_wordsfb,$db_iftag; $read['lou'] = $start_limit; $read['jupend'] = $start_limit==$count-1 ? "<a name=a></a><a name=$read[pid]></a>" : "<a name=$read[pid]></a>"; $tpc_buy = $read['buy']; $tpc_pid = $read['pid']; $tpc_tag = NULL; $tpc_att = 1; $read['ifsign']<2 && $read['content'] = str_replace("\n","<br />",$read['content']); $anonymous=($read['anonymous']&&!$SYSTEM['viewhide']&&!$admincheck&&$winduid!=$read['authorid']) ? 1 : 0; if ($read['groupid'] && !$anonymous) { $read['groupid']=='-1' && $read['groupid']=$read['memberid']; !array_key_exists($read['groupid'],(array)$lpic) && $read['groupid'] = 8; $read['lpic'] = $lpic[$read['groupid']]; $read['level'] = $ltitle[$read['groupid']]; $read['regdate'] = get_date($read['regdate'],"Y-m-d"); $read['lastlogin'] = get_date($read['lastvisit'],"Y-m-d"); $read['aurvrc'] = floor($read['rvrc']/10); $read['author'] = $read['username']; $tpc_author = $read['author']; if (!empty($GLOBALS['showfield'])) { $customdata = $read['customdata'] ? (array)unserialize($read['customdata']) : array(); $read['customdata'] = array(); foreach ($customdata as $key=>$val) { if ($val && in_array($key,$GLOBALS['showfield'])) { $read['customdata'][$key] = $val; } } } $read['ipfrom'] = $db_ipfrom == 1 && $_G['viewipfrom'] ? ' From:'.$read['ipfrom'] : ''; if ($SYSTEM['viewip']==1 || ($admincheck && $SYSTEM['viewip']==2)) { $read['ip'] = "IP:$read[userip] |"; } $read['ontime'] = (int)($read['onlinetime']/3600); $read['groupid']==6 && $read['honor'] = ''; if ($read['groupid']<>6 && ($read['ifsign']==1 || $read['ifsign']==3)) { global $sign; if (!$sign[$read['author']]) { global $db_signmoney,$db_signgroup,$tdtime,$db_signcurtype; $curvalue = $db_signcurtype=='rvrc' ? $read['aurvrc'] : $read[$db_signcurtype]; if (strpos($db_signgroup,",$read[groupid],") !== false && $db_signmoney && (!$read['showsign'] || (!$read['starttime'] || $curvalue < (($tdtime-$read['starttime'])/86400)*$db_signmoney))) { $read['signature'] = ''; } else { if ($db_signwindcode && $read['signchange']==2) { if ($gp_right[$read['groupid']]['imgwidth'] && $gp_right[$read['groupid']]['imgheight']) { $db_windpic['picwidth'] = $gp_right[$read['groupid']]['imgwidth']; $db_windpic['picheight'] = $gp_right[$read['groupid']]['imgheight']; } if ($gp_right[$read['groupid']]['fontsize']) { $db_windpic['size'] = $gp_right[$read['groupid']]['fontsize']; } $read['signature'] = convert($read['signature'],$db_windpic,2); } $read['signature'] = str_replace("\n","<br />",$read['signature']); } $sign[$read['author']] = $read['signature']; } else { $read['signature'] = $sign[$read['author']]; } } else { $read['signature'] = ''; } } else { $read['lpic'] = '8'; $read['level'] = $read['digests'] = $read['postnum'] = $read['money'] = '*'; $read['aurvrc'] = $read['lastlogin'] = $read['credit'] = $read['regdate'] = '*'; $read['honor'] = $read['signature'] = $read['micon'] = ''; if ($anonymous) { $read['payemail'] = $read['oicq'] = $read['ip'] = $read['medals'] = $read['ipfrom'] = ''; $read['author'] = $GLOBALS['db_anonymousname']; $read['authorid'] = 0; foreach ($GLOBALS['customfield'] as $key=>$val) { $field="field_".(int)$val['id']; $read[$field] = '*'; } } } $read['face'] = showfacedesign($read['micon']); $read['postdate'] = get_date($read['postdate']); $read['mark'] = $read['reward'] = $read['tag'] = NULL; if ($read['ifmark']) { $markdb = explode("\t",$read['ifmark']); foreach ($markdb as $key=>$value) { $read['mark'] .= "<li>$value</li>"; } } if ($rewardtype != null) { if ($read['lou']==0 || $read['ifreward']>0 || ($rewardtype=='0' && $winduid==$GLOBALS['authorid'] && $winduid!=$read['authorid'])) { $read['reward'] = Getrewhtml($read['lou'],$read['ifreward'],$read['pid']); } } if ($read['icon']) { $read['icon'] = "<img src=\"$imgpath/post/emotion/$read[icon].gif\" align=\"left\" border=\"0\" />"; } else{ $read['icon'] = ''; } if ($md_ifopen && $read['medals']) { $medals = ''; $md_a = explode(',',$read['medals']); foreach ($md_a as $key=>$value) { if ($value) $medals .= "<img src=\"hack/medal/image/{$_MEDALDB[$value][picurl]}\" alt=\"{$_MEDALDB[$value][name]}\"> "; } $read['medals'] = $medals.'<br />'; } else { $read['medals'] = ''; } $read['leaveword'] && $read['content'] .= leaveword($read['leaveword'],$read['pid']); if ($db_iftag && $read['tags']) { list($tagdb,$tpc_tag) = explode("\t",$read['tags']); $tagdb = explode(' ',$tagdb); foreach ($tagdb as $key=>$tag) { $tag && $read['tag'] .= "<a href=\"job.php?action=tag&tagname=".rawurlencode($tag)."\"><span class=\"s3\">$tag</span></a> "; } } if ($read['ifshield'] || $read['groupid'] == 6 && $db_shield) { if ($read['ifshield'] == 2) { $read['content'] = shield('shield_del_article'); $read['subject'] = ''; $tpc_att = 0; } else { if ($groupid == '3') { $read['subject'] = shield('shield_title'); } else { $read['content'] = shield($read['ifshield'] ? 'shield_article' : 'ban_article'); $read['subject'] = ''; $tpc_att = 0; } } $read['icon'] = ''; } else { $read['ifwordsfb']!=$db_wordsfb && $read['content'] = wordsfb($read['content'],$read['ifwordsfb']); if ($read['ifconvert']==2) { $read['content'] = convert($read['content'],$db_windpost); } else { $tpc_tag && $read['content'] = relatetag($read['content'],$tpc_tag); strpos($read['content'],'[s:')!==false && $read['content'] = showface($read['content']); } } $GLOBALS['foruminfo']['copyctrl'] && $read['content'] = preg_replace("/<br \/>/eis","copyctrl()",$read['content']); if ($read['aid'] && $tpc_att) { $attachments = array(); $attachs = unserialize(stripslashes($read['aid'])); $read['ifhide']>0 && ifpost($tid)==1 && $read['ifhide'] = 0; if (is_array($attachs) && $read['ifhide']==0) { if ($winduid==$read['authorid'] || $admincheck || ($groupid!=5 && $SYSTEM['delattach'])) { $dfadmin=1; } else { $dfadmin=0; } foreach ($attachs as $at) { if ($at['type']=='img' && $at['needrvrc']==0 && (!$GLOBALS['downloadimg'] || !$GLOBALS['downloadmoney'] || $gp_allowdownload==2)) { $a_url = geturl($at['attachurl'],'show'); if (is_array($a_url)) { $dfurl='<br>'.cvpic($a_url[0],1,$db_windpost['picwidth'],$db_windpost['picheight'],$at['ifthumb']); $read['pic'][$at['aid']]=array($at['aid'],$dfurl,$dfadmin,$at['desc']); $attachments[$at['aid']]="<b>$at[desc]</b>$dfurl"; } elseif ($a_url=='imgurl') { $read['picurl'][$at['aid']]['0']=$attachments[$at['aid']]="<a href=\"job.php?action=showimg&tid={$tid}&pid={$read[pid]}&fid={$fid}&aid={$at[aid]}&verify=".md5("showimg{$tid}{$read[pid]}{$fid}{$at[aid]}{$GLOBALS[db_hash]}")."\" target=\"_blank\">$at[name]</a>"; $read['picurl'][$at['aid']]['1']=$dfadmin; } } else { $read['downattach'][$at['aid']] = array($at['aid'], $at['name'], $at['size'], $at['hits'], $at['needrvrc'], $at['type'], $dfadmin, $at['desc']); $attachments[$at['aid']] = "<a href='job.php?action=download&pid=$read[pid]&tid=$tid&aid=$at[aid]' target='_blank' title='文件大小:$at[size] K\n下载次数:$at[hits]'>$at[name]</a>"; $at['desc'] && $attachments[$at['aid']] = "<b>$at[desc]</b><br>".$attachments[$at['aid']]; } } $aids = array(); $read['content'] = attachment($read['content']); foreach ($aids as $key => $value) { if ($read['pic'][$value]) { unset($read['pic'][$value]); } if ($read['downattach'][$value]) { unset($read['downattach'][$value]); } if ($read['picurl'][$value]) { unset($read['picurl'][$value]); } } } } /** * convert the post content */ $read['alterinfo'] && $read['content'].="<div id=\"alert_$read[pid]\" style=\"color:gray;margin-top:30px\">[ $read[alterinfo] ]</div>"; if ($read['remindinfo']) { $remind = explode("\t",$read['remindinfo']); $remind[0] = str_replace("\n","<br />",$remind[0]); $remind[2] && $remind[2] = get_date($remind[2]); $read['remindinfo'] = $remind; } if ($_GET['keyword']) { $keywords = explode("|",$_GET['keyword']); foreach ($keywords as $key => $value) { if ($value) $read['content'] = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($value,'/').")([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$)/siU","<u><font color=\"red\">\\1</font></u>\\2",$read['content']); } } return $read; } ?>