Files
IPB/upload/sources/action_public/memberlist.php
T
2025-12-19 00:21:15 -08:00

536 lines
19 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.1.7
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Tuesday 18th of July 2006 05:56:00 PM
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
+---------------------------------------------------------------------------
| > $Date: 2006-01-11 22:47:48 +0000 (Wed, 11 Jan 2006) $
| > $Revision: 122 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Show all the members
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Wed 19 May 2004
| > Quality Checked: Wed 15 Sept. 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Íåêîððåêòíûé àäðåñ</h1>Âû íå èìååòå äîñòóïà ê ýòîìó ôàéëó íàïðÿìóþ. Åñëè âû íåäàâíî îáíîâëÿëè ôîðóì, âû äîëæíû îáíîâèòü âñå ñîîòâåòñòâóþùèå ôàéëû.";
exit();
}
class memberlist
{
# Classes
var $ipsclass;
# Others
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $first = 0;
var $max_results = 10;
var $sort_key = 'members_display_name';
var $sort_order = 'asc';
var $filter = 'ALL';
var $mem_titles = array();
var $mem_groups = array();
var $ucp_html = "";
var $topic = "";
/*-------------------------------------------------------------------------*/
// Auto-run
/*-------------------------------------------------------------------------*/
function auto_run()
{
//-----------------------------------------
// Require the HTML and language modules
//-----------------------------------------
$this->ipsclass->load_language('lang_mlist');
$this->ipsclass->load_template('skin_mlist');
if ($this->ipsclass->member['g_mem_info'] != 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
}
//-----------------------------------------
// Grab topics.php to parse member
//-----------------------------------------
require_once( ROOT_PATH.'sources/action_public/topics.php' );
$this->topic = new topics();
$this->topic->ipsclass =& $this->ipsclass;
$this->topic->topic_init( 1 );
$see_groups = array();
//-----------------------------------------
// Get the member groups, member titles stuff
//-----------------------------------------
foreach( $this->ipsclass->cache['group_cache'] as $id => $row )
{
if ( $row['g_hide_from_list'] )
{
continue;
}
$see_groups[] = $row['g_id'];
$this->mem_groups[ $row['g_id'] ] = array( 'TITLE' => $row['g_title'],
'ICON' => $row['g_icon'],
);
}
$the_filter = array( 'ALL' => $this->ipsclass->lang['show_all'] );
foreach($this->mem_groups as $id => $data)
{
if ($id == $this->ipsclass->vars['guest_group'])
{
continue;
}
$the_filter[$id] = $data['TITLE'];
}
$group_string = implode( ",", $see_groups );
//-----------------------------------------
// Test for input
//-----------------------------------------
if (isset($this->ipsclass->input['st'])) $this->first = intval($this->ipsclass->input['st']);
if (isset($this->ipsclass->input['max_results'])) $this->max_results = $this->ipsclass->input['max_results'];
if (isset($this->ipsclass->input['sort_key'])) $this->sort_key = $this->ipsclass->input['sort_key'];
if (isset($this->ipsclass->input['sort_order'])) $this->sort_order = $this->ipsclass->input['sort_order'];
if (isset($this->ipsclass->input['filter'])) $this->filter = $this->ipsclass->input['filter'];
//-----------------------------------------
// Init some arrays
//-----------------------------------------
$the_sort_key = array( 'members_display_name' => 'sort_by_name',
'posts' => 'sort_by_posts',
'joined' => 'sort_by_joined',
);
$the_max_results = array( 10 => '10',
20 => '20',
30 => '30',
40 => '40',
50 => '50',
);
$the_sort_order = array( 'desc' => 'descending_order',
'asc' => 'ascending_order',
);
//-----------------------------------------
// Start the form stuff
//-----------------------------------------
$filter_html = "<select name='filter' class='forminput'>\n";
$sort_key_html = "<select name='sort_key' class='forminput'>\n";
$max_results_html = "<select name='max_results' class='forminput'>\n";
$sort_order_html = "<select name='sort_order' class='forminput'>\n";
foreach ($the_sort_order as $k => $v)
{
$sort_order_html .= $k == $this->sort_order ? "<option value='$k' selected>" . $this->ipsclass->lang[ $the_sort_order[ $k ] ] . "</option>\n"
: "<option value='$k'>" . $this->ipsclass->lang[ $the_sort_order[ $k ] ] . "</option>\n";
}
foreach ($the_filter as $k => $v)
{
$filter_html .= $k == $this->filter ? "<option value='$k' selected>" . $the_filter[ $k ] . "</option>\n"
: "<option value='$k'>" . $the_filter[ $k ] . "</option>\n";
}
foreach ($the_sort_key as $k => $v)
{
$sort_key_html .= $k == $this->sort_key ? "<option value='$k' selected>" . $this->ipsclass->lang[ $the_sort_key[ $k ] ] . "</option>\n"
: "<option value='$k'>" . $this->ipsclass->lang[ $the_sort_key[ $k ] ] . "</option>\n";
}
foreach ($the_max_results as $k => $v)
{
$max_results_html .= $k == $this->max_results ? "<option value='$k' selected>". $the_max_results[ $k ] . "</option>\n"
: "<option value='$k'>" . $the_max_results[ $k ] . "</option>\n";
}
$this->ipsclass->lang['sorting_text'] = preg_replace( "/<#FILTER#>/" , $filter_html."</select>" , $this->ipsclass->lang['sorting_text'] );
$this->ipsclass->lang['sorting_text'] = preg_replace( "/<#SORT_KEY#>/" , $sort_key_html."</select>" , $this->ipsclass->lang['sorting_text'] );
$this->ipsclass->lang['sorting_text'] = preg_replace( "/<#SORT_ORDER#>/" , $sort_order_html."</select>" , $this->ipsclass->lang['sorting_text'] );
$this->ipsclass->lang['sorting_text'] = preg_replace( "/<#MAX_RESULTS#>/" , $max_results_html."</select>", $this->ipsclass->lang['sorting_text'] );
$error = 0;
if ( ! isset($the_sort_key[ $this->sort_key ]) ) $error = 1;
if ( ! isset($the_sort_order[ $this->sort_order ]) ) $error = 1;
if ( ! isset($the_filter[ $this->filter ]) ) $error = 1;
if ( ! isset($the_max_results[ $this->max_results ]) ) $error = 1;
//-----------------------------------------
// Error?
//-----------------------------------------
if ($error == 1 )
{
if ( $this->ipsclass->input['b'] == 1 )
{
$this->ipsclass->Error( array( LEVEL=> 1, MSG =>'ml_error') );
}
else
{
$this->ipsclass->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
}
}
//-----------------------------------------
// Quick form?
//-----------------------------------------
$quick_jump = "";
for ( $i = 65; $i <= 90; $i++ )
{
$letter = strtolower(chr($i));
$selected = $this->ipsclass->input['quickjump'] == $letter ? ' selected="selected"' : '';
$quick_jump .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_quick_jump_entry( $letter, $selected );
}
//-----------------------------------------
// Get custom profile information
//-----------------------------------------
$custom_fields = "";
$this->topic->custom_fields->admin = intval($this->ipsclass->member['g_access_cp']);
$this->topic->custom_fields->supmod = intval($this->ipsclass->member['g_is_supmod']);
$this->topic->custom_fields->member_id = $this->ipsclass->member['id'];
$this->topic->custom_fields->mem_data_id = 0;
$this->topic->custom_fields->init_data();
$this->topic->custom_fields->parse_to_edit();
//-----------------------------------------
// Query..
//-----------------------------------------
$query = array();
$url = array();
$query_string = "";
//-----------------------------------------
// Quick jump rehash...
//-----------------------------------------
if ( $this->ipsclass->input['qjbutton'] and $this->ipsclass->input['quickjump'] )
{
$this->ipsclass->input['name_box'] = 'begins';
$this->ipsclass->input['name'] = $this->ipsclass->input['quickjump'];
}
//-----------------------------------------
// Member Groups...
//-----------------------------------------
if ($this->filter != 'ALL')
{
if ( ! preg_match( "/(^|,)".$this->filter."(,|$)/", $group_string ) )
{
$query[] = "m.mgroup IN($group_string)";
}
else
{
$query[] = "m.mgroup='".$this->filter."' ";
}
}
//-----------------------------------------
// NOT IN Member Groups...
//-----------------------------------------
if ( is_array( $this->ipsclass->cache['group_cache'] ) and count ( $this->ipsclass->cache['group_cache'] ) )
{
$hide_ids = array();
foreach( $this->ipsclass->cache['group_cache'] as $id => $data )
{
if ( $data['g_hide_from_list'] )
{
$hide_ids[] = $data['g_id'];
}
}
if ( count( $hide_ids ) )
{
$query[] = "m.mgroup NOT IN(".implode( ",", $hide_ids ).")";
}
}
//-----------------------------------------
// Build query
//-----------------------------------------
$dates = array( 'lastpost', 'lastvisit', 'joined' );
$mapit = array( 'aim' => 'me.aim_name',
'yahoo' => 'me.yahoo',
'icq' => 'me.icq_number',
'msn' => 'me.msnname',
'posts' => 'm.posts',
'joined' => 'm.joined',
'lastpost' => 'm.last_post',
'lastvisit' => 'm.last_visit',
'signature' => 'me.signature',
'homepage' => 'me.website',
'name' => 'm.name',
'photoonly' => 'me.photo_location',
);
//-----------------------------------------
// Do search
//-----------------------------------------
foreach( $mapit as $in => $tbl )
{
$inbit = $this->ipsclass->parse_clean_value(trim(urldecode(stripslashes($this->ipsclass->input[ $in ]))));
$url[] = $in.'='.$this->ipsclass->input[ $in ];
//-----------------------------------------
// Name...
//-----------------------------------------
if ( $in == 'name' and $inbit != "" )
{
if ( $this->ipsclass->input['name_box'] == 'begins' )
{
$query[] = "m.members_display_name LIKE '".$inbit."%'";
}
else
{
$query[] = "m.members_display_name LIKE '%".$inbit."%'";
}
}
else if ( $in == 'posts' and intval($inbit) > 0 )
{
$ltmt = $this->ipsclass->input[ $in .'_ltmt' ] == 'lt' ? '<' : '>';
$query[] = $tbl. ' '.$ltmt.' '.intval($inbit);
$url[] = $in .'_ltmt=' . $this->ipsclass->input[ $in .'_ltmt' ];
}
else if ( in_array( $in, $dates ) and $inbit )
{
list( $month, $day, $year ) = explode( '-', $this->ipsclass->input[ $in ] );
$month = intval($month);
$day = intval($day);
$year = intval($year);
if ( ! checkdate( $month, $day, $year ) )
{
continue;
}
$time_int = mktime( 0, 0 ,0,$month, $day, $year );
$ltmt = $this->ipsclass->input[ $in .'_ltmt' ] == 'lt' ? '<' : '>';
$query[] = $tbl. ' '.$ltmt.' '.$time_int;
$url[] = $in .'_ltmt=' . $this->ipsclass->input[ $in .'_ltmt' ];
}
else if ( $in == 'photoonly' )
{
if ( $this->ipsclass->input['photoonly'] == 1 )
{
$query[] = $tbl. "<> ''";
}
}
else if ( $inbit != "" )
{
$query[] = $tbl. " LIKE '%{$inbit}%'";
}
}
//-----------------------------------------
// Custom fields?
//-----------------------------------------
if ( count( $this->topic->custom_fields->out_fields ) )
{
foreach( $this->topic->custom_fields->out_fields as $id => $data )
{
if ( $this->ipsclass->input['field_'.$id] )
{
$query[] = "p.field_{$id} LIKE '{$this->ipsclass->input['field_'.$id]}%'";
$url[] = "field_{$id}=".$this->ipsclass->input['field_'.$id];
}
}
}
//-----------------------------------------
// Finish query
//-----------------------------------------
if ( count($query) )
{
$query_string = implode( " AND ", $query );
}
//-----------------------------------------
// Count...
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'mlist_count', array( 'query' => $query_string ) );
$this->ipsclass->DB->cache_exec_query();
$max = $this->ipsclass->DB->fetch_row();
$links = $this->ipsclass->build_pagelinks( array( 'TOTAL_POSS' => $max['total_members'],
'PER_PAGE' => $this->max_results,
'CUR_ST_VAL' => $this->first,
'L_SINGLE' => "",
'L_MULTI' => $this->ipsclass->lang['pages'],
'BASE_URL' => $this->ipsclass->base_url."&amp;name_box={$this->ipsclass->input['name_box']}&amp;sort_key={$this->sort_key}&amp;sort_order={$this->sort_order}&amp;filter={$this->filter}&amp;act=members&amp;max_results={$this->max_results}&amp;".implode( '&amp;', $url )
)
);
$this->output = $this->ipsclass->compiled_templates['skin_mlist']->mlist_start();
$this->output .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_page_header( $links, $quick_jump );
//-----------------------------------------
// Get custom profile information
//-----------------------------------------
$custom_fields = "";
if ( count( $this->topic->custom_fields->out_fields ) )
{
foreach( $this->topic->custom_fields->out_fields as $id => $data )
{
if ( $this->topic->custom_fields->cache_data[ $id ]['pf_type'] == 'drop' )
{
$tmp = $this->ipsclass->compiled_templates['skin_mlist']->mlist_custom_field_dropdown( 'field_'.$id, $data );
}
else
{
$tmp = $this->ipsclass->compiled_templates['skin_mlist']->mlist_custom_field_textinput( 'field_'.$id );
}
$custom_fields .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_custom_field_entry( $this->topic->custom_fields->field_names[ $id ], $tmp );
}
}
//-----------------------------------------
// START THE LISTING
//-----------------------------------------
if ( $max['total_members'] > 0 )
{
$this->ipsclass->DB->cache_add_query( 'mlist_get_members', array( 'query' => $query_string,
'sort' => $this->sort_key,
'order' => $this->sort_order,
'limit_a' => $this->first,
'limit_b' => $this->max_results ) );
$this->ipsclass->DB->cache_exec_query();
while ($member = $this->ipsclass->DB->fetch_row() )
{
$member = $this->topic->parse_member( $member );
$photo_vars = $this->ipsclass->cache['group_cache'][$member['mgroup']]['g_photo_max_vars'];
$photo_dims = array( 'pwidth' => 180, 'pheight' => 180 );
if( strpos( $photo_vars, ":" ) )
{
$tmp = array();
$tmp = explode( ":", $photo_vars );
$photo_dims['pwidth'] = $tmp[1]+30;
$photo_dims['pheight'] = $tmp[2]+30;
unset( $tmp, $photo_vars );
}
$member['joined'] = $this->ipsclass->get_date( $member['joined'], 'JOINED' );
$member['group'] = $this->mem_groups[ $member['mgroup'] ]['TITLE'];
if ($member['photo_type'] and $member['photo_location'])
{
$member['camera'] = "<a href=\"javascript:PopUp('{$this->ipsclass->base_url}act=Profile&amp;CODE=showphoto&amp;MID={$member['id']}','Photo','{$photo_dims['pwidth']}','{$photo_dims['pheight']}','0','1','1','1')\"><{CAMERA}></a>";
}
$member['posts'] = $this->ipsclass->do_number_format($member['posts']);
//-----------------------------------------
// Bug fix... name-- breaks formatting
// xhmlt invalid..
//-----------------------------------------
$member['members_display_name'] = str_replace( '--', '&#45;&#45;', $member['members_display_name'] );
$this->output .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_show_row($member);
}
}
else
{
$this->output .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_no_results();
}
$checked = $this->ipsclass->input['photoonly'] == 1 ? 'checked="checked"' : "";
//-----------------------------------------
// Print bottom...
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_page_end( $checked );
$this->output .= $this->ipsclass->compiled_templates['skin_mlist']->mlist_end( $links );
if ( $custom_fields )
{
$this->output = str_replace( '<!--CUSTOM_FIELDS-->', $this->ipsclass->compiled_templates['skin_mlist']->mlist_custom_field_wrap($custom_fields), $this->output );
}
//-----------------------------------------
// Push to print handler
//-----------------------------------------
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->lang['page_title'], 'JS' => 0, 'NAV' => array( $this->ipsclass->lang['page_title'] ) ) );
}
}
?>