Top 10 Posters today and This Week

Started by burtybob, June 03, 2008, 11:34:31 PM

Previous topic - Next topic

burtybob


TOP 10 POSTERS TODAY AND THIS WEEK STATS v1.1
By Karl Benson

Link to Mod | Support Topic | Demo | Donate

Compatibility
For SMF 1.1.x and SMF 2.0 Beta 2/2.1 (and newer)

Introduction
Adds the top 10 posters today and this week to your Stats page (action=stats)

Features
o Adds Top 10 Posters Today
- Based on Server time including your forum time offset
o Adds Top 10 Posters This Week
- Starts on Sunday
- Based on Server time including your forum time offset
o Supports Languages
- English/English-utf8
- English_British/English_British-utf8
- Turkish/Turkish-utf8 (Thanks to eslao)
I welcome translations for other languages. Please post the translated language strings in the Support Topic.

Installation
Any previous versions of this mod MUST be uninstalled BEFORE installing this version.

Simply install the package to install on the SMF Default Core Theme ONLY.

A Manual edit will be required for ALL themes (other than SMF Default Core Theme) which have a custom Stats.template.php

If your theme has its own versions of the language files Modifications.english.php and/or Modifications.english-utf8.php, OR if your using a language other than those supported (listed above) by the mod then you will need to copy the language strings into each custom version of those files.

Useful Links
SMF Package Parser
Manual Installation Of Mods
How Do I Modify Files?

Donate
Has this modification helped you? Support the developer by Donating

Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0 - 22nd February 2008
o Initial release
1.1 - 29th February 2008
o Fixed (hopefully!) some issues with stats not reporting
o Added Turkish/Turkish-utf8 support (Thanks to eslao)
1.1 - 1st June 2008
o Burtybob has taken over developement of this and would once again like to thank Karl for another great mod.
1.2 - 9th July 2008
o Thanks to tyty1993 for making the code for a monthly one, it does replace the existing day slot, there is 3 different ones aviliable.
1) Day and Month
2) Week and Month
3) Day and Week.
1.3 - 13th July
o Important update for the monthly users the monthly data was not updating this has now been fixed thanks to tyty1993 once again.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

Apllicmz

nICE Work
Good Mod

translate portuguese and Brazilian

<file name="$languagedir/Modifications.portuguese.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['top_posters_day'] = 'Top 10 Postaram hoje';
$txt['top_posters_week'] = 'Top 10 Postaram esta semana';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.brazilian.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['top_posters_day'] = 'Top 10 Postaram hoje';
$txt['top_posters_week'] = 'Top 10 Postaram esta semana';
]]></add>
</operation>
</file>



Jelle Mees

This mod isn't new. I installed this weeks ago on my forum.
Wth is this??? Seriously, this is not new.

burtybob

Quote from: Jelle Mees on June 04, 2008, 04:30:00 PM
This mod isn't new. I installed this weeks ago on my forum.
Wth is this??? Seriously, this is not new.

I KNOW READ KARLS POST, *bangs head on table* Looks up *bangs head on table*
Thats better, Karls given me control of this MOD so from now on all updates will be coming from me :D, not karl, Karl is giving loads of his away but most of gone.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

jossanaijr

Any news about the weekly issue?  I reinstalled this mod and weekly stats is not working.

burtybob

Quote from: jossanaijr on June 05, 2008, 03:35:46 PM
Any news about the weekly issue?  I reinstalled this mod and weekly stats is not working.

Hi,

Sorry to hear that, looking at my forums it seems to be working fine.
What do you mean by its not working? The more information you can give me the easier i can fix it for you.

Burtybob
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

jossanaijr

If you check original topic there are a discussion about this mod not working probably because of another mod.  Well I have 70 installed and one of them must be interfering... What happens is that week stats reset every day as daily stat.

vosje505

Quote from: jossanaijr on June 05, 2008, 05:35:29 PM
If you check original topic there are a discussion about this mod not working probably because of another mod.  Well I have 70 installed and one of them must be interfering... What happens is that week stats reset every day as daily stat.
i've got the same problem

burtybob

Ok thank you

What version are you using SMF2 or SMF1?
I will take a look and see what i can find.

Thanks,

Burtybob
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

burtybob

Im cross referencing the MODs that other people have said that they have installed when they have this problem and ill say what i find from that :D, the worst it will do is take an hour of my time to find that there is 7/8 MODs that are "getting their wires crossed".
Ill post asap.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

burtybob

Below is a table of the cross referenced MODs that come up more than once! Please can you look and see what ones you may have installed?
If you do have any of the below installed please can you post them thanks.


















MOD NameNumber Of people
Auto Embed Video Clips3 out of 4
Users Online Today3 out of 4
Monthly Statistics On Profile2 out of 4
Spam Me Not2 out of 4
Neat Board Layout2 out of 4
Topic Starter2 out of 4
Wrap Text Around Images2 out of 4
Remove Quoted Images2 out of 4
Tiny Portal2 out of 4
Advanced Recent Posts2 out of 4
Enhanced Quick Reply2 out of 4
Attatchments Posititon2 out of 4
Link Tree2 out of 4
User E-Mail System2 out of 4
Avatar On Board2 out of 4
Custom Profile Field2 out of 4

I know that there is only one in there that is directly related to Stats BUT these are the MODs that appear more than once when i cross referenced the four peoples MODs, there were about 50 different MODs installed between the 4 of them and these are the ones that cropped up.
I know it is unlikely but it MAY just MAY be one or more of them that is causing some "crossing of the wires" somewhere.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

vosje505

Quote from: burtybob on June 06, 2008, 07:22:45 AM
Ok thank you

What version are you using SMF2 or SMF1?
I will take a look and see what i can find.

Thanks,

Burtybob

1.1.5

vosje505

Quote from: burtybob on June 06, 2008, 09:29:36 AM
Below is a table of the cross referenced MODs that come up more than once! Please can you look and see what ones you may have installed?
If you do have any of the below installed please can you post them thanks.


















MOD NameNumber Of people
Auto Embed Video Clips3 out of 4
Users Online Today3 out of 4
Monthly Statistics On Profile2 out of 4
Spam Me Not2 out of 4
Neat Board Layout2 out of 4
Topic Starter2 out of 4
Wrap Text Around Images2 out of 4
Remove Quoted Images2 out of 4
Tiny Portal2 out of 4
Advanced Recent Posts2 out of 4
Enhanced Quick Reply2 out of 4
Attatchments Posititon2 out of 4
Link Tree2 out of 4
User E-Mail System2 out of 4
Avatar On Board2 out of 4
Custom Profile Field2 out of 4

I know that there is only one in there that is directly related to Stats BUT these are the MODs that appear more than once when i cross referenced the four peoples MODs, there were about 50 different MODs installed between the 4 of them and these are the ones that cropped up.
I know it is unlikely but it MAY just MAY be one or more of them that is causing some "crossing of the wires" somewhere.

i've got none of this list running

burtybob

Hello again,

Very sorry to hear that, as i said mine works and Karl looked through his several times and never been able to find a problem, being new to this MOD i do not have an idea as to where the problem my be.
Can i ask for a screenshot/list of the MODs that you do ahve installed as i can not seem to recreate this problem and Karl said the same in his post when he was developing this MOD.

Sorry,
Ben (burtybob)
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

Dragonsbrethren

I just installed this mod last night and it's working great but I'm getting an error in my log every time someone views the stat page:

8: Undefined index: 33
File: /Sources/Stats.php
Line: 571


I looked at line 571 and nothing jumped out at me as being wrong, could someone else take a look at it and see if they can find the problem?

Code (Stats.php) Select
<?php
/**********************************************************************************
* Stats.php                                                                       *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel ([email protected])                    *
* =============================================================================== *
* Software Version:           SMF 1.1                                             *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
*           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 Simple Machines LLC.          *
*                                                                                 *
* 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.        *
**********************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');

/* This function has only one job: providing a display for forum statistics.
As such, it has only one function:

void DisplayStats()
- gets all the statistics in order and puts them in.
- uses the Stats template and language file. (and main sub template.)
- requires the view_stats permission.
- accessed from ?action=stats.

void getDailyStats(string $condition)
- called by DisplayStats().
- loads the statistics on a daily basis in $context.

void SMStats()
- called by simplemachines.org.
- only returns anything if stats was enabled during installation.
- can also be accessed by the admin, to show what stats sm.org collects.
- does not return any data directly to sm.org, instead starts a new request for security.

*/

// Display some useful/interesting board statistics.
function DisplayStats()
{
global $txt$scripturl$db_prefix$modSettings$user_info$context;

if (!empty($_REQUEST['expand']))
{
$month = (int) substr($_REQUEST['expand'], 4);
$year = (int) substr($_REQUEST['expand'], 04);
if ($year 1900 && $year 2200 && $month >= && $month <= 12)
$_SESSION['expanded_stats'][$year][] = $month;
}
elseif (!empty($_REQUEST['collapse']))
{
$month = (int) substr($_REQUEST['collapse'], 4);
$year = (int) substr($_REQUEST['collapse'], 04);
if (!empty($_SESSION['expanded_stats'][$year]))
$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
}

// Handle the XMLHttpRequest.
if (isset($_REQUEST['xml']))
{
// Collapsing stats only needs adjustments of the session variables.
if (!empty($_REQUEST['collapse']))
obExit(false);

$context['sub_template'] = 'stats';
getDailyStats("YEAR(date) = $year AND MONTH(date) = $month");
$context['monthly'][$year sprintf('%02d'$month)]['date'] = array(
'month' => sprintf('%02d'$month),
'year' => $year,
);
return;
}

loadLanguage('Stats');
loadTemplate('Stats');

isAllowedTo('view_stats');

// Build the link tree......
$context['linktree'][] = array(
'url' => $scripturl '?action=stats',
'name' => $txt['smf_stats_1']
);
$context['page_title'] = $context['forum_name'] . ' - ' $txt['smf_stats_1'];

$context['show_member_list'] = allowedTo('view_mlist');

// Get averages...
$result db_query("
SELECT
SUM(posts) AS posts, SUM(topics) AS topics, SUM(registers) AS registers,
SUM(mostOn) AS mostOn, MIN(date) AS date, SUM(hits) AS hits
FROM 
{$db_prefix}log_activity"__FILE____LINE__);
$row mysql_fetch_assoc($result);
mysql_free_result($result);

// This would be the amount of time the forum has been up... in days...
$total_days_up ceil((time() - strtotime($row['date'])) / (60 60 24));

$context['average_posts'] = round($row['posts'] / $total_days_up2);
$context['average_topics'] = round($row['topics'] / $total_days_up2);
$context['average_members'] = round($row['registers'] / $total_days_up2);
$context['average_online'] = round($row['mostOn'] / $total_days_up2);
$context['average_hits'] = round($row['hits'] / $total_days_up2);

$context['num_hits'] = $row['hits'];

// How many users are online now.
$result db_query("
SELECT COUNT(*)
FROM 
{$db_prefix}log_online"__FILE____LINE__);
list ($context['users_online']) = mysql_fetch_row($result);
mysql_free_result($result);

// Statistics such as number of boards, categories, etc.
$result db_query("
SELECT COUNT(*)
FROM 
{$db_prefix}boards AS b"__FILE____LINE__);
list ($context['num_boards']) = mysql_fetch_row($result);
mysql_free_result($result);

$result db_query("
SELECT COUNT(*)
FROM 
{$db_prefix}categories AS c"__FILE____LINE__);
list ($context['num_categories']) = mysql_fetch_row($result);
mysql_free_result($result);

$context['num_members'] = &$modSettings['totalMembers'];
$context['num_posts'] = &$modSettings['totalMessages'];
$context['num_topics'] = &$modSettings['totalTopics'];
$context['most_members_online'] = array(
'number' => &$modSettings['mostOnline'],
'date' => timeformat($modSettings['mostDate'])
);
$context['latest_member'] = &$context['common_stats']['latest_member'];

// Male vs. female ratio - let's calculate this only every four minutes.
if (($context['gender'] = cache_get_data('stats_gender'240)) == null)
{
$result db_query("
SELECT COUNT(*) AS totalMembers, gender
FROM 
{$db_prefix}members
GROUP BY gender"
__FILE____LINE__);
$context['gender'] = array();
while ($row mysql_fetch_assoc($result))
{
// Assuming we're telling... male or female?
if (!empty($row['gender']))
$context['gender'][$row['gender'] == 'females' 'males'] = $row['totalMembers'];
}
mysql_free_result($result);

// Set these two zero if the didn't get set at all.
if (empty($context['gender']['males']))
$context['gender']['males'] = 0;
if (empty($context['gender']['females']))
$context['gender']['females'] = 0;

// Try and come up with some "sensible" default states in case of a non-mixed board.
if ($context['gender']['males'] == $context['gender']['females'])
$context['gender']['ratio'] = '1:1';
elseif ($context['gender']['males'] == 0)
$context['gender']['ratio'] = '0:1';
elseif ($context['gender']['females'] == 0)
$context['gender']['ratio'] = '1:0';
elseif ($context['gender']['males'] > $context['gender']['females'])
$context['gender']['ratio'] = round($context['gender']['males'] / $context['gender']['females'], 1) . ':1';
elseif ($context['gender']['females'] > $context['gender']['males'])
$context['gender']['ratio'] = '1:' round($context['gender']['females'] / $context['gender']['males'], 1);

cache_put_data('stats_gender'$context['gender'], 240);
}

$date strftime('%Y%m%d'forum_time(false));

// Members online so far today.
$result db_query("
SELECT mostOn
FROM 
{$db_prefix}log_activity
WHERE date = 
$date
LIMIT 1"
__FILE____LINE__);
list ($context['online_today']) = mysql_fetch_row($result);
mysql_free_result($result);

$context['online_today'] = (int) $context['online_today'];

// Poster top 10.
$members_result db_query("
SELECT ID_MEMBER, realName, posts
FROM 
{$db_prefix}members
WHERE posts > 0
ORDER BY posts DESC
LIMIT 10"
__FILE____LINE__);
$context['top_posters'] = array();
$max_num_posts 1;
while ($row_members mysql_fetch_assoc($members_result))
{
$context['top_posters'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['posts'],
'href' => $scripturl '?action=profile;u=' $row_members['ID_MEMBER'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row_members['ID_MEMBER'] . '">' $row_members['realName'] . '</a>'
);

if (!empty($modSettings['MemberColorStats']))
$context['MemberColor_ID_MEMBER'][$row_members['ID_MEMBER']] = $row_members['ID_MEMBER'];

if (!empty($modSettings['MemberColorStats']))
$MemberColor_ID_MEMBER[$row_members['ID_MEMBER']] = $row_members['ID_MEMBER'];

if ($max_num_posts $row_members['posts'])
$max_num_posts $row_members['posts'];
}
mysql_free_result($members_result);

foreach ($context['top_posters'] as $i => $poster)
$context['top_posters'][$i]['post_percent'] = round(($poster['num_posts'] * 100) / $max_num_posts);

// Board top 10.
$boards_result db_query("
SELECT ID_BOARD, name, numPosts
FROM 
{$db_prefix}boards AS b
WHERE 
$user_info[query_see_board]. (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > "
AND b.ID_BOARD != 
$modSettings[recycle_board]'') . "
ORDER BY numPosts DESC
LIMIT 10"
__FILE____LINE__);
$context['top_boards'] = array();
$max_num_posts 1;
while ($row_board mysql_fetch_assoc($boards_result))
{
$context['top_boards'][] = array(
'id' => $row_board['ID_BOARD'],
'name' => $row_board['name'],
'num_posts' => $row_board['numPosts'],
'href' => $scripturl '?board=' $row_board['ID_BOARD'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row_board['ID_BOARD'] . '.0">' $row_board['name'] . '</a>'
);

if (!empty($modSettings['MemberColorStats']))
$context['MemberColor_ID_MEMBER'][$row_members['ID_MEMBER_STARTED']] = $row_members['ID_MEMBER_STARTED'];

if (!empty($modSettings['MemberColorStats']))
$MemberColor_ID_MEMBER[$row_members['ID_MEMBER_STARTED']] = $row_members['ID_MEMBER_STARTED'];

if ($max_num_posts $row_board['numPosts'])
$max_num_posts $row_board['numPosts'];
}
mysql_free_result($boards_result);

foreach ($context['top_boards'] as $i => $board)
$context['top_boards'][$i]['post_percent'] = round(($board['num_posts'] * 100) / $max_num_posts);

// Are you on a larger forum?  If so, let's try to limit the number of topics we search through.
if ($modSettings['totalMessages'] > 100000)
{
$request db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}topics
WHERE numReplies != 0
ORDER BY numReplies DESC
LIMIT 100"
__FILE____LINE__);
$topic_ids = array();
while ($row mysql_fetch_assoc($request))
$topic_ids[] = $row['ID_TOPIC'];
mysql_free_result($request);
}
else
$topic_ids = array();

// Topic replies top 10.
$topic_reply_result db_query("
SELECT m.subject, t.numReplies, t.ID_BOARD, t.ID_TOPIC, b.name
FROM (
{$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG = t.ID_FIRST_MSG
AND 
$user_info[query_see_board]. (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > "
AND b.ID_BOARD != 
$modSettings[recycle_board]'') . "
AND t.ID_BOARD = b.ID_BOARD" 
. (!empty($topic_ids) ? "
AND t.ID_TOPIC IN (" 
implode(', '$topic_ids) . ")" '') . "
ORDER BY t.numReplies DESC
LIMIT 10"
__FILE____LINE__);
$context['top_topics_replies'] = array();
$max_num_replies 1;
while ($row_topic_reply mysql_fetch_assoc($topic_reply_result))
{
censorText($row_topic_reply['subject']);

$context['top_topics_replies'][] = array(
'id' => $row_topic_reply['ID_TOPIC'],
'board' => array(
'id' => $row_topic_reply['ID_BOARD'],
'name' => $row_topic_reply['name'],
'href' => $scripturl '?board=' $row_topic_reply['ID_BOARD'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row_topic_reply['ID_BOARD'] . '.0">' $row_topic_reply['name'] . '</a>'
),
'subject' => $row_topic_reply['subject'],
'num_replies' => $row_topic_reply['numReplies'],
'href' => $scripturl '?topic=' $row_topic_reply['ID_TOPIC'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row_topic_reply['ID_TOPIC'] . '.0">' $row_topic_reply['subject'] . '</a>'
);

if ($max_num_replies $row_topic_reply['numReplies'])
$max_num_replies $row_topic_reply['numReplies'];
}
mysql_free_result($topic_reply_result);

foreach ($context['top_topics_replies'] as $i => $topic)
$context['top_topics_replies'][$i]['post_percent'] = round(($topic['num_replies'] * 100) / $max_num_replies);

// Large forums may need a bit more prodding...
if ($modSettings['totalMessages'] > 100000)
{
$request db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}topics
WHERE numViews != 0
ORDER BY numViews DESC
LIMIT 100"
__FILE____LINE__);
$topic_ids = array();
while ($row mysql_fetch_assoc($request))
$topic_ids[] = $row['ID_TOPIC'];
mysql_free_result($request);
}
else
$topic_ids = array();

// Topic views top 10.
$topic_view_result db_query("
SELECT m.subject, t.numViews, t.ID_BOARD, t.ID_TOPIC, b.name
FROM (
{$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG = t.ID_FIRST_MSG
AND 
$user_info[query_see_board]. (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > "
AND b.ID_BOARD != 
$modSettings[recycle_board]'') . "
AND t.ID_BOARD = b.ID_BOARD" 
. (!empty($topic_ids) ? "
AND t.ID_TOPIC IN (" 
implode(', '$topic_ids) . ")" '') . "
ORDER BY t.numViews DESC
LIMIT 10"
__FILE____LINE__);
$context['top_topics_views'] = array();
$max_num_views 1;
while ($row_topic_views mysql_fetch_assoc($topic_view_result))
{
censorText($row_topic_views['subject']);

$context['top_topics_views'][] = array(
'id' => $row_topic_views['ID_TOPIC'],
'board' => array(
'id' => $row_topic_views['ID_BOARD'],
'name' => $row_topic_views['name'],
'href' => $scripturl '?board=' $row_topic_views['ID_BOARD'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row_topic_views['ID_BOARD'] . '.0">' $row_topic_views['name'] . '</a>'
),
'subject' => $row_topic_views['subject'],
'num_views' => $row_topic_views['numViews'],
'href' => $scripturl '?topic=' $row_topic_views['ID_TOPIC'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row_topic_views['ID_TOPIC'] . '.0">' $row_topic_views['subject'] . '</a>'
);

if ($max_num_views $row_topic_views['numViews'])
$max_num_views $row_topic_views['numViews'];
}
mysql_free_result($topic_view_result);

foreach ($context['top_topics_views'] as $i => $topic)
$context['top_topics_views'][$i]['post_percent'] = round(($topic['num_views'] * 100) / $max_num_views);

// Top 10 Posters so far today
// Change the time depending on server time offset
list($year$month$day) = explode('-'date('Y-m-d'));
    
$starttime mktime(000$month$day$year);
// Offset based on forum time
$starttime forum_time(false$starttime);

$request db_query("
SELECT me.ID_MEMBER, me.realName, COUNT(*) as count_posts
FROM 
{$db_prefix}messages AS m
LEFT JOIN 
{$db_prefix}members AS me ON (me.ID_MEMBER = m.ID_MEMBER)
WHERE m.posterTime > " 
$starttime "
AND m.ID_MEMBER != 0
GROUP BY me.ID_MEMBER
ORDER BY count_posts DESC
LIMIT 10"
__FILE____LINE__);

$context['top_posters_day'] = array();
$max_num_posts 1;
while ($row_members mysql_fetch_assoc($request))
{
$context['top_posters_day'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['count_posts'],
'href' => $scripturl '?action=profile;u=' $row_members['ID_MEMBER'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row_members['ID_MEMBER'] . '">' $row_members['realName'] . '</a>'
);

if ($max_num_posts $row_members['count_posts'])
$max_num_posts $row_members['count_posts'];
}
mysql_free_result($request);

foreach ($context['top_posters_day'] as $i => $j)
$context['top_posters_day'][$i]['post_percent'] = round(($j['num_posts'] * 100) / $max_num_posts);

// Tidy up
unset($max_num_posts$row_members$j$i);

// Top 10 Posters so far this week  (starts sunday)
$starttime mktime(000date("n"), date("j"), date("Y")) - (date("N")*3600*24);
// Offset based on forum time
$starttime forum_time(false$starttime);

$request db_query("
SELECT me.ID_MEMBER, me.realName, COUNT(*) as count_posts
FROM 
{$db_prefix}messages AS m
LEFT JOIN 
{$db_prefix}members AS me ON (me.ID_MEMBER = m.ID_MEMBER)
WHERE m.posterTime > " 
$starttime "
AND m.ID_MEMBER != 0
GROUP BY me.ID_MEMBER
ORDER BY count_posts DESC
LIMIT 10"
__FILE____LINE__);

$context['top_posters_week'] = array();
$max_num_posts 1;
while ($row_members mysql_fetch_assoc($request))
{
$context['top_posters_week'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['count_posts'],
'href' => $scripturl '?action=profile;u=' $row_members['ID_MEMBER'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row_members['ID_MEMBER'] . '">' $row_members['realName'] . '</a>'
);

if ($max_num_posts $row_members['count_posts'])
$max_num_posts $row_members['count_posts'];
}
mysql_free_result($request);

foreach ($context['top_posters_week'] as $i => $j)
$context['top_posters_week'][$i]['post_percent'] = round(($j['num_posts'] * 100) / $max_num_posts);

// Tidy up
unset($max_num_posts$row_members$j$i);

// Try to cache this when possible, because it's a little unavoidably slow.
if (($members cache_get_data('stats_top_starters'360)) == null)
{
$request db_query("
SELECT ID_MEMBER_STARTED, COUNT(*) AS hits
FROM 
{$db_prefix}topics" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > "
WHERE ID_BOARD != 
$modSettings[recycle_board]'') . "
GROUP BY ID_MEMBER_STARTED
ORDER BY hits DESC
LIMIT 20"
__FILE____LINE__);
$members = array();
while ($row mysql_fetch_assoc($request))
$members[$row['ID_MEMBER_STARTED']] = $row['hits'];
mysql_free_result($request);

cache_put_data('stats_top_starters'$members360);
}

if (empty($members))
$members = array(=> 0);

// Topic poster top 10.
$members_result db_query("
SELECT ID_MEMBER, realName
FROM 
{$db_prefix}members
WHERE ID_MEMBER IN (" 
implode(', 'array_keys($members)) . ")
GROUP BY ID_MEMBER
ORDER BY FIND_IN_SET(ID_MEMBER, '" 
implode(','array_keys($members)) . "')
LIMIT 10"
__FILE____LINE__);
$context['top_starters'] = array();
$max_num_topics 1;
while ($row_members mysql_fetch_assoc($members_result))
{
$context['top_starters'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_topics' => $members[$row_members['ID_MEMBER']],
'href' => $scripturl '?action=profile;u=' $row_members['ID_MEMBER'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row_members['ID_MEMBER'] . '">' $row_members['realName'] . '</a>'
);

if ($max_num_topics $members[$row_members['ID_MEMBER']])
$max_num_topics $members[$row_members['ID_MEMBER']];
}
mysql_free_result($members_result);

foreach ($context['top_starters'] as $i => $topic)
$context['top_starters'][$i]['post_percent'] = round(($topic['num_topics'] * 100) / $max_num_topics);

// Time online top 10.
// !!!SLOW This query is sorta slow.  Should we just add a key? (or would that be bad in the long run?)
$temp cache_get_data('stats_total_time_members'600);
$members_result db_query("
SELECT ID_MEMBER, realName, totalTimeLoggedIn
FROM 
{$db_prefix}members" . (!empty($temp) ? "
WHERE ID_MEMBER IN (" 
implode(', '$temp) . ")" '') . "
ORDER BY totalTimeLoggedIn DESC
LIMIT 20"
__FILE____LINE__);
$context['top_time_online'] = array();
$temp2 = array();
$max_time_online 1;
while ($row_members mysql_fetch_assoc($members_result))
{
$temp2[] = (int) $row_members['ID_MEMBER'];
if (count($context['top_time_online']) >= 10)
continue;

// Figure out the days, hours and minutes.
$timeDays floor($row_members['totalTimeLoggedIn'] / 86400);
$timeHours floor(($row_members['totalTimeLoggedIn'] % 86400) / 3600);

// Figure out which things to show... (days, hours, minutes, etc.)
$timelogged '';
if ($timeDays 0)
$timelogged .= $timeDays $txt['totalTimeLogged5'];
if ($timeHours 0)
$timelogged .= $timeHours $txt['totalTimeLogged6'];
$timelogged .= floor(($row_members['totalTimeLoggedIn'] % 3600) / 60) . $txt['totalTimeLogged7'];

$context['top_time_online'][] = array(
'id' => $row_members['ID_MEMBER'],
'name' => $row_members['realName'],
'time_online' => $timelogged,
'seconds_online' => $row_members['totalTimeLoggedIn'],
'href' => $scripturl '?action=profile;u=' $row_members['ID_MEMBER'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row_members['ID_MEMBER'] . '">' $row_members['realName'] . '</a>'
);

if (!empty($modSettings['MemberColorStats']))
$context['MemberColor_ID_MEMBER'][$row_members['ID_MEMBER']] = $row_members['ID_MEMBER'];

if (!empty($modSettings['MemberColorStats']))
$MemberColor_ID_MEMBER[$row_members['ID_MEMBER']] = $row_members['ID_MEMBER'];

if ($max_time_online $row_members['totalTimeLoggedIn'])
$max_time_online $row_members['totalTimeLoggedIn'];
}
mysql_free_result($members_result);

foreach ($context['top_time_online'] as $i => $member)
$context['top_time_online'][$i]['time_percent'] = round(($member['seconds_online'] * 100) / $max_time_online);

if (!empty($modSettings['latestMember']) && !empty($modSettings['MemberColorLatestMember']))
$context['MemberColor_ID_MEMBER'][$modSettings['latestMember']] = $modSettings['latestMember'];

//Yeah baby give me some colors =) .oO(sometimes who read this ;D).
if (!empty($context['MemberColor_ID_MEMBER'])) {
$colorDatas load_onlineColors($context['MemberColor_ID_MEMBER']);
if (!empty($modSettings['MemberColorStats'])) {
// First the Top Posters =)
foreach($context['top_posters'] as $key => $value) {
if(!empty($context['top_posters'][$key]['id']))
$context['top_posters'][$key]['link'] = $colorDatas[$context['top_posters'][$key]['id']]['colored_link'];
}
// First the Top Starter =)
foreach($context['top_starters'] as $key => $value) {
if(!empty($context['top_starters'][$key]['id']))
$context['top_starters'][$key]['link'] = $colorDatas[$context['top_starters'][$key]['id']]['colored_link'];
}
// First the Top Onliner =)
foreach($context['top_time_online'] as $key => $value) {
if(!empty($context['top_time_online'][$key]['id']))
$context['top_time_online'][$key]['link'] = $colorDatas[$context['top_time_online'][$key]['id']]['colored_link'];
}
}
if (!empty($modSettings['latestMember']) && !empty($modSettings['MemberColorLatestMember']))
$context['latest_member']['link'] = $colorDatas[$modSettings['latestMember']]['colored_link'];
}

if (!empty($modSettings['latestMember']) && !empty($modSettings['MemberColorLatestMember']))
$MemberColor_ID_MEMBER[$modSettings['latestMember']] = $modSettings['latestMember'];

//Yeah baby give me some colors =).
if (!empty($MemberColor_ID_MEMBER)) {
//Now Load the Missing global :)
global $user_profile;
loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid NULL;
if (!empty($modSettings['MemberColorStats'])) {
// First the Top Posters =)
foreach($context['top_posters'] as $key => $value) {
$cmemcolid $context['top_posters'][$key]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['top_posters'][$key]['link'] = '<a href="' $scripturl '?action=profile;u=' $profile['ID_MEMBER'] . '" title="' $txt[92] . ' ' $profile['realName'] . '"><span style="color:'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).';">' $profile['realName'] . '</span></a>';
}
// First the Top Starter =)
foreach($context['top_starters'] as $key => $value) {
$cmemcolid $context['top_starters'][$key]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['top_starters'][$key]['link'] = '<a href="' $scripturl '?action=profile;u=' $profile['ID_MEMBER'] . '" title="' $txt[92] . ' ' $profile['realName'] . '"><span style="color:'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).';">' $profile['realName'] . '</span></a>';
}
// First the Top Onliner =)
foreach($context['top_time_online'] as $key => $value) {
$cmemcolid $context['top_time_online'][$key]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['top_time_online'][$key]['link'] = '<a href="' $scripturl '?action=profile;u=' $profile['ID_MEMBER'] . '" title="' $txt[92] . ' ' $profile['realName'] . '"><span style="color:'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).';">' $profile['realName'] . '</span></a>';
}
}
if (!empty($modSettings['latestMember']) && !empty($modSettings['MemberColorLatestMember'])) {
$profile = &$user_profile[$modSettings['latestMember']];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['latest_member']['link'] = '<a href="' $scripturl '?action=profile;u=' $profile['ID_MEMBER'] . '" title="' $txt[92] . ' ' $profile['realName'] . '"><span style="color:'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).';">' $profile['realName'] . '</span></a>';
}
}

// Cache the ones we found for a bit, just so we don't have to look again.
if ($temp !== $temp2)
cache_put_data('stats_total_time_members'$temp2480);

// Activity by month.
$months_result db_query("
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, COUNT(*) AS numDays
FROM 
{$db_prefix}log_activity
GROUP BY stats_year, stats_month"
__FILE____LINE__);
$context['monthly'] = array();
while ($row_months mysql_fetch_assoc($months_result))
{
$ID_MONTH $row_months['stats_year'] . sprintf('%02d'$row_months['stats_month']);
$expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]);

$context['monthly'][$ID_MONTH] = array(
'id' => $ID_MONTH,
'date' => array(
'month' => sprintf('%02d'$row_months['stats_month']),
'year' => $row_months['stats_year']
),
'href' => $scripturl '?action=stats;' . ($expanded 'collapse' 'expand') . '=' $ID_MONTH '#' $ID_MONTH,
'link' => '<a href="' $scripturl '?action=stats;' . ($expanded 'collapse' 'expand') . '=' $ID_MONTH '#' $ID_MONTH '">' $txt['months'][$row_months['stats_month']] . ' ' $row_months['stats_year'] . '</a>',
'month' => $txt['months'][$row_months['stats_month']],
'year' => $row_months['stats_year'],
'new_topics' => $row_months['topics'],
'new_posts' => $row_months['posts'],
'new_members' => $row_months['registers'],
'most_members_online' => $row_months['mostOn'],
'hits' => $row_months['hits'],
'num_days' => $row_months['numDays'],
'days' => array(),
'expanded' => $expanded
);
}

// This gets rid of the filesort on the query ;).
krsort($context['monthly']);

if (empty($_SESSION['expanded_stats']))
return;

$condition = array();
foreach ($_SESSION['expanded_stats'] as $year => $months)
if (!empty($months))
$condition[] = "YEAR(date) = $year AND MONTH(date) IN (" implode(', '$months) . ')';

// No daily stats to even look at?
if (empty($condition))
return;

getDailyStats(implode(' OR '$condition));
}

function 
getDailyStats($condition)
{
global $context$db_prefix;

// Activity by day.
$days_result db_query("
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits
FROM 
{$db_prefix}log_activity
WHERE 
$condition
ORDER BY stats_day ASC"
__FILE____LINE__);
while ($row_days mysql_fetch_assoc($days_result))
$context['monthly'][$row_days['stats_year'] . sprintf('%02d'$row_days['stats_month'])]['days'][] = array(
'day' => sprintf('%02d'$row_days['stats_day']),
'month' => sprintf('%02d'$row_days['stats_month']),
'year' => $row_days['stats_year'],
'new_topics' => $row_days['topics'],
'new_posts' => $row_days['posts'],
'new_members' => $row_days['registers'],
'most_members_online' => $row_days['mostOn'],
'hits' => $row_days['hits']
);
mysql_free_result($days_result);
}

// This is the function which returns stats to simple machines.org IF enabled!
// See http://www.simplemachines.org/about/stats.php for more info.
function SMStats()
{
global $modSettings$user_info$forum_version;

// First, is it disabled?
if (empty($modSettings['allow_sm_stats']))
die();

// Are we saying who we are, and are we right? (OR an admin)
if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats']))
die();

// Verify the referer...
if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085'))
die();

// Get the actual stats.
$stats_to_send = array(
'UID' => $modSettings['allow_sm_stats'],
'time_added' => time(),
'members' => $modSettings['totalMembers'],
'messages' => $modSettings['totalMessages'],
'topics' => $modSettings['totalTopics'],
'boards' => 0,
'php_version' => PHP_VERSION,
'mysql_version' => '',
'smf_version' => $forum_version,
'smfd_version' => $modSettings['smfVersion'],
);

$request db_query("
SELECT VERSION()"
__FILE____LINE__);
list ($stats_to_send['mysql_version']) = mysql_fetch_row($request);
mysql_free_result($request);

// Encode all the data, for security.
foreach ($stats_to_send as $k => $v)
$stats_to_send[$k] = urlencode($k) . '=' urlencode($v);

// Turn this into the query string!
$stats_to_send implode('&'$stats_to_send);

// If we're an admin, just plonk them out.
if ($user_info['is_admin'])
echo $stats_to_send;
else
{
// Connect to the collection script.
$fp = @fsockopen("www.simplemachines.org"80$errno$errstr);
if ($fp)
{
$length strlen($stats_to_send);

$out "POST /smf/stats/collect_stats.php HTTP/1.1\r\n";
$out .= "Host: www.simplemachines.org\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: $length\r\n\r\n";
$out .= "$stats_to_send\r\n"
$out .= "Connection: Close\r\n\r\n";
fwrite($fp$out);
fclose($fp);
}
}

// Die.
die('OK');
}

?>

jossanaijr

Quote from: burtybob on June 06, 2008, 09:29:36 AM
Below is a table of the cross referenced MODs that come up more than once! Please can you look and see what ones you may have installed?
If you do have any of the below installed please can you post them thanks.


















MOD NameNumber Of people
Auto Embed Video Clips3 out of 4
Users Online Today3 out of 4
Monthly Statistics On Profile2 out of 4
Spam Me Not2 out of 4
Neat Board Layout2 out of 4
Topic Starter2 out of 4
Wrap Text Around Images2 out of 4
Remove Quoted Images2 out of 4
Tiny Portal2 out of 4
Advanced Recent Posts2 out of 4
Enhanced Quick Reply2 out of 4
Attatchments Posititon2 out of 4
Link Tree2 out of 4
User E-Mail System2 out of 4
Avatar On Board2 out of 4
Custom Profile Field2 out of 4

I know that there is only one in there that is directly related to Stats BUT these are the MODs that appear more than once when i cross referenced the four peoples MODs, there were about 50 different MODs installed between the 4 of them and these are the ones that cropped up.
I know it is unlikely but it MAY just MAY be one or more of them that is causing some "crossing of the wires" somewhere.
Auto Embed Video Clips
Users Online Today
Topic Starter
Enhanced Quick Reply
Custom Profile Field


burtybob

#16
Quote from: jossanaijr on June 07, 2008, 01:46:22 PM
Quote from: burtybob on June 06, 2008, 09:29:36 AM
Below is a table of the cross referenced MODs that come up more than once! Please can you look and see what ones you may have installed?
If you do have any of the below installed please can you post them thanks.


















MOD NameNumber Of people
Auto Embed Video Clips3 out of 4
Users Online Today3 out of 4
Monthly Statistics On Profile2 out of 4
Spam Me Not2 out of 4
Neat Board Layout2 out of 4
Topic Starter2 out of 4
Wrap Text Around Images2 out of 4
Remove Quoted Images2 out of 4
Tiny Portal2 out of 4
Advanced Recent Posts2 out of 4
Enhanced Quick Reply2 out of 4
Attatchments Posititon2 out of 4
Link Tree2 out of 4
User E-Mail System2 out of 4
Avatar On Board2 out of 4
Custom Profile Field2 out of 4

I know that there is only one in there that is directly related to Stats BUT these are the MODs that appear more than once when i cross referenced the four peoples MODs, there were about 50 different MODs installed between the 4 of them and these are the ones that cropped up.
I know it is unlikely but it MAY just MAY be one or more of them that is causing some "crossing of the wires" somewhere.
Auto Embed Video Clips
Users Online Today
Topic Starter
Enhanced Quick Reply
Custom Profile Field
Hey thanks for the list, i think its something connected to stats but it could easily be anything as it all runs from the database, have you tried uninstalling those mods and seeing if that works??
If you havent uninstall them, but dont delete them and if it works after that re-apply them one by one to see which it is.
Sorry i cant be more helpful, dragonsbretheren what mod is that installed with for the color changes as im guessing looking at the code you have a mod installed which allows you to change the colours of something, also is it ALLWAYS 33 as that line has an "id" bit which if its not allways 33 that may be the problem!
Thanks to everyone for their help and patience on this one.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

Dragonsbrethren

I have Member Color Link installed. I could try uninstalling that and reinstalling this mod to see if the problem clears up.

burtybob

Quote from: Dragonsbrethren on June 07, 2008, 03:08:22 PM
I have Member Color Link installed. I could try uninstalling that and reinstalling this mod to see if the problem clears up.

I would only recomend doing this if one or the other is not working! if they are both working fine leave them untill there is a problem as i can not see any reason for the error.
If your support topic does not have a link i will NOT assist you.
A link is easy to add AND is a massive help very often.
And a login account would be usefull even if its only pass and user =demo and its a normal account its not hard to add those two pieces of information.

I will do edits for you but not for free :) time costs money.

THE BRA1N

#19
Quote from: jossanaijr on June 05, 2008, 03:35:46 PM
Any news about the weekly issue?  I reinstalled this mod and weekly stats is not working.

Same issue. I was hoping this version would fix it.

1.     Auto Embed Video/Audio Clips     3.0     
2.    Top 10 Posters Today And This Week Stats    1.1    
3.    Image Quote Removal Package    1.0    
4.    Member Color Link    2.1.6    
5.    Simple Award System    2.0.0b    
6.    Users Online Today    1.5.2    
7.    Grouped Who's Online    1.0
8.    Advanced Reputation System    1.4.1    
9.    DeInCreasePostBox    1.2    
10.    More Spiders    1.1

Powered by SMF 2.0 Beta 3.1 Public

Advertisement: