About This File
[img]http://s29.postimg.org/3z67um9kn/image.jpg[/img]
[for use with custom sidebar blocks]
[color=#282828][font=helvetica]Add an "Active Users" block with the following settings[/font][/color]
[color=#282828][font=helvetica]This block requires some custom block templates, so first download the hook and[/font][/color][color=#282828][font=helvetica] extract it, and import the [/font][/color]CSBActiveUsersTemplates[color=#282828][font=helvetica].xml file from ACP->Manage Hooks[/font][/color]
[color=#282828][font=helvetica]Then create a new Custom Sidebar Block with the following data:[/font][/color]
[color=#282828][font=helvetica]Name: Active Users[/font][/color]
[color=#282828][font=helvetica]Enabled : Yes[/font][/color]
[color=#282828][font=helvetica]Hide From Main Custom Block: Depends on where you want it[/font][/color]
[color=#282828][font=helvetica]Full Image Name: user.png (or whatever you wish as long as it is in the proper directory and your reference it)[/font][/color]
[color=#282828][font=helvetica]Enable RAW HTML/JS mode: No[/font][/color]
[color=#282828][font=helvetica]Enable PHP Mode: Yes[/font][/color]
[color=#282828][font=helvetica]Use Table/Border/Title/Image?: Yes[/font][/color]
[color=#282828][font=helvetica]Remove Ability for User to Collapse Block? Up to you[/font][/color][code=auto:0] $active = array( 'TOTAL' => 0 , 'NAMES' => array(), 'GUESTS' => 0 , 'MEMBERS' => 0 , 'ANON' => 0 , ); if ( $this->settings['show_active'] ) { if( !$this->settings['au_cutoff'] ) { $this->settings['au_cutoff'] = 15; } //----------------------------------------- // Get the users from the DB //----------------------------------------- $cut_off = $this->settings['au_cutoff'] * 60; $time = time() - $cut_off; $rows = array(); $ar_time = time(); if ( $this->memberData['member_id'] ) { $rows = array( $ar_time.'.'.md5( microtime() ) => array( 'id' => 0, 'login_type' => substr( $this->memberData['login_anonymous'], 0, 1), 'running_time' => $ar_time, 'seo_name' => $this->memberData['members_seo_name'], 'member_id' => $this->memberData['member_id'], 'member_name' => $this->memberData['members_display_name'], 'member_group' => $this->memberData['member_group_id'], 'cns_prefix' => (ipsRegistry::$settings['cns_on']) ? $this->memberData['cns_prefix'] : "", 'cns_suffix' => (ipsRegistry::$settings['cns_on']) ? $this->memberData['cns_suffix'] : "" ) ); } if (ipsRegistry::$settings['cns_on']) { $customNameStyleJoin = array( 0 => array( 'select' => 'pp.cns_prefix, pp.cns_suffix', 'from' => array( 'profile_portal' => 'pp' ), 'where' => "s.member_id = pp.pp_member_id", 'type' => 'left', ) ); } $this->DB->build( array( 'select' => 's.id, s.member_id, s.member_name, s.seo_name, s.login_type, s.running_time, s.member_group, s.uagent_type', 'from' => array( 'sessions' => 's' ), 'where' => "running_time > {$time}", 'add_join' => $customNameStyleJoin ) ); $this->DB->execute(); //----------------------------------------- // FETCH... //----------------------------------------- while ( $r = $this->DB->fetch() ) { $rows[ $r['running_time'].'.'.$r['id'] ] = $r; } krsort( $rows ); //----------------------------------------- // cache all printed members so we // don't double print them //----------------------------------------- $cached = array(); foreach ( $rows as $result ) { $last_date = $this->registry->getClass('class_localization')->getDate( $result['running_time'], 'TINY' ); //----------------------------------------- // Bot? //----------------------------------------- if ( isset( $result['uagent_type'] ) && $result['uagent_type'] == 'search' ) { /* Skipping bot? */ if ( ! $this->settings['spider_active'] ) { continue; } //----------------------------------------- // Seen bot of this type yet? //----------------------------------------- if ( ! $cached[ $result['member_name'] ] ) { $active['NAMES'][] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'], $result['cns_prefix'], $result['cns_suffix'] ); $cached[ $result['member_name'] ] = 1; } else { //----------------------------------------- // Yup, count others as guest //----------------------------------------- $active['GUESTS']++; } } //----------------------------------------- // Guest? //----------------------------------------- else if ( ! $result['member_id'] OR ! $result['member_name'] ) { $active['GUESTS']++; } //----------------------------------------- // Member? //----------------------------------------- else { if ( empty( $cached[ $result['member_id'] ] ) ) { $cached[ $result['member_id'] ] = 1; $result['member_name'] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'], $result['cns_prefix'], $result['cns_suffix'] ); if ( $result['login_type'] ) { if ( $this->memberData['g_access_cp'] ) { $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl( "showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser' ) . "' title='$last_date'>{$result['member_name']}</a>*"; $active['ANON']++; } else { $active['ANON']++; } } else { $active['MEMBERS']++; $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl( "showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser' ) ."' title='$last_date'>{$result['member_name']}</a>"; } } } } $active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON']; $this->users_online = $active['TOTAL']; } $this->lang->words['active_users'] = sprintf( $this->lang->words['active_users'], $this->settings['au_cutoff'] ); return $this->registry->output->getTemplate('boards')->customSidebarBlockActiveUsers($active); [/code]
[for use with custom sidebar blocks]
[color=#282828][font=helvetica]Add an "Active Users" block with the following settings[/font][/color]
[color=#282828][font=helvetica]This block requires some custom block templates, so first download the hook and[/font][/color][color=#282828][font=helvetica] extract it, and import the [/font][/color]CSBActiveUsersTemplates[color=#282828][font=helvetica].xml file from ACP->Manage Hooks[/font][/color]
[color=#282828][font=helvetica]Then create a new Custom Sidebar Block with the following data:[/font][/color]
[color=#282828][font=helvetica]Name: Active Users[/font][/color]
[color=#282828][font=helvetica]Enabled : Yes[/font][/color]
[color=#282828][font=helvetica]Hide From Main Custom Block: Depends on where you want it[/font][/color]
[color=#282828][font=helvetica]Full Image Name: user.png (or whatever you wish as long as it is in the proper directory and your reference it)[/font][/color]
[color=#282828][font=helvetica]Enable RAW HTML/JS mode: No[/font][/color]
[color=#282828][font=helvetica]Enable PHP Mode: Yes[/font][/color]
[color=#282828][font=helvetica]Use Table/Border/Title/Image?: Yes[/font][/color]
[color=#282828][font=helvetica]Remove Ability for User to Collapse Block? Up to you[/font][/color][code=auto:0] $active = array( 'TOTAL' => 0 , 'NAMES' => array(), 'GUESTS' => 0 , 'MEMBERS' => 0 , 'ANON' => 0 , ); if ( $this->settings['show_active'] ) { if( !$this->settings['au_cutoff'] ) { $this->settings['au_cutoff'] = 15; } //----------------------------------------- // Get the users from the DB //----------------------------------------- $cut_off = $this->settings['au_cutoff'] * 60; $time = time() - $cut_off; $rows = array(); $ar_time = time(); if ( $this->memberData['member_id'] ) { $rows = array( $ar_time.'.'.md5( microtime() ) => array( 'id' => 0, 'login_type' => substr( $this->memberData['login_anonymous'], 0, 1), 'running_time' => $ar_time, 'seo_name' => $this->memberData['members_seo_name'], 'member_id' => $this->memberData['member_id'], 'member_name' => $this->memberData['members_display_name'], 'member_group' => $this->memberData['member_group_id'], 'cns_prefix' => (ipsRegistry::$settings['cns_on']) ? $this->memberData['cns_prefix'] : "", 'cns_suffix' => (ipsRegistry::$settings['cns_on']) ? $this->memberData['cns_suffix'] : "" ) ); } if (ipsRegistry::$settings['cns_on']) { $customNameStyleJoin = array( 0 => array( 'select' => 'pp.cns_prefix, pp.cns_suffix', 'from' => array( 'profile_portal' => 'pp' ), 'where' => "s.member_id = pp.pp_member_id", 'type' => 'left', ) ); } $this->DB->build( array( 'select' => 's.id, s.member_id, s.member_name, s.seo_name, s.login_type, s.running_time, s.member_group, s.uagent_type', 'from' => array( 'sessions' => 's' ), 'where' => "running_time > {$time}", 'add_join' => $customNameStyleJoin ) ); $this->DB->execute(); //----------------------------------------- // FETCH... //----------------------------------------- while ( $r = $this->DB->fetch() ) { $rows[ $r['running_time'].'.'.$r['id'] ] = $r; } krsort( $rows ); //----------------------------------------- // cache all printed members so we // don't double print them //----------------------------------------- $cached = array(); foreach ( $rows as $result ) { $last_date = $this->registry->getClass('class_localization')->getDate( $result['running_time'], 'TINY' ); //----------------------------------------- // Bot? //----------------------------------------- if ( isset( $result['uagent_type'] ) && $result['uagent_type'] == 'search' ) { /* Skipping bot? */ if ( ! $this->settings['spider_active'] ) { continue; } //----------------------------------------- // Seen bot of this type yet? //----------------------------------------- if ( ! $cached[ $result['member_name'] ] ) { $active['NAMES'][] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'], $result['cns_prefix'], $result['cns_suffix'] ); $cached[ $result['member_name'] ] = 1; } else { //----------------------------------------- // Yup, count others as guest //----------------------------------------- $active['GUESTS']++; } } //----------------------------------------- // Guest? //----------------------------------------- else if ( ! $result['member_id'] OR ! $result['member_name'] ) { $active['GUESTS']++; } //----------------------------------------- // Member? //----------------------------------------- else { if ( empty( $cached[ $result['member_id'] ] ) ) { $cached[ $result['member_id'] ] = 1; $result['member_name'] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'], $result['cns_prefix'], $result['cns_suffix'] ); if ( $result['login_type'] ) { if ( $this->memberData['g_access_cp'] ) { $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl( "showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser' ) . "' title='$last_date'>{$result['member_name']}</a>*"; $active['ANON']++; } else { $active['ANON']++; } } else { $active['MEMBERS']++; $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl( "showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser' ) ."' title='$last_date'>{$result['member_name']}</a>"; } } } } $active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON']; $this->users_online = $active['TOTAL']; } $this->lang->words['active_users'] = sprintf( $this->lang->words['active_users'], $this->settings['au_cutoff'] ); return $this->registry->output->getTemplate('boards')->customSidebarBlockActiveUsers($active); [/code]