[外掛修正]在首頁顯示album隨機圖片

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
lcsuen
星球普通子民
星球普通子民
文章: 8
註冊時間: 2003-07-23 11:27

[外掛修正]在首頁顯示album隨機圖片

文章 lcsuen »

之前亦有相同的外掛,不過好像未完成,希望沒重覆。另,我不懂php的,如果出現問題,請題出,我看看是否漏了什麼。 :lol:
這只是在album找出的code,有些註解del了的(因為在album有,沒必要重覆),如果如此做有問題的話,請告訴我,讓我加回,謝。 :lol:

請先安裝album外掛

打開index.php

尋找\r

代碼: 選擇全部

	// Start output of page
在之前加上

代碼: 選擇全部

//Start Add - Random Photo
//'Recent Pics' Code by Smartor
//'Random Pics' Code by CLowN
$album_root_path = $phpbb_root_path . 'album_mod/';
include($album_root_path . 'album_common.'.$phpEx);

$sql = "SELECT c.*, COUNT(p.pic_id) AS count
		FROM ". ALBUM_CAT_TABLE ." AS c
			LEFT JOIN ". ALBUM_TABLE ." AS p ON c.cat_id = p.pic_cat_id
		WHERE cat_id <> 0
		GROUP BY cat_id
		ORDER BY cat_order ASC";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}

$catrows = array();

while( $row = $db->sql_fetchrow($result) )
{
	$album_user_access = album_user_access($row['cat_id'], $row, 1, 0, 0, 0, 0, 0); // VIEW
	if ($album_user_access['view'] == 1)
	{
		$catrows[] = $row;
	}
}
$allowed_cat = ''; 
for ($i = 0; $i < count($catrows); $i++)
{
	$allowed_cat .= ($allowed_cat == '') ? $catrows[$i]['cat_id'] : ',' . $catrows[$i]['cat_id'];
}
if ($allowed_cat != '') 
{ 
   $sql = "SELECT p.pic_id, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_user_ip, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_view_count, u.user_id, u.username, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments 
         FROM ". ALBUM_TABLE ." AS p 
            LEFT JOIN ". USERS_TABLE ." AS u ON p.pic_user_id = u.user_id 
            LEFT JOIN ". ALBUM_CAT_TABLE ." AS ct ON p.pic_cat_id = ct.cat_id 
            LEFT JOIN ". ALBUM_RATE_TABLE ." AS r ON p.pic_id = r.rate_pic_id 
            LEFT JOIN ". ALBUM_COMMENT_TABLE ." AS c ON p.pic_id = c.comment_pic_id 
         WHERE p.pic_cat_id IN ($allowed_cat) AND ( p.pic_approval = 1 OR ct.cat_approval = 0 ) 
         GROUP BY p.pic_id 
         ORDER BY RAND() 
         LIMIT ". $album_config['cols_per_page']; 
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(GENERAL_ERROR, 'Could not query rand pics information', '', __LINE__, __FILE__, $sql); 
   } 

   $randrow = array(); 

   while( $row = $db->sql_fetchrow($result) ) 
   { 
      $randrow[] = $row; 
   } 


   if (count($randrow) > 0) 
   { 
      for ($i = 0; $i < count($randrow); $i += $album_config['cols_per_page']) 
      { 
         $template->assign_block_vars('rand_pics', array()); 

         for ($j = $i; $j < ($i + $album_config['cols_per_page']); $j++) 
         { 
            if( $j >= count($randrow) ) 
            { 
               break; 
            } 

            if(!$randrow[$j]['rating']) 
            { 
               $randrow[$j]['rating'] = $lang['Not_rated']; 
            } 
            else 
            { 
               $randrow[$j]['rating'] = round($randrow[$j]['rating'], 2); 
            } 

            $template->assign_block_vars('rand_pics.rand_col', array( 
               'U_PIC' => ($album_config['fullpic_popup']) ? append_sid("album_pic.$phpEx?pic_id=". $randrow[$j]['pic_id']) : append_sid("album_page.$phpEx?pic_id=". $randrow[$j]['pic_id']), 
               'THUMBNAIL' => append_sid("album_thumbnail.$phpEx?pic_id=". $randrow[$j]['pic_id']), 
               'DESC' => $randrow[$j]['pic_desc'] 
               ) 
            ); 

            if( ($randrow[$j]['user_id'] == ALBUM_GUEST) or ($randrow[$j]['username'] == '') ) 
            { 
               $rand_poster = ($randrow[$j]['pic_username'] == '') ? $lang['Guest'] : $randrow[$j]['pic_username']; 
            } 
            else 
            { 
               $rand_poster = '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $randrow[$j]['user_id']) .'">'. $randrow[$j]['username'] .'</a>'; 
            } 

            $template->assign_block_vars('rand_pics.rand_detail', array( 
               'TITLE' => $randrow[$j]['pic_title'], 
               'POSTER' => $rand_poster, 
               'TIME' => create_date($board_config['default_dateformat'], $randrow[$j]['pic_time'], $board_config['board_timezone']), 

               'VIEW' => $randrow[$j]['pic_view_count'], 

               'RATING' => ($album_config['rate'] == 1) ? ( '<a href="'. append_sid("album_rate.$phpEx?pic_id=". $randrow[$j]['pic_id']) . '">' . $lang['Rating'] . '</a>: ' . $randrow[$j]['rating'] . '<br />') : '', 

               'COMMENTS' => ($album_config['comment'] == 1) ? ( '<a href="'. append_sid("album_comment.$phpEx?pic_id=". $randrow[$j]['pic_id']) . '">' . $lang['Comments'] . '</a>: ' . $randrow[$j]['comments'] . '<br />') : '', 

               'IP' => ($userdata['user_level'] == ADMIN) ? $lang['IP_Address'] . ': <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . decode_ip($randrow[$j]['pic_user_ip']) . '" target="_blank">' . decode_ip($randrow[$j]['pic_user_ip']) .'</a><br />' : '' 
               ) 
            ); 
         } 
      } 
   } 
   else 
   { 
      $template->assign_block_vars('no_pics', array()); 
   } 
} 
else 
{ 
   $template->assign_block_vars('no_pics', array()); 
} 
//End Add - Random Photo
尋找\r

代碼: 選擇全部

		'FORUM_LOCKED_IMG' => $images['forum_locked'],
\r

在之後加上

代碼: 選擇全部

// Start add - Random Photo
		'S_COLS' => $album_config['cols_per_page'],
		'S_COL_WIDTH' => (100/$album_config['cols_per_page']) . '%',
		'TARGET_BLANK' => ($album_config['fullpic_popup']) ? 'target="_blank"' : '',
		'L_NO_PICS' => $lang['No_Pics'],
		'L_PIC_TITLE' => $lang['Pic_Title'],
		'L_VIEW' => $lang['View'],
		'L_POSTER' => $lang['Poster'],
		'L_POSTED' => $lang['Posted'],
// End add - Random Photo
打開
\templates\subSilver\index_body.tpl

在你喜歡的位置加入\r

代碼: 選擇全部

<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> 
  <tr> 
   <th class="thTop" height="25" colspan="{S_COLS}" nowrap="nowrap">隨機圖片</th> 
  </tr> 
  <!-- BEGIN no_pics --> 
  <tr> 
   <td class="row1" align="center" colspan="{S_COLS}" height="50"><span class="gen">{L_NO_PICS}</span></td> 
  </tr> 
  <!-- END no_pics --> 
  <!-- BEGIN rand_pics --> 
  <tr> 
  <!-- BEGIN rand_col --> 
   <td class="row1" width="{S_COL_WIDTH}" align="center"><a href="{rand_pics.rand_col.U_PIC}" {TARGET_BLANK}><img src="{rand_pics.rand_col.THUMBNAIL}" border="0" alt="{rand_pics.rand_col.DESC}" title="{rand_pics.rand_col.DESC}" vspace="10" /></a></td> 
  <!-- END rand_col --> 
  </tr> 
  <tr> 
  <!-- BEGIN rand_detail --> 
    <td class="row2"><span class="gensmall">{L_PIC_TITLE}: {rand_pics.rand_detail.TITLE}<br /> 
     {L_POSTER}: {rand_pics.rand_detail.POSTER}<br />{L_POSTED}: {rand_pics.rand_detail.TIME}<br /> 
     {L_VIEW}: {rand_pics.rand_detail.VIEW}<br />{rand_pics.rand_detail.RATING}{rand_pics.rand_detail.COMMENTS}{rand_pics.rand_detail.IP}</span> 
   </td> 
  <!-- END rand_detail --> 
  </tr> 
  <!-- END rand_pics --> 
</table>
完成
吾乃稻草居士是也!
Diablo 2 Exp: US East
圖檔
主題已鎖定

回到「非官方認證外掛」