2001-05-11 23:16:31 +00:00
< ? php
2003-09-07 13:46:51 +00:00
// -------------------------------------------------------------
//
// $Id$
//
// FILENAME : memberlist.php
// STARTED : Sat Feb 13, 2001
// COPYRIGHT : <20> 2001, 2003 phpBB Group
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
2001-08-30 22:20:23 +00:00
2003-06-19 16:13:53 +00:00
// TODO
// Add permission check for IM clients
// Combine Jabber and email contact capabilities?
2003-06-19 16:48:47 +00:00
// When registering a new jabber user the message doesn't get sent first time
2003-06-19 16:13:53 +00:00
2002-03-18 13:35:43 +00:00
define ( 'IN_PHPBB' , true );
2002-03-31 00:06:34 +00:00
$phpbb_root_path = './' ;
2003-09-07 17:58:19 +00:00
$phpEx = substr ( strrchr ( __FILE__ , '.' ), 1 );
2001-07-13 16:14:37 +00:00
include ( $phpbb_root_path . 'common.' . $phpEx );
2001-05-11 23:16:31 +00:00
// Start session management
2002-10-20 19:19:07 +00:00
$user -> start ();
$auth -> acl ( $user -> data );
2003-07-14 22:54:39 +00:00
$user -> setup ();
2002-11-12 20:55:18 +00:00
// Grab data
2003-06-19 16:13:53 +00:00
$mode = ( isset ( $_REQUEST [ 'mode' ])) ? htmlspecialchars ( $_REQUEST [ 'mode' ]) : '' ;
$action = ( isset ( $_REQUEST [ 'action' ])) ? htmlspecialchars ( $_REQUEST [ 'action' ]) : '' ;
$user_id = ( isset ( $_GET [ 'u' ])) ? intval ( $_GET [ 'u' ]) : ANONYMOUS ;
$topic_id = ( isset ( $_GET [ 't' ])) ? intval ( $_GET [ 't' ]) : 0 ;
2002-11-12 20:55:18 +00:00
2003-04-26 01:17:40 +00:00
switch ( $mode )
2003-03-10 17:48:08 +00:00
{
2003-04-26 01:17:40 +00:00
case 'email' :
break ;
2003-05-03 23:58:45 +00:00
2003-04-26 01:17:40 +00:00
default :
// Can this user view profiles/memberslist?
2003-05-03 23:58:45 +00:00
if ( ! $auth -> acl_gets ( 'u_viewprofile' , 'a_user' , 'a_useradd' , 'a_userdel' ))
2003-04-26 01:17:40 +00:00
{
if ( $user -> data [ 'user_id' ] != ANONYMOUS )
{
trigger_error ( $user -> lang [ 'NO_VIEW_USERS' ]);
}
2003-03-17 00:53:38 +00:00
2003-04-26 01:17:40 +00:00
login_box ( preg_replace ( '#.*?([a-z]+?\.' . $phpEx . '.*?)$#i' , '\1' , htmlspecialchars ( $_SERVER [ 'REQUEST_URI' ])));
}
break ;
2003-03-10 17:48:08 +00:00
}
2003-04-26 01:17:40 +00:00
2003-08-27 16:32:44 +00:00
$start = ( isset ( $_GET [ 'start' ])) ? intval ( $_GET [ 'start' ]) : (( isset ( $_GET [ 'page' ])) ? ( intval ( $_GET [ 'page' ]) - 1 ) * $config [ 'topics_per_page' ] : 0 );
2003-06-19 16:13:53 +00:00
$form = ( ! empty ( $_GET [ 'form' ])) ? htmlspecialchars ( $_GET [ 'form' ]) : 0 ;
$field = ( isset ( $_GET [ 'field' ])) ? htmlspecialchars ( $_GET [ 'field' ]) : 'username' ;
2002-11-12 20:55:18 +00:00
2003-03-04 16:49:02 +00:00
$sort_key = ( ! empty ( $_REQUEST [ 'sk' ])) ? htmlspecialchars ( $_REQUEST [ 'sk' ]) : 'c' ;
$sort_dir = ( ! empty ( $_REQUEST [ 'sd' ])) ? htmlspecialchars ( $_REQUEST [ 'sd' ]) : 'a' ;
2002-11-12 20:55:18 +00:00
2003-06-19 16:13:53 +00:00
$username = ( ! empty ( $_REQUEST [ 'username' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'username' ])) : '' ;
$email = ( ! empty ( $_REQUEST [ 'email' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'email' ])) : '' ;
$icq = ( ! empty ( $_REQUEST [ 'icq' ])) ? intval ( htmlspecialchars ( $_REQUEST [ 'icq' ])) : '' ;
$aim = ( ! empty ( $_REQUEST [ 'aim' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'aim' ])) : '' ;
$yahoo = ( ! empty ( $_REQUEST [ 'yahoo' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'yahoo' ])) : '' ;
$msn = ( ! empty ( $_REQUEST [ 'msn' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'msn' ])) : '' ;
2003-03-17 00:53:38 +00:00
2003-06-19 16:13:53 +00:00
$joined_select = ( ! empty ( $_REQUEST [ 'joined_select' ])) ? htmlspecialchars ( $_REQUEST [ 'joined_select' ]) : 'lt' ;
$active_select = ( ! empty ( $_REQUEST [ 'active_select' ])) ? htmlspecialchars ( $_REQUEST [ 'active_select' ]) : 'lt' ;
$count_select = ( ! empty ( $_REQUEST [ 'count_select' ])) ? htmlspecialchars ( $_REQUEST [ 'count_select' ]) : 'eq' ;
$joined = ( ! empty ( $_REQUEST [ 'joined' ])) ? explode ( '-' , trim ( htmlspecialchars ( $_REQUEST [ 'joined' ]))) : array ();
$active = ( ! empty ( $_REQUEST [ 'active' ])) ? explode ( '-' , trim ( htmlspecialchars ( $_REQUEST [ 'active' ]))) : array ();
$count = ( ! empty ( $_REQUEST [ 'count' ])) ? intval ( $_REQUEST [ 'count' ]) : '' ;
$ipdomain = ( ! empty ( $_REQUEST [ 'ip' ])) ? trim ( htmlspecialchars ( $_REQUEST [ 'ip' ])) : '' ;
2003-02-22 17:18:44 +00:00
2003-04-20 14:36:52 +00:00
2003-03-04 16:49:02 +00:00
// Grab rank information for later
2003-06-19 16:13:53 +00:00
$ranks = array ();
obtain_ranks ( $ranks );
2003-02-22 17:18:44 +00:00
2003-04-20 14:36:52 +00:00
2003-03-17 00:53:38 +00:00
// What do you want to do today? ... oops, I think that line is taken ...
2003-03-09 16:14:50 +00:00
switch ( $mode )
2001-07-05 00:57:28 +00:00
{
2003-03-17 00:53:38 +00:00
case 'leaders' :
2003-05-03 23:58:45 +00:00
// Display a listing of board admins, moderators?
2003-03-17 00:53:38 +00:00
break ;
2003-04-15 23:42:06 +00:00
case 'contact' :
$page_title = $user -> lang [ 'IM_USER' ];
$template_html = 'memberlist_im.html' ;
2003-06-19 16:13:53 +00:00
$presence_img = '' ;
switch ( $action )
{
case 'icq' :
$lang = 'ICQ' ;
$sql_field = 'user_icq' ;
$s_select = 'S_SEND_ICQ' ;
$s_action = 'http://wwp.icq.com/scripts/WWPMsg.dll' ;
break ;
case 'aim' :
$lang = 'AIM' ;
$sql_field = 'user_aim' ;
$s_select = 'S_SEND_AIM' ;
$s_action = '' ;
break ;
case 'msnm' :
$lang = 'MSNM' ;
$sql_field = 'user_msnm' ;
$s_select = 'S_SEND_MSNM' ;
$s_action = '' ;
break ;
case 'jabber' :
$lang = 'JABBER' ;
$sql_field = 'user_jabber' ;
$s_select = ( @ extension_loaded ( 'xml' )) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER' ;
$s_action = " memberlist. $phpEx $SID &mode=contact&action= $action &u= $user_id " ;
break ;
}
// Grab relevant data
$sql = " SELECT user_id, username, user_email, user_lang, $sql_field
FROM " . USERS_TABLE . "
WHERE user_id = $user_id " ;
$result = $db -> sql_query ( $sql );
if ( ! ( $row = $db -> sql_fetchrow ( $result )))
{
trigger_error ( $user -> lang [ 'NO_USER_DATA' ]);
}
$db -> sql_freeresult ( $result );
// Post data grab actions
switch ( $action )
{
case 'icq' :
$presence_img = '<img src="http://web.icq.com/whitepages/online?icq=' . $row [ $sql_field ] . '&img=5" width="18" height="18" border="0" alt="" />' ;
break ;
case 'jabber' :
if ( isset ( $_POST [ 'submit' ]) && @ extension_loaded ( 'xml' ))
{
require ( $phpbb_root_path . 'includes/functions_jabber.' . $phpEx );
$jabber = new Jabber ;
$jabber -> server = ( ! empty ( $config [ 'jab_host' ])) ? $config [ 'jab_host' ] : 'jabber.org' ;
if ( ! $jabber -> Connect ())
{
trigger_error ( 'Could not connect to Jabber server' , E_USER_ERROR );
}
$jabber -> username = ( ! empty ( $config [ 'jab_username' ])) ? $config [ 'jab_username' ] : '' ;
$jabber -> password = ( ! empty ( $config [ 'jab_password' ])) ? $config [ 'jab_password' ] : '' ;
2003-09-07 13:46:51 +00:00
$jabber -> resource = 'phpBB' ;
2003-06-19 16:13:53 +00:00
// If a username/password are set we will try and authorise. If they don't we will
// try and create a new user, username will be the basic domain name with _phpbb
// appended + a numeric
if ( $jabber -> username && $jabber -> password )
{
if ( ! $jabber -> SendAuth ())
{
trigger_error ( 'Could not authorise on Jabber server' , E_USER_ERROR );
}
}
else
{
$jabber -> username = implode ( '_' , array_slice ( explode ( '.' , $config [ 'server_name' ]), - 2 )) . '_phpbb' ;
for ( $i = 0 ; $i < 10 ; $i ++ )
{
$jabber -> password .= chr ( rand ( 65 , 122 ));
}
for ( $i = 0 ; $i < 10 ; $i ++ )
{
$jabber -> username .= $i ;
if ( $result = $jabber -> AccountRegistration ( $config [ 'contact_email' ], str_replace ( '.' , '_' , $config [ 'server_name' ])))
{
break ;
}
}
if ( ! $result )
{
trigger_error ( 'Could not create new user on Jabber server' , E_USER_ERROR );
}
set_config ( 'jab_username' , $jabber -> username );
set_config ( 'jab_password' , $jabber -> password );
}
2003-09-07 13:46:51 +00:00
$jabber -> SendPresence ( NULL , NULL , 'online' );
2003-08-27 16:32:44 +00:00
2003-06-19 16:13:53 +00:00
// This _really_ needs to be an "email" template I think ... indeed the whole system is probably
// best suited "merged" with email in some way. Would enable notifications, etc. to be sent via
// Jabber more easily too I think
$subject = sprintf ( $user -> lang [ 'IM_JABBER_SUBJECT' ], $user -> data [ 'username' ], $config [ 'server_name' ]);
$message = stripslashes ( htmlspecialchars ( $_POST [ 'message' ]));
2003-09-07 13:46:51 +00:00
$jabber -> SendMessage ( $row [ $sql_field ], 'normal' , NULL , array ( 'subject' => $subject , 'body' => $message ), '' );
2003-06-19 16:13:53 +00:00
$jabber -> Disconnect ();
$s_select = 'S_SENT_JABBER' ;
}
break ;
}
// Send vars to the template
$template -> assign_vars ( array (
'IM_CONTACT' => $row [ $sql_field ],
'USERNAME' => addslashes ( $row [ 'username' ]),
'EMAIL' => $row [ 'user_email' ],
'CONTACT_NAME' => $row [ $sql_field ],
'SITENAME' => addslashes ( $config [ 'sitename' ]),
'PRESENCE_IMG' => $presence_img ,
'L_SEND_IM_EXPLAIN' => $user -> lang [ 'IM_' . $lang ],
2003-06-19 16:48:47 +00:00
'L_IM_SENT_JABBER' => sprintf ( $user -> lang [ 'IM_SENT_JABBER' ], $row [ 'username' ]),
2003-06-19 16:13:53 +00:00
$s_select => true ,
'S_IM_ACTION' => $s_action )
);
2003-04-15 23:42:06 +00:00
break ;
2003-03-09 16:14:50 +00:00
case 'viewprofile' :
// Display a profile
$page_title = sprintf ( $user -> lang [ 'VIEWING_PROFILE' ], $row [ 'username' ]);
$template_html = 'memberlist_view.html' ;
if ( $user_id == ANONYMOUS )
{
trigger_error ( $user -> lang [ 'NO_USER' ]);
}
2002-11-12 20:55:18 +00:00
2003-03-09 16:14:50 +00:00
// Do the SQL thang
2003-03-10 17:48:08 +00:00
$sql = " SELECT g.group_id, g.group_name, g.group_type
FROM " . GROUPS_TABLE . " g , " . USER_GROUP_TABLE . " ug
WHERE ug . user_id = $user_id
2003-06-19 16:13:53 +00:00
AND g . group_id = ug . group_id " . (( $auth->acl_get ('a_groups'))? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
2003-03-10 18:20:29 +00:00
ORDER BY group_type , group_name ' ;
2003-03-09 16:14:50 +00:00
$result = $db -> sql_query ( $sql );
2001-07-05 00:57:28 +00:00
2003-03-10 17:48:08 +00:00
$group_options = '' ;
while ( $row = $db -> sql_fetchrow ( $result ))
2003-03-09 16:14:50 +00:00
{
2003-03-10 17:48:08 +00:00
$group_options .= '<option value="' . $row [ 'group_id' ] . '">' . (( $row [ 'group_type' ] == GROUP_SPECIAL ) ? $user -> lang [ 'G_' . $row [ 'group_name' ]] : $row [ 'group_name' ]) . '</option>' ;
2003-03-09 16:14:50 +00:00
}
2003-03-18 22:47:50 +00:00
// We left join on the session table to see if the user is currently online
2003-06-19 16:13:53 +00:00
$sql = ' SELECT username , user_id , user_colour , user_permissions , user_karma , user_sig , user_sig_bbcode_uid , user_sig_bbcode_bitfield , user_allow_viewemail , user_posts , user_regdate , user_rank , user_from , user_occ , user_interests , user_website , user_email , user_icq , user_aim , user_yim , user_msnm , user_jabber , user_avatar , user_avatar_width , user_avatar_height , user_avatar_type , user_allowavatar , user_lastvisit
2003-05-28 14:20:11 +00:00
FROM ' . USERS_TABLE . "
WHERE user_id = $user_id " ;
2003-03-18 22:47:50 +00:00
$result = $db -> sql_query ( $sql );
2003-05-28 14:20:11 +00:00
if ( ! ( $member = $db -> sql_fetchrow ( $result )))
2003-03-18 22:47:50 +00:00
{
trigger_error ( $user -> lang [ 'NO_USER' ]);
}
$db -> sql_freeresult ( $result );
2003-05-28 14:20:11 +00:00
$sql = ' SELECT MAX ( session_time ) AS session_time
FROM ' . SESSIONS_TABLE . "
WHERE session_user_id = $user_id " ;
$result = $db -> sql_query ( $sql );
$row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
$member [ 'session_time' ] = ( isset ( $row [ 'session_time' ])) ? $row [ 'session_time' ] : 0 ;
unset ( $row );
2003-05-03 23:58:45 +00:00
2003-06-19 16:13:53 +00:00
// Obtain list of forums where this users post count is incremented
2003-03-18 22:47:50 +00:00
$auth2 = new auth ();
2003-05-28 14:20:11 +00:00
$auth2 -> acl ( $member );
2003-06-19 16:13:53 +00:00
$f_postcount_ary = $auth2 -> acl_getf ( 'f_postcount' );
$sql_forums = array ();
foreach ( $f_postcount_ary as $forum_id => $allow )
2003-03-18 22:47:50 +00:00
{
2003-06-19 16:13:53 +00:00
if ( $allow )
2003-03-18 22:47:50 +00:00
{
2003-06-19 16:13:53 +00:00
$sql_forums [] = $forum_id ;
2003-03-18 22:47:50 +00:00
}
}
2003-05-03 23:58:45 +00:00
2003-06-19 16:13:53 +00:00
$post_count_sql = ( sizeof ( $sql_forums )) ? 'AND f.forum_id IN (' . implode ( ', ' , $sql_forums ) . ')' : '' ;
unset ( $sql_forums );
unset ( $f_postcount_ary );
unset ( $auth2 );
2003-06-03 21:40:02 +00:00
2003-03-18 22:47:50 +00:00
// Grab all the relevant data
2003-06-19 16:13:53 +00:00
$sql = ' SELECT COUNT ( p . post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . FORUMS_TABLE . " f
2003-03-09 16:14:50 +00:00
WHERE p . poster_id = $user_id
2003-03-18 22:47:50 +00:00
AND f . forum_id = p . forum_id
$post_count_sql " ;
2003-03-09 16:14:50 +00:00
$result = $db -> sql_query ( $sql );
2003-07-14 22:54:39 +00:00
$num_real_posts = min ( $user -> data [ 'user_posts' ], $db -> sql_fetchfield ( 'num_posts' , 0 , $result ));
2003-03-09 16:14:50 +00:00
$db -> sql_freeresult ( $result );
2003-06-19 16:13:53 +00:00
$sql = ' SELECT f . forum_id , f . forum_name , COUNT ( post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . FORUMS_TABLE . " f
2003-03-09 16:14:50 +00:00
WHERE p . poster_id = $user_id
AND f . forum_id = p . forum_id
2003-03-18 22:47:50 +00:00
$post_count_sql
2003-03-09 16:14:50 +00:00
GROUP BY f . forum_id , f . forum_name
2003-03-25 00:05:28 +00:00
ORDER BY num_posts DESC " ;
$result = $db -> sql_query_limit ( $sql , 1 );
2003-03-09 16:14:50 +00:00
$active_f_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
2003-06-19 16:13:53 +00:00
$sql = ' SELECT t . topic_id , t . topic_title , COUNT ( p . post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . TOPICS_TABLE . ' t , ' . FORUMS_TABLE . " f
2003-03-09 16:14:50 +00:00
WHERE p . poster_id = $user_id
AND t . topic_id = p . topic_id
AND f . forum_id = t . forum_id
2003-03-18 22:47:50 +00:00
$post_count_sql
2003-03-09 16:14:50 +00:00
GROUP BY t . topic_id , t . topic_title
2003-03-25 00:05:28 +00:00
ORDER BY num_posts DESC " ;
$result = $db -> sql_query_limit ( $sql , 1 );
2003-03-09 16:14:50 +00:00
$active_t_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
// Do the relevant calculations
2003-05-28 14:20:11 +00:00
$memberdays = max ( 1 , round (( time () - $member [ 'user_regdate' ]) / 86400 ));
$posts_per_day = $member [ 'user_posts' ] / $memberdays ;
2003-03-09 16:14:50 +00:00
$percentage = ( $config [ 'num_posts' ]) ? min ( 100 , ( $num_real_posts / $config [ 'num_posts' ]) * 100 ) : 0 ;
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '' ;
if ( ! empty ( $active_f_row [ 'num_posts' ]))
{
$active_f_name = $active_f_row [ 'forum_name' ];
$active_f_id = $active_f_row [ 'forum_id' ];
$active_f_count = $active_f_row [ 'num_posts' ];
2003-05-28 14:20:11 +00:00
$active_f_pct = ( $active_f_count / $member [ 'user_posts' ]) * 100 ;
2003-03-09 16:14:50 +00:00
}
unset ( $active_f_row );
2003-02-22 17:18:44 +00:00
2003-03-09 16:14:50 +00:00
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '' ;
if ( ! empty ( $active_t_row [ 'num_posts' ]))
{
$active_t_name = $active_t_row [ 'topic_title' ];
$active_t_id = $active_t_row [ 'topic_id' ];
$active_t_count = $active_t_row [ 'num_posts' ];
2003-05-28 14:20:11 +00:00
$active_t_pct = ( $active_t_count / $member [ 'user_posts' ]) * 100 ;
2003-03-09 16:14:50 +00:00
}
unset ( $active_t_row );
2003-02-22 17:18:44 +00:00
2003-06-19 16:13:53 +00:00
if ( $member [ 'user_sig_bbcode_bitfield' ] && $member [ 'user_sig' ])
2003-05-28 14:20:11 +00:00
{
include_once ( $phpbb_root_path . 'includes/bbcode.' . $phpEx );
$bbcode = new bbcode ();
$bbcode -> bbcode_second_pass ( $member [ 'user_sig' ], $member [ 'user_sig_bbcode_uid' ], $member [ 'user_sig_bbcode_bitfield' ]);
}
2003-06-19 16:13:53 +00:00
if ( $member [ 'user_sig' ])
{
$member [ 'user_sig' ] = ( $config [ 'enable_smilies' ]) ? preg_replace ( '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#' , '\1' , $member [ 'user_sig' ]) : str_replace ( '<img src="{SMILE_PATH}' , '<img src="' . $config [ 'smilies_path' ], $member [ 'user_sig' ]);
}
2003-05-28 14:20:11 +00:00
$poster_avatar = '' ;
if ( ! empty ( $member [ 'user_avatar' ]))
{
switch ( $member [ 'user_avatar_type' ])
{
case AVATAR_UPLOAD :
$poster_avatar = $config [ 'avatar_path' ] . '/' ;
break ;
case AVATAR_GALLERY :
$poster_avatar = $config [ 'avatar_gallery_path' ] . '/' ;
break ;
}
$poster_avatar .= $member [ 'user_avatar' ];
2003-06-03 21:40:02 +00:00
$poster_avatar = '<img src="' . $poster_avatar . '" width="' . $member [ 'user_avatar_width' ] . '" height="' . $member [ 'user_avatar_height' ] . '" border="0" alt="" />' ;
2003-05-28 14:20:11 +00:00
}
$template -> assign_vars ( show_profile ( $member ));
2003-02-22 17:18:44 +00:00
2003-03-09 16:14:50 +00:00
$template -> assign_vars ( array (
'POSTS_DAY' => sprintf ( $user -> lang [ 'POST_DAY' ], $posts_per_day ),
'POSTS_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $percentage ),
'ACTIVE_FORUM' => $active_f_name ,
'ACTIVE_FORUM_POSTS' => ( $active_f_count == 1 ) ? sprintf ( $user -> lang [ 'USER_POST' ], 1 ) : sprintf ( $user -> lang [ 'USER_POSTS' ], $active_f_count ),
'ACTIVE_FORUM_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $active_f_pct ),
'ACTIVE_TOPIC' => $active_t_name ,
'ACTIVE_TOPIC_POSTS' => ( $active_t_count == 1 ) ? sprintf ( $user -> lang [ 'USER_POST' ], 1 ) : sprintf ( $user -> lang [ 'USER_POSTS' ], $active_t_count ),
'ACTIVE_TOPIC_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $active_t_pct ),
2003-05-28 14:20:11 +00:00
'OCCUPATION' => ( ! empty ( $member [ 'user_occ' ])) ? $member [ 'user_occ' ] : '' ,
'INTERESTS' => ( ! empty ( $member [ 'user_interests' ])) ? $member [ 'user_interests' ] : '' ,
'SIGNATURE' => ( ! empty ( $member [ 'user_sig' ])) ? str_replace ( " \n " , '<br />' , $member [ 'user_sig' ]) : '' ,
'AVATAR_IMG' => $poster_avatar ,
2003-06-19 16:13:53 +00:00
'PM_IMG' => $user -> img ( 'btn_pm' , $user -> lang [ 'MESSAGE' ]),
'EMAIL_IMG' => $user -> img ( 'btn_email' , $user -> lang [ 'EMAIL' ]),
'WWW_IMG' => $user -> img ( 'btn_www' , $user -> lang [ 'WWW' ]),
'ICQ_IMG' => $user -> img ( 'btn_icq' , $user -> lang [ 'ICQ' ]),
'AIM_IMG' => $user -> img ( 'btn_aim' , $user -> lang [ 'AIM' ]),
'MSN_IMG' => $user -> img ( 'btn_msnm' , $user -> lang [ 'MSNM' ]),
'YIM_IMG' => $user -> img ( 'btn_yim' , $user -> lang [ 'YIM' ]),
'JABBER_IMG' => $user -> img ( 'btn_jabber' , $user -> lang [ 'JABBER' ]),
'SEARCH_IMG' => $user -> img ( 'btn_search' , $user -> lang [ 'SEARCH' ]),
2003-03-09 16:14:50 +00:00
2003-03-10 17:48:08 +00:00
'S_PROFILE_ACTION' => " groupcp. $phpEx $SID " ,
'S_GROUP_OPTIONS' => $group_options ,
2003-10-04 14:00:31 +00:00
'U_ADD_FRIEND' => " ucp. $phpEx $SID &i=zebra&add= " . urlencode ( $member [ 'username' ]),
2003-03-09 16:14:50 +00:00
'U_ACTIVE_FORUM' => " viewforum. $phpEx $SID &f= $active_f_id " ,
'U_ACTIVE_TOPIC' => " viewtopic. $phpEx $SID &t= $active_t_id " ,)
);
break ;
2002-03-31 00:06:34 +00:00
2003-03-09 16:14:50 +00:00
case 'email' :
// Send an email
$page_title = $user -> lang [ 'SEND_EMAIL' ];
$template_html = 'memberlist_email.html' ;
2003-03-05 00:50:03 +00:00
2003-06-19 16:13:53 +00:00
if ( empty ( $config [ 'email_enable' ]))
{
trigger_error ( $user -> lang [ 'EMAIL_DISABLED' ]);
}
if (( $user_id == ANONYMOUS || empty ( $config [ 'board_email_form' ])) && ! $topic_id )
2003-03-05 00:50:03 +00:00
{
2003-03-09 16:14:50 +00:00
trigger_error ( $user -> lang [ 'NO_EMAIL' ]);
2003-03-05 00:50:03 +00:00
}
2002-11-12 20:55:18 +00:00
2003-06-19 16:13:53 +00:00
if ( ! $auth -> acl_get ( 'u_sendemail' ))
2003-03-05 00:50:03 +00:00
{
2003-03-09 16:14:50 +00:00
trigger_error ( $user -> lang [ 'NO_EMAIL' ]);
2003-03-05 00:50:03 +00:00
}
2003-03-09 16:14:50 +00:00
// Are we trying to abuse the facility?
if ( time () - $user -> data [ 'user_emailtime' ] < $config [ 'flood_interval' ])
2003-03-05 00:50:03 +00:00
{
2003-03-09 16:14:50 +00:00
trigger_error ( $lang [ 'FLOOD_EMAIL_LIMIT' ]);
}
2003-03-05 00:50:03 +00:00
2003-05-05 22:48:17 +00:00
$email_lang = ( ! empty ( $_POST [ 'lang' ])) ? htmlspecialchars ( $_POST [ 'lang' ]) : '' ;
2003-06-19 16:13:53 +00:00
$name = ( ! empty ( $_POST [ 'name' ])) ? trim ( strip_tags ( $_POST [ 'name' ])) : '' ;
$email = ( ! empty ( $_POST [ 'email' ])) ? trim ( strip_tags ( $_POST [ 'email' ])) : '' ;
$subject = ( ! empty ( $_POST [ 'subject' ])) ? trim ( stripslashes ( $_POST [ 'subject' ])) : '' ;
$message = ( ! empty ( $_POST [ 'message' ])) ? trim ( stripslashes ( $_POST [ 'message' ])) : '' ;
2003-05-05 22:48:17 +00:00
// Are we sending an email to a user on this board? Or are we sending a
// topic heads-up message?
if ( ! $topic_id )
2003-03-09 16:14:50 +00:00
{
2003-05-05 22:48:17 +00:00
// Get the appropriate username, etc.
2003-06-19 16:13:53 +00:00
$sql = ' SELECT username , user_email , user_allow_viewemail , user_lang
FROM ' . USERS_TABLE . "
2003-05-05 22:48:17 +00:00
WHERE user_id = $user_id
AND user_active = 1 " ;
$result = $db -> sql_query ( $sql );
if ( ! ( $row = $db -> sql_fetchrow ( $result )))
{
trigger_error ( $user -> lang [ 'NO_USER' ]);
}
$db -> sql_freeresult ( $result );
2003-03-05 00:50:03 +00:00
2003-05-05 22:48:17 +00:00
// Can we send email to this user?
2003-06-19 16:13:53 +00:00
if ( empty ( $row [ 'user_allow_viewemail' ]) && ! $auth -> acl_get ( 'a_user' ))
2003-03-09 16:14:50 +00:00
{
2003-05-05 22:48:17 +00:00
trigger_error ( $user -> lang [ 'NO_EMAIL' ]);
2003-03-05 00:50:03 +00:00
}
2003-05-05 22:48:17 +00:00
}
else
{
2003-06-19 16:13:53 +00:00
$sql = ' SELECT forum_id , topic_title
FROM ' . TOPICS_TABLE . "
2003-05-05 22:48:17 +00:00
WHERE topic_id = $topic_id " ;
$result = $db -> sql_query ( $sql );
if ( ! ( $row = $db -> sql_fetchrow ( $result )))
{
trigger_error ( $user -> lang [ 'NO_TOPIC' ]);
}
$db -> sql_freeresult ( $result );
if ( ! $auth -> acl_get ( 'f_read' , $row [ 'forum_id' ]))
{
trigger_error ( $user -> lang [ 'NO_FORUM_READ' ]);
}
if ( ! $auth -> acl_get ( 'f_email' , $row [ 'forum_id' ]))
2003-03-05 00:50:03 +00:00
{
2003-05-05 22:48:17 +00:00
trigger_error ( $user -> lang [ 'NO_EMAIL' ]);
2003-03-05 00:50:03 +00:00
}
2003-05-05 22:48:17 +00:00
}
2003-02-22 17:18:44 +00:00
2003-05-05 22:48:17 +00:00
// User has submitted a message, handle it
$error = array ();
if ( isset ( $_POST [ 'submit' ]))
{
if ( ! $topic_id )
2003-03-09 16:14:50 +00:00
{
2003-05-05 22:48:17 +00:00
if ( $subject == '' )
{
$error [] = $user -> lang [ 'EMPTY_SUBJECT_EMAIL' ];
}
if ( $message == '' )
{
$error [] = $user -> lang [ 'EMPTY_MESSAGE_EMAIL' ];
}
2003-03-09 16:14:50 +00:00
}
else
{
2003-10-04 14:00:31 +00:00
if ( ! $email || ! preg_match ( '#^.*?@(.*?\.)?[a-z0-9\-]+\.[a-z]{2,4}$#i' , $email ))
2003-05-05 22:48:17 +00:00
{
$error [] = $user -> lang [ 'EMPTY_ADDRESS_EMAIL' ];
}
2003-10-04 14:00:31 +00:00
if ( ! $name )
2003-05-05 22:48:17 +00:00
{
$error [] = $user -> lang [ 'EMPTY_NAME_EMAIL' ];
}
2003-03-09 16:14:50 +00:00
}
2003-03-05 00:50:03 +00:00
2003-05-05 22:48:17 +00:00
if ( ! sizeof ( $error ))
2003-03-09 16:14:50 +00:00
{
2003-06-19 16:13:53 +00:00
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_emailtime = ' . time() . '
WHERE user_id = ' . $user->data[' user_id ' ];
2003-03-09 16:14:50 +00:00
$result = $db -> sql_query ( $sql );
2003-03-05 00:50:03 +00:00
2003-03-09 16:14:50 +00:00
include ( $phpbb_root_path . 'includes/emailer.' . $phpEx );
2003-03-25 16:50:18 +00:00
$emailer = new emailer ();
2003-05-05 22:48:17 +00:00
$email_tpl = ( ! $topic_id ) ? 'profile_send_email' : 'email_notify' ;
$email_lang = ( ! $topic_id ) ? $row [ 'user_lang' ] : $email_lang ;
$emailer -> template ( $email_tpl , $email_lang );
2003-04-21 14:16:21 +00:00
$emailer -> subject ( $subject );
2003-03-05 00:50:03 +00:00
2003-04-21 14:16:21 +00:00
$emailer -> replyto ( $user -> data [ 'user_email' ]);
2003-05-05 22:48:17 +00:00
if ( ! $topic_id )
{
$emailer -> to ( $row [ 'user_email' ], $row [ 'username' ]);
}
else
{
$emailer -> to ( $email , $name );
}
2003-03-09 16:14:50 +00:00
if ( ! empty ( $_POST [ 'cc_email' ]))
{
2003-04-21 14:16:21 +00:00
$emailer -> cc ( $user -> data [ 'user_email' ], $user -> data [ 'username' ]);
2003-03-09 16:14:50 +00:00
}
2003-04-21 14:16:21 +00:00
2003-05-05 22:48:17 +00:00
$emailer -> headers ( 'X-AntiAbuse: Board servername - ' . $config [ 'server_name' ]);
2003-04-21 14:16:21 +00:00
$emailer -> headers ( 'X-AntiAbuse: User_id - ' . $user -> data [ 'user_id' ]);
$emailer -> headers ( 'X-AntiAbuse: Username - ' . $user -> data [ 'username' ]);
$emailer -> headers ( 'X-AntiAbuse: User IP - ' . $user -> ip );
2003-03-09 16:14:50 +00:00
$emailer -> assign_vars ( array (
'SITENAME' => $config [ 'sitename' ],
2003-03-25 16:50:18 +00:00
'BOARD_EMAIL' => $config [ 'board_contact' ],
'FROM_USERNAME' => $user -> data [ 'username' ],
2003-05-05 22:48:17 +00:00
'TO_USERNAME' => ( $topic_id ) ? $name : $row [ 'username' ],
'MESSAGE' => $message ,
'TOPIC_NAME' => ( $topic_id ) ? strtr ( $row [ 'topic_title' ], array_flip ( get_html_translation_table ( HTML_ENTITIES ))) : '' ,
'U_TOPIC' => ( $topic_id ) ? generate_board_url () . " /viewtopic. $phpEx ?f= " . $row [ 'forum_id' ] . " &t=topic_id " : '' )
2003-03-09 16:14:50 +00:00
);
2003-03-25 16:50:18 +00:00
2003-03-09 16:14:50 +00:00
$emailer -> send ();
$emailer -> reset ();
2003-05-05 22:48:17 +00:00
meta_refresh ( 3 , " index. $phpEx $SID " );
$message = ( ! $topic_id ) ? sprintf ( $user -> lang [ 'RETURN_INDEX' ], '<a href="' . " index. $phpEx $SID " . '">' , '</a>' ) : sprintf ( $user -> lang [ 'RETURN_TOPIC' ], " <a href= \" viewtopic. $phpEx $SID &f= $forum_id &t= " . $row [ 'topic_id' ] . '">' , '</a>' );
trigger_error ( $user -> lang [ 'EMAIL_SENT' ] . '<br /><br />' . $message );
2003-03-09 16:14:50 +00:00
}
}
2003-03-05 00:50:03 +00:00
2003-05-05 22:48:17 +00:00
if ( $topic_id )
{
$template -> assign_vars ( array (
'EMAIL' => htmlspecialchars ( $email ),
'NAME' => htmlspecialchars ( $name ),
'TOPIC_TITLE' => $row [ 'topic_title' ],
'U_TOPIC' => " viewtopic. $phpEx $SID &f= " . $row [ 'forum_id' ] . " &t=topic_id " ,
'S_LANG_OPTIONS' => ( $topic_id ) ? language_select ( $email_lang ) : '' )
);
}
2003-03-05 00:50:03 +00:00
$template -> assign_vars ( array (
2003-05-05 22:48:17 +00:00
'USERNAME' => ( ! $topic_id ) ? addslashes ( $row [ 'username' ]) : '' ,
'ERROR_MESSAGE' => ( sizeof ( $error )) ? implode ( '<br />' , $error ) : '' ,
'L_EMAIL_BODY_EXPLAIN' => ( ! $topic_id ) ? $user -> lang [ 'EMAIL_BODY_EXPLAIN' ] : $user -> lang [ 'EMAIL_TOPIC_EXPLAIN' ],
2003-03-09 16:14:50 +00:00
2003-05-05 22:48:17 +00:00
'S_POST_ACTION' => ( ! $topic_id ) ? " memberlist. $phpEx $SID &mode=email&u= $user_id " : " memberlist. $phpEx $SID &mode=email&f= $forum_id &t= $topic_id " ,
'S_SEND_USER' => ( ! $topic_id ) ? true : false )
2003-03-05 00:50:03 +00:00
);
2003-03-09 16:14:50 +00:00
break ;
2002-11-12 20:55:18 +00:00
2003-03-09 16:14:50 +00:00
default :
// The basic memberlist
$page_title = $user -> lang [ 'MEMBERLIST' ];
$template_html = 'memberlist_body.html' ;
2003-03-05 00:50:03 +00:00
2003-03-09 16:14:50 +00:00
// Sorting
2003-04-20 14:36:52 +00:00
$sort_key_text = array ( 'a' => $user -> lang [ 'SORT_USERNAME' ], 'b' => $user -> lang [ 'SORT_LOCATION' ], 'c' => $user -> lang [ 'SORT_JOINED' ], 'd' => $user -> lang [ 'SORT_POST_COUNT' ], 'e' => $user -> lang [ 'SORT_EMAIL' ], 'f' => $user -> lang [ 'WEBSITE' ], 'g' => $user -> lang [ 'ICQ' ], 'h' => $user -> lang [ 'AIM' ], 'i' => $user -> lang [ 'MSNM' ], 'j' => $user -> lang [ 'YIM' ], 'k' => $user -> lang [ 'SORT_LAST_ACTIVE' ], 'l' => $user -> lang [ 'SORT_RANK' ]);
$sort_key_sql = array ( 'a' => 'username' , 'b' => 'user_from' , 'c' => 'user_regdate' , 'd' => 'user_posts' , 'e' => 'user_email' , 'f' => 'user_website' , 'g' => 'user_icq' , 'h' => 'user_aim' , 'i' => 'user_msnm' , 'j' => 'user_yim' , 'k' => 'user_lastvisit' , 'l' => 'user_rank DESC, user_posts' );
2003-03-09 16:14:50 +00:00
$sort_dir_text = array ( 'a' => $user -> lang [ 'ASCENDING' ], 'd' => $user -> lang [ 'DESCENDING' ]);
2003-03-17 00:53:38 +00:00
$s_sort_key = '' ;
2003-03-09 16:14:50 +00:00
foreach ( $sort_key_text as $key => $value )
2003-03-05 00:50:03 +00:00
{
2003-03-09 16:14:50 +00:00
$selected = ( $sort_key == $key ) ? ' selected="selected"' : '' ;
$s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
2003-03-05 00:50:03 +00:00
2003-03-17 00:53:38 +00:00
$s_sort_dir = '' ;
2003-03-09 16:14:50 +00:00
foreach ( $sort_dir_text as $key => $value )
{
$selected = ( $sort_dir == $key ) ? ' selected="selected"' : '' ;
$s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
2003-03-05 00:50:03 +00:00
2003-04-15 23:42:06 +00:00
// Additional sorting options for user search ... if search is enabled, if not
// then only admins can make use of this (for ACP functionality)
2003-03-09 16:14:50 +00:00
$where_sql = '' ;
2003-04-15 23:42:06 +00:00
if ( $mode == 'searchuser' && ( ! empty ( $config [ 'load_search' ]) || $auth -> acl_get ( 'a_' )))
2003-03-09 16:14:50 +00:00
{
$find_key_match = array ( 'lt' => '<' , 'gt' => '>' , 'eq' => '=' );
$find_count = array ( 'lt' => $user -> lang [ 'LESS_THAN' ], 'eq' => $user -> lang [ 'EQUAL_TO' ], 'gt' => $user -> lang [ 'MORE_THAN' ]);
$s_find_count = '' ;
foreach ( $find_count as $key => $value )
{
$selected = ( $count_select == $key ) ? ' selected="selected"' : '' ;
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
$find_time = array ( 'lt' => $user -> lang [ 'BEFORE' ], 'gt' => $user -> lang [ 'AFTER' ]);
$s_find_join_time = '' ;
foreach ( $find_time as $key => $value )
{
$selected = ( $joined_select == $key ) ? ' selected="selected"' : '' ;
$s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
$s_find_active_time = '' ;
foreach ( $find_time as $key => $value )
{
$selected = ( $active_select == $key ) ? ' selected="selected"' : '' ;
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
$where_sql .= ( $username ) ? " AND username LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $username )) . " ' " : '' ;
$where_sql .= ( $email ) ? " AND user_email LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $email )) . " ' " : '' ;
$where_sql .= ( $icq ) ? " AND user_icq LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $icq )) . " ' " : '' ;
$where_sql .= ( $aim ) ? " AND user_aim LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $aim )) . " ' " : '' ;
$where_sql .= ( $yahoo ) ? " AND user_yim LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $yahoo )) . " ' " : '' ;
$where_sql .= ( $msn ) ? " AND user_msnm LIKE ' " . str_replace ( '*' , '%' , $db -> sql_escape ( $msn )) . " ' " : '' ;
$where_sql .= ( $joined ) ? " AND user_regdate " . $find_key_match [ $joined_select ] . " " . gmmktime ( 0 , 0 , 0 , intval ( $joined [ 1 ]), intval ( $joined [ 2 ]), intval ( $joined [ 0 ])) : '' ;
$where_sql .= ( $count ) ? " AND user_posts " . $find_key_match [ $count_select ] . " $count " : '' ;
$where_sql .= ( $active ) ? " AND user_lastvisit " . $find_key_match [ $active_select ] . " " . gmmktime ( 0 , 0 , 0 , $active [ 1 ], intval ( $active [ 2 ]), intval ( $active [ 0 ])) : '' ;
if ( ! empty ( $ipdomain ))
{
$ips = ( preg_match ( '#[a-z]#' , $ipdomain )) ? implode ( ', ' , preg_replace ( '#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#' , " ' \\ 1' " , gethostbynamel ( $ipdomain ))) : " ' " . str_replace ( '*' , '%' , $ipdomain ) . " ' " ;
2003-07-14 22:54:39 +00:00
$sql = ' SELECT DISTINCT poster_id
FROM ' . POSTS_TABLE . '
WHERE poster_ip ' . ((preg_match(' #%#', $ips)) ? 'LIKE' : 'IN') . " ($ips)";
2003-03-09 16:14:50 +00:00
$result = $db -> sql_query ( $sql );
if ( $row = $db -> sql_fetchrow ( $result ))
{
$ip_sql = '' ;
do
{
$ip_sql .= (( $ip_sql != '' ) ? ', ' : '' ) . $row [ 'poster_id' ];
}
while ( $row = $db -> sql_fetchrow ( $result ));
$where_sql .= " AND user_id IN ( $ip_sql ) " ;
}
else
{
// A minor fudge but it does the job :D
$where_sql .= " AND user_id IN ('-1') " ;
}
}
}
// Sorting and order
$order_by = $sort_key_sql [ $sort_key ] . ' ' . (( $sort_dir == 'a' ) ? 'ASC' : 'DESC' );
2003-03-05 00:50:03 +00:00
2003-03-09 16:14:50 +00:00
// Count the users ...
2003-03-25 00:05:28 +00:00
if ( $where_sql != '' )
{
$sql = " SELECT COUNT(user_id) AS total_users
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . "
$where_sql " ;
$result = $db -> sql_query ( $sql );
2003-03-09 16:14:50 +00:00
2003-03-25 00:05:28 +00:00
$total_users = ( $row = $db -> sql_fetchrow ( $result )) ? $row [ 'total_users' ] : 0 ;
}
else
{
$total_users = $config [ 'num_users' ];
}
2003-03-09 16:14:50 +00:00
// Pagination string
2003-03-17 00:53:38 +00:00
$pagination_url = " memberlist. $phpEx $SID &mode= $mode " ;
2003-03-09 16:14:50 +00:00
2003-04-20 14:36:52 +00:00
// Build a relevant pagination_url
$global_var = ( isset ( $_POST [ 'submit' ])) ? '_POST' : '_GET' ;
foreach ( $$global_var as $key => $var )
2003-03-09 16:14:50 +00:00
{
2003-04-20 14:36:52 +00:00
if ( in_array ( $key , array ( 'submit' , 'start' , 'mode' )) || $var == '' )
2003-03-17 00:53:38 +00:00
{
2003-04-20 14:36:52 +00:00
continue ;
2003-03-17 00:53:38 +00:00
}
2003-04-20 14:36:52 +00:00
$pagination_url .= '&' . $key . '=' . urlencode ( $var );
}
2003-03-17 00:53:38 +00:00
2003-04-20 14:36:52 +00:00
// Some search user specific data
if ( $mode == 'searchuser' && ( ! empty ( $config [ 'load_search' ]) || $auth -> acl_get ( 'a_' )))
{
2003-03-09 16:14:50 +00:00
$template -> assign_vars ( array (
'USERNAME' => $username ,
'EMAIL' => $email ,
'ICQ' => $icq ,
'AIM' => $aim ,
'YAHOO' => $yahoo ,
'MSNM' => $msn ,
'JOINED' => implode ( '-' , $joined ),
'ACTIVE' => implode ( '-' , $active ),
'COUNT' => $count ,
'IP' => $ipdomain ,
'S_SEARCH_USER' => true ,
'S_FORM_NAME' => $form ,
'S_FIELD_NAME' => $field ,
'S_COUNT_OPTIONS' => $s_find_count ,
'S_SORT_OPTIONS' => $s_sort_key ,
'S_USERNAME_OPTIONS' => $username_list ,
'S_JOINED_TIME_OPTIONS' => $s_find_join_time ,
'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time ,
'S_SEARCH_ACTION' => " memberslist. $phpEx $SID &mode=searchuser&field= $field " )
);
2003-02-22 17:18:44 +00:00
}
2003-03-09 16:14:50 +00:00
2003-03-10 17:48:08 +00:00
$sql = ' SELECT session_user_id , MAX ( session_time ) AS session_time
FROM ' . SESSIONS_TABLE . '
WHERE session_time >= ' . (time() - 300) . '
AND session_user_id <> ' . ANONYMOUS . '
GROUP BY session_user_id ' ;
$result = $db -> sql_query ( $sql );
$session_times = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$session_times [ $row [ 'session_user_id' ]] = $row [ 'session_time' ];
}
$db -> sql_freeresult ( $result );
2003-03-09 16:14:50 +00:00
// Do the SQL thang
2003-06-19 16:13:53 +00:00
$sql = ' SELECT username , user_id , user_colour , user_allow_viewemail , user_posts , user_regdate , user_rank , user_from , user_website , user_email , user_icq , user_aim , user_yim , user_msnm , user_avatar , user_avatar_type , user_allowavatar , user_lastvisit
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . "
2003-03-17 00:53:38 +00:00
$where_sql
2003-03-25 00:05:28 +00:00
ORDER BY $order_by " ;
$result = $db -> sql_query_limit ( $sql , $config [ 'topics_per_page' ], $start );
2003-03-09 16:14:50 +00:00
if ( $row = $db -> sql_fetchrow ( $result ))
{
$i = 0 ;
do
{
2003-03-10 17:48:08 +00:00
$row [ 'session_time' ] = ( ! empty ( $session_times [ $row [ 'user_id' ]])) ? $session_times [ $row [ 'user_id' ]] : '' ;
2003-03-09 16:14:50 +00:00
$template -> assign_block_vars ( 'memberrow' , array_merge ( show_profile ( $row ), array (
'ROW_NUMBER' => $i + ( $start + 1 ),
'S_ROW_COUNT' => $i ,
'U_VIEWPROFILE' => " memberlist. $phpEx $SID &mode=viewprofile&u= " . $row [ 'user_id' ]))
);
$i ++ ;
}
while ( $row = $db -> sql_fetchrow ( $result ));
2003-02-22 17:18:44 +00:00
}
2003-03-05 00:50:03 +00:00
// Generate page
$template -> assign_vars ( array (
'PAGINATION' => generate_pagination ( $pagination_url , $total_users , $config [ 'topics_per_page' ], $start ),
2003-03-17 00:53:38 +00:00
'PAGE_NUMBER' => on_page ( $total_users , $config [ 'topics_per_page' ], $start ),
2003-03-25 00:05:28 +00:00
'TOTAL_USERS' => ( $total_users == 1 ) ? $user -> lang [ 'LIST_USER' ] : sprintf ( $user -> lang [ 'LIST_USERS' ], $total_users ),
2003-03-05 00:50:03 +00:00
2003-06-19 16:13:53 +00:00
'PROFILE_IMG' => $user -> img ( 'btn_profile' , $user -> lang [ 'PROFILE' ]),
'PM_IMG' => $user -> img ( 'btn_pm' , $user -> lang [ 'MESSAGE' ]),
'EMAIL_IMG' => $user -> img ( 'btn_email' , $user -> lang [ 'EMAIL' ]),
'WWW_IMG' => $user -> img ( 'btn_www' , $user -> lang [ 'WWW' ]),
'ICQ_IMG' => $user -> img ( 'btn_icq' , $user -> lang [ 'ICQ' ]),
'AIM_IMG' => $user -> img ( 'btn_aim' , $user -> lang [ 'AIM' ]),
'MSN_IMG' => $user -> img ( 'btn_msnm' , $user -> lang [ 'MSNM' ]),
'YIM_IMG' => $user -> img ( 'btn_yim' , $user -> lang [ 'YIM' ]),
'JABBER_IMG' => $user -> img ( 'btn_jabber' , $user -> lang [ 'JABBER' ]),
'SEARCH_IMG' => $user -> img ( 'btn_search' , $user -> lang [ 'SEARCH' ]),
2003-04-15 23:42:06 +00:00
'U_FIND_MEMBER' => ( ! empty ( $config [ 'load_search' ]) || $auth -> acl_get ( 'a_' )) ? " memberlist. $phpEx $SID &mode=searchuser " : '' ,
2003-03-05 00:50:03 +00:00
'U_SORT_USERNAME' => " memberlist. $phpEx $SID &sk=a&sd= " . (( $sort_key == 'a' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_FROM' => " memberlist. $phpEx $SID &sk=b&sd= " . (( $sort_key == 'b' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_JOINED' => " memberlist. $phpEx $SID &sk=c&sd= " . (( $sort_key == 'c' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_POSTS' => " memberlist. $phpEx $SID &sk=d&sd= " . (( $sort_key == 'd' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_EMAIL' => " memberlist. $phpEx $SID &sk=e&sd= " . (( $sort_key == 'e' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_WEBSITE' => " memberlist. $phpEx $SID &sk=f&sd= " . (( $sort_key == 'f' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_ICQ' => " memberlist. $phpEx $SID &sk=g&sd= " . (( $sort_key == 'g' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_AIM' => " memberlist. $phpEx $SID &sk=h&sd= " . (( $sort_key == 'h' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_MSN' => " memberlist. $phpEx $SID &sk=i&sd= " . (( $sort_key == 'i' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_YIM' => " memberlist. $phpEx $SID &sk=j&sd= " . (( $sort_key == 'j' && $sort_dir == 'a' ) ? 'd' : 'a' ),
'U_SORT_ACTIVE' => " memberlist. $phpEx $SID &sk=k&sd= " . (( $sort_key == 'k' && $sort_dir == 'a' ) ? 'd' : 'a' ),
2003-04-20 14:36:52 +00:00
'U_SORT_RANK' => " memberlist. $phpEx $SID &sk=l&sd= " . (( $sort_key == 'l' && $sort_dir == 'a' ) ? 'd' : 'a' ),
2003-03-05 00:50:03 +00:00
'S_MODE_SELECT' => $s_sort_key ,
'S_ORDER_SELECT' => $s_sort_dir ,
'S_MODE_ACTION' => " memberlist. $phpEx $SID &mode= $mode &form= $form " )
);
2002-03-31 00:06:34 +00:00
}
2001-07-07 00:57:58 +00:00
2003-03-08 22:10:24 +00:00
// Output the page
2003-05-03 23:58:45 +00:00
page_header ( $page_title );
2003-03-08 22:10:24 +00:00
$template -> set_filenames ( array (
2003-03-09 16:14:50 +00:00
'body' => $template_html )
2003-03-08 22:10:24 +00:00
);
make_jumpbox ( 'viewforum.' . $phpEx );
2003-05-03 23:58:45 +00:00
page_footer ();
2003-03-08 22:10:24 +00:00
// ---------
// FUNCTIONS
//
function show_profile ( $data )
{
2003-06-19 16:13:53 +00:00
global $config , $auth , $template , $user , $ranks , $SID , $phpEx ;
2003-03-08 22:10:24 +00:00
$username = $data [ 'username' ];
$user_id = $data [ 'user_id' ];
2001-07-05 00:57:28 +00:00
2003-03-05 00:50:03 +00:00
$rank_title = $rank_img = '' ;
2003-06-19 16:13:53 +00:00
if ( ! empty ( $data [ 'user_rank' ]))
2003-03-05 00:50:03 +00:00
{
2003-06-19 16:13:53 +00:00
$rank_title = $ranks [ 'special' ][ $data [ 'user_rank' ]][ 'rank_title' ];
$rank_img = ( ! empty ( $ranks [ 'special' ][ $data [ 'user_rank' ]][ 'rank_image' ])) ? '<img src="' . $config [ 'ranks_path' ] . '/' . $ranks [ 'special' ][ $data [ 'user_rank' ]][ 'rank_image' ] . '" border="0" alt="' . $ranks [ 'special' ][ $data [ 'user_rank' ]][ 'rank_title' ] . '" title="' . $ranks [ 'special' ][ $data [ 'user_rank' ]][ 'rank_title' ] . '" /><br />' : '' ;
2003-03-05 00:50:03 +00:00
}
else
{
2003-06-19 16:13:53 +00:00
foreach ( $ranks [ 'normal' ] as $rank )
{
if ( $data [ 'user_posts' ] >= $rank [ 'rank_min' ])
{
$rank_title = $rank [ 'rank_title' ];
$rank_img = ( ! empty ( $rank [ 'rank_image' ])) ? '<img src="' . $config [ 'ranks_path' ] . '/' . $rank [ 'rank_image' ] . '" border="0" alt="' . $rank [ 'rank_title' ] . '" title="' . $rank [ 'rank_title' ] . '" /><br />' : '' ;
break ;
}
}
2002-01-16 17:40:02 +00:00
}
2001-07-05 00:57:28 +00:00
2003-06-19 16:13:53 +00:00
$email = ( ! empty ( $data [ 'user_allow_viewemail' ]) || $auth -> acl_get ( 'a_email' )) ? (( ! empty ( $config [ 'board_email_form' ])) ? " memberlist. $phpEx $SID &mode=email&u= $user_id " : 'mailto:' . $row [ 'user_email' ]) : '' ;
2003-03-08 22:10:24 +00:00
2003-03-09 16:14:50 +00:00
$last_visit = ( ! empty ( $data [ 'session_time' ])) ? $data [ 'session_time' ] : $data [ 'user_lastvisit' ];
2003-06-19 16:13:53 +00:00
// Dump it out to the template
// TODO
// Add permission check for IM clients
return array (
2003-03-25 16:50:18 +00:00
'USERNAME' => $username ,
'USER_COLOR' => ( ! empty ( $data [ 'user_colour' ])) ? $data [ 'user_colour' ] : '' ,
'RANK_TITLE' => $rank_title ,
2003-07-14 22:54:39 +00:00
'KARMA' => ( ! empty ( $data [ 'user_karma' ])) ? $data [ 'user_karma' ] : 0 ,
2003-06-05 00:53:39 +00:00
'JOINED' => $user -> format_date ( $data [ 'user_regdate' ], $user -> lang [ 'DATE_FORMAT' ]),
'VISITED' => ( empty ( $last_visit )) ? ' - ' : $user -> format_date ( $last_visit , $user -> lang [ 'DATE_FORMAT' ]),
'POSTS' => ( $data [ 'user_posts' ]) ? $data [ 'user_posts' ] : 0 ,
2003-06-19 16:13:53 +00:00
'KARMA_IMG' => '<img src="images/karma' . $data [ 'user_karma' ] . '.gif" alt="' . $user -> lang [ 'KARMA_LEVEL' ] . ': ' . $user -> lang [ 'KARMA' ][ $data [ 'user_karma' ]] . '" title="' . $user -> lang [ 'KARMA_LEVEL' ] . ': ' . $user -> lang [ 'KARMA' ][ $data [ 'user_karma' ]] . '" />' ,
'ONLINE_IMG' => ( intval ( $data [ 'session_time' ]) >= time () - ( $config [ 'load_online_time' ] * 60 )) ? $user -> img ( 'btn_online' , $user -> lang [ 'USER_ONLINE' ]) : $user -> img ( 'btn_offline' , $user -> lang [ 'USER_ONLINE' ]),
'RANK_IMG' => $rank_img ,
'ICQ_STATUS_IMG' => ( ! empty ( $data [ 'user_icq' ])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data [ 'user_icq' ] . '&img=5" width="18" height="18" border="0" />' : '' ,
2003-09-15 23:52:22 +00:00
'U_PROFILE' => " memberlist. $phpEx $SID &mode=viewprofile&u= $user_id " ,
'U_SEARCH_USER' => ( $auth -> acl_get ( 'u_search' )) ? " search. $phpEx $SID &search_author= " . urlencode ( $username ) . " &show_results=posts " : '' ,
'U_PM' => ( $auth -> acl_get ( 'u_sendpm' )) ? " ucp. $phpEx $SID &mode=pm&action=send&u= $user_id " : '' ,
'U_EMAIL' => $email ,
'U_WWW' => ( ! empty ( $data [ 'user_website' ])) ? $data [ 'user_website' ] : '' ,
'U_ICQ' => ( $data [ 'user_icq' ]) ? " memberlist. $phpEx $SID &mode=contact&action=icq&u= $user_id " : '' ,
'U_AIM' => ( $data [ 'user_aim' ]) ? " memberlist. $phpEx $SID &mode=contact&action=aim&u= $user_id " : '' ,
'U_YIM' => ( $data [ 'user_yim' ]) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row [ 'user_yim' ] . '&.src=pg' : '' ,
'U_MSN' => ( $data [ 'user_msn' ]) ? " memberlist. $phpEx $SID &mode=contact&action=msn&u= $user_id " : '' ,
'U_JABBER' => ( $data [ 'user_jabber' ]) ? " memberlist. $phpEx $SID &mode=contact&action=jabber&u= $user_id " : '' ,
2003-06-05 00:53:39 +00:00
'S_ONLINE' => ( intval ( $data [ 'session_time' ]) >= time () - 300 ) ? true : false
2003-03-05 00:50:03 +00:00
);
2003-03-08 22:10:24 +00:00
}
//
// FUNCTIONS
// ---------
2001-07-05 00:57:28 +00:00
2002-03-31 00:06:34 +00:00
?>