Board Statistics & Top Smilies

Installatie lukt niet? Plotseling een foutmelding. Of weet je niet hoe iets werkt. Problemen met phpBB2 kun je in dit archief opzoeken.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
maico
Berichten: 562
Lid geworden op: 04 jan 2004, 18:26

Board Statistics & Top Smilies

Bericht door maico » 10 feb 2005, 21:15

Hoi,

Bij het gebruik van:

Mod Title: Board Statistics
Mod Version: 2.1.5
Op een 2.0.11 board heb ik het volgende probleempje me3t het gebruik van:

Module Name: Top Smilies
Module Version: 2.1.3
Module Author: Acyd Burn


Het probleempje is hij laat bij de rank 1 t\m 10 overal een 1 dus alle smilies zijn allemaal 1 keer gebruikt
En hetzelfde is het bij de procent aantal overal 1%
Verder slaan de meters vol uit alsof ik overal 100% heb.

Met andere woorden hij laat ze gewoon in de volgorde zien zoals ze in de smlilies.pak staan!

Code: Selecteer alles

doei.gif=+:Doei=+::doei:
goedzo.gif=+:Goedzo=+::goedzo:
fout.gif=+:Fout=+::fout:
klappen.gif=+:Klappen=+::klappen:
hoi.gif=+:Hoi=+::hoi:
nadenken.gif=+:Nadenken=+::nadenken:
bevestigen.gif=+:Bevestigen=+::bevestigen:
ontkennen.gif=+:Ontkennen=+::ontkennen:
dank u.gif=+:Dank U=+::dank u:
boos.gif=+:Boos=+::boos:
Dit is de enige van de module`s die raar doet de rest is allemaal ok.
Herkent iemand dit probleem of liever nog hoe los ik het op

djrandall
Berichten: 181
Lid geworden op: 30 jan 2004, 09:37
Locatie: Dongen
Contacteer:

Bericht door djrandall » 11 feb 2005, 12:08

Ik heb dat probleem ook!
Heb jij ook de smiley volgorde Mod geinstalleerd?
De smilies zelf laat hij wel zien!
En zo is het!

maico
Berichten: 562
Lid geworden op: 04 jan 2004, 18:26

Bericht door maico » 11 feb 2005, 12:24

Hoi,

Nee ik heb alleen wat module`s erop staan en verder niets dat met de smilies in verband gebracht wordt.

Afbeelding

Heb vandaag al weer eens ziten zoeken mmaar kan er niets over vinden.

djrandall
Berichten: 181
Lid geworden op: 30 jan 2004, 09:37
Locatie: Dongen
Contacteer:

Bericht door djrandall » 11 feb 2005, 12:35

idd, ziet er bij mij ook zo uit!
En zo is het!

maico
Berichten: 562
Lid geworden op: 04 jan 2004, 18:26

Bericht door maico » 11 feb 2005, 22:06

Voor wie nog met het probleem zitten.
Vervang je module.php met de onderstaande en probleem opgelost. :wink:

Code: Selecteer alles

<?php
/***************************************************************************
 *								module.php
 *                            -------------------
 *   begin                : Tuesday, Sep 03, 2002
 *   copyright            : (C) 2002 Meik Sievertsen
 *   email                : acyd.burn@gmx.de
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

//
// Modules should be considered to already have access to the following variables which
// the parser will give out to it:

// $return_limit - Control Panel defined number of items to display
// $module_info['name'] - The module name specified in the info.txt file
// $module_info['email'] - The author email
// $module_info['author'] - The author name
// $module_info['version'] - The version
// $module_info['url'] - The author url
//
// To make the module more compatible, please do not use any functions here
// and put all your code inline to keep from redeclaring functions on accident.
//

//
// All your code
//
// Top Smilies
//

//
// 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 = 1;

$vote_left = 'images/vote_lcap.gif';
$vote_right = 'images/vote_rcap.gif';
$vote_bar = 'images/voting_bar.gif';

//
// End user modifiable variables
//

$percentage = 0;
$bar_percent = 0;

//
// Functions
//

//
// Do the math ;)
//
function smilies_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 smilies_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);
}

//
// END Functions
//

$template->assign_vars(array(
	'L_TOP_SMILIES' => $lang['Top_Smilies'],

	'L_USES' => $lang['Uses'],
	'L_RANK' => $lang['Rank'],
	'L_PERCENTAGE' => $lang['Percent'],
	'L_GRAPH' => $lang['Graph'],
	'L_IMAGE' => $lang['smiley_url'],
	'L_CODE' => $lang['smiley_code'],
	'PAGE_NAME' => $lang['Statistics'])
);


//
// 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)
);

//
// Most used smilies
//
$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++)
		{
			$smile_codes[$j]['code'] = str_replace("'", "\'", $smile_codes[$j]['code']);
			$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 = 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++)
{
	if ($all_smilies[$i]['count'] != 0)
	{
		$class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];

		smilies_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">')
		);
	}
}

?>

djrandall
Berichten: 181
Lid geworden op: 30 jan 2004, 09:37
Locatie: Dongen
Contacteer:

Bericht door djrandall » 11 feb 2005, 22:15

DUDE! :thumb:
En zo is het!

Gebruikersavatar
voetbalstats
Berichten: 37
Lid geworden op: 22 mei 2004, 03:22
Contacteer:

Bericht door voetbalstats » 07 mar 2005, 20:27

Thank You !

The Sting
Berichten: 762
Lid geworden op: 11 okt 2004, 16:12
Locatie: Brabant

Bericht door The Sting » 12 mar 2005, 16:30

maico schreef:Voor wie nog met het probleem zitten.
Vervang je module.php met de onderstaande en probleem opgelost. :wink:
:bier: :bier: Bedankt :thumb:
Met groet, The Sting

Gebruikersavatar
runman
Berichten: 176
Lid geworden op: 21 feb 2005, 21:08
Locatie: 's-Hertogenbosch
Contacteer:

Bericht door runman » 22 mar 2005, 14:57

ook bedankt namens mij :thumb: zat ook met dat probleem

Gesloten