0 Membros e 2 Visitantes estão a ver este tópico.
<?php/******************************************************************************* Viewers.php ********************************************************************************* SMF: Simple Machines Forum ** Open-Source Project Inspired by Zef Hemel ([email protected]) ** =========================================================================== ** Software Version: SMF 1.1 RC3 ** Software by: Simple Machines (http://www.simplemachines.org) ** Copyright 2001-2006 by: Lewis Media (http://www.lewismedia.com) ** Support, News, Updates at: http://www.simplemachines.org ********************************************************************************* This program is free software; you may redistribute it and/or modify it ** under the terms of the provided license as published by Lewis Media. ** ** This program is distributed in the hope that it is and will be useful, ** but WITHOUT ANY WARRANTIES; without even any implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** ** See the "license.txt" file for details of the Simple Machines license. ** The latest version can always be found at http://www.simplemachines.org. ********************************************************************************* ** This file is distributed within Board Viewers Mod. ** Mod by HarzeM ** *******************************************************************************/if (!defined('SMF')) die('Hacking attempt...');/* This file is distributed within Board Viewers Mod for SMF. Its aim is to display a popup window when someone clicks on the necessary link. void BoardViewers() - shows a popup for displaying board viewers. - detects the board hierarchy to count child boards. - counts the members and guests in the board and its child boards. - reads the member names and group colors to display in a colorfull way. - uses the yardım template, popup sub template, no layers. - accessed via ?action=viewers;board=??; array getBoardList() - returns all level child boards of a board. - uses getBoardsRecursive function to detect parents. boolean getBoardsRecursive() - uses recursion to detect whenther a given board is any level child of another board. - returns boolean value.*/function BoardViewers(){ global $txt, $context, $board, $db_prefix, $modSettings, $scripturl, $ID_MEMBER; // No pass after this line! if (empty($modSettings['enable_board_viewers']) || empty($modSettings['boardViewersClickable']) || empty($board)) redirectexit($scripturl); // Load the admin yardım language file and template. loadLanguage('yardım'); loadTemplate('yardım'); // Don't show any template layers, just the popup sub template. $context['template_layers'] = array(); $context['sub_template'] = 'popup'; $boards = array(); // Read boards from the database. $result = db_query(" SELECT ID_BOARD, ID_PARENT, name FROM {$db_prefix}boards ",__FILE__,__LINE__); while(* = mysql_fetch_assoc($result)) { $boards[*['ID_BOARD']] = isset(*['ID_PARENT']) ? *['ID_PARENT'] : 0; // also get the name of our dear board :) if(*['ID_BOARD'] == $board) $boardname = *['name']; } // Get the boards that is childs of the board we are checking into. $boardList = getBoardList($boards); $board_query = array(); foreach($boardList as $b) $board_query[] = "INSTR(url, 's:5:\"board\";i:".$b.";')"; // get the users that are on the boards we are interested in looking. $request = db_query(" SELECT session, url, ID_MEMBER FROM {$db_prefix}log_online WHERE ".implode(" OR ",$board_query), __FILE__ , __LINE__); // create some variables. $members_in_this = 0; $guests_in_this = 0; $members_in_child = 0; $guests_in_child = 0; $board_viewers = array(); // for each user ... while(* = mysql_fetch_assoc($request)) { // no user ?! useless forum! if (empty(*['session'])) continue; $viewerdata = @unserialize(*['url']); // if a member, but not you of course. You are just looking at the viewers, not the board itself! if(*['ID_MEMBER'] > 0 && *['ID_MEMBER'] != $ID_MEMBER) $board_viewers[*['ID_MEMBER']] = $viewerdata['board']; elseif(*['ID_MEMBER'] == 0) { if($viewerdata['board'] == $board) $guests_in_this ++; else $guests_in_child ++; } } mysql_free_result($request); $member_list_this = ''; $member_list_child = ''; // If we have any members at all if($board_viewers != array()) { $member_array = array(); foreach($board_viewers as $id => $dummy) $member_array[] = $id; // Now get the user names and colors. $request = db_query(" SELECT mem.ID_MEMBER as ID_MEMBER, mem.realName as name, mg.onlineColor as color FROM {$db_prefix}members as mem LEFT JOIN {$db_prefix}membergroups as mg ON (mem.ID_GROUP = mg.ID_GROUP) WHERE FIND_IN_SET(mem.ID_MEMBER , '" . implode(",",$member_array) . "')", __FILE__, __LINE__); while(* = mysql_fetch_assoc($request)) { // add a member to the list $dummy = '<li><a href="'.$scripturl.'?action=profile;u='.*['ID_MEMBER'].'" target="_blank"><span'. (!empty(*['color']) ? ' style="color:'.*['color'].'"' : '') .'>'.*['name'].'</span></a></li>'; // decide which list to add the member if($board == $board_viewers[*['ID_MEMBER']]) { $member_list_this .= $dummy; $members_in_this ++; } else { $member_list_child = $dummy; $members_in_child ++; } } } $context['help_text'] = ''; if($members_in_this + $guests_in_this + $members_in_child + $guests_in_child == 0) $context['help_text'] .= $txt['bv_members_guests_none']; if($members_in_this + $guests_in_this > 0) $context['help_text'] .= sprintf($txt['bv_members_guests_this'],$members_in_this ,$guests_in_this); if($members_in_this > 0) $context['help_text'] .= '<br/><br/><b>' . $txt['bv_members'] . ':</b><ul>' . $member_list_this . '</ul>'; if($members_in_child + $guests_in_child > 0) $context['help_text'] .= sprintf($txt['bv_members_guests_child'],$members_in_child ,$guests_in_child); if($members_in_child > 0) $context['help_text'] .= '<br/><br/><b>' . $txt['bv_members'] . ':</b><ul>' . $member_list_child . '</ul>'; // Set the page title to something relevant. $context['page_title'] = $context['forum_name'] . ' - ' . $boardname; }function getBoardList($boards){ global $board, $db_prefix; $collected = array(); // we have a trivial board in the list! $collected[] = $board; foreach($boards as $b => $p) // board => parent { // If the parent is our board, record the child. // Or if it has a parent, check whether one of the parents is our board if($p == $board || ((!empty($p) && getBoardsRecursive($b, $boards, $collected)))) $collected[] = $b; } return $collected;}function getBoardsRecursive($b, $boards, $collected){ global $board; // If the parent is our board, store it. if($boards[$b] == $board || (!empty($boards[$b]) && getBoardsRecursive($boards[$b], $boards, $collected))) return true; return false; }?>
array('check', 'who_enabled'),
'', // Board Viewers By Candidosa2 array('check', 'enable_board_viewers'), array('check', 'boardViewersGuestsMembers'), array('check', 'boardViewersClickable'), array('check', 'countChildPosts'),
<b><a href="', $board['href'],
',$board['viewer_text'],'
$child['posts']
. $child['viewer_text']
'viewErrorLog' => array('ManageErrors.php', 'ViewErrorLog'),
'viewers' => array('Viewers.php', 'BoardViewers'),
// Remember the most recent topic for optimizing the recent posts feature. $most_recent_topic = array( 'timestamp' => 0, 'ref' => null );
// Board Viewers - by HarzeM $board_viewers = array(); if (!empty($modSettings['enable_board_viewers'])) { // get the users that are on some boards :) $request = db_query(" SELECT session, url, ID_MEMBER FROM {$db_prefix}log_online WHERE INSTR(url, 's:5:\"board\";i:')", __FILE__, __LINE__); // for each user ... while(* = mysql_fetch_assoc($request)) { // no user ?! useless forum! if (empty(*['session'])) continue; $viewerdata = @unserialize(*['url']); // Check if there was no action or the action is display. if (!isset($viewerdata['action']) || $viewerdata['action'] == 'display') { if (isset($viewerdata['board'])) { if(!isset($board_viewers[$viewerdata['board']])) $board_viewers[$viewerdata['board']] = array ('guests' => 0, 'members' => 0); if(*['ID_MEMBER'] > 0) $board_viewers[$viewerdata['board']]['members']++; else $board_viewers[$viewerdata['board']]['guests']++; } } } mysql_free_result($request); }
'posts' => $row_board['numPosts'],
'viewers' => isset($board_viewers[$row_board['ID_BOARD']]) ? array( 'guests' => $board_viewers[$row_board['ID_BOARD']]['guests'], 'members' => $board_viewers[$row_board['ID_BOARD']]['members']) : array('guests' => 0, 'members' =>0 ), // Board Viewers - by Candidosa2
$this_category[$row_board['ID_PARENT']]['topics'] += $row_board['numTopics'];
if(isset($board_viewers[$row_board['ID_BOARD']])) // Board Viewers - by HarzeM { $this_category[$row_board['ID_PARENT']]['viewers']['guests'] += $board_viewers[$row_board['ID_BOARD']]['guests']; $this_category[$row_board['ID_PARENT']]['viewers']['members'] += $board_viewers[$row_board['ID_BOARD']]['members']; }
$parent_map[$row_board['ID_PARENT']][1]['topics'] += $row_board['numTopics'];
if(isset($board_viewers[$row_board['ID_BOARD']])) // Board Viewers - by HarzeM { $parent_map[$row_board['ID_PARENT']][0]['viewers']['guests'] += $board_viewers[$row_board['ID_BOARD']]['guests']; $parent_map[$row_board['ID_PARENT']][0]['viewers']['members'] += $board_viewers[$row_board['ID_BOARD']]['members']; $parent_map[$row_board['ID_PARENT']][1]['viewers']['guests'] += $board_viewers[$row_board['ID_BOARD']]['guests']; $parent_map[$row_board['ID_PARENT']][1]['viewers']['members'] += $board_viewers[$row_board['ID_BOARD']]['members']; }
'ref' => &$this_category[$isChild ? $row_board['ID_PARENT'] : $row_board['ID_BOARD']]['last_post'], ); } mysql_free_result($result_boards);
// Aren't children wonderful things?
'viewers' => isset($board_viewers[$row_board['ID_BOARD']]) ? array( 'guests' => $board_viewers[$row_board['ID_BOARD']]['guests'], 'members' => $board_viewers[$row_board['ID_BOARD']]['members']) : array('guests' => 0, 'members' =>0 ), // Board Viewers - by HarzeM
$parent_map[*['ID_PARENT']][1]['topics'] += *['numTopics'];
// Nosey, nosey - who's viewing this topic?
// Calculation of board viewers ... By HarzeM if (!empty($modSettings['enable_board_viewers']) && isset($context['boards']) && is_array($context['boards'])) foreach($context['boards'] as $key => $boards) { $this_guests = $boards['viewers']['guests']; $this_members = $boards['viewers']['members']; $this_viewers = $this_guests + $this_members; $context['boards'][$key]['viewer_text'] = ($this_viewers > 0) ? ('<span class="smalltext" style="float:right;">(' . ($modSettings['boardViewersClickable'] ? '<a href="'.$scripturl.'?action=viewers;board='.$key.'" onclick="return reqWin(this.href);" title="'.$txt['viewersBrowsing'].'">' : '') . ($modSettings['boardViewersGuestsMembers'] ? ((($this_members > 1) ? "<b>".$this_members."</b> ". $txt['board_v_members'] : "<b>".$this_members."</b> ". $txt['board_v_member']) . (($this_guests > 1) ? ", <b>".$this_guests."</b> ". $txt['board_v_guests'] : ", <b>".$this_guests."</b> ". $txt['board_v_guest'])) : (($this_viewers > 1) ? "<b>".$this_viewers."</b> ". $txt['board_viewers'] : "<b>".$this_viewers."</b> ". $txt['board_viewer']) ) . ($modSettings['boardViewersClickable'] ? '</a>' : '') . ')</span>') : '' ; if($boards['children'] !== array()) { foreach($boards['children'] as $keych => $child) { $this_guests = $child['viewers']['guests']; $this_members = $child['viewers']['members']; $this_viewers = $this_guests + $this_members; $context['boards'][$key]['children'][$keych]['viewer_text'] = ($this_viewers > 0) ? (($this_viewers > 1) ? ", ". $txt['board_viewers_child'] . ": " . $this_viewers : ", ". $txt['board_viewer_child'] . ": " . $this_viewers) : ''; } } }
?>
// Board Viewers Mod Translate By Candidosa2$txt['enable_board_viewers'] = 'Activar ver quadros';$txt['boardViewersGuestsMembers'] = 'Seperate guest and member numbers';$txt['boardViewersClickable'] = 'Quadro a visto por Membros';$txt['countChildPosts'] = 'Numero de visitantes a ler o quadro';$txt['bv_members_guests_none'] = 'Quadro de vistaas nao existente.';$txt['bv_members_guests_this'] = '%s Membro %s visitante a ver o quadro.';$txt['bv_members_guests_child'] = 'Quadro do forum %visto %s Visitante .';$txt['bv_members'] = 'Membro';$txt['viewersBrowsing'] = 'Ver a pesquisa';$txt['board_v_members'] = 'Membros'; // 43 members$txt['board_v_member'] = 'Membro'; // 1 member$txt['board_v_guests'] = 'Visitantes'; // 26 guests$txt['board_v_guest'] = 'Visitante'; // 1 guest$txt['board_viewers'] = 'Ver o quadro'; // 32 viewing$txt['board_viewer'] = 'Ver o quadro'; // 1 viewing$txt['board_viewers_child'] = 'Ver o quadro'; // Viewers: 145$txt['board_viewer_child'] = 'Ver o quadro'; // Viewer: 1// End Of Board Viewers Mod