Pagina 1 din 1

Modificare mod 24 H stats

Scris: 18-Oct-2009, 12:53:54
de masacre
Cum pot modifica acel mod sa arate useri si toate cele in ultimele 48 de ore , ci nu 24 de ore ?

Re: Modificare mod 24 H stats

Scris: 19-Oct-2009, 21:34:17
de dorin
Un link către acest MOD ?

Re: Modificare mod 24 H stats

Scris: 03-Noi-2009, 22:51:11
de Tiestto
Posteaza aici fisierul .php din includes , este o rezolvare usoara ;) .

Re: Modificare mod 24 H stats

Scris: 05-Noi-2009, 15:25:40
de MajeStik
care fisier php ? functions_activity_stats.php ? ca si pe mine ma intereseaza

Re: Modificare mod 24 H stats

Scris: 07-Noi-2009, 12:22:54
de Tiestto
da !

Re: Modificare mod 24 H stats

Scris: 07-Noi-2009, 19:04:07
de MajeStik

Cod: Selectaţi tot

<?php
/**
*
* @package phpBB3
* @author Highway of Life ( David Lewis ) http://startrekguide.com
* @version $Id$
* @copyright (c) 2008 Star Trek Guide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit();
}

/**
 * Display extra stats, activity over the last 24 hours for new users, posts and topics.
 *
 * @return bool
 */
function activity_mod()
{
	global $template, $user;

	$user->add_lang('mods/activity_stats');

	// if the user is a bot, we won’t even process this function...
	if ($user->data['is_bot'])
	{
		return false;
	}

	// obtain user activity data
	$active_users = obtain_active_user_data();
	
	// obtain posts/topics/new users activity
	$activity = obtain_activity_data();

	// 24 hour users online list, assign to the template block: lastvisit
	foreach ($active_users as $row)
	{
			$template->assign_block_vars('lastvisit', array(
				'USERNAME_FULL'	=> get_username_string((($row['user_type'] == USER_IGNORE) ? 'no_profile' : 'full'), $row['user_id'], $row['username'], $row['user_colour']),
			));
	}

	// assign the stats to the template.
	$template->assign_vars(array(
		'USERS_24HOUR_TOTAL'	=> sprintf($user->lang['USERS_24HOUR_TOTAL'], sizeof($active_users)),
		'24HOUR_TOPICS'			=> sprintf($user->lang['24HOUR_TOPICS'], $activity['topics']),
		'24HOUR_POSTS'			=> sprintf($user->lang['24HOUR_POSTS'], $activity['posts']),
		'24HOUR_USERS'			=> sprintf($user->lang['24HOUR_USERS'], $activity['users']),
	));

	return true;
}

/**
 * Obtain an array of active users over the last 24 hours.
 *
 * @return array
 */
function obtain_active_user_data()
{
	global $cache;

	if (($active_users = $cache->get('_active_users')) === false)
	{
		global $db;

		$active_users = array();

		// grab a list of users who are currently online
		// and users who have visited in the last 24 hours
		$sql_ary = array(
			'SELECT'	=> 'u.user_id, u.user_colour, u.username, u.user_type',
			'FROM'		=> array(USERS_TABLE => 'u'),
			'LEFT_JOIN'	=> array(
				array(
					'FROM'	=> array(SESSIONS_TABLE => 's'),
					'ON'	=> 's.session_user_id = u.user_id',
				),
			),
			'WHERE'		=> 'u.user_lastvisit > ' . (time() - 86400) . ' OR s.session_user_id <> ' . ANONYMOUS,
			'GROUP_BY'	=> 'u.user_id',
			'ORDER_BY'	=> 'u.username',
		);

		$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));

		while ($row = $db->sql_fetchrow($result))
		{
			$active_users[$row['user_id']] = array(
				'user_id'		=> $row['user_id'],
				'user_type'		=> $row['user_type'],
				'username'		=> $row['username'],
				'user_colour'	=> $row['user_colour'],
			);
		}
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_active_users', $active_users, 3600);
	}

	return $active_users;
}

/**
 * obtained cached 24 hour activity data
 *
 * @return array
 */
function obtain_activity_data()
{
	global $cache;

	if (($activity = $cache->get('_activity_mod')) === false)
	{
		global $db;

		// set interval to 24 hours ago
		$interval = time() - 86400;

		$activity = array();

		// total new posts in the last 24 hours
		$sql = 'SELECT COUNT(post_id) AS new_posts
				FROM ' . POSTS_TABLE . '
				WHERE post_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['posts'] = $db->sql_fetchfield('new_posts');
		$db->sql_freeresult($result);

		// total new topics in the last 24 hours
		$sql = 'SELECT COUNT(topic_id) AS new_topics
				FROM ' . TOPICS_TABLE . '
				WHERE topic_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['topics'] = $db->sql_fetchfield('new_topics');
		$db->sql_freeresult($result);

		// total new users in the last 24 hours, counts inactive users as well
		$sql = 'SELECT COUNT(user_id) AS new_users
				FROM ' . USERS_TABLE . '
				WHERE user_regdate > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['users'] = $db->sql_fetchfield('new_users');
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_activity_mod', $activity, 3600);
	}

	return $activity;
}
?>

Re: Modificare mod 24 H stats

Scris: 21-Noi-2009, 00:13:50
de Tiestto
Poftim incearcva cu asta :

Cod: Selectaţi tot

<?php
/**
*
* @package phpBB3
* @author Highway of Life ( David Lewis ) http://startrekguide.com
* @version $Id$
* @copyright (c) 2008 Star Trek Guide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit();
}

/**
 * Display extra stats, activity over the last 24 hours for new users, posts and topics.
 *
 * @return bool
 */
function activity_mod()
{
	global $template, $user;

	$user->add_lang('mods/activity_stats');

	// if the user is a bot, we won’t even process this function...
	if ($user->data['is_bot'])
	{
		return false;
	}

	// obtain user activity data
	$active_users = obtain_active_user_data();
	
	// obtain posts/topics/new users activity
	$activity = obtain_activity_data();

	// 24 hour users online list, assign to the template block: lastvisit
	foreach ($active_users as $row)
	{
			$template->assign_block_vars('lastvisit', array(
				'USERNAME_FULL'	=> get_username_string((($row['user_type'] == USER_IGNORE) ? 'no_profile' : 'full'), $row['user_id'], $row['username'], $row['user_colour']),
			));
	}

	// assign the stats to the template.
	$template->assign_vars(array(
		'USERS_24HOUR_TOTAL'	=> sprintf($user->lang['USERS_24HOUR_TOTAL'], sizeof($active_users)),
		'24HOUR_TOPICS'			=> sprintf($user->lang['24HOUR_TOPICS'], $activity['topics']),
		'24HOUR_POSTS'			=> sprintf($user->lang['24HOUR_POSTS'], $activity['posts']),
		'24HOUR_USERS'			=> sprintf($user->lang['24HOUR_USERS'], $activity['users']),
	));

	return true;
}

/**
 * Obtain an array of active users over the last 24 hours.
 *
 * @return array
 */
function obtain_active_user_data()
{
	global $cache;

	if (($active_users = $cache->get('_active_users')) === false)
	{
		global $db;

		$active_users = array();

		// grab a list of users who are currently online
		// and users who have visited in the last 24 hours
		$sql_ary = array(
			'SELECT'	=> 'u.user_id, u.user_colour, u.username, u.user_type',
			'FROM'		=> array(USERS_TABLE => 'u'),
			'LEFT_JOIN'	=> array(
				array(
					'FROM'	=> array(SESSIONS_TABLE => 's'),
					'ON'	=> 's.session_user_id = u.user_id',
				),
			),
			'WHERE'		=> 'u.user_lastvisit > ' . (time() - 345600) . ' OR s.session_user_id <> ' . ANONYMOUS,
			'GROUP_BY'	=> 'u.user_id',
			'ORDER_BY'	=> 'u.username',
		);

		$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));

		while ($row = $db->sql_fetchrow($result))
		{
			$active_users[$row['user_id']] = array(
				'user_id'		=> $row['user_id'],
				'user_type'		=> $row['user_type'],
				'username'		=> $row['username'],
				'user_colour'	=> $row['user_colour'],
			);
		}
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_active_users', $active_users, 7200);
	}

	return $active_users;
}

/**
 * obtained cached 24 hour activity data
 *
 * @return array
 */
function obtain_activity_data()
{
	global $cache;

	if (($activity = $cache->get('_activity_mod')) === false)
	{
		global $db;

		// set interval to 24 hours ago
		$interval = time() - 345600;

		$activity = array();

		// total new posts in the last 24 hours
		$sql = 'SELECT COUNT(post_id) AS new_posts
				FROM ' . POSTS_TABLE . '
				WHERE post_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['posts'] = $db->sql_fetchfield('new_posts');
		$db->sql_freeresult($result);

		// total new topics in the last 24 hours
		$sql = 'SELECT COUNT(topic_id) AS new_topics
				FROM ' . TOPICS_TABLE . '
				WHERE topic_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['topics'] = $db->sql_fetchfield('new_topics');
		$db->sql_freeresult($result);

		// total new users in the last 24 hours, counts inactive users as well
		$sql = 'SELECT COUNT(user_id) AS new_users
				FROM ' . USERS_TABLE . '
				WHERE user_regdate > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['users'] = $db->sql_fetchfield('new_users');
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_activity_mod', $activity, 7200);
	}

	return $activity;
}
?>


Scuzama de intarziere !