-
Notifications
You must be signed in to change notification settings - Fork 0
/
album_personal_index.php
207 lines (173 loc) · 6.19 KB
/
album_personal_index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/***************************************************************************
* album_personal_index.php
* -------------------
* begin : Monday, February 24, 2003
* copyright : (C) 2003 Smartor
* email : [email protected]
*
* $Id: album_personal_index.php,v 2.0.3 2003/02/28 11:32:52 ngoctu Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
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);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_ALBUM);
init_userprefs($userdata);
//
// End session management
//
//
// Get general album information
//
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']) ) ? $HTTP_POST_VARS['mode'] : $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';
}
//
// Memberlist sorting
//
$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>';
/*
+----------------------------------------------------------
| Start output the page
+----------------------------------------------------------
*/
$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) ) ? $theme['td_class1'] : $theme['td_class2'],
'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'] ))
)
);
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
// +------------------------------------------------------+
// | Powered by Photo Album 2.x.x (c) 2002-2003 Smartor |
// +------------------------------------------------------+
?>