. /** * @package MantisBT * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org * @copyright Copyright (C) 2002 - 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net * @link http://www.mantisbt.org */ /** * MantisBT Core API's */ require_once( 'core.php' ); require_once( 'icon_api.php' ); auth_reauthenticate(); access_ensure_global_level( config_get( 'manage_user_threshold' ) ); $t_user_table = db_get_table( 'mantis_user_table' ); $t_cookie_name = config_get( 'manage_users_cookie' ); $t_lock_image = '' . lang_get( 'protected' ) . ''; $c_filter = ''; $f_save = gpc_get_bool( 'save' ); $f_filter = utf8_strtoupper( gpc_get_string( 'filter', config_get( 'default_manage_user_prefix' ) ) ); $f_page_number = gpc_get_int( 'page_number', 1 ); if( !$f_save && !is_blank( gpc_get_cookie( $t_cookie_name, '' ) ) ) { $t_manage_arr = explode( ':', gpc_get_cookie( $t_cookie_name ) ); # Hide Inactive $f_hide_inactive = (bool)$t_manage_arr[0]; # Sort field if ( isset( $t_manage_arr[1] ) ) { $f_sort = $t_manage_arr[1]; } else { $f_sort = 'username'; } # Sort order if ( isset( $t_manage_arr[2] ) ) { $f_dir = $t_manage_arr[2]; } else { $f_dir = 'DESC'; } # Show Disabled if ( isset( $t_manage_arr[3] ) ) { $f_show_disabled = $t_manage_arr[3]; } } else { $f_sort = gpc_get_string( 'sort', 'username' ); $f_dir = gpc_get_string( 'dir', 'ASC' ); $f_hide_inactive = gpc_get_bool( 'hideinactive' ); $f_show_disabled = gpc_get_bool( 'showdisabled' ); } # Clean up the form variables if ( !db_field_exists( $f_sort, $t_user_table ) ) { $c_sort = 'username'; } else { $c_sort = addslashes( $f_sort ); } $c_dir = ( $f_dir == 'ASC' ) ? 'ASC' : 'DESC'; # 0 = show inactive users, anything else = hide them $c_hide_inactive = ( $f_hide_inactive == 0 ) ? 0 : 1; $t_hide_inactive_filter = '&hideinactive=' . $c_hide_inactive; # 0 = hide disabled users, anything else = show them $c_show_disabled = ( $f_show_disabled == 0 ) ? 0 : 1; $t_show_disabled_filter = '&showdisabled=' . $c_show_disabled; # set cookie values for hide inactive, sort by, dir and show disabled if ( $f_save ) { $t_manage_string = $c_hide_inactive.':'.$c_sort.':'.$c_dir.':'.$c_show_disabled; gpc_set_cookie( $t_cookie_name, $t_manage_string, true ); } html_page_top( lang_get( 'manage_users_link' ) ); print_manage_menu( 'manage_user_page.php' ); # New Accounts Form BEGIN $days_old = 7 * SECONDS_PER_DAY; $query = "SELECT * FROM $t_user_table WHERE ".db_helper_compare_days("" . db_now() . "","date_created","<= $days_old")." ORDER BY date_created DESC"; $result = db_query_bound( $query ); $g_db->debug=false; $new_user_count = db_num_rows( $result); # Never Logged In Form BEGIN $query = "SELECT * FROM $t_user_table WHERE ( login_count = 0 ) AND ( date_created = last_visit ) ORDER BY date_created DESC"; $result = db_query_bound( $query ); $unused_user_count = db_num_rows( $result ); # Manage Form BEGIN $t_prefix_array = array(); $t_prefix_array['ALL'] = lang_get( 'show_all_users' ); for ( $i = 'A'; $i != 'AA'; $i++ ) { $t_prefix_array[$i] = $i; } for ( $i = 0; $i <= 9; $i++ ) { $t_prefix_array["$i"] = "$i"; } $t_prefix_array['UNUSED'] = lang_get( 'users_unused' ); $t_prefix_array['NEW'] = lang_get( 'users_new' ); echo '
'; foreach ( $t_prefix_array as $t_prefix => $t_caption ) { echo ''; } echo '
'; if ( $t_prefix === $f_filter ) { $c_filter = $f_filter; echo "$t_caption"; } else { print_manage_user_sort_link( 'manage_user_page.php', $t_caption, $c_sort, $c_dir, null, $c_hide_inactive, $t_prefix, $c_show_disabled ); } if ( $t_prefix === 'UNUSED' ) { echo ' [' . $unused_user_count . '] (' . lang_get( 'never_logged_in_title' ) . ')'; } else if ( $t_prefix === 'NEW' ) { echo ' [' . $new_user_count . '] (' . lang_get( '1_week_title' ) . ')'; } echo '
'; $t_where_params = null; if ( $f_filter === 'ALL' ) { $t_where = '(1 = 1)'; } else if ( $f_filter === 'UNUSED' ) { $t_where = '(login_count = 0) AND ( date_created = last_visit )'; } else if ( $f_filter === 'NEW' ) { $t_where = db_helper_compare_days("" . db_now() . "","date_created","<= $days_old"); } else { $c_prefix = db_prepare_string($f_filter); $t_where = "(UPPER(username) LIKE '$c_prefix%')"; } $p_per_page = 50; $t_offset = ( ( $f_page_number - 1 ) * $p_per_page ); $total_user_count = 0; # Get the user data in $c_sort order $result = ''; if( 1 == $c_show_disabled ) { $t_show_disabled_cond = ''; } else { $t_show_disabled_cond = ' AND enabled = ' . db_prepare_bool(true); } if ( 0 == $c_hide_inactive ) { $query = "SELECT count(*) as usercnt FROM $t_user_table WHERE $t_where $t_show_disabled_cond"; $result = db_query_bound($query, $t_where_params); $row = db_fetch_array( $result ); $total_user_count = $row['usercnt']; } else { $query = "SELECT count(*) as usercnt FROM $t_user_table WHERE $t_where AND " . db_helper_compare_days("" . db_now() . "","last_visit","< $days_old") . $t_show_disabled_cond; $result = db_query_bound($query, $t_where_params); $row = db_fetch_array( $result ); $total_user_count = $row['usercnt']; } $t_page_count = ceil($total_user_count / $p_per_page); if ( $t_page_count < 1 ) { $t_page_count = 1; } # Make sure $p_page_number isn't past the last page. if ( $f_page_number > $t_page_count ) { $f_page_number = $t_page_count; } # Make sure $p_page_number isn't before the first page if ( $f_page_number < 1 ) { $f_page_number = 1; } if ( 0 == $c_hide_inactive ) { $query = "SELECT * FROM $t_user_table WHERE $t_where $t_show_disabled_cond ORDER BY $c_sort $c_dir"; $result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset); } else { $query = "SELECT * FROM $t_user_table WHERE $t_where AND " . db_helper_compare_days( "" . db_now() . "", "last_visit", "< $days_old" ) . " $t_show_disabled_cond ORDER BY $c_sort $c_dir"; $result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset ); } $user_count = db_num_rows( $result ); ?>
"; print_manage_user_sort_link( 'manage_user_page.php', lang_get( $t_col ), $t_col, $c_dir, $c_sort, $c_hide_inactive, $c_filter, $c_show_disabled ); print_sort_icon( $c_dir, $c_sort, $t_col ); echo "\n"; } ?> >
[]
/> />