www.gusucode.com > ShopEx481 & PHPWind 整合版码程序 > bbs/new.php
<?php /* ************************************************************************** * * PHPWind 首页调用 * * $color : 标题后增加显示信息颜色,例如作者,时间,点击数 * $prefix : 标题前字符,可以用图片 : <img src="http://bbs.phpwind.net/pre.gif" border="0"> * ************************************************************************** */ require_once('global.php'); ob_end_clean(); $db_obstart && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start(); $color = '#666666'; $prefix = array('<li>','◇','·','○','●','- ','□-'); $per = $db_jsper; $REFERER = parse_url($_SERVER['HTTP_REFERER']); include(GetLang('other')); if(!$db_jsifopen){ exit("document.write(\"$lang[js_close]\");"); } if($db_bindurl && $_SERVER['HTTP_REFERER'] && strpos(",$db_bindurl,",",$REFERER[host],") === false){ exit("document.write(\"$lang[bindurl]\");"); } InitGP(array('action')); if($action == 'forum'){ include_once(D_P.'data/bbscache/forum_cache.php'); InitGP(array('pre','fidin')); $pre = is_numeric($pre) ? $prefix[$pre] : $prefix[0]; $fids = explode('_',$fidin); $foruminfo = ''; foreach($fids as $key => $value){ if(is_numeric($value)){ $foruminfo .= "$pre <a href='$db_bbsurl/thread.php?fid=$value' target='_blank'>".$forum[$value]['name']."</a><br>"; } } echo "document.write(\"$foruminfo\");"; } elseif($action == 'notice'){ InitGP(array('pre','num','length')); $cachefile = D_P."data/bbscache/new_{$action}_".md5($action.(int)$pre.(int)$num.(int)$length); if($timestamp - @filemtime($cachefile) >= $per){ $pre = is_numeric($pre) ? $prefix[$pre] : $prefix[0]; $num = is_numeric($num) ? $num : 5; $length = is_numeric($length) ? $length : 35; $noticedb = ''; $query = $db->query("SELECT aid,subject,startdate FROM pw_announce WHERE fid='-1' ORDER BY vieworder,startdate DESC LIMIT $num"); while($rt = $db->fetch_array($query)){ $startdate = $date ? '('.gmdate('Y-m-d H:i',$rt['startdate']+8*3600).')' : ''; $noticedb .= "$pre <a href='$db_bbsurl/notice.php?fid=-1#$rt[aid]' target='_blank'>".substrs(preg_replace("/\<(.+?)\>/eis",'',$rt['subject']),$length)."</a>$startdate<br>"; } $noticedb = str_replace('"','\"',$noticedb); $noticedb = "document.write(\"$noticedb\");"; echo $noticedb; writeover($cachefile,$noticedb); } else { @readfile($cachefile); } } elseif($action == 'info'){ InitGP(array('pre','member','article','yesterday','online')); $cachefile = D_P."data/bbscache/new_{$action}_".md5($action.(int)$pre.(int)$member.(int)$article.(int)$yesterday.(int)$online); if($timestamp - @filemtime($cachefile) >= $per){ $pre = is_numeric($pre) ? $prefix[$pre] : $prefix[0]; $bbsinfo = $db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1"); if($bbsinfo['tdtcontrol']!=$tdtime){ if($db_hostweb == 1){ $rt=$db->get_one("SELECT SUM(fd.tpost) as tposts FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.cms!='1'"); $db->update("UPDATE pw_bbsinfo SET yposts='$rt[tposts]',tdtcontrol='$tdtime' WHERE id=1"); $db->update("UPDATE pw_forumdata SET tpost=0 WHERE tpost<>'0'"); } } $info = ''; if($member){ $info .= "$pre $lang[js_totalmember]:$bbsinfo[totalmember]<br>$pre $lang[js_newmember]:$bbsinfo[newmember]<br>"; } if($article){ $rs = $db->get_one("SELECT SUM(fd.topic) as topic,SUM(fd.subtopic) as subtopic,SUM(fd.article) as article,SUM(fd.tpost) as tposts FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.cms!='1'"); $topic = $rs['topic'] + $rs['subtopic']; $article = $rs['article']; $info .= "$pre $lang[js_topic]:$topic<br>$pre $lang[js_article]:$article<br>"; } if($yesterday){ if(!$article){ $rs = $db->get_one("SELECT SUM(fd.tpost) as tposts FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.cms!='1'"); } if(!$member){ $bbsinfo = $db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1"); } $tposts = $rs['tposts']; $info .= "$pre $lang[js_today]:$tposts<br>$pre $lang[js_yesterday]:$bbsinfo[yposts]<br>$pre $lang[js_highday]:$bbsinfo[hposts]<br>"; } if($online){ if(!$member && !$yesterday){ $bbsinfo = $db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1"); } @include_once(D_P.'data/bbscache/olcache.php'); $usertotal = $guestinbbs+$userinbbs; $higholtime = gmdate('Y-m-d',$bbsinfo['higholtime']+8*3600); $info .= "$pre $lang[js_online]:$usertotal<br>$pre $lang[js_onlinemen]:$userinbbs<br>$pre $lang[js_onlineguest]:$guestinbbs<br>$pre $lang[js_highonline]:$bbsinfo[higholnum]<br>$pre $lang[js_happen]:$higholtime"; } $info = "document.write(\"$info\");"; echo $info ; writeover($cachefile,$info); } else { @readfile($cachefile); } } elseif($action == 'member'){ InitGP(array('num','pre','order')); $cachefile = D_P."data/bbscache/new_{$action}_".md5($action.(int)$num.(int)$pre.(int)$order); if($timestamp - @filemtime($cachefile) >= $per){ $num = is_numeric($num) ? $num : 10; $pre = is_numeric($pre) ? $prefix[$pre] : $prefix[0]; $orderway = array( '1' => 'uid', '2' => 'postnum', '3' => 'digests', '4' => 'rvrc', '5' => 'money', '6' => 'credit' ); $orderby = is_numeric($order) ? $orderway[$order] : $orderway[1]; $query = $db->query("SELECT m.uid,m.username,md.$orderby FROM pw_memberdata md LEFT JOIN pw_members m USING(uid) ORDER BY md.$orderby DESC LIMIT $num"); while($rt = $db->fetch_array($query)){ if($orderby != 'uid'){ $orderby == 'rvrc' && $rt[$orderby] = floor($rt[$orderby] /= 10); $useradd = "($rt[$orderby])"; } else{ $useradd = ''; } $userdb = "$pre <a href='$db_bbsurl/profile.php?action=show&uid=$rt[uid]' target='_blank'>$rt[username]</a> $useradd"; $newlist .= "document.write(\"$userdb<br>\");\n"; } echo $newlist; writeover($cachefile,$newlist); } else { @readfile($cachefile); } } elseif($action == 'article'){ InitGP(array('num','length','fidin','fidout','postdate','author','fname','hits','replies','pre','digest','order')); $cachefile = D_P."data/bbscache/new_{$action}_".md5($action.(int)$num.(int)$length.$fidin.$fidout.(int)$postdate.(int)$author.(int)$fname.(int)$hits.(int)$replies.(int)$pre.(int)$digest.(int)$order); if($timestamp - @filemtime($cachefile) >= $per){ $num = is_numeric($num) ? $num : 10; $length = is_numeric($length) ? $length : 35; $pre = is_numeric($pre) ? $prefix[$pre] : $prefix[0]; $fname && include_once(D_P.'data/bbscache/forum_cache.php'); $orderway = array( '1' => 'lastpost', '2' => 'postdate', '3' => 'replies', '4' => 'hits' ); $orderby = is_numeric($order) ? $orderway[$order] : $orderway[1]; $sqladd = "ifcheck=1"; $fidoff=$ext=''; $query = $db->query("SELECT fid FROM pw_forums WHERE password!='' OR allowvisit!='' OR f_type='hidden'"); while($rt=$db->fetch_array($query)){ $fidoff .= $ext.$rt['fid']; !$ext && $ext = ','; } $fidoff && $sqladd .= " AND fid NOT IN($fidoff)"; if($fidin){ $sqladd .= " AND fid IN ('".str_replace('_', "','", $fidin)."')"; } elseif($fidout){ $sqladd .= " AND fid NOT IN ('".str_replace('_', "','", $fidout)."')"; } $digest && $sqladd .= " AND digest>'0'"; $query = $db->query("SELECT tid,fid,author,authorid,subject,postdate,hits,replies FROM pw_threads WHERE $sqladd ORDER BY $orderby DESC LIMIT 0, $num"); while($threads = $db->fetch_array($query)){ $threads['subject'] = substrs($threads['subject'], $length); $article = "$pre <a href='$db_bbsurl/read.php?tid=$threads[tid]' target='_blank'>$threads[subject]</a> "; if($postdate){ $article .= " <font color='$color'>(".date("Y-m-d H:i",$threads['postdate']).')</font>'; } if($author){ $article .= " <a href='$db_bbsurl/profile.php?action=show&uid=$threads[authorid]' target='_blank'><font color='$color'>($threads[author])</font></a>"; } if($replies){ $article .= " <font color='$color'>($lang[js_replies]:$threads[replies])</font></a>"; } if($hits){ $article .= " <font color='$color'>($lang[js_hits]:$threads[hits])</font></a>"; } if($fname){ $article .= " <a href='$db_bbsurl/thread.php?fid=$threads[fid]' target='_blank'><font color='$color'>(".$forum[$threads['fid']]['name'].")</font></a>"; } $newlist .= "document.write(\"$article<br>\");\n"; } echo $newlist; writeover($cachefile,$newlist); } else { @readfile($cachefile); } } ?>