MyBB.de Forum
Forum aus den statistiken ausschließen - Druckversion

+- MyBB.de Forum (https://www.mybb.de/forum)
+-- Forum: Anpassungen (https://www.mybb.de/forum/forum-47.html)
+--- Forum: Plugin-Diskussionen (https://www.mybb.de/forum/forum-38.html)
+--- Thema: Forum aus den statistiken ausschließen (/thread-16732.html)



Forum aus den statistiken ausschließen - MH_Razen - 13.08.2010

Ich würde gerne das forum mit der id 26 aus den statistiken ausnehmen - das hab ich bei 1.4 schonmal gemacht, funzt hier aber nur zur hälfte:

PHP-Code:
<?php
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: stats.php 5016 2010-06-12 00:24:02Z RyanGordon $
 */

define("IN_MYBB"1);
define('THIS_SCRIPT''stats.php');

$templatelist "stats,stats_thread";
require_once 
"./global.php";
require_once 
MYBB_ROOT."inc/functions_post.php";
require_once 
MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

// Load global language phrases
$lang->load("stats");

add_breadcrumb($lang->nav_stats);

$stats $cache->read("stats");

if(
$stats['numthreads'] < || $stats['numusers'] < 1)
{
    
error($lang->not_enough_info_stats);
}

$plugins->run_hooks("stats_start");

$repliesperthread my_number_format(round((($stats['numposts'] - $stats['numthreads']) / $stats['numthreads']), 2));
$postspermember my_number_format(round(($stats['numposts'] / $stats['numusers']), 2));

// Get number of days since board start (might need improvement)
$query $db->simple_select("users""regdate""", array('order_by' => 'regdate''limit' => 1));
$result $db->fetch_array($query);
$days = (TIME_NOW $result['regdate']) / 86400;
if(
$days 1)
{
    
$days 1;
}
// Get "per day" things
$postsperday my_number_format(round(($stats['numposts'] / $days), 2));
$threadsperday my_number_format(round(($stats['numthreads'] / $days), 2));
$membersperday my_number_format(round(($stats['numusers'] / $days), 2));

// Get forum permissions
$unviewableforums get_unviewable_forums(true);

// edit by MH

if(empty($unviewableforums)) {
    
$unviewableforums "26";
} else {
    
$unviewableforums .= ",26";


//end of edit

$fidnot '1=1';
$unviewableforumsarray = array();
if(
$unviewableforums)
{
    
$fidnot "fid NOT IN ($unviewableforums)";
    
$unviewableforumsarray explode(','$unviewableforums);
}

// Most replied-to threads



$most_replied $cache->read("most_replied_threads");

if(!
$most_replied)
{
    
$cache->update_most_replied_threads();
    
$most_replied $cache->read("most_replied_threads"true);
}

if(!empty(
$most_replied))
{
    foreach(
$most_replied as $key => $thread)
    {
        if(!
in_array("'{$thread['fid']}'"$unviewableforumsarray))
        {
            
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
            
$numberbit my_number_format($thread['replies']);
            
$numbertype $lang->replies;
            
$thread['threadlink'] = get_thread_link($thread['tid']);
            eval(
"\$mostreplies .= \"".$templates->get("stats_thread")."\";");
        }
    }
}

// Most viewed threads
$most_viewed $cache->read("most_viewed_threads");

if(!
$most_viewed)
{
    
$cache->update_most_viewed_threads();
    
$most_viewed $cache->read("most_viewed_threads"true);
}

if(!empty(
$most_viewed))
{
    foreach(
$most_viewed as $key => $thread)
    {
        if(!
in_array("'{$thread['fid']}'"$unviewableforumsarray))
        {
            
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
            
$numberbit my_number_format($thread['views']);
            
$numbertype $lang->views;
            
$thread['threadlink'] = get_thread_link($thread['tid']);
            eval(
"\$mostviews .= \"".$templates->get("stats_thread")."\";");
        }
    }
}

// Top forum
if(!empty($fidnot))
{
    
$fidnot .= " AND";
}
$query $db->simple_select("forums""fid, name, threads, posts""$fidnot type='f'", array('order_by' => 'posts''order_dir' => 'DESC''limit' => 1));
$forum $db->fetch_array($query);
if(!
$forum['posts'])
{
    
$topforum $lang->none;
    
$topforumposts $lang->no;
    
$topforumthreads $lang->no;
}
else
{
    
$topforum "<a href=\"".get_forum_link($forum['fid'])."\">{$forum['name']}</a>";
    
$topforumposts $forum['posts'];
    
$topforumthreads $forum['threads'];
}

// Today's top poster
$timesearch TIME_NOW 86400;
switch(
$db->type)
{
    case 
"pgsql":
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY "
.$db->build_fields_string("users""u.")." ORDER BY poststoday DESC
            LIMIT 1
        "
);
        break;
    default:
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        "
);
}
$user $db->fetch_array($query);
if(!
$user['poststoday'])
{
    
$topposter $lang->nobody;
    
$topposterposts $lang->no_posts;
}
else
{
    if(!
$user['uid'])
    {
        
$topposter $lang->guest;
    }
    else
    {
        
$topposter build_profile_link($user['username'], $user['uid']);
    }
    
$topposterposts $user['poststoday'];
}

// What percent of members have posted?
$query $db->simple_select("users""COUNT(*) AS count""postnum > 0");
$posters $db->fetch_field($query"count");
$havepostedpercent my_number_format(round((($posters $stats['numusers']) * 100), 2)) . "%";

$lang->todays_top_poster $lang->sprintf($lang->todays_top_poster$toppostermy_number_format($topposterposts));
$lang->popular_forum $lang->sprintf($lang->popular_forum$topforummy_number_format($topforumposts), my_number_format($topforumthreads));

$stats['numposts'] = my_number_format($stats['numposts']);
$stats['numthreads'] = my_number_format($stats['numthreads']);
$stats['numusers'] = my_number_format($stats['numusers']);
$stats['newest_user'] = build_profile_link($stats['lastusername'], $stats['lastuid']);

$plugins->run_hooks("stats_end");

eval(
"\$stats = \"".$templates->get("stats")."\";");
output_page($stats);
?>

Für den Most-Popular Teil führt das was ich bisher drin hab :;

PHP-Code:
// Most replied-to threads

// edit by MH

$unviewableforumsarray[] = "'26'";

// end of edit

$most_replied $cache->read("most_replied_threads"); 

Dazu dass weniger Threads (in meinem fall gar keine da alle populärsten thread im forum 26 sind) angezeigt werden, wie muss ich das anpassen?


RE: Forum aus den statistiken ausschließen - StefanT - 13.08.2010

Was funktioniert denn mit der alten Änderung nicht?


RE: Forum aus den statistiken ausschließen - MH_Razen - 13.08.2010

wie schon gesaagt - anstelle threads au anderen foren erscheinen weniger threads (also 10 abzüglich der threads aus dem gesperrten forum)


RE: Forum aus den statistiken ausschließen - Michael - 14.08.2010

Das ist logisch. Die Statistiken werden aus einem Cache gelesen, welcher nur eine bestimmte Anzahl an Datensätzen enthält. Aus diesen filterst du dann noch welche raus. Die bessere Methoder wäre der Ausschluss des Forums bei der Generierung der Caches (in/class_datacache.php; Funktionen: update_most_replied_threads() & update_most_viewed_threads()).


RE: Forum aus den statistiken ausschließen - MH_Razen - 14.08.2010

naja, php kann ich leider nicht - ich hab nur den code gepostet den ich bisher verwendet hab...


RE: Forum aus den statistiken ausschließen - Michael - 14.08.2010

Suche in beiden Funktionen nach
Code:
"visible='1'"
Ersetzen durch:
Code:
"visible='1' AND fid !='26'"



RE: Forum aus den statistiken ausschließen - MH_Razen - 15.08.2010

Folgende Änderung:
PHP-Code:
        else
        {
            
// Normal users
            
$p_unapproved_where visible='1' AND fid !='26';
            
$t_unapproved_where 'visible < 1';
        } 


Da kam folgende Fehlermeldung:

Parse error: syntax error, unexpected '=' in /var/www/web742/html/lfe/forum/search.php on line 660



RE: Forum aus den statistiken ausschließen - StefanT - 15.08.2010

PHP-Code:
        else
        {
            
// Normal users
            
$p_unapproved_where "visible='1' AND fid !='26'";
            
$t_unapproved_where 'visible < 1';
        }