1500'; $vals_rarity = array(); $vals_rarity[0] = ''; $vals_rarity[1] = ''; $vals_rarity[2] = ''; $vals_rarity[3] = ''; //**************************************** //** ELEMENT, RARITY STATS ** //**************************************** $stats = array(); $total = 0; for($i = 0; $i < 7; $i++) { $start = $bereich[$i]['start']; $end = $bereich[$i]['end']; $sql = "SELECT COUNT(*) as count, y.rarity FROM youtd_items y WHERE goldcost >= ".$start." AND goldcost <= ".$end." AND status $statusStr GROUP BY rarity"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $val = intval($row['count']); $rarity = intval($row['rarity']); $stats[$rarity][$i] = $val; $stats[$rarity]['max'] = max($val,$stats[$rarity]['max']); } $sql = "SELECT COUNT(*) as count FROM youtd_items y WHERE goldcost >= ".$start." AND goldcost <= ".$end." AND status $statusStr"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $val = intval($row['count']); $total += $val; $stats[4][$i] = $val; $stats[4]['max'] = max($val,$stats[4]['max']); } } $sql = "SELECT COUNT(*) as count, y.rarity FROM youtd_items y WHERE status $statusStr GROUP BY rarity"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $stats[intval($row['rarity'])][7] = intval($row['count']); } $template->assign_block_vars('goldrar', array( 'ROWNAME' => '', )); for($key2 = 0; $key2<7;$key2++){ $template->assign_block_vars('goldrar.row', array( 'COUNT' => $bereich[$key2]['string'], 'STYLE' => '' )); } $template->assign_block_vars('goldrar.row', array( 'COUNT' => 'TOTAL' )); for($key = 0; $key<4;$key++){ $value = $stats[$key]; $template->assign_block_vars('goldrar', array( 'ROWNAME' => $vals_rarity_names[$key], )); for($key2 = 0; $key2<8;$key2++){ $value2 = isset($value[$key2])?$value[$key2]:0; if (($key == 0 AND $key2 == 6) || ($key == 1 AND $key2 == 6)) { $template->assign_block_vars('goldrar.row', array( 'COUNT' => "--", 'STYLE' => "max-width: 90px; background-color: #80FFFF;", 'LINK' => ($key2==7?"?mode=item&rar=$key":"?mode=item&ming=".$bereich[$key2]['start']."&maxg=".$bereich[$key2]['end']."&rar=$key") )); } else { $template->assign_block_vars('goldrar.row', array( 'COUNT' => $value2, 'STYLE' => getBarStyle($value2,$value['max']), 'LINK' => ($key2==7?"?mode=item&rar=$key":"?mode=item&ming=".$bereich[$key2]['start']."&maxg=".$bereich[$key2]['end']."&rar=$key") )); } } } $template->assign_block_vars('goldrar', array( 'ROWNAME' => 'TOTAL', )); $stats[4][7] = $total; for($key2 = 0; $key2<8;$key2++){ if (!isset($stats[4][$key2])) $value2 = 0; else $value2 = $stats[4][$key2]; $template->assign_block_vars('goldrar.row', array( 'COUNT' => $value2, 'STYLE' => getBarStyle($value2,$stats[4]['max']), 'LINK' => ($key2==7?'?mode=item':"?mode=item&ming=".$bereich[$key2]['start']."&maxg=".$bereich[$key2]['end']) )); } //**************************************** //** CREATOR STATS ** //**************************************** $sql = "SELECT ytd_score as count, user_id AS id, username FROM board_users u ORDER BY ytd_score DESC LIMIT 10"; $result = $db->sql_query($sql); $stats = array(); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('creator', array( 'ID' => $row['id'], 'NAME' => $row['username'], 'COUNT' => $row['count'] ));; } //**************************************** //** LATEST ITEM STATS ** //**************************************** $sql = "SELECT name, id, goldcost, rarity, icon FROM youtd_items ORDER BY submit_date DESC LIMIT 15"; $result = $db->sql_query($sql); $stats = array(); $i = 0; while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('lasttwrs', array( 'ID' => $row['id'], 'ICON_ID' => $row['icon'], 'GOLD' =>$row['goldcost'], 'NAME' => $vals_rarity[$row["rarity"]].$row['name']."", 'NEWROW' => ($i>0&&$i%5==0) ));; $i++; } //**************************************** //** FOOTER ** //**************************************** $template->set_filenames(array( 'body' => 'youtd_item_stats.html', )); page_footer(); function getTwoHex($val){ $hex = dechex($val); if(strlen($hex) == 1) return '0' . $hex; return $hex; } function getBarStyle($val,$total){ if($total <= 0) $total = 1; $val = max(round(100*$val / $total),11); if($val > 100){ $val = 100; $color = "80FFFF"; } else { $green = min($val * 255 / 50,255); $red = min((100-$val) * 255 / 50,255); $color = getTwoHex($red) . getTwoHex($green) . "00"; } $length = round($val * 0.9); return "max-width: {$length}px; background-color: #$color;"; } ?>