/** * Feturn HTML block * * @param array Member information * @return string HTML block */ public function return_html_block($member = array()) { //----------------------------------------- // Got a member? //----------------------------------------- if (!is_array($member) or !count($member)) { return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show'); } $friends = array(); //----------------------------------------- // Grab the friends //----------------------------------------- /* How many friends do we have? */ $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1')); /* Sort out pagination */ $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0; $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => self::FRIENDS_PER_PAGE, 'currentStartValue' => $st, 'baseUrl' => "showuser={$member['member_id']}&tab=friends", 'seoTemplate' => 'showuser', 'seoTitle' => $member['members_seo_name'])); /* Get em! */ $queryData = array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => 'f.friends_member_id=' . $member['member_id'] . ' AND f.friends_approved=1 AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')', 'add_join' => array(1 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=f.friends_friend_id', 'type' => 'left'), 2 => array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id', 'type' => 'left'))); // Ordering is bad because it causes a filesort, but if they have more than 100 members, we're going to have // to order so we can paginate if ($count['dracula'] > self::FRIENDS_PER_PAGE) { $queryData['order'] = 'm.members_display_name'; $queryData['limit'] = array($st, self::FRIENDS_PER_PAGE); } $this->DB->build($queryData); $outer = $this->DB->execute(); //----------------------------------------- // Get and store... //----------------------------------------- while ($row = $this->DB->fetch($outer)) { if ($row['member_id']) { $friends[IPSText::mbstrtolower($row['members_display_name'])] = IPSMember::buildDisplayData($row, 0); } } ksort($friends); $content = $this->registry->getClass('output')->getTemplate('profile')->tabFriends($friends, $member, $pagination); //----------------------------------------- // Macros... //----------------------------------------- $content = $this->registry->output->replaceMacros($content); //----------------------------------------- // Return content.. //----------------------------------------- return $content ? $content : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show'); }
/** * List all current friends. * * @return @e void [Prints to screen] * @since IPB 2.2.0.2006-08-08 */ protected function _viewList() { //----------------------------------------- // INIT //----------------------------------------- $friends = array(); $tab = substr(IPSText::alphanumericalClean($this->request['tab']), 0, 20); $per_page = 25; $start = intval($this->request['st']); //----------------------------------------- // Check we're a member //----------------------------------------- if (!$this->memberData['member_id']) { $this->registry->output->showError('no_friend_mid', 10267, null, null, 404); } //----------------------------------------- // To what are we doing to whom? //----------------------------------------- if ($tab == 'pending') { $query = 'f.friends_approved=0 AND f.friends_friend_id=' . $this->memberData['member_id']; $joinKey = 'f.friends_member_id'; } else { $query = 'f.friends_approved=1 AND f.friends_member_id=' . $this->memberData['member_id']; $joinKey = 'f.friends_friend_id'; } /* Not banned or spammed */ $query .= ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')'; //----------------------------------------- // Get count... //----------------------------------------- $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'add_join' => array(array('select' => '', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'inner')))); //----------------------------------------- // Pages... //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => intval($count['count']), 'noDropdown' => 1, 'itemsPerPage' => $per_page, 'currentStartValue' => $start, 'baseUrl' => 'app=members&module=profile&section=friends&do=list&tab=' . $tab)); //----------------------------------------- // Get current friends... //----------------------------------------- $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'order' => 'm.members_l_display_name ASC', 'limit' => array($start, $per_page), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=' . $joinKey, 'type' => 'left'), array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'left')))); $q = $this->DB->execute(); //----------------------------------------- // Get and store... //----------------------------------------- while ($row = $this->DB->fetch($q)) { $row = IPSMember::buildDisplayData($row, array('warn' => 0)); $friends[] = $row; } //----------------------------------------- // Show... //----------------------------------------- $content = $this->registry->getClass('output')->getTemplate('profile')->friendsList($friends, $pages); $this->registry->output->setTitle($this->lang->words['m_title_friends'] . ' - ' . ipsRegistry::$settings['board_name']); $this->registry->output->addNavigation($this->lang->words['m_title_friends'], ''); $this->registry->getClass('output')->addContent($content); $this->registry->getClass('output')->sendOutput(); }
/** * Class entry point * * @param object Registry reference * @return @e void [Outputs to screen/redirects] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Get HTML and skin //----------------------------------------- $this->registry->class_localization->loadLanguageFile(array('public_list'), 'members'); //----------------------------------------- // Can we access? //----------------------------------------- if (!$this->memberData['g_mem_info']) { $this->registry->output->showError('cannot_view_memberlist', 10221, null, null, 403); } //----------------------------------------- // Init variables //----------------------------------------- $see_groups = array(); $the_filter = array('ALL' => $this->lang->words['show_all']); $the_members = array(); $query = array("m.members_l_display_name !='' AND m.members_l_display_name " . $this->DB->buildIsNull(false)); $url = array(); $pp_rating_real = isset($this->request['pp_rating_real']) ? intval($this->request['pp_rating_real']) : 0; $this->first = isset($this->request['st']) ? intval($this->request['st']) : 0; $this->max_results = !empty($this->request['max_results']) ? $this->request['max_results'] : $this->max_results; $this->sort_key = !empty($this->request['sort_key']) ? $this->request['sort_key'] : 'members_display_name'; $this->sort_order = !empty($this->request['sort_order']) ? $this->request['sort_order'] : 'asc'; $this->filter = !empty($this->request['filter']) ? $this->request['filter'] == 'ALL' ? 'ALL' : intval($this->request['filter']) : 'ALL'; $this->request['showall'] = isset($this->request['showall']) ? intval($this->request['showall']) : 0; $this->request['name_box'] = isset($this->request['name_box']) ? $this->request['name_box'] : ''; $this->request['quickjump'] = isset($this->request['quickjump']) ? $this->request['quickjump'] : 0; $_queryPP = false; //----------------------------------------- // Set some of the URL params //----------------------------------------- if ($this->request['quickjump']) { $this->request['name_box'] = 'begins'; $this->request['name'] = $this->request['quickjump']; } $url['app'] = "app=members&module=list"; $url['showall'] = 'showall=' . $this->request['showall']; $url['sort_key'] = "sort_key={$this->sort_key}"; $url['sort_order'] = "sort_order={$this->sort_order}"; $url['max_results'] = "max_results={$this->max_results}"; $url['quickjump'] = "quickjump={$this->request['quickjump']}"; $url['name_box'] = 'name_box=' . $this->request['name_box']; $url['name'] = isset($this->request['name']) ? "name={$this->request['name']}" : "name="; //----------------------------------------- // Sort the member group info //----------------------------------------- foreach ($this->caches['group_cache'] as $row) { if ($row['g_hide_from_list']) { if (!($this->memberData['g_access_cp'] and $this->request['showall'])) { $hide_ids[] = $row['g_id']; continue; } } $see_groups[] = $row['g_id']; $this->mem_groups[$row['g_id']] = array('TITLE' => $row['g_title'], 'ICON' => $row['g_icon']); if ($row['g_id'] == $this->settings['guest_group']) { continue; } $the_filter[$row['g_id']] = $row['g_title']; } //----------------------------------------- // Init some arrays //----------------------------------------- $the_sort_key = array('members_l_display_name' => 'sort_by_name', 'posts' => 'pcount', 'joined' => 'sort_by_joined', 'members_profile_views' => 'm_dd_views'); $the_max_results = array(10 => '10', 20 => '20', 40 => '40', 60 => '60'); $the_sort_order = array('desc' => 'descending_order', 'asc' => 'ascending_order'); $dropdowns = array('filter' => $the_filter, 'sort_key' => $the_sort_key, 'sort_order' => $the_sort_order, 'max_results' => $the_max_results); $defaults = array('filter' => $this->filter, 'sort_key' => $this->sort_key, 'sort_order' => $this->sort_order, 'max_results' => $this->max_results, 'photoonly' => !empty($this->request['photoonly']) ? 1 : 0); //----------------------------------------- // Final vars for query //----------------------------------------- $this->sort_key = isset($the_sort_key[$this->sort_key]) ? $this->sort_key : 'members_l_display_name'; $this->sort_order = isset($the_sort_order[$this->sort_order]) ? $this->sort_order : 'asc'; $this->filter = isset($the_filter[$this->filter]) ? $this->filter : 'ALL'; $this->max_results = isset($the_max_results[$this->max_results]) ? $this->max_results : 20; //----------------------------------------- // Get custom profile information //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields'); $this->custom_fields = new $classToLoad(); $this->custom_fields->initData('edit', 1); $this->custom_fields->parseToEdit('mlist'); //----------------------------------------- // Member Groups... //----------------------------------------- if ($this->filter != 'ALL') { if (!in_array($this->filter, $see_groups)) { $query[] = 'm.member_group_id IN(' . implode(',', $see_groups) . ')'; } else { $query[] = 'm.member_group_id=' . $this->filter; } $url['filter'] = 'filter=' . $this->filter; } //----------------------------------------- // NOT IN Member Groups... //----------------------------------------- if (count($hide_ids)) { $query[] = "m.member_group_id NOT IN(" . implode(",", $hide_ids) . ")"; } /* Not banned */ $query[] = "m.member_banned=0"; /* Not a spammer */ $query[] = '( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')'; //----------------------------------------- // Build query //----------------------------------------- $dates = array('lastpost', 'lastvisit', 'joined'); $mapit = array('posts' => 'm.posts', 'joined' => 'm.joined', 'lastpost' => 'm.last_post', 'lastvisit' => 'm.last_visit', 'signature' => 'pp.signature', 'name' => 'm.members_display_name', 'photoonly' => 'pp.pp_main_photo'); //----------------------------------------- // Do search //----------------------------------------- foreach ($mapit as $in => $tbl) { /** * Leave isset && != '', can't use empty or 0 values are skipped as well * @link http://community.invisionpower.com/tracker/issue-37350-sorting-members-by-post-count/ */ $this->request[$in] = isset($this->request[$in]) && $this->request[$in] != '' ? $this->request[$in] : ''; $inbit = $this->request[$in] = IPSText::parseCleanValue(trim(urldecode(IPSText::stripslashes($this->request[$in])))); $url[$in] = $in . '=' . urlencode($this->request[$in]); //----------------------------------------- // Name... //----------------------------------------- if ($in == 'name' and $inbit != "") { if ($this->request['name_box'] == 'begins') { $query[] = "m.members_l_display_name LIKE '" . strtolower($inbit) . "%'"; } else { $query[] = "m.members_l_display_name LIKE '%" . strtolower($inbit) . "%'"; } } else { if ($in == 'posts' and is_numeric($inbit) and intval($inbit) > -1) { $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>'; $query[] = $tbl . ' ' . $ltmt . ' ' . intval($inbit); $url[$in] = $in . '_ltmt=' . $this->request[$in . '_ltmt'] . '&posts=' . intval($inbit); } else { if (in_array($in, $dates) and $inbit) { if (preg_match('/\\d{2}-\\d{2}-\\d{4}/', $this->request[$in])) { $_tmp = explode('-', $this->request[$in]); $time_int = mktime(23, 59, 59, $_tmp[0], $_tmp[1], $_tmp[2]); } else { $time_int = strtotime($inbit); } if ($time_int) { $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>'; $query[] = $tbl . ' ' . $ltmt . ' ' . $time_int; $url[$in . '_ltmt'] = $in . '_ltmt=' . $this->request[$in . '_ltmt']; } } else { if ($in == 'photoonly') { if ($this->request['photoonly'] == 1) { $_queryPP = true; $query[] = $tbl . "<> ''"; $url[] = 'photoonly=1'; } } else { if ($inbit != "" and $in != 'posts') { $_queryPP = true; $query[] = $tbl . " LIKE '%{$inbit}%'"; } } } } } } //----------------------------------------- // Custom fields? //----------------------------------------- if (count($this->custom_fields->out_fields)) { foreach ($this->custom_fields->out_fields as $id => $data) { if (!empty($this->request['field_' . $id])) { $_queryPP = true; if (is_array($this->request['field_' . $id])) { foreach ($this->request['field_' . $id] as $k => $v) { $this->request['field_' . $id][$k] = urldecode($v); $url['field_' . $id] = "field_{$id}[{$k}]=" . $v; } } else { $url['field_' . $id] = "field_{$id}=" . $this->request['field_' . $id]; $this->request['field_' . $id] = urldecode($this->request['field_' . $id]); } if ($this->custom_fields->cache_data[$id]['pf_type'] == 'drop') { $query[] = "p.field_{$id}='" . $this->request['field_' . $id] . "'"; } else { if ($this->custom_fields->cache_data[$id]['pf_type'] == 'cbox') { if (count($this->request['field_' . $id])) { foreach ($this->request['field_' . $id] as $k => $v) { $query[] = "p.field_{$id} LIKE '%|{$k}|%'"; } } } else { $query[] = $this->custom_fields->cache_data[$id]['pf_search_type'] == 'loose' ? "p.field_{$id} LIKE '%" . $this->request['field_' . $id] . "%'" : "p.field_{$id} = '" . $this->request['field_' . $id] . "'"; } } } } } //----------------------------------------- // Rating.. //----------------------------------------- if ($pp_rating_real) { $_queryPP = true; $query[] = "pp.pp_rating_real > " . $pp_rating_real; $url['pp_rating_real'] = "pp_rating_real=" . $pp_rating_real; } //----------------------------------------- // Finish query //----------------------------------------- //$query[] = "m.members_l_display_name != ''"; $joins = array(); if ($_queryPP) { $joins[] = array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'); $joins[] = array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'); } //----------------------------------------- // Reputation //----------------------------------------- if (!ipsRegistry::isClassLoaded('repCache')) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache'); ipsRegistry::setClass('repCache', new $classToLoad()); } //----------------------------------------- // START THE LISTING //----------------------------------------- $notInMembers = 0; foreach ($query as $q) { if (!strstr($q, 'm.')) { $notInMembers++; } } /* Get the count */ if ($notInMembers > 0 or $this->sort_key != 'members_l_display_name' or $this->request['request_method'] == 'post') { $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'add_join' => $joins)); $this->DB->build(array('select' => ' m.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results), 'add_join' => $joins)); } else { $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => 'members m', 'where' => implode(" AND ", $query))); $this->DB->build(array('select' => 'm.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results))); } /* Fetch IDs */ $mids = array(); $this->DB->execute(); while ($m = $this->DB->fetch()) { if ($m['member_id']) { $mids[] = $m['member_id']; } } if (count($mids)) { $members = array(); $_members = IPSMember::load($mids, 'all'); /* Make sure that we keep the ordering from the query */ foreach ($mids as $id) { $members[$id] = $_members[$id]; } } $max = $_max['cnt']; if (is_array($members) and count($members)) { foreach ($members as $id => $member) { /* Damn SQL thing with member_id */ if (!$member['member_id']) { $member['member_id'] = $member['member_table_id']; } $member['members_display_name'] = $member['members_display_name'] ? $member['members_display_name'] : $member['name']; $member['members_seo_name'] = IPSMember::fetchSeoName($member); $member['group'] = $this->mem_groups[$member['member_group_id']]['TITLE']; $member = IPSMember::buildProfilePhoto($member); $member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0; $member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']); /* Reputation */ if ($this->settings['reputation_protected_groups']) { if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) { $member['pp_reputation_points'] = null; $member['author_reputation'] = null; } } $the_members[] = $member; } } /* make sure URL doesn't contain empty params */ $_url = $url; $url = array(); foreach ($_url as $key => $bit) { if (strrpos($bit, '=') + 1 == strlen($bit)) { continue; } $url[] = $bit; } $pages = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $this->max_results, 'currentStartValue' => $this->first, 'seoTitle' => "false", 'seoTemplate' => 'members_list', 'baseUrl' => implode('&', $url))); //----------------------------------------- // Print... //----------------------------------------- $this->output .= $this->registry->getClass('output')->getTemplate('mlist')->member_list_show($the_members, $pages, $dropdowns, $defaults, $this->custom_fields, implode('&', $url)); //----------------------------------------- // Push to print handler //----------------------------------------- $this->registry->output->addContent($this->output); $this->registry->output->setTitle($this->lang->words['page_title'] . ' - ' . ipsRegistry::$settings['board_name']); $this->registry->output->addNavigation($this->lang->words['page_title'], 'app=members', "false", 'members_list'); $this->registry->output->sendOutput(); }
/** * Get the WHERE part of the SQL query * * @return string SQL WHERE string */ public function getWhereClause() { //----------------------------------------- // Ignore filters? //----------------------------------------- if ($this->showAllMembers) { return ''; } //----------------------------------------- // Init //----------------------------------------- $data = $this->generateFilterBoxes(); $_sql = array(); //print_r($data);exit; //----------------------------------------- // Filters //----------------------------------------- if ($data['member_contains_text']) { $_field = ''; $_text = $this->DB->addSlashes($data['member_contains_text']); switch ($data['member_contains']) { default: case 'member_id': $_field = 'm.member_id'; break; case 'name': $_field = 'm.members_l_username'; $_text = strtolower($_text); break; case 'members_display_name': $_field = 'm.members_l_display_name'; $_text = strtolower($_text); break; case 'email': $_field = 'm.email'; break; case 'ip_address': $_field = 'm.ip_address'; break; case 'signature': $_field = 'pp.signature'; break; } switch ($data['member_contains_type']) { default: case 'contains': $_sql[] = $this->DB->buildCast($_field, 'VARCHAR') . " LIKE '%" . $_text . "%'"; break; case 'begins': $_sql[] = $this->DB->buildCast($_field, 'VARCHAR') . " LIKE '" . $_text . "%'"; break; case 'ends': $_sql[] = $this->DB->buildCast($_field, 'VARCHAR') . " LIKE '%" . $_text . "'"; break; case 'equals': $_sql[] = $this->DB->buildCast($_field, 'VARCHAR') . " = '" . $_text . "'"; break; } } //----------------------------------------- // "Simple" all-in-one search //----------------------------------------- if ($data['member_string'] and strlen($data['member_string']) >= 3) { /* Fix from ticket 766094 */ $_text = $this->DB->addSlashes(IPSText::convertCharsets($data['member_string'], 'utf-8', IPS_DOC_CHAR_SET)); $_sql[] = '(' . $this->DB->buildCast('m.name', 'VARCHAR') . " LIKE '%" . $_text . "%' OR " . $this->DB->buildCast('m.members_display_name', 'VARCHAR') . " LIKE '%" . $_text . "%' OR " . $this->DB->buildCast('m.email', 'VARCHAR') . " LIKE '%" . $_text . "%' OR " . $this->DB->buildCast('m.ip_address', 'VARCHAR') . " LIKE '%" . $_text . "%')"; } //----------------------------------------- // Group limiting //----------------------------------------- if ($data['primary_group']) { if ($data['include_secondary']) { $_sql[] = "( m.member_group_id=" . intval($data['primary_group']) . " OR " . "m.mgroup_others LIKE '%," . intval($data['primary_group']) . ",%' OR " . "m.mgroup_others LIKE '" . intval($data['primary_group']) . ",%' OR " . "m.mgroup_others LIKE '%," . intval($data['primary_group']) . "' OR " . "m.mgroup_others='" . intval($data['primary_group']) . "' )"; } else { $_sql[] = "m.member_group_id=" . intval($data['primary_group']); } } if ($data['secondary_group']) { $_sql[] = "( m.mgroup_others LIKE '%," . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '" . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '%," . $data['secondary_group'] . "' OR " . "m.mgroup_others='" . $data['secondary_group'] . "' )"; } //----------------------------------------- // Post count //----------------------------------------- if (($data['post_count'] or $data['post_count'] == '0') and $data['post_count_type']) { $_type = ''; if ($data['post_count_type'] == 'gt') { $_type = '>'; } else { if ($data['post_count_type'] == 'lt') { $_type = '<'; } else { if ($data['post_count_type'] == 'eq') { $_type = '='; } } } if ($_type) { $_sql[] = "m.posts" . $_type . intval($data['post_count']); } } //----------------------------------------- // Date filters //----------------------------------------- foreach (array('reg', 'post', 'active') as $_bit) { foreach (array('from', 'to') as $_when) { $bit = 'date_' . $_bit . '_' . $_when; if ($data[$bit]) { //----------------------------------------- // mm/dd/yyyy instead of mm-dd-yyyy //----------------------------------------- $data[$bit] = str_replace('/', '-', $data[$bit]); list($month, $day, $year) = explode('-', $data[$bit]); if (!checkdate($month, $day, $year)) { $this->registry->output->global_message = sprintf($this->lang->words['m_daterange'], $month, $day, $year); } else { /* Bug #24067 */ /* Original fix caused this bug: http://community.invisionpower.com/tracker/issue-24416-search-dates-invalid-acp/ Changed to just verify the result is an int, as that is all that's needed to prevent DB error */ $time_int = mktime(0, 0, 0, $month, $day, $year); if (!is_int($time_int)) { $this->registry->output->global_message = sprintf($this->lang->words['m_daterange'], $month, $day, $year); } else { switch ($_bit) { case 'reg': $field = 'joined'; break; case 'post': $field = 'last_post'; break; case 'active': $field = 'last_activity'; break; } if ($_when == 'from') { $_sql[] = 'm.' . $field . ' > ' . $time_int; } else { $_sql[] = 'm.' . $field . ' < ' . $time_int; } } } } } } //----------------------------------------- // Custom fields... //----------------------------------------- if (is_array($data['custom_fields']) and count($data['custom_fields'])) { foreach ($data['custom_fields'] as $id => $value) { if ($value) { if ($this->caches['profilefields'][$id]['pf_type'] == 'drop') { $_sql[] = "p.field_{$id}='" . $this->DB->addSlashes($value) . "'"; } else { if ($this->caches['profilefields'][$id]['pf_type'] == 'cbox') { if (count($value)) { foreach (explode(',', $value) as $k) { $_sql[] = "p.field_{$id} LIKE '%|" . $this->DB->addSlashes($k) . "|%'"; } } } else { $_sql[] = $this->caches['profilefields'][$id]['pf_search_type'] == 'loose' ? "p.field_{$id} LIKE '%" . $this->DB->addSlashes($value) . "%'" : "p.field_{$id} = '" . $this->DB->addSlashes($value) . "'"; } } } } } //----------------------------------------- // Search member status type //----------------------------------------- if ($data['member_status']) { switch ($data['member_status']) { case 'banned': $_sql[] = "(m.member_banned=1)"; break; case 'spam': $_sql[] = '(' . IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has') . ' OR val.spam_flag=1)'; break; case 'validating': $_sql[] = "(val.lost_pass=0 AND val.vid " . $this->DB->buildIsNull(false) . ")"; break; case 'incomplete': $_sql[] = "par.partial_member_id " . $this->DB->buildIsNull(false); break; case 'locked': if ($this->settings['ipb_bruteforce_attempts'] > 0) { $_sql[] = "m.failed_login_count >= " . intval($this->settings['ipb_bruteforce_attempts']); } else { $_sql[] = "m.failed_login_count > 0"; } break; default: case 'all': //----------------------------------------- // Hide partial members if showing 'all', and // we did not explicitly search //----------------------------------------- if (!count($_sql)) { $_sql[] = "par.partial_member_id " . $this->DB->buildIsNull(); } break; } } //----------------------------------------- // Return search string //----------------------------------------- return count($_sql) ? implode(" AND ", $_sql) : ''; }
/** * List members * * @access private * @return void [Outputs to screen] */ private function _memberList() { //----------------------------------------- // INIT //----------------------------------------- $data = $this->_generateFilterBoxes(); $_sql = array(); $st = intval($this->request['st']); $members = array(); $perpage = 20; //----------------------------------------- // FILTERS //----------------------------------------- if ($data['member_contains_text']) { $_field = ''; $_text = $this->DB->addSlashes($data['member_contains_text']); switch ($data['member_contains']) { default: case 'member_id': $_field = 'm.member_id'; break; case 'name': $_field = 'm.name'; break; case 'members_display_name': $_field = 'm.members_display_name'; break; case 'email': $_field = 'm.email'; break; case 'ip_address': $_field = 'm.ip_address'; break; case 'signature': $_field = 'pp.signature'; break; } switch ($data['member_contains_type']) { default: case 'contains': $_sql[] = $_field . " LIKE '%" . $_text . "%'"; break; case 'begins': $_sql[] = $_field . " LIKE '" . $_text . "%'"; break; case 'ends': $_sql[] = $_field . " LIKE '%" . $_text . "'"; break; case 'equals': $_sql[] = $_field . " = '" . $_text . "'"; break; } } if ($data['member_type']) { switch ($data['member_type']) { case 'suspended': $_sql[] = "m.temp_ban > 0"; break; case 'notsuspended': $_sql[] = "( m.temp_ban < 1 or m.temp_ban='' or m.temp_ban " . $this->DB->buildIsNull(true) . " )"; break; } } /* Banned status */ if ($data['banned_type']) { switch ($data['banned_type']) { case 'banned': $_sql[] = "m.member_banned=1"; break; case 'notbanned': $_sql[] = "m.member_banned=0"; break; } } /* Spam status */ if ($data['spam_type']) { switch ($data['spam_type']) { case 'spam': $_sql[] = IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has'); break; case 'notspam': $_sql[] = "NOT (" . IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has') . ")"; break; } } if ($data['primary_group']) { $_sql[] = "m.member_group_id=" . intval($data['primary_group']); } if ($data['post_count'] and $data['post_count_type']) { $_type = ''; if ($data['post_count_type'] == 'gt') { $_type = '>'; } else { if ($data['post_count_type'] == 'lt') { $_type = '<'; } else { if ($data['post_count_type'] == 'eq') { $_type = '='; } } } if ($_type) { $_sql[] = "m.posts" . $_type . intval($data['post_count']); } } if ($data['secondary_group']) { $_sql[] = "( m.mgroup_others LIKE '%," . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '" . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '%," . $data['secondary_group'] . "' OR " . "m.mgroup_others='" . $data['secondary_group'] . "' )"; } foreach (array('reg', 'post', 'active') as $_bit) { foreach (array('from', 'to') as $_when) { $bit = 'date_' . $_bit . '_' . $_when; if ($data[$bit]) { //----------------------------------------- // mm/dd/yyyy instead of mm-dd-yyyy //----------------------------------------- $data[$bit] = str_replace('/', '-', $data[$bit]); list($month, $day, $year) = explode('-', $data[$bit]); if (!checkdate($month, $day, $year)) { $this->registry->output->global_message = sprintf($this->lang->words['m_daterange'], $month, $day, $year); } else { $time_int = mktime(0, 0, 0, $month, $day, $year); switch ($_bit) { case 'reg': $field = 'joined'; break; case 'post': $field = 'last_post'; break; case 'active': $field = 'last_activity'; break; } if ($_when == 'from') { $_sql[] = 'm.' . $field . ' > ' . $time_int; } else { $_sql[] = 'm.' . $field . ' < ' . $time_int; } } } } } //----------------------------------------- // Check we have correct fields //----------------------------------------- switch ($data['order_direction']) { case 'asc': $order_direction = 'asc'; break; default: case 'desc': $order_direction = 'desc'; break; } switch ($data['order_by']) { default: case 'joined': $order_by = 'm.joined'; break; case 'members_l_username': $order_by = 'm.members_l_username'; break; case 'members_l_display_name': $order_by = 'm.members_l_display_name'; break; case 'email': $order_by = 'm.email'; break; } //----------------------------------------- // Custom fields... //----------------------------------------- if (is_array($data['custom_fields']) and count($data['custom_fields'])) { foreach ($data['custom_fields'] as $id => $value) { if ($value) { $_sql[] = 'p.field_' . $id . " LIKE '%" . $value . "%'"; } } } //----------------------------------------- // get 'owt? //----------------------------------------- $real_query = count($_sql) ? implode(" AND ", $_sql) : ''; //----------------------------------------- // Get the number of results //----------------------------------------- $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('members' => 'm'), 'where' => $real_query, 'add_join' => array(0 => array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), 1 => array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left')))); if ($count['count'] < 1) { $this->registry->output->global_message = $this->lang->words['m_nomembers']; // Reset the filter $real_query = ''; // And reset the cookie so we don't get the message on every page view ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array()); $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'members')); } $pages = $this->registry->output->generatePagination(array('totalItems' => $count['count'], 'itemsPerPage' => $perpage, 'currentStartValue' => $st, 'baseUrl' => $this->settings['base_url'] . "&{$this->form_code}&do=" . $this->request['do'])); //----------------------------------------- // Run the query //----------------------------------------- $this->DB->build(array('select' => 'm.*, m.member_id as mem_id', 'from' => array('members' => 'm'), 'where' => $real_query, 'order' => $order_by . ' ' . $order_direction, 'limit' => array($st, $perpage), 'add_join' => array(1 => array('select' => 'p.*', 'from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'), 2 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $r['member_id'] = $r['mem_id']; $r['_joined'] = $this->registry->class_localization->getDate($r['joined'], 'JOINED'); $r['group_title'] = $this->caches['group_cache'][$r['member_group_id']]['g_title']; $members[] = IPSMember::buildDisplayData($r); } //----------------------------------------- // Prune you fookers? //----------------------------------------- if ($data['search_type'] == 'delete') { $this->_memberPruneForm($count['count']); return; } else { if ($data['search_type'] == 'move') { $this->_memberMoveForm($count['count']); return; } } $this->registry->output->extra_nav[] = array('', $this->lang->words['m_viewlist']); $this->registry->output->html .= $this->html->members_list($members, $pages); }
/** * Rebuild upcoming events cache * * @return @e void */ public function rebuildCalendarEventsCache() { //----------------------------------------- // Ensure calendar is installed //----------------------------------------- if (!$this->DB->checkForTable('cal_calendars')) { return; } if (!IPSLib::appIsInstalled('calendar')) { $this->cache->setCache('calendar_events', array(), array('array' => 1)); $this->cache->setCache('birthdays', array(), array('array' => 1)); return; } //----------------------------------------- // Init //----------------------------------------- $this->settings['calendar_limit'] = (intval($this->settings['calendar_limit']) < 2 ? 1 : intval($this->settings['calendar_limit'])) + 1; $birthdays = array(); $events = array(); $calendars = $this->cache->getCache('calendars'); $seenids = array(); //-------------------------------------------- // Set time stuff //-------------------------------------------- $startTime = gmmktime(0, 0, 0, gmstrftime('%m'), 1); $endTime = gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') + $this->settings['calendar_limit']); $nowTime = gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') - 1); list($month, $day, $year) = explode('-', gmstrftime('%m-%d-%Y')); list($last_month, $last_day, $last_year) = explode('-', gmstrftime('%m-%d-%Y', $nowTime)); list($next_month, $next_day, $next_year) = explode('-', gmstrftime('%m-%d-%Y', gmmktime(0, 0, 0, gmstrftime('%m'), gmstrftime('%d') + 1))); //-------------------------------------------- // Get classes //-------------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('calendar') . '/modules_public/calendar/view.php', 'public_calendar_calendar_view'); $calendar = new $classToLoad($this->registry); $calendar->makeRegistryShortcuts($this->registry); if (!$calendar->initCalendar(true, true)) { $this->cache->setCache('calendar_events', array(), array('array' => 1)); $this->cache->setCache('birthdays', array(), array('array' => 1)); return; } //-------------------------------------------- // Load the events //-------------------------------------------- $calendar->calendarGetEventsSQL($month, $year, array('timenow' => $startTime, 'timethen' => $endTime, 'minimal' => true, 'no_date_convert' => true)); //-------------------------------------------- // Loop through events and cache //-------------------------------------------- for ($i = 0; $i <= $this->settings['calendar_limit']; $i++) { list($_month, $_day, $_year) = explode('-', gmstrftime('%m-%d-%Y', $nowTime)); $eventcache = $calendar->calendarGetDayEvents($_month, $_day, $_year); foreach ($eventcache as $event) { if ($event['event_approved'] and !in_array($event['event_id'], $seenids)) { if (!$event['event_recurring'] or $calendar->checkRecurring($event, $_month, $_day, $_year)) { unset($event['event_content'], $event['event_smilies']); $event['perm_view'] = $calendars[$event['event_calendar_id']]['perm_view']; $events[$event['event_id']] = $event; } $seenids[$event['event_id']] = $event['event_id']; } } $nowTime += 86400; } //----------------------------------------- // Grab birthdays //----------------------------------------- $append_string = ""; if (!gmdate("L")) { if ($month == 2 and $day > 26) { $append_string = " OR ( bday_month=2 AND bday_day=29 )"; } } $_days = array(); $this->DB->build(array('select' => 'member_id, members_seo_name, members_display_name, member_group_id, bday_day, bday_month, bday_year', 'from' => 'members', 'where' => "member_banned=0 AND ( !" . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ")\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND ( ( bday_day={$last_day} AND bday_month={$last_month} )\r\n\t\t\t\t\t\t\t\t\t\t\t\tOR ( bday_day={$day} AND bday_month={$month} )\r\n\t\t\t\t\t\t\t\t\t\t\t\tOR ( bday_day={$next_day} AND bday_month={$next_month} ) {$append_string} )")); $this->DB->execute(); while ($r = $this->DB->fetch()) { /* Only allow 6 per day, then the "upcoming birthdays" can display 5 and know there are more to display */ $_days[$r['bday_month'] . '.' . $r['bday_day']]++; if ($_days[$r['bday_month'] . '.' . $r['bday_day']] > 6) { continue; } $birthdays[$r['member_id']] = $r; } //-------------------------------------------- // Update calendar array //-------------------------------------------- $this->cache->setCache('calendar_events', $events, array('array' => 1)); $this->cache->setCache('birthdays', $birthdays, array('array' => 1)); }
/** * Get 12 random friends * * @param array $member Member data * @return @e array */ protected function _getRandomFriends($member) { # Get random number from member's friend cache... grab 10 random. array_rand( array, no.) # also fall back on last 10 if no cache $_member_ids = array(); $friends = array(); if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) { $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']); if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) { foreach ($member['_cache']['friends'] as $id => $approved) { $id = intval($id); if ($approved and $id) { $_member_ids[] = $id; } } $member['_total_approved_friends'] = count($_member_ids); if (is_array($_member_ids) and $member['_total_approved_friends']) { $_max = $member['_total_approved_friends'] > 12 ? 12 : $member['_total_approved_friends']; $_rand = array_rand($_member_ids, $_max); $_final = array(); # If viewing member is in list, let's show em if (in_array($this->memberData['member_id'], $_member_ids)) { $_final[] = $this->memberData['member_id']; $new_mids = array(); foreach ($_member_ids as $mid) { if ($mid == $this->memberData['member_id']) { continue; } $new_mids[] = $mid; } $_member_ids = $new_mids; unset($new_mids); if (is_array($_rand)) { if (count($_rand) >= 12) { array_pop($_rand); } } } if (is_array($_rand) and count($_rand)) { foreach ($_rand as $_id) { $_final[] = $_member_ids[$_id]; } } if (count($_final)) { $sql_extra = ' AND friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')'; } } } /* Fetch friends */ $_memberIds = array(); $_members = array(); $_friends = array(); $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id')), 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1' . ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')' . $sql_extra, 'limit' => array(0, 12), 'order' => 'friends_approved DESC')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $_memberIds[] = $row['friends_friend_id']; $_friends[] = $row; } /* Got members? */ $_members = IPSMember::load($_memberIds, 'core,extendedProfile'); foreach ($_friends as $row) { if (!isset($_members[$row['friends_friend_id']])) { continue; } $row = array_merge($row, $_members[$row['friends_friend_id']]); $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT'); $row = IPSMember::buildProfilePhoto($row); $friends[] = $row; } } return $friends; }
/** * Resets the last registered member * * @param bool $return If TRUE returns the value instead of updating it * @return @e mixed */ public static function resetLastRegisteredMember($return = false) { /* Init vsrs */ $groups = array(); $_extra = ''; $update = array('last_mem_id' => 0, 'last_mem_name' => '', 'last_mem_name_seo' => ''); /* Exclude certain groups */ foreach (ipsRegistry::cache()->getCache('group_cache') as $_gid => $_gdata) { if ($_gdata['g_hide_online_list'] || $_gid == ipsRegistry::$settings['auth_group']) { $groups[] = $_gid; } } /* Groups to skip? */ $_extra = count($groups) ? "member_group_id NOT IN (" . implode(',', $groups) . ") AND " : ''; $r = ipsRegistry::DB()->buildAndFetch(array('select' => 'member_id, members_display_name, members_seo_name', 'from' => 'members', 'where' => "{$_extra} members_display_name != '' AND members_display_name " . ipsRegistry::DB()->buildIsNull(false) . " AND member_banned=0 AND ( ! " . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ")", 'order' => "member_id DESC", 'limit' => array(0, 1))); $update['last_mem_id'] = intval($r['member_id']); $update['last_mem_name'] = trim($r['members_display_name']); $update['last_mem_name_seo'] = trim($r['members_seo_name']); /* Update our stats or return? */ if ($return) { return $update; } else { $stats = ipsRegistry::cache()->getCache('stats'); $stats = array_merge($stats, $update); ipsRegistry::cache()->setCache('stats', $stats, array('array' => 1)); } }
/** * Mark a topic as 'unAnswered' * @param mixed $topic * @param mixed $post */ public function unAnswerTopicSingle($post, $topic = null) { if (is_numeric($post)) { $post = $this->getPostById($post); } if ($topic === null) { $topic = $post['topic_id']; } if (is_numeric($topic)) { $topic = $this->getTopicById($topic); } if (!$topic['tid'] || !$post['pid']) { throw new Exception('missing_data'); } if ($this->canAnswerTopic($topic) !== true) { throw new Exception('no_permission'); } /* Remove flag this post */ $sql = IPSBWOptions::sql('bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'invert'); $where = IPSBWOptions::sql('bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'has'); $this->DB->update('posts', 'post_bwoptions=' . $sql, 'pid=' . $post['pid'] . ' AND ' . $where, false, true); /* Update topic */ $this->DB->update('topics', array('topic_answered_pid' => 0), 'tid=' . $topic['tid']); return true; }
/** * View queues (validating, locked, banned) * * @access private * @param string Queue to view [validating, locked, banned] * @return void [Outputs to screen] */ private function _viewQueue($type = 'validating') { //----------------------------------------- // INIT //----------------------------------------- $this->request['ord'] = $this->request['ord'] ? $this->request['ord'] : ''; $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0; $ord = $this->request['ord'] == 'asc' ? 'asc' : 'desc'; $new_ord = $ord == 'asc' ? 'desc' : 'asc'; $filter = $this->request['filter'] ? $this->request['filter'] : ''; $q_extra = ""; $content = ""; //----------------------------------------- // Run teh query //----------------------------------------- switch ($type) { case 'validating': switch ($filter) { case 'reg_user_validate': if ($this->settings['reg_auth_type'] != 'admin') { $q_extra = " AND v.new_reg=1 AND v.user_verified=0"; } break; case 'reg_admin_validate': if ($this->settings['reg_auth_type'] == 'admin') { $q_extra = " AND v.new_reg=1"; } else { $q_extra = " AND v.new_reg=1 AND v.user_verified=1"; } break; case 'email_chg': $q_extra = " AND v.email_chg=1"; break; case 'coppa': $q_extra = " AND v.coppa_user=1"; break; } $row = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as queue', 'from' => array('validating' => 'v'), 'where' => "v.lost_pass=0 AND m.member_group_id=" . $this->settings['auth_group'] . $q_extra, 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left')))); break; case 'locked': if ($this->settings['ipb_bruteforce_attempts']) { $row = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as queue', 'from' => 'members', 'where' => "failed_login_count >= " . intval($this->settings['ipb_bruteforce_attempts']))); } else { $row['queue'] = 0; } break; case 'banned': $row = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as queue', 'from' => 'members', 'where' => "member_banned=1")); break; case 'spam': $row = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as queue', 'from' => 'members', 'where' => IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has'))); break; } $cnt = intval($row['queue']); //----------------------------------------- // Grab default sorting //----------------------------------------- switch ($type) { case 'validating': $col = 'v.entry_date'; break; case 'locked': $col = 'm.members_display_name'; break; case 'banned': $col = 'm.members_display_name'; break; case 'spam': $col = 'm.joined'; break; } //----------------------------------------- // And actual sorting.. //----------------------------------------- switch ($this->request['sort']) { case 'mem': $col = 'm.members_display_name'; break; case 'email': $col = 'm.email'; break; case 'sent': if ($type == 'validating') { $col = 'v.entry_date'; } break; case 'failed': if ($type == 'locked') { $col = 'm.failed_login_count'; } break; case 'group': if ($type == 'banned') { $col = 'g.g_title'; } break; case 'posts': $col = 'm.posts'; break; case 'joined': $col = 'm.joined'; break; } //----------------------------------------- // Pages... //----------------------------------------- $links = $this->registry->output->generatePagination(array('totalItems' => $cnt, 'itemsPerPage' => 75, 'currentStartValue' => $st, 'baseUrl' => $this->settings['base_url'] . "&{$this->form_code}&do={$type}&ord={$ord}&filter={$filter}")); //----------------------------------------- // Print... //----------------------------------------- if ($cnt > 0) { switch ($type) { case 'validating': $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => "v.lost_pass=0 AND m.member_group_id=" . $this->settings['auth_group'] . $q_extra, 'order' => $col . ' ' . $ord, 'limit' => array($st, 75), 'add_join' => array(array('select' => 'm.name, m.member_group_id, m.members_display_name, m.ip_address, m.member_id, m.email, m.posts, m.joined', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left')))); break; case 'locked': $this->DB->build(array('select' => 'm.member_group_id, m.members_display_name, m.ip_address, m.member_id, m.email, m.posts, m.joined, m.failed_logins, m.failed_login_count', 'from' => 'members m', 'where' => "m.failed_login_count >= " . intval($this->settings['ipb_bruteforce_attempts']), 'order' => $col . ' ' . $ord, 'limit' => array($st, 75))); break; case 'banned': $this->DB->build(array('select' => 'm.member_group_id, m.members_display_name, m.ip_address, m.member_id, m.email, m.posts, m.joined, m.failed_logins, m.failed_login_count', 'from' => array('members' => 'm'), 'where' => "m.member_banned=1", 'order' => $col . ' ' . $ord, 'limit' => array($st, 75), 'add_join' => array(array('select' => 'g.g_title', 'from' => array('groups' => 'g'), 'where' => 'g.g_id=m.member_group_id', 'type' => 'left')))); break; case 'spam': $this->DB->build(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has'), 'order' => $col . ' ' . $ord, 'limit' => array($st, 75), 'add_join' => array(array('select' => 'g.g_title', 'from' => array('groups' => 'g'), 'where' => 'g.g_id=m.member_group_id', 'type' => 'left')))); break; } $this->DB->execute(); while ($r = $this->DB->fetch()) { $r['_joined'] = ipsRegistry::getClass('class_localization')->getDate($r['joined'], 'TINY'); $r['members_display_name'] = $r['members_display_name'] ? $r['members_display_name'] : $this->lang->words['t_deletedmem']; $r['group_title'] = IPSLib::makeNameFormatted($this->caches['group_cache'][$r['member_group_id']]['g_title'], $r['member_group_id']); switch ($type) { case 'validating': $r['_coppa'] = $r['coppa_user'] ? $this->lang->words['t_coppa'] : ''; //----------------------------------------- // Sort out 'where' //----------------------------------------- $r['_where'] = $r['lost_pass'] ? $this->lang->words['t_lostpass'] : ($r['new_reg'] ? $this->lang->words['t_userval'] : ($r['email_chg'] ? $this->lang->words['t_emailchange'] : $this->lang->words['t_na'])); if (isset($r['email_chg']) and $r['email_chg']) { $r['_where'] .= " (<a href='" . $this->settings['base_url'] . "{$this->form_code}&do=unappemail&mid={$r['member_id']}'>{$this->lang->words['t_unapprove']}</a>)"; } if ($r['new_reg'] and ($r['user_verified'] == 1 or $this->settings['reg_auth_type'] == 'admin')) { $r['_where'] = $this->lang->words['t_adminval']; } //----------------------------------------- // How long ago did this start? //----------------------------------------- $r['_hours'] = floor((time() - $r['entry_date']) / 3600); $r['_days'] = intval($r['_hours'] / 24); $r['_rhours'] = intval($r['_hours'] - $r['_days'] * 24); //----------------------------------------- // Format time //----------------------------------------- $r['_entry'] = ipsRegistry::getClass('class_localization')->getDate($r['entry_date'], 'TINY'); break; case 'locked': //----------------------------------------- // Sort out lovely locked info //----------------------------------------- $used_ips = array(); $this_attempt = array(); $oldest = 0; $newest = 0; if ($r['failed_logins']) { $failed_logins = explode(",", IPSText::cleanPermString($r['failed_logins'])); if (is_array($failed_logins) and count($failed_logins)) { sort($failed_logins); foreach ($failed_logins as $attempt) { $this_attempt = explode("-", $attempt); $used_ips[] = $this_attempt[1]; } $oldest = array_shift($failed_logins); $newest = array_pop($failed_logins); } } $newest = explode("-", $newest); $oldest = explode("-", $oldest); $r['oldest_fail'] = ipsRegistry::getClass('class_localization')->getDate($oldest[0], 'SHORT'); $r['newest_fail'] = ipsRegistry::getClass('class_localization')->getDate($newest[0], 'SHORT'); //----------------------------------------- // Some nice IP address info //----------------------------------------- $r['ip_addresses'] = ""; $used_ips = array_unique($used_ips); foreach ($used_ips as $ip_address) { $r['ip_addresses'] .= "{$this->lang->words['t_ipcolon']} <a href='" . $this->settings['base_url'] . "&module=members&section=tools&do=learn_ip&ip={$ip_address}'>{$ip_address}</a><br />"; } break; } //----------------------------------------- // Print row //----------------------------------------- $function = $type . 'Row'; $content .= $this->html->{$function}($r); } } else { $content = $this->html->queueNoRows(sprintf($this->lang->words['t_notype'], $this->lang->words['t_rowtype_' . $type])); } //----------------------------------------- // Output //----------------------------------------- $this->registry->output->html .= $this->html->queueWrapper($type, $content, $st, $new_ord, $links); //----------------------------------------- // Extra navigation //----------------------------------------- switch ($type) { case 'validating': $this->registry->output->extra_nav[] = array('', $this->lang->words['t_validating']); break; case 'locked': $this->registry->output->extra_nav[] = array('', $this->lang->words['t_locked']); break; case 'banned': $this->registry->output->extra_nav[] = array('', $this->lang->words['t_banned']); break; } }