[ PHPXref.com ] [ Generated: Sun Jul 20 18:37:24 2008 ] [ MetaBB 5.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> adr_character_list.php (source)

   1  <?php 
   2  /***************************************************************************

   3   *                    adr_character_list.php

   4   *                ------------------------

   5   *    begin             : 12/02/2004

   6   *    copyright            : Malicious Rabbit / Dr DLP

   7   *

   8   *

   9   ***************************************************************************/
  10  
  11  /***************************************************************************

  12   *

  13   *   This program is free software; you can redistribute it and/or modify

  14   *   it under the terms of the GNU General Public License as published by

  15   *   the Free Software Foundation; either version 2 of the License, or

  16   *   (at your option) any later version.

  17   *

  18   *

  19   ***************************************************************************/
  20  
  21  define('IN_PHPBB', true); 
  22  define('IN_ADR_SHOPS', true); 
  23  define('IN_ADR_CHARACTER', true);
  24  $phpbb_root_path = './'; 
  25  include ($phpbb_root_path . 'extension.inc'); 
  26  include($phpbb_root_path . 'common.'.$phpEx);
  27  
  28  $loc = 'character_prefs';
  29  $sub_loc = 'adr_character_list';
  30  
  31  //

  32  // Start session management

  33  $userdata = session_pagestart($user_ip, PAGE_INDEX); 
  34  init_userprefs($userdata); 
  35  // End session management

  36  //

  37  
  38  include($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx);
  39  
  40  $user_id = $userdata['user_id'];
  41  
  42  // Get the general settings

  43  $adr_general = adr_get_general_config();
  44  adr_enable_check();
  45  adr_ban_check($user_id);
  46  adr_character_created_check($user_id);
  47  
  48  // Sorry , only logged users ...

  49  if ( !$userdata['session_logged_in'] )
  50  {
  51      $redirect = "adr_character_inventory.$phpEx";
  52      $redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
  53      header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
  54  }
  55  
  56  include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  57  
  58  if ( (!( isset($HTTP_POST_VARS[POST_USERS_URL]) || isset($HTTP_GET_VARS[POST_USERS_URL]))) || ( empty($HTTP_POST_VARS[POST_USERS_URL]) && empty($HTTP_GET_VARS[POST_USERS_URL])))
  59  { 
  60      $view_userdata = $userdata; 
  61  } 
  62  else 
  63  { 
  64      $view_userdata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL])); 
  65  } 
  66  $searchid = $view_userdata['user_id'];
  67  
  68  $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  69  
  70  adr_template_file('adr_character_list_body.tpl');
  71  
  72  if ( isset($HTTP_GET_VARS['mode2']) || isset($HTTP_POST_VARS['mode2']) )
  73  {
  74      $mode2 = ( isset($HTTP_POST_VARS['mode2']) ) ? htmlspecialchars($HTTP_POST_VARS['mode2']) : htmlspecialchars($HTTP_GET_VARS['mode2']);
  75  }
  76  else
  77  {
  78      $mode2 = 'username';
  79  }
  80  
  81  if(isset($HTTP_POST_VARS['order']))
  82  {
  83      $sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
  84  }
  85  else if(isset($HTTP_GET_VARS['order']))
  86  {
  87      $sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
  88  }
  89  else
  90  {
  91      $sort_order = 'ASC';
  92  }
  93  
  94  
  95  $mode_types_text = array( $lang['Username'] , $lang['Adr_character'] , $lang['Adr_character_level'] , $lang['Adr_shop_name'] );
  96  $mode_types = array( 'username', 'character_name' , 'level' , 'shop_name' );
  97  
  98  $select_sort_mode = '<select name="mode2">';
  99  for($i = 0; $i < count($mode_types_text); $i++)
 100  {
 101      $selected = ( $mode2 == $mode_types[$i] ) ? ' selected="selected"' : '';
 102      $select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
 103  }
 104  $select_sort_mode .= '</select>';
 105  
 106  $select_sort_order = '<select name="order">';
 107  if($sort_order == 'ASC')
 108  {
 109      $select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
 110  }
 111  else
 112  {
 113      $select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
 114  }
 115  $select_sort_order .= '</select>';
 116  
 117  switch( $mode2 )
 118  {
 119      case 'username':
 120          $order_by = "u.username $sort_order LIMIT $start, " . $board_config['topics_per_page'];
 121          break;
 122      case 'character_name':
 123          $order_by = "c.character_name $sort_order LIMIT $start, " . $board_config['topics_per_page'];
 124          break;
 125      case 'level':
 126          $order_by = "c.character_level $sort_order LIMIT $start, " . $board_config['topics_per_page'];
 127          break;
 128      case 'shop_name':
 129          $order_by = "s.shop_name $sort_order LIMIT $start, " . $board_config['topics_per_page'];
 130          break;
 131      default:
 132          $order_by = "u.username $sort_order LIMIT $start, " . $board_config['topics_per_page'];
 133          break;
 134  }
 135  
 136  $sql = "SELECT c.* , s.shop_id , s.shop_name , u.username , u.user_id , u.user_avatar_type , u.user_allowavatar , u.user_avatar FROM " . ADR_CHARACTERS_TABLE . " c , " . USERS_TABLE . " u 
 137      LEFT JOIN " . ADR_SHOPS_TABLE . " s ON ( s.shop_owner_id = u.user_id )
 138      WHERE c.character_id = u.user_id
 139      AND u.user_id > 1
 140      ORDER BY $order_by";
 141  if( !($result = $db->sql_query($sql)) )
 142  {
 143      message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
 144  }
 145  
 146  if ( $row = $db->sql_fetchrow($result) )
 147  {
 148      $i = 0;
 149      do
 150      {
 151          $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 152  
 153          $user_avatar = '';
 154          if ( $row['user_avatar_type'] && $row['user_allowavatar'] )
 155          {
 156              switch( $row['user_avatar_type'] )
 157              {
 158                  case USER_AVATAR_UPLOAD:
 159                      $user_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : '';
 160                  break;
 161                  case USER_AVATAR_REMOTE:
 162                      $user_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : '';
 163                  break;
 164                  case USER_AVATAR_GALLERY:
 165                      $user_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : '';
 166                  break;
 167              }
 168          }
 169  
 170          $shop_name = ( $row['shop_id'] ) ? $row['shop_name'] : '';
 171              
 172          $template->assign_block_vars('characters', array(
 173              "ROW_CLASS" => $row_class,
 174              "AVATAR" => $user_avatar,
 175              "USERNAME" => $row['username'],
 176              "SHOP_NAME" => $shop_name,
 177              "CHARACTER_NAME" => $row['character_name'],
 178              "CHARACTER_LEVEL" => $row['character_level'],
 179              "U_SHOP_NAME" => append_sid("adr_shops.$phpEx?mode=see_shop&amp;shop_id=".$row['shop_id']),
 180              "U_CHARACTER_NAME" => append_sid("adr_character.$phpEx?" . POST_USERS_URL ."=".$row['user_id']),
 181              "U_INVENTORY" => append_sid("adr_character_inventory.$phpEx?" . POST_USERS_URL ."=".$row['user_id']),
 182          ));
 183  
 184          $i++;
 185      }
 186      while ( $row = $db->sql_fetchrow($result) );
 187  
 188  }
 189  
 190  $sql = "SELECT count(*) AS total FROM " . ADR_CHARACTERS_TABLE ;
 191  if ( !($result = $db->sql_query($sql)) )
 192  {
 193      message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);
 194  }
 195  if ( $total = $db->sql_fetchrow($result) )
 196  {
 197      $total_users = $total['total'];
 198      $pagination = generate_pagination("adr_character_list.$phpEx?".POST_USERS_URL."=$searchid&amp;mode2=$mode2&amp;order=$sort_order", $total_users, $board_config['topics_per_page'], $start). '&nbsp;';    
 199  }
 200  
 201  $template->assign_vars(array(    
 202      'L_SHOP_NAME' => $lang['Adr_shop_name'],
 203      'L_CHARACTER_NAME' => $lang['Adr_character'],
 204      'L_USERNAME' => $lang['Username'],
 205      'L_LEVEL' => $lang['Adr_character_level'],
 206      'L_ITEMS' => $lang['Adr_inventory_page_name'],
 207      'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
 208      'L_ORDER' => $lang['Order'],
 209      'L_SORT' => $lang['Sort'],
 210      'S_MODE_SELECT' => $select_sort_mode,
 211      'S_ORDER_SELECT' => $select_sort_order,
 212      'PAGINATION' => $pagination,
 213      'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_users / $board_config['topics_per_page'] )), 
 214      'L_GOTO_PAGE' => $lang['Goto_page'],
 215      "S_LIST_ACTION" => append_sid("adr_character_list.$phpEx?".POST_USERS_URL."=$searchid&amp;mode2=$mode2&amp;order=$sort_order"),
 216      "S_HIDDEN_FIELDS" => $s_hidden_fields, 
 217  ));
 218  
 219  
 220  include($phpbb_root_path . 'adr/includes/adr_header.'.$phpEx);
 221  
 222  $template->pparse('body');
 223  include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 224   
 225  ?> 


[ Powered by PHPXref - Served by Debian GNU/Linux ]