<?php
/***************************************************************************
* album_personal_index.php
* -------------------
* Разработка: (C) 2003 Smartor
* Модификация: чел
***************************************************************************/
/***************************************************************************
*
* Эта версия phpBB-WAP является бесплатным
* программным обеспечением и распространяется
* в рамках лицензии GNU General Public License.
* Автор модификации настоятельно не
* рекомендует распрострянять её так, как
* распространялась 5 версия мода.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$album_root_path = $phpbb_root_path . 'album_mod/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_ALBUM);
init_userprefs($userdata);
include($album_root_path . 'album_common.'.$phpEx);
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? htmlspecialchars($HTTP_POST_VARS['mode']) : htmlspecialchars($HTTP_GET_VARS['mode']);
}
else
{
$mode = 'joined';
}
if(isset($HTTP_POST_VARS['order']))
{
$sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
else if(isset($HTTP_GET_VARS['order']))
{
$sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
else
{
$sort_order = 'ASC';
}
$mode_types_text = array($lang['Sort_Joined'], $lang['Sort_Username'], $lang['Pics'], $lang['Last_Pic']);
$mode_types = array('joindate', 'username', 'pics', 'last_pic');
$select_sort_mode = '<select name="mode">';
for($i = 0; $i < count($mode_types_text); $i++)
{
$selected = ( $mode == $mode_types[$i] ) ? ' selected="selected"' : '';
$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';
$select_sort_order = '<select name="order">';
if($sort_order == 'ASC')
{
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
}
else
{
$select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
}
$select_sort_order .= '</select>';
$page_title = $lang['Album'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'album_personal_index_body.tpl')
);
$template->assign_vars(array(
'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
'L_ORDER' => $lang['Order'],
'L_SORT' => $lang['Sort'],
'L_JOINED' => $lang['Joined'],
'L_PICS' => $lang['Pics'],
'L_USERS_PERSONAL_GALLERIES' => $lang['Users_Personal_Galleries'],
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
'S_MODE_ACTION' => append_sid("album_personal_index.$phpEx")
)
);
switch( $mode )
{
case 'joined':
$order_by = "user_regdate ASC LIMIT $start, " . $board_config['topics_per_page'];
break;
case 'username':
$order_by = "username $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
case 'pics':
$order_by = "pics $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
case 'last_pic':
$order_by = "last_pic $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
default:
$order_by = "user_regdate $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
}
$sql = "SELECT u.username, u.user_id, u.user_regdate, COUNT(p.pic_id) AS pics, MAX(p.pic_id) AS last_pic
FROM ". USERS_TABLE ." AS u, ". ALBUM_TABLE ." as p
WHERE u.user_id <> ". ANONYMOUS ."
AND u.user_id = p.pic_user_id
AND p.pic_cat_id = ". PERSONAL_GALLERY ."
GROUP BY user_id
ORDER BY $order_by";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
}
$memberrow = array();
while( $row = $db->sql_fetchrow($result) )
{
$memberrow[] = $row;
}
for ($i = 0; $i < count($memberrow); $i++)
{
$template->assign_block_vars('memberrow', array(
'ROW_CLASS' => ( !($i % 2) ) ? 'row_easy' : 'row_hard',
'USERNAME' => $memberrow[$i]['username'],
'U_VIEWGALLERY' => append_sid("album_personal.$phpEx?user_id=". $memberrow[$i]['user_id']),
'JOINED' => create_date($lang['DATE_FORMAT'], $memberrow[$i]['user_regdate'], $board_config['board_timezone']),
'PICS' => $memberrow[$i]['pics'])
);
}
$sql = "SELECT COUNT(DISTINCT u.user_id) AS total
FROM ". USERS_TABLE ." AS u, ". ALBUM_TABLE ." AS p
WHERE u.user_id <> ". ANONYMOUS ."
AND u.user_id = p.pic_user_id
AND p.pic_cat_id = ". PERSONAL_GALLERY;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error getting total galleries', '', __LINE__, __FILE__, $sql);
}
if ( $total = $db->sql_fetchrow($result) )
{
$total_galleries = $total['total'];
$pagination = generate_pagination("album_personal_index.$phpEx?mode=$mode&order=$sort_order", $total_galleries, $board_config['topics_per_page'], $start). ' ';
}
$template->assign_vars(array(
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_galleries / $board_config['topics_per_page'] ))
)
);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>S_MODE_SELECT