ALTER TABLE bbX_smilies ADD smiliecount INT(16) NOT NULL
?>
function countsmilies($post) {
global $db, $n;
$result = array();
$smilies = $db->query("SELECT smilieid, smiliecode FROM bb".$n."_smilies");
while($row = $db->fetch_array($smilies)) {
$result[$row['smilieid']] = substr_count($post, $row['smiliecode']);
}
return $result;
}
function updatesmiliecount($smiliecount, $oldpost = '') {
global $db, $n;
if($oldpost != '') {
$oldsmilies = countsmilies($oldpost);
reset($oldsmilies);
while (list($key, $val) = each($oldsmilies)) {
if($val != 0)
$db->query("UPDATE bb".$n."_smilies SET smiliecount = smiliecount - ".intval($val)." WHERE smilieid = ".intval($key)." LIMIT 1");
}
}
reset($smiliecount);
while (list($key, $val) = each($smiliecount)) {
if($val != 0)
$db->query("UPDATE bb".$n."_smilies SET smiliecount = smiliecount + ".intval($val)." WHERE smilieid = ".intval($key)." LIMIT 1");
}
}
// TOPPOSTERS
// SMILIES
$i = 0;
$x = 0;
$rank = 0;
$max_value = 0;
$max_value = $db->query_first("SELECT max(smiliecount) as cnt FROM bb".$n."_smilies");
$max_value = $max_value['cnt'];
$topsmilies = $db->query("SELECT smiliepath, smilietitle, smiliecount FROM bb".$n."_smilies ORDER BY smiliecount DESC LIMIT $topx_limit;");
while($row = $db->fetch_array($topsmilies)) {
$rank++;
$i++;
$tdclass = getone($i, "tablea", "tableb");
$smiliepath = str_replace("{imagefolder}", $style['imagefolder'], $row['smiliepath']);
$smilietitle = htmlentities($row['smilietitle']);
$smiliecount = number_format($row['smiliecount'], 0, $lang->get("LANG_GLOBAL_DEC_POINT"), $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
// Grafik
if($rank == 1) {
$gfx = 90;
$max_value = $row['smiliecount'];
} else {
if($max_value == 0) $gfx = 90;
else $gfx = ceil($row['smiliecount']*90/$max_value);
}
if ($x == 5) $x = 0;
$x++;
eval("\$top_smilies_bit .= \"".$tpl->get("statistics_top_smilies_bit")."\";");
}
$db->query("UPDATE bb".$n."_statistics SET posts=posts+1 WHERE date>='".mktime(0,0,0, date(m, time()), date(d, time()), date(Y, time()))."';");
updatesmiliecount(countsmilies($message));
$db->query("UPDATE bb".$n."_statistics SET posts=posts+1 WHERE date>='".mktime(0,0,0, date(m, time()), date(d, time()), date(Y, time()))."';");
updatesmiliecount(countsmilies($message));
if ($parseurl == 1 && $allowbbcode == 1) $message = parseURL($message);
// *** STATISTIK ***
$oldmessage = $db->query_first("SELECT message FROM bb".$n."_posts WHERE postid = '$postid'");
$oldmessage = $oldmessage['message'];
updatesmiliecount(countsmilies($message), $oldmessage);
// *** STATISTIK ***
<tr align="left" class="smallfont">
<td class="$tdclass" align="center">$rank</td>
<td class="$tdclass"><img src="$smiliepath" alt="$smilietitle" tile="$smilietitle" /></td>
<td class="$tdclass"><div><span style="float:right">$smiliecount</span></div><img src="{$style['imagefolder']}/vote_middle$x.gif" style="width:$gfx%; height:9px" alt="" /></td>
</tr>
<if($statistics_enable_top_posters == 1 && $wbbuserdata['can_view_statistics_top_posters'] == 1)><then>
<table cellpadding="{$style['tableincellpadding']}" cellspacing="{$style['tableincellspacing']}" border="{$style['tableinborder']}" style="width:100%" class="tableinborder">
<tr class="smallfont">
<td class="tabletitle" align="center" colspan="3"><span class="normalfont"><b>{$lang->items['LANG_STATISTICS_TOP_POSTER']}</b></span></td>
</tr>
<tr class="smallfont">
<td class="tabletitle" align="center" style="width:2%"><b>#</b></td>
<td class="tabletitle" align="center" style="width:23%"><b>{$lang->items['LANG_STATISTICS_TOP_POSTER_USER']}</b></td>
<td class="tabletitle" align="center" style="width:75%"><b>{$lang->items['LANG_STATISTICS_TOP_BOARDS_POSTS_POSTS']}</b></td>
</tr>
$top_posters_bit
</table>
<br />
</then></if>
<table cellpadding="{$style['tableincellpadding']}" cellspacing="{$style['tableincellspacing']}" border="{$style['tableinborder']}" style="width:100%" class="tableinborder">
<tr class="smallfont">
<td class="tabletitle" align="center" colspan="3"><span class="normalfont"><b>Top-Smilies</b></span></td>
</tr>
<tr class="smallfont">
<td class="tabletitle" align="center" style="width:2%"><b>#</b></td>
<td class="tabletitle" align="center" style="width:23%"><b>Smilie</b></td>
<td class="tabletitle" align="center" style="width:75%"><b>Anzahl</b></td>
</tr>
$top_smilies_bit
</table>
<br />