Added:
trunk/upload/forumdata/cache_idx/
trunk/upload/templates/babel/touch_view.htm
Modified:
trunk/upload/parasy/ParasyCore.php
Log:
rand_topic() Updated
Modified: trunk/upload/parasy/ParasyCore.php
==============================================================================
--- trunk/upload/parasy/ParasyCore.php (original)
+++ trunk/upload/parasy/ParasyCore.php Thu Apr 3 23:38:01 2008
@@ -464,32 +464,61 @@
function rand_topic($fup,$items = 14) {
global $db, $_DCACHE, $timestamp, $tablepre, $timeoffset, $maxbdays,$smcols, $smrows,$discuz_uid, $groupid, $fid, $indexname;
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
- foreach($_DCACHE['forums'] as $forum_all) {
- if($forum_all['type'] == 'group' ) {
- $visible[$forum_all['fid']] = true;
- } elseif($forum_all['type'] == 'forum' && $forum_all['fup']== $fup&& isset($visible[$forum_all['fup']]) && (!$forum_all['viewperm'] ||($forum_all['viewperm'] && forumperm($forum_all['viewperm'])) ||strstr($forum_all['users'], "\t$discuz_uid\t"))) {
- $_forums[] =$forum_all['fid'];
- $visible[$forum_all['fid']] = true;
+ $_seed = rand(1, 10);
+ @include DISCUZ_ROOT.'./forumdata/cache_idx/cache_idx_'.$fup.'_'.$_seed.'.php';
+ if((@!include(DISCUZ_ROOT.'forumdata/cache_idx/cache_idx_'.$fup.'_'.$_seed.'.php')) || $idx_expiration < time()) {
+ require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
+ foreach($_DCACHE['forums'] as $forum_all) {
+ if($forum_all['type'] == 'group' ) {
+ $visible[$forum_all['fid']] = true;
+ } elseif($forum_all['type'] == 'forum' && $forum_all['fup']== $fup&& isset($visible[$forum_all['fup']]) && (!$forum_all['viewperm'] ||($forum_all['viewperm'] && forumperm($forum_all['viewperm'])) ||strstr($forum_all['users'], "\t$discuz_uid\t"))) {
+ $_forums[] =$forum_all['fid'];
+ $visible[$forum_all['fid']] = true;
+ }
}
- }
- $forum_list_sql = implode(',', $_forums);
- $forum_topic_list = array();
- $query = $db->query("SELECT t.tid,t.subject,t.replies FROM {$tablepre}threads t WHERE t.displayorder!='-1' and t.fid IN ({$forum_list_sql}) ORDER BY rand() LIMIT 0, {$items}");
- while($idx_forum_topic = $db->fetch_array($query)) {
- $idx_forum_topic['uid'] = $idx_forum_topic['uid'];
- $idx_forum_topic['size'] = vxGetItemSize($idx_forum_topic['replies']).'px';
- if ($idx_forum_topic['replies'] < 5){
- $idx_forum_topic['csscolor'] = rand_gray();
- }else{
- $idx_forum_topic['csscolor'] = rand_color();
+ $forum_list_sql = implode(',', $_forums);
+ $forum_topic_list = array();
+
+ $query = $db->query("SELECT t.tid,t.subject,t.replies FROM {$tablepre}threads t WHERE t.displayorder!='-1' and t.fid IN ({$forum_list_sql}) ORDER BY rand() LIMIT 0, 20");
+ while($topic = $db->fetch_array($query)) {
+ $data['topic'][$topic[tid]]['tid'] = $topic['tid'];
+ $data['topic'][$topic[tid]]['subject'] = $topic['subject'];
+ $data['topic'][$topic[tid]]['replies'] = $topic['replies'];
+ $data['topic'][$topic[tid]]['size'] = vxGetItemSize($topic['replies']).'px';
}
- $forum_topic_list[] = $idx_forum_topic;
- }
- if(is_array($forum_topic_list)) {
- foreach($forum_topic_list as $toploop) {
- echo '<span class="tip_i"><a href="viewthread.php?tid='.$toploop['tid'].'"style="color: '.$toploop['csscolor'].';font-size: '.$toploop['size'].';"class="var">'.$toploop['subject'].'</a> </span>';
+ $data['idx_expiration'] = 900 + time();
+ nmwritetocache('cache_idx_'.$fup.'_'.$_seed, '', nmgetcachevars($data),'','cache_idx');
+ $topic = $data['topic'];
+ @shuffle($topic);
+ if(is_array($topic)) {
+ foreach($topic as $toploop) {
+ if ($toploop['replies'] < 5){
+ $toploop['color'] = rand_gray();
+ }else{
+ $toploop['color'] = rand_color();
+ }
+ $i ++;
+ if ($i < $items) {
+ echo '<span class="tip_i"><a href="viewthread.php?tid='.$toploop['tid'].'"style="color: '.$toploop['color'].';font-size: '.$toploop['size'].';"class="var">'.$toploop['subject'].'</a> </span>';
+ }
+ }
}
+ } else {
+ @shuffle($topic);
+ if(is_array($topic)) {
+ foreach($topic as $toploop) {
+ if ($toploop['replies'] < 5){
+ $toploop['color'] = rand_gray();
+ }else{
+ $toploop['color'] = rand_color();
+ }
+ $i ++;
+ if ($i < $items) {
+ echo '<span class="tip_i"><a href="viewthread.php?tid='.$toploop['tid'].'"style="color: '.$toploop['color'].';font-size: '.$toploop['size'].';"class="var">'.$toploop['subject'].'</a> </span>';
+ }
+ }
+ }
+
}
}
Added: trunk/upload/templates/babel/touch_view.htm
==============================================================================
--- (empty file)
+++ trunk/upload/templates/babel/touch_view.htm Thu Apr 3 23:38:01 2008
@@ -0,0 +1,31 @@
+{template touch_header}
+<!--{eval $thread['subject'] = iconv('gbk', 'utf-8', $thread['subject']);}-->
+<div id="nav_title">$thread['subject']</div>
+<!--{loop $postlist $post}-->
+<!--{eval $thisbg = isset($thisbg) && $thisbg == 'odd' ? 'even' : 'odd';}-->
+<!--{eval $post['author'] = iconv('gbk', 'utf-8', $post['author']);}-->
+<!--{eval $post['subject'] = iconv('gbk', 'utf-8', $post['subject']);}-->
+<!--{eval $post['message'] = iconv('gbk', 'utf-8', $post['message']);}-->
+<!--{if $post['number'] == 0}-->
+<div class="item_$thisbg">
+<div class="re_info"><small>楼主 - $post[dateline]<!--{if $forum['ismoderator'] && $allowdelpost}--><input type="checkbox" name="delete[]" value="$post[pid]"><!--{/if}--></small></div>
+<!--{if $post['authorid'] && $post['username'] && !$post['anonymous']}-->
+<!--{if $post['avatar']}--><img src="$bbsdir/$post[smavatar]" align="absmiddle" class="avatar_s" /><!--{else}--><img src="$bbsdir/images/common/nohead_s.gif" align="absmiddle" class="re_port" /><!--{/if}--> <a href="$bbsdir/uid/$post[authorid]" class="t">$post[author]</a>
+<!--{else}-->
+<img src="$bbsdir/images/common/nohead_s.gif" align="absmiddle" class="re_port" /><!--{if !$post['authorid']}-->{lang guest} <small>$post[useip]</small>{lang unregistered}<!--{elseif $post['authorid'] && $post['username'] && $post['anonymous']}--><!--{if $forum['ismoderator']}--><a href="$bbsdir/viewpro.php?uid=$post[authorid]" target="_blank" style="color: $topic_color;" class="var">匿名人士</a><!--{else}--><span style="color: $topic_color;">匿名人士</span><!--{/if}--><!--{else}--><a href="$bbsdir/uid/$post[authorid]">$post[author]</a>{lang member_deleted}<!--{/if}-->
+<!--{/if}-->
+<div class="view_content">$post[message]</div></div>
+<!--{else}-->
+<div class="item_$thisbg">
+<div class="re_info"><small>#$post[number] - $post[dateline]<!--{if $forum['ismoderator'] && $allowdelpost}--><input type="checkbox" name="delete[]" value="$post[pid]"><!--{/if}--></small></div>
+<!--{if $post['authorid'] && $post['username'] && !$post['anonymous']}-->
+<!--{if $post['avatar']}--><img src="$bbsdir/$post[smavatar]" align="absmiddle" class="avatar_s" /><!--{else}--><img src="$bbsdir/images/common/nohead_s.gif" align="absmiddle" class="avatar_s" /><!--{/if}--> <a href="$bbsdir/uid/$post[authorid]" class="t">$post[author]</a>
+<!--{else}-->
+<img src="$bbsdir/images/common/nohead_s.gif" align="absmiddle" class="avatar_s" /><!--{if !$post['authorid']}-->{lang guest} <small>$post[useip]</small>{lang unregistered}<!--{elseif $post['authorid'] && $post['username'] && $post['anonymous']}--><!--{if $forum['ismoderator']}--><a href="$bbsdir/viewpro.php?uid=$post[authorid]" class="t">匿名人士</a><!--{else}--><span class="t">匿名人士</span><!--{/if}--><!--{else}--><a href="$bbsdir/uid/$post[authorid]">$post[author]</a>{lang member_deleted}<!--{/if}-->
+<!--{/if}-->
+<div class="view_content"><!--{if $post['subject']}-->$post[subject]<br /><!--{/if}-->
+$post[message]</div></div>
+<!--{/if}-->
+<!--{/loop}-->
+<!--{if $touch_multipage}--><div id="page"><div align="center">$touch_multipage</div></div><!--{/if}-->
+{template touch_footer}
\ No newline at end of file