ZhukovK » 22.12.2005 18:26
Portal.php
=======================
$sql = "Declare @pic_id int
Declare @pic_t int
Declare @RandInd int
Declare @Counter int
SELECT @RandInd=cast(round(ROUND(RAND()*100,0)/(100/(Select count(pic_id)-1 from phpbb_album where pic_approval=1))+1,0) as integer)
Set @Counter=1
Declare cur cursor FOR
Select pic_id from phpbb_album where pic_approval=1
open Cur
FETCH NEXT FROM Cur into @pic_t
WHILE @@FETCH_STATUS = 0
BEGIN
if (@Counter=@RandInd) Set @pic_id=@pic_t
FETCH NEXT FROM Cur into @pic_t
Set @Counter=@Counter+1
END
CLOSE Cur
DEALLOCATE Cur
SELECT pic_id, pic_title, pic_username, pic_time FROM phpbb_album where pic_id=@pic_id
";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query album information', '', __LINE__, __FILE__, $sql);
}
$picrow = $db->sql_fetchrow($result);
.......................
$template->assign_vars(array(
'WELCOME_TEXT' => $CFG['welcome_text'],
'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
'TOTAL_TOPICS' => sprintf($lang['total_topics'], $total_topics),
'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),
'L_FORUM' => $lang['Forum'],
'L_BOARD_NAVIGATION' => $lang['Board_navigation'],
'L_STATISTICS' => $lang['Statistics'],
'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
'L_POSTED' => $lang['Posted'],
'L_COMMENTS' => $lang['Comments'],
'L_VIEW_COMMENTS' => $lang['View_comments'],
'L_POST_COMMENT' => $lang['Post_your_comment'],
'L_SEND_PASSWORD' => $lang['Forgotten_password'],
'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
'L_REGISTER_NEW_ACCOUNT' => sprintf($lang['Register_new_account'], '<a href="' . append_sid("profile.$phpEx?mode=register") . '">', '</a>'),
'L_REMEMBER_ME' => $lang['Remember_me'],
'L_VIEW_COMPLETE_LIST' => $lang['View_complete_list'],
'L_POLL' => $lang['Poll'],
'L_VOTE_BUTTON' => $lang['Vote'],
// Photo Album
'L_NEWEST_PIC' => $lang['Newest_pic'],
'PIC_IMAGE' => append_sid('album_thumbnail.'. $phpEx . '?pic_id=' . $picrow['pic_id']),
'PIC_TITLE' => $picrow['pic_title'],
'PIC_POSTER' => $picrow['pic_username'],
//'U_PIC_LINK' => append_sid('album_view.' . $phpEx . '?id=' . $picrow['pic_id']),
'U_PIC_LINK' => append_sid('album_pic.' . $phpEx . '?pic_id=' . $picrow['pic_id']),
'PIC_TIME' => create_date($board_config['default_dateformat'], $picrow['pic_time'], $board_config['board_timezone']),
// Welcome Avatar
'L_NAME_WELCOME' => $lang['Welcome'],
'U_NAME_LINK' => $name_link,
'AVATAR_IMG' => $avatar_img)
);
===========================
portal_body.tpl
===========================
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="25"><span class="genmed"><b>{L_NEWEST_PIC}</b></span></td>
</tr>
<tr>
<td class="row1" align="left"><span class="gensmall" style="line-height:150%"><center><br /><br /><a href="{U_PIC_LINK}"><img src="{PIC_IMAGE}" border="0" alt="{L_NEWEST_PIC}"></a><br /></center><b>{PIC_TITLE}</b> àâòîð <b>{PIC_POSTER}</b><br />on {PIC_TIME}<br /> </span></td>
</tr>
</table>