[verplaatst] Statistieken over bepaalde fora genereren
Forumregels
Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.

[verplaatst] Statistieken over bepaalde fora genereren
Is het mogelijk om het voor elkaar te krijgen dat de Top 10 Actieve Topics (in je Statistiekenpagina) alleen van bepaalde fora topics showed?
In de huidige situatie kijkt de Statistiekenpagina namelijk naar alle fora op mijn board en dan kiest hij de topics waar natuurlijk de meeste posts in staan. Maar dat zijn over het algemeen topics uit non-serieuze fora.
Het gaat er mij dus om of ik kan instellen dat die Actieve Topiclijst alleen topics uit serieuze fora laat zien.
Wie kan mij helpen?
Verplaatst door mosymuis
In de huidige situatie kijkt de Statistiekenpagina namelijk naar alle fora op mijn board en dan kiest hij de topics waar natuurlijk de meeste posts in staan. Maar dat zijn over het algemeen topics uit non-serieuze fora.
Het gaat er mij dus om of ik kan instellen dat die Actieve Topiclijst alleen topics uit serieuze fora laat zien.
Wie kan mij helpen?
Verplaatst door mosymuis
Code: Selecteer alles
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$attachment_mod_installed = ( defined('ATTACH_VERSION') ) ? TRUE : FALSE;
$attachment_version = ($attachment_mod_installed) ? ATTACH_VERSION : '';
if ( $attachment_mod_installed )
{
include($phpbb_root_path . 'attach_mod/includes/functions_admin.'.$phpEx);
}
//
// Start user modifiable variables
//
//
// Set smile_pref to 0, if you want that smilies are only counted once per post.
// This means that, if the same smilie is entered ten times in a message, only one is counted in that message.
//
$smile_pref = 0;
//
// Define the Number of topics/smilies/users in statistics output
//
$return_limit = 10;
$vote_left = 'images/vote_lcap.gif';
$vote_right = 'images/vote_rcap.gif';
$vote_bar = 'images/voting_bar.gif';
//
// What to display ?
//
// Statistics
$display_adminstats = TRUE;
// Do you want to allow only the admins to view the statistics ? (display_adminstats have to be TRUE)
$display_stats_only_to_admin = FALSE;
// Display Top Posters
$display_topposters = TRUE;
// Display Most viewed topics and Most active topics
$display_mostviewed_active = TRUE;
// This is displayed only if the Attachment Mod is installed
$display_topdownloads = TRUE;
// Display Top Smilies
$display_topsmilies = TRUE;
//
// End user modifiable variables
//
$percentage = 0;
$bar_percent = 0;
//
// Functions
//
//
// Do the math ;)
//
function do_math($firstval, $value, $total)
{
global $percentage, $bar_percent;
$cst = ($firstval > 0) ? 90 / $firstval : 90;
if ( $value != 0 )
{
$percentage = ( $total ) ? round( min(100, ($value / $total) * 100)) : 0;
}
else
{
$percentage = 0;
}
$bar_percent = round($value * $cst);
}
//
// sort multi-dimensional array - from File Attachment Mod
//
function sort_multi_array_attachment ($sort_array, $key, $sort_order)
{
$last_element = count($sort_array) - 1;
$string_sort = ( is_string($sort_array[$last_element-1][$key]) ) ? TRUE : FALSE;
for ($i = 0; $i < $last_element; $i++)
{
$num_iterations = $last_element - $i;
for ($j = 0; $j < $num_iterations; $j++)
{
$next = 0;
//
// do checks based on key
//
$switch = FALSE;
if ( !($string_sort) )
{
if ( ( ($sort_order == 'DESC') && (intval($sort_array[$j][$key]) < intval($sort_array[$j + 1][$key])) ) || ( ($sort_order == 'ASC') && (intval($sort_array[$j][$key]) > intval($sort_array[$j + 1][$key])) ) )
{
$switch = TRUE;
}
}
else
{
if ( ( ($sort_order == 'DESC') && (strcasecmp($sort_array[$j][$key], $sort_array[$j + 1][$key]) < 0) ) || ( ($sort_order == 'ASC') && (strcasecmp($sort_array[$j][$key], $sort_array[$j + 1][$key]) > 0) ) )
{
$switch = TRUE;
}
}
if ($switch)
{
$temp = $sort_array[$j];
$sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp;
}
}
}
return ($sort_array);
}
//
// Forum Stats
//
function evaluate_admin_statistics()
{
global $db, $template, $lang, $board_config, $phpbb_root_path, $phpEx, $theme, $dbname, $attachment_mod_installed;
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$total_topics = get_db_stat('topiccount');
$start_date = create_date($board_config['default_dateformat'], $board_config['board_startdate'], $board_config['board_timezone']);
$boarddays = max(1, round( ( time() - $board_config['board_startdate'] ) / 86400 ));
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
$users_per_day = sprintf('%.2f', $total_users / $boarddays);
$avatar_dir_size = 0;
if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']))
{
while( $file = @readdir($avatar_dir) )
{
if( $file != '.' && $file != '..' )
{
$avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . '/' . $file);
}
}
@closedir($avatar_dir);
//
// This bit of code translates the avatar directory size into human readable format
// Borrowed the code from the PHP.net annoted manual, origanally written by:
// Jesse (jesse@jess.on.ca)
//
if (!$attachment_mod_installed)
{
if($avatar_dir_size >= 1048576)
{
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' MB';
}
else if($avatar_dir_size >= 1024)
{
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' KB';
}
else
{
$avatar_dir_size = $avatar_dir_size . ' Bytes';
}
}
else
{
if($avatar_dir_size >= 1048576)
{
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' ' . $lang['MB'];
}
else if($avatar_dir_size >= 1024)
{
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' ' . $lang['KB'];
}
else
{
$avatar_dir_size = $avatar_dir_size . ' ' . $lang['Bytes'];
}
}
}
else
{
$avatar_dir_size = $lang['Not_available'];
}
if ($posts_per_day > $total_posts)
{
$posts_per_day = $total_posts;
}
if ($topics_per_day > $total_topics)
{
$topics_per_day = $total_topics;
}
if ($users_per_day > $total_users)
{
$users_per_day = $total_users;
}
//
// DB size ... MySQL only
//
// This code is heavily influenced by a similar routine
// in phpMyAdmin 2.2.0
//
if( preg_match("/^mysql/", SQL_LAYER) )
{
$sql = "SELECT VERSION() AS mysql_version";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$version = $row['mysql_version'];
if( preg_match("/^(3\.23|4\.)/", $version) )
{
$db_name = ( preg_match("/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)/", $version) ) ? "`$dbname`" : $dbname;
$sql = "SHOW TABLE STATUS
FROM " . $db_name;
if($result = $db->sql_query($sql))
{
$tabledata_ary = $db->sql_fetchrowset($result);
$dbsize = 0;
for($i = 0; $i < count($tabledata_ary); $i++)
{
if( $tabledata_ary[$i]['Type'] != "MRG_MyISAM" )
{
if( $table_prefix != "" )
{
if( strstr($tabledata_ary[$i]['Name'], $table_prefix) )
{
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
}
else
{
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
}
}
if ($attachment_mod_installed)
{
if( $dbsize >= 1048576 )
{
$dbsize = sprintf('%.2f ' . $lang['MB'], ( $dbsize / 1048576 ));
}
else if( $dbsize >= 1024 )
{
$dbsize = sprintf('%.2f ' . $lang['KB'], ( $dbsize / 1024 ));
}
else
{
$dbsize = sprintf('%.2f ' . $lang['Bytes'], $dbsize);
}
}
else
{
if( $dbsize >= 1048576 )
{
$dbsize = sprintf('%.2f MB', ( $dbsize / 1048576 ));
}
else if( $dbsize >= 1024 )
{
$dbsize = sprintf('%.2f KB', ( $dbsize / 1024 ));
}
else
{
$dbsize = sprintf('%.2f Bytes', $dbsize);
}
}
} // Else we couldn't get the table status.
}
else
{
$dbsize = $lang['Not_available'];
}
}
else
{
$dbsize = $lang['Not_available'];
}
}
else
{
$dbsize = $lang['Not_available'];
}
//
// Newest user data
//
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];
$sql = 'SELECT user_regdate
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $newest_uid . '
LIMIT 1';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve users data', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$newest_user_date = $row['user_regdate'];
//
// Most Online data
//
$sql = "SELECT *
FROM " . CONFIG_TABLE . "
WHERE config_name = 'record_online_users' OR config_name = 'record_online_date'";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve configuration data', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$most_users_date = ($row['config_value'] > 0) ? create_date($board_config['default_dateformat'], $row['config_value'], $board_config['board_timezone']) : $most_users_date = $lang['Not_available'];
$row = $db->sql_fetchrow($result);
$most_users = ($row['config_value'] > 0) ? $row['config_value'] : $lang['Not_available'];
$statistic_array = array($lang['Number_posts'], $lang['Posts_per_day'], $lang['Number_topics'], $lang['Topics_per_day'], $lang['Number_users'], $lang['Users_per_day'], $lang['Board_started'], $lang['Board_Up_Days'], $lang['Database_size'], $lang['Avatar_dir_size'], $lang['Latest_Reg_User_Date'], $lang['Latest_Reg_User'], $lang['Most_Ever_Online_Date'], $lang['Most_Ever_Online'], $lang['Gzip_compression']);
$value_array = array($total_posts, $posts_per_day, $total_topics, $topics_per_day, $total_users, $users_per_day, $start_date, sprintf('%.2f', $boarddays), $dbsize, $avatar_dir_size, create_date($board_config['default_dateformat'], $newest_user_date, $board_config['board_timezone']), sprintf('<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $newest_uid) . '">' . $newest_user . '</a>'), $most_users_date, $most_users, ( $board_config['gzip_compress'] ) ? $lang['Enabled'] : $lang['Disabled']);
//
// Disk Usage, if Attachment Mod is installed
//
if ( $attachment_mod_installed )
{
$disk_usage = get_formatted_dirsize();
$statistic_array[] = $lang['Disk_usage'];
$value_array[] = $disk_usage;
}
for ($i = 0; $i < count($statistic_array); $i += 2)
{
$template->assign_block_vars('adminrow', array(
'STATISTIC' => $statistic_array[$i],
'VALUE' => $value_array[$i],
'STATISTIC2' => (isset($statistic_array[$i+1])) ? $statistic_array[$i + 1] : '',
'VALUE2' => (isset($value_array[$i+1])) ? $value_array[$i + 1] : '')
);
}
}
//
// Top posters
//
function evaluate_top_posters()
{
global $db, $lang, $template, $bar_percent, $percentage, $phpbb_root_path, $return_limit, $theme;
$sql = 'SELECT user_id, username, user_posts
FROM ' . USERS_TABLE . '
WHERE (user_id <> ' . ANONYMOUS . ' ) AND (user_posts > 0)
ORDER BY user_posts DESC
LIMIT ' . $return_limit;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve users data', '', __LINE__, __FILE__, $sql);
}
$user_count = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);
$firstcount = $user_data[0]['user_posts'];
for ($i = 0; $i < $user_count; $i++)
{
$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
do_math($firstcount, $user_data[$i]['user_posts'], get_db_stat('postcount'));
$template->assign_block_vars('users', array(
'RANK' => $i+1,
'CLASS' => $class,
'USERNAME' => $user_data[$i]['username'],
'PERCENTAGE' => $percentage,
'BAR' => $bar_percent,
'URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data[$i]['user_id']),
'POSTS' => $user_data[$i]['user_posts'])
);
}
}
//
// Most active topics and Most viewed topics
//
function evaluate_most_viewed_active()
{
global $db, $lang, $template, $phpbb_root_path, $return_limit, $auth_data_sql, $theme;
$sql = 'SELECT topic_id, topic_title, topic_replies
FROM ' . TOPICS_TABLE . '
WHERE forum_id IN (' . $auth_data_sql . ') AND (topic_status <> 2) AND (topic_replies > 0)
ORDER BY topic_replies DESC
LIMIT ' . $return_limit;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve topic data', '', __LINE__, __FILE__, $sql);
}
$topic_count = $db->sql_numrows($result);
$topic_data = $db->sql_fetchrowset($result);
for ($i = 0; $i < $topic_count; $i++)
{
$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
$template->assign_block_vars('topicreplies', array(
'RANK' => $i+1,
'CLASS' => $class,
'TITLE' => $topic_data[$i]['topic_title'],
'REPLIES' => $topic_data[$i]['topic_replies'],
'URL' => append_sid($phpbb_root_path . 'viewtopic.php?t=' . $topic_data[$i]['topic_id']))
);
}
//
// Most viewed topics
//
$sql = 'SELECT topic_id, topic_title, topic_views
FROM ' . TOPICS_TABLE . '
WHERE forum_id IN (' . $auth_data_sql . ') AND (topic_status <> 2) AND (topic_views > 0)
ORDER BY topic_views DESC
LIMIT ' . $return_limit;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve topic data', '', __LINE__, __FILE__, $sql);
}
$topic_count = $db->sql_numrows($result);
$topic_data = $db->sql_fetchrowset($result);
for ($i = 0; $i < $topic_count; $i++)
{
$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
$template->assign_block_vars('topicviews', array(
'RANK' => $i+1,
'CLASS' => $class,
'TITLE' => $topic_data[$i]['topic_title'],
'VIEWS' => $topic_data[$i]['topic_views'],
'URL' => append_sid($phpbb_root_path . 'viewtopic.php?t=' . $topic_data[$i]['topic_id']))
);
}
}
if ( $attachment_mod_installed )
{
function evaluate_top_downloads()
{
global $language, $db, $template, $lang, $userdata, $board_config, $attach_config, $phpEx, $return_limit, $theme, $attachment_version, $phpbb_root_path;
if( !file_exists($phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.'.$phpEx) )
{
$language = 'dutch';
}
include($phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.' . $phpEx);
//
// Assign Table Names
//
if (strstr($attachment_version, '2.3.'))
{
$attach_table = ATTACHMENTS_TABLE;
$attach_desc_table = ATTACHMENTS_DESC_TABLE;
}
else
{
$attach_table = ATTACH_TABLE;
$attach_desc_table = ATTACH_DESC_TABLE;
}
//
// Most downloaded Attachments
//
$top_attachments = array();
$attachment = array();
$template->assign_vars(array(
'L_ATTACHMENTS' => $lang['Top_downloads'],
'L_FILENAME' => $lang['File_name'],
'L_FILECOMMENT' => $lang['File_comment'],
'L_SIZE' => $lang['Size_in_kb'],
'L_DOWNLOADS' => $lang['Downloads'],
'L_POST_TIME' => $lang['Post_time'],
'L_POSTED_IN_TOPIC' => $lang['Posted_in_topic'])
);
$sql = 'SELECT attach_id
FROM ' . $attach_desc_table . '
ORDER BY download_count DESC';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t query attachments', '', __LINE__, __FILE__, $sql);
}
$num_rows = $db->sql_numrows($result);
$db->sql_freeresult($result);
for ($i = 0; $i < $num_rows && count($top_attachments) <= $return_limit; $i++)
{
//
// Fetch one Attachment
//
$sql = 'SELECT *
FROM ' . $attach_desc_table . '
ORDER BY download_count DESC, filesize DESC
LIMIT ' . intval($i) . ', 1';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t query attachment', '', __LINE__, __FILE__, $sql);
}
$attachment = $db->sql_fetchrow($result);
//
// get forum_id for attachment authorization or private message authorization
//
$authorised = FALSE;
$sql = 'SELECT *
FROM ' . $attach_table . '
WHERE attach_id = ' . $attachment['attach_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query attachment informations', '', __LINE__, __FILE__, $sql);
}
$auth_pages = $db->sql_fetchrowset($result);
$num_auth_pages = $db->sql_numrows($result);
for ($j = 0; $j < $num_auth_pages && $authorised == FALSE; $j++)
{
if ($auth_pages[$j]['post_id'] != 0)
{
$sql = 'SELECT forum_id
FROM ' . POSTS_TABLE . '
WHERE post_id = ' . $auth_pages[$j]['post_id'];
}
else
{
break;
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query post information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
if ($auth_pages[$j]['post_id'] != 0)
{
$forum_id = $row['forum_id'];
$is_auth = array();
$is_auth = auth(AUTH_DOWNLOAD, $forum_id, $userdata);
if ( $is_auth['auth_download'] )
{
$authorised = TRUE;
}
}
else
{
if ( ($attach_config['allow_pm_attach']) && ( ($userdata['user_id'] == $row['privmsgs_to_userid']) || ($userdata['user_id'] == $row['privmsgs_from_userid']) ) || ($userdata['user_level'] == ADMIN) )
{
$authorised = TRUE;
}
}
}
if ($authorised)
{
$top_attachments[] = $attachment;
}
}
// $top_attachments = sort_multi_array($top_attachments, 'download_count', 'ASC');
$top_attachments = limit_array($top_attachments, 0, $return_limit);
for ($i = 0; $i < count($top_attachments); $i++)
{
$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
//
// Is the Attachment assigned to more than one post ?
// If it's not assigned to any post, it's an private message thingy. ;)
//
$post_titles = array();
$sql = 'SELECT *
FROM ' . $attach_table . '
WHERE attach_id = ' . $top_attachments[$i]['attach_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t query attachments', '', __LINE__, __FILE__, $sql);
}
$ids = $db->sql_fetchrowset($result);
$num_ids = $db->sql_numrows($result);
for ($j = 0; $j < $num_ids; $j++)
{
if ($ids[$j]['post_id'] != 0)
{
$sql = 'SELECT t.topic_title
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE p.post_id = ' . $ids[$j]['post_id'] . ' AND p.topic_id = t.topic_id
GROUP BY t.topic_id, t.topic_title';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t query topic', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$post_title = $row['topic_title'];
if (strlen($post_title) > 32)
{
$post_title = substr($post_title, 0, 30) . '...';
}
$view_topic = append_sid('viewtopic.' . $phpEx . '?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id']);
$post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $post_title . '</a>';
}
else
{
$post_titles[] = $lang['Private_Message'];
}
}
$post_titles = implode('<br />', $post_titles);
$comment = $top_attachments[$i]['comment'];
if (strlen($comment) > 32)
{
$comment = substr($comment, 0, 30) . '...';
}
if (strstr($attachment_version, '2.3.'))
{
$filename = $top_attachments[$i]['real_filename'];
}
else
{
$filename = $top_attachments[$i]['filename'];
}
if (strlen($filename) > 32)
{
$filename = substr($filename, 0, 30) . '...';
}
$template->assign_block_vars('attachrow', array(
'RANK' => $i+1,
'CLASS' => $class,
'FILENAME' => $filename,
'COMMENT' => $comment,
'SIZE' => round($top_attachments[$i]['filesize'] / 1024),
'DOWNLOAD_COUNT' => $top_attachments[$i]['download_count'],
'POST_TIME' => create_date($board_config['default_dateformat'], $top_attachments[$i]['filetime'], $board_config['board_timezone']),
'POST_TITLE' => $post_titles,
'U_VIEW_ATTACHMENT' => append_sid('download.' . $phpEx . '?id=' . $top_attachments[$i]['attach_id']))
);
}
}
}
//
// Most used smilies
//
function evaluate_top_smilies()
{
global $db, $smile_pref, $board_config, $return_limit, $percentage, $bar_percent, $template, $theme;
$sql = 'SELECT smile_url
FROM ' . SMILIES_TABLE . '
GROUP BY smile_url';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve smilies data', '', __LINE__, __FILE__, $sql);
}
$all_smilies = array();
$total_smilies = 0;
if ($db->sql_numrows($result) > 0)
{
$smilies = $db->sql_fetchrowset($result);
for ($i = 0; $i < count($smilies); $i++)
{
$sql = "SELECT *
FROM " . SMILIES_TABLE . "
WHERE smile_url = '" . $smilies[$i]['smile_url'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve smilies data', '', __LINE__, __FILE__, $sql);
}
$smile_codes = $db->sql_fetchrowset($result);
$count = 0;
for ($j = 0; $j < count($smile_codes); $j++)
{
$sql = "SELECT post_id, post_text
FROM " . POSTS_TEXT_TABLE . "
WHERE post_text LIKE '%" . $smile_codes[$j]['code'] . "%'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve smilies data', '', __LINE__, __FILE__, $sql);
}
if ($smile_pref == 0)
{
$count = $count + $db->sql_numrows($result);
}
else
{
while ($post = $db->sql_fetchrow($result))
{
$count = $count + substr_count($post['post_text'], $smile_codes[$j]['code']);
}
}
}
$all_smilies[$i]['count'] = $count;
$all_smilies[$i]['code'] = $smile_codes[0]['code'];
$all_smilies[$i]['smile_url'] = $smile_codes[0]['smile_url'];
$total_smilies = $total_smilies + $count;
}
}
// Sort array
$all_smilies = sort_multi_array_attachment($all_smilies, 'count', 'DESC');
$limit = ( $return_limit > count($all_smilies) ) ? count($all_smilies) : $return_limit;
for ($i = 0; $i < $limit; $i++)
{
$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
do_math($all_smilies[0]['count'], $all_smilies[$i]['count'], $total_smilies);
$template->assign_block_vars('topsmilies', array(
'RANK' => $i+1,
'CLASS' => $class,
'CODE' => $all_smilies[$i]['code'],
'USES' => $all_smilies[$i]['count'],
'PERCENTAGE' => $percentage,
'BAR' => $bar_percent,
'URL' => '<img src="'. $board_config['smilies_path'] . '/' . $all_smilies[$i]['smile_url'] . '" alt="' . $all_smilies[$i]['smile_url'] . '" border="0">')
);
}
}
//
// END Functions
//
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
// include 'language'
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_statistics.' . $phpEx);
$page_title = $lang['Statistics'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'statistics.tpl')
);
$template->assign_vars(array(
'L_ADMIN_STATISTICS' => $lang['Admin_Stats'],
'L_TOP_SMILIES' => $lang['Top_Smilies'],
'L_MOST_ACTIVE' => $lang['Most_Active_Topics'],
'L_MOST_VIEWED' => $lang['Most_Viewed_Topics'],
'L_TOP_POSTERS' => $lang['Top_Posting_Users'],
'L_USES' => $lang['Uses'],
'L_RANK' => $lang['Rank'],
'L_PERCENTAGE' => $lang['Percent'],
'L_GRAPH' => $lang['Graph'],
'L_REPLIES' => $lang['Replies'],
'L_TOPIC' => $lang['Topic'],
'L_VIEWS' => $lang['Views'],
'L_USERNAME' => $lang['Username'],
'L_POSTS' => $lang['Posts'],
'L_STATISTIC' => $lang['Statistic'],
'L_VALUE' => $lang['Value'],
'L_IMAGE' => $lang['smiley_url'],
'L_CODE' => $lang['smiley_code'],
'PAGE_NAME' => $lang['Statistics'])
);
//
// Authorization SQL - forum-based
//
$auth_data_sql = '';
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve forum_id data', '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result))
{
$is_auth = auth('auth_view', $row['forum_id'], $userdata);
if ($is_auth['auth_view'])
{
$auth_data_sql .= ( $auth_data_sql != '') ? ', ' . $row['forum_id'] : $row['forum_id'];
}
}
//
// Getting voting bar info
//
if( !$board_config['override_user_style'] )
{
if( ($userdata['user_id'] != ANONYMOUS) && (isset($userdata['user_style'])) )
{
$style = $userdata['user_style'];
if( !$theme )
{
$style = $board_config['default_style'];
}
}
else
{
$style = $board_config['default_style'];
}
}
else
{
$style = $board_config['default_style'];
}
$sql = 'SELECT *
FROM ' . THEMES_TABLE . '
WHERE themes_id = ' . $style;
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Couldn\'t query database for theme info.');
}
if( !$row = $db->sql_fetchrow($result) )
{
message_die(CRITICAL_ERROR, 'Couldn\'t get theme data for themes_id=' . $style . '.');
}
$current_template_path = 'templates/' . $row['template_name'] . '/';
$template->assign_vars(array(
'LEFT_GRAPH_IMAGE' => $current_template_path . $vote_left,
'RIGHT_GRAPH_IMAGE' => $current_template_path . $vote_right,
'GRAPH_IMAGE' => $current_template_path . $vote_bar)
);
if ($display_adminstats)
{
if ( ( ($display_stats_only_to_admin) && ($userdata['user_level'] == ADMIN) ) || (!$display_stats_only_to_admin) )
{
$template->assign_block_vars('switch_admin_stats', array());
evaluate_admin_statistics();
}
}
if ($display_topposters)
{
$template->assign_block_vars('switch_top_posters', array());
evaluate_top_posters();
}
if ($display_mostviewed_active)
{
$template->assign_block_vars('switch_most_viewed_active', array());
evaluate_most_viewed_active();
}
if ( ($display_topdownloads) && ($attachment_mod_installed) )
{
$template->assign_block_vars('switch_top_downloads', array());
evaluate_top_downloads();
}
if ($display_topsmilies)
{
$template->assign_block_vars('switch_top_smilies', array());
evaluate_top_smilies();
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>

Gokje:
Zoek
Plaats eronder
Zoek
Vervang met
Zoek
Vervang met
Zoek
Code: Selecteer alles
// Getting voting bar info
//
* (geef de forum_id's op)$allowed_forums = '1,2,4,7';
Zoek
Code: Selecteer alles
WHERE forum_id IN (' . $auth_data_sql . ') AND (topic_status <> 2) AND (topic_replies > 0)
Code: Selecteer alles
WHERE forum_id IN (' . $auth_data_sql . ') AND forum_id IN (' . $allowed_forums . ') AND (topic_status <> 2) AND (topic_replies > 0)
Code: Selecteer alles
WHERE forum_id IN (' . $auth_data_sql . ') AND (topic_status <> 2) AND (topic_views > 0)
Code: Selecteer alles
WHERE forum_id IN (' . $auth_data_sql . ') AND forum_id IN (' . $allowed_forums . ') AND (topic_status <> 2) AND (topic_views > 0)
Dat klonk heel veelbelovend, en ik heb dat natuurlijk precies uitgevoerd, maar helaas levert dat de volgende error op:
Overigens heb ik niet ál die forum_id nummers ingevoerd. Ik had slechts een selectie van 14 fora... 
Code: Selecteer alles
Couldn't retrieve topic data
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax near ') AND (topic_status <> 2) AND (topic_replies > 0) ORDER BY topic_replies DESC ' at line 3
SELECT topic_id, topic_title, topic_replies FROM forum_topics WHERE forum_id IN (1, 2, 3, 4, 8, 9, 11, 12, 13, 15, 16, 17, 19, 23, 25, 27, 29, 30, 31, 32, 33, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60) AND forum_id IN () AND (topic_status <> 2) AND (topic_replies > 0) ORDER BY topic_replies DESC LIMIT 10
Line : 431

Oja.
Zoek
Vervang met
Zoek
Code: Selecteer alles
global $db, $lang, $template, $phpbb_root_path, $return_limit, $auth_data_sql, $theme;
Code: Selecteer alles
global $db, $lang, $template, $phpbb_root_path, $return_limit, $auth_data_sql, $theme, $allowed_forums;