function draw($result, $numitems, $width = 100, $align = 'center') { global $g_options, $game, $realgame, $db; $numpages = ceil($numitems / $this->numperpage); ?> <div class="subblock" style="width:<?php echo $width; ?> %;text-align:<?php echo $align; ?> ;"> <table class="data-table"> <tr class="data-table-head"> <?php $totalwidth = 0; if ($this->showranking) { $totalwidth += 5; echo "<td style=\"width:5%;text-align=:right;\" class=\"fSmall\">Rank</td>\n"; } foreach ($this->columns as $col) { $totalwidth += $col->width; echo "<td style=\"width:{$col->width}%;text-align:{$col->align};\" class=\"fSmall\">"; if ($col->sort != 'no') { echo getSortArrow($this->sort, $this->sortorder, $col->name, $col->title, $this->var_sort, $this->var_sortorder, $this->sorthash, $this->ajax); } else { echo $col->title; } echo "</td>\n"; } ?> </tr> <?php if ($totalwidth != 100) { error("Warning: Column widths do not add to 100%! (={$totalwidth}%)", false); } $rank = ($this->page - 1) * $this->numperpage + 1; while ($rowdata = $db->fetch_array($result)) { echo "<tr>\n"; $i = 0; if ($this->showranking) { $c = $i % 2 + 1; $i++; echo "<td style=\"text-align:right;\" class=\"bg{$c}\">{$rank}</td>\n"; } foreach ($this->columns as $col) { $c = $i % 2 + 1; $class = ""; $cellbody = ''; $colval = $rowdata[$col->name]; if ($col->align != 'left') { $colalign = " style=\"text-align:{$col->align};\""; } else { $colalign = ""; } $class = "bg{$c}"; if ($col->icon || $col->flag) { $cellbody = ' '; } if ($col->link) { if (strpos($col->link, 'javascript:') === false) { $link = str_ireplace('%k', urlencode($rowdata[$this->keycol]), $col->link); $cellbody .= "<a href=\"" . $g_options['scripturl'] . "?{$link}\">"; } else { $col->link = str_replace('\\\\', '', $col->link); $link = str_ireplace('%k', $rowdata[$this->keycol], $col->link); $cellbody .= "<a href=\"{$link}\">"; } } if ($col->icon) { $image = getImage("/{$col->icon}"); if ($image) { $cellbody .= '<img src="' . $image['url'] . "\" class=\"tableicon\" alt=\"{$col->icon}\" />"; } } elseif ($col->flag) { #$link = ereg_replace("%f", $col->link); if ($g_options['countrydata'] == 1) { if ($rowdata['flag'] == '') { $rowdata['flag'] = '0'; $alt_text = 'No Country'; } else { $alt_text = ucfirst(strtolower($rowdata['country'])); } $cellbody .= '<img src="' . getFlag($rowdata['flag']) . "\" class=\"tableicon\" alt=\"{$alt_text}\" title=\"{$alt_text}\" />"; } else { $col->flag = 'player'; $cellbody .= '<img src="' . IMAGE_PATH . "/{$col->flag}.gif\" class=\"tableicon\" alt=\"{$col->icon}.gif\" />"; } } switch ($col->type) { case 'timestamp': $cellbody = timestamp_to_str($colval); break; case 'roleimg': $image = getImage("/games/{$game}/roles/" . strtolower($colval)); // check if image exists for game -- otherwise check realgame if ($image) { $cellbody .= '<img src="' . $image['url'] . '" alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" /> '; } elseif ($image = getImage("/games/{$realgame}/roles/" . strtolower($colval))) { $cellbody .= '<img src="' . $image['url'] . '" alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" /> '; } if ($col->fname[$colval] != '') { $cellbody .= '<b>' . $col->fname[$colval] . '</b>'; } else { $cellbody .= '<b>' . ucwords(preg_replace('/_/', ' ', $colval)) . '</b>'; } break; case 'weaponimg': // Check if game has the image -- if not, failback to real game. If not, no image. $image = getImage("/games/{$realgame}/weapons/" . strtolower($colval)); if ($image) { $cellbody .= '<img src="' . $image['url'] . '" ' . $image['size'] . ' alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />'; } elseif ($image = getImage("/games/{$realgame}/weapons/" . strtolower($colval))) { $cellbody .= '<img src="' . $image['url'] . '" ' . $image['size'] . ' alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />'; } else { $cellbody .= '<b>' . ($col->fname[$colval] != '' ? $col->fname[$colval] : ucwords(preg_replace('/_/', ' ', $colval))) . '</b>'; } break; case 'bargraph': $cellbody .= '<img src="' . IMAGE_PATH . '/bar'; if ($colval > 40) { $cellbody .= '6'; } elseif ($colval > 30) { $cellbody .= '5'; } elseif ($colval > 20) { $cellbody .= '4'; } elseif ($colval > 10) { $cellbody .= '3'; } elseif ($colval > 5) { $cellbody .= '2'; } else { $cellbody .= '1'; } $cellbody .= '.gif" style="width:'; if ($colval < 1) { $cellbody .= '1'; } elseif ($colval > 100) { $cellbody .= '100'; } else { $cellbody .= sprintf("%d", $colval + 0.5); } $cellbody .= "%;\" class=\"bargraph\" alt=\"{$colval}%\" />"; break; case 'heatmap': $heatmap = getImage("/games/{$game}/heatmaps/{$colval}-kill"); $heatmapthumb = getImage("/games/{$game}/heatmaps/{$colval}-kill-thumb"); if ($heatmap) { $cellbody .= "<span style=\"text-align: center;\"><a href=\"" . $heatmap['url'] . "\" rel=\"boxed\"><img width=\"20\" height=\"16\" src=\"" . $heatmapthumb['url'] . "\" /></a></span>"; } else { $cellbody .= " "; } break; default: if ($this->showranking && $rank == 1 && $i == 1) { $cellbody .= '<b>'; } if (is_numeric($colval) && $colval >= 1000) { $colval = number_format($colval); } $colval = nl2br(htmlspecialchars($colval, ENT_COMPAT)); if ($col->embedlink == 'yes') { $colval = preg_replace(array('/%A%([^ %]+)%/', '/%\\/A%/'), array("<a href=\"\$1\">", '</a>'), $colval); } $cellbody .= $colval; if ($this->showranking && $rank == 1 && $i == 1) { $cellbody .= '</b>'; } break; } if ($col->link) { $cellbody .= '</a>'; } if ($col->append) { $cellbody .= $col->append; } if ($col->skill_change) { if ($rowdata['last_skill_change'] == '') { $rowdata['last_skill_change'] = 0; } if ($rowdata['last_skill_change'] == 0) { $cellbody .= " <img src=\"" . IMAGE_PATH . "/t1.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />"; } elseif ($rowdata['last_skill_change'] > 0) { $cellbody .= " <img src=\"" . IMAGE_PATH . "/t0.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />"; } elseif ($rowdata['last_skill_change'] < 0) { $cellbody .= " <img src=\"" . IMAGE_PATH . "/t2.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />"; } } echo "<td{$colalign} class=\"{$class}\">" . $cellbody . "</td>\n"; $i++; } echo "</tr>\n\n"; $rank++; } ?> </table> </div><br /><br /> <?php if ($numpages > 1) { ?> <div class="subblock" style="text-align:right;"> <span style="text-align:right;"> <?php echo 'Page: '; $start = $this->page - intval($this->maxpagenumbers / 2); if ($start < 1) { $start = 1; } $end = $numpages; if ($end > $this->maxpagenumbers + $start - 1) { $end = $this->maxpagenumbers + $start - 1; } if ($end - $start + 1 < $this->maxpagenumbers) { $start = $end - $this->maxpagenumbers + 1; } if ($start < 1) { $start = 1; } if ($start > 1) { if ($start > 2) { $this->_echoPageNumber(1, "First page", "", " ..."); } else { $this->_echoPageNumber(1, 1); } } for ($i = $start; $i <= $end; $i++) { if ($i == $this->page) { echo "<b>{$i}</b> "; } else { $this->_echoPageNumber($i, $i); } if ($i == $end && $i < $numpages) { if ($i < $numpages - 1) { $this->_echoPageNumber($numpages, "Last page", "... "); } else { $this->_echoPageNumber($numpages, 10); } } } ?> </span> </div><br /><br /> <?php } }
</td> </tr> <tr class="bg1"> <td>Total Connection Time:</td> <td colspan="2"><?php echo timestamp_to_str($clandata['connection_time']); ?> </td> </tr> <tr class="bg2"> <td>Avg. Connection Time:</td> <td colspan="2"><?php if ($clandata['connection_time'] > 0) { echo timestamp_to_str($clandata['connection_time'] / $clandata['nummembers']); } else { echo '-'; } ?> </td> </tr> <tr class="bg1"> <td>Favorite Server:*</td> <td colspan="2"><?php $db->query("\r\n\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\thlstats_Events_Entries.serverId,\r\n\t\t\t\t\t\t\thlstats_Servers.name,\r\n\t\t\t\t\t\t\tCOUNT(hlstats_Events_Entries.serverId) AS cnt\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\thlstats_Events_Entries\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\thlstats_Servers\r\n\t\t\t\t\t\tON\r\n\t\t\t\t\t\t\thlstats_Servers.serverId=hlstats_Events_Entries.serverId\r\n\t\t\t\t\t\tINNER JOIN \r\n\t\t\t\t\t\t\thlstats_Players\r\n\t\t\t\t\t\tON\r\n\t\t\t\t\t\t\t(hlstats_Events_Entries.playerId=hlstats_Players.playerId) \r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\tclan={$clan}\r\n\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\thlstats_Events_Entries.serverId\r\n\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\tcnt DESC\r\n\t\t\t\t\t\tLIMIT 1 \t\r\n\t\t\t\t\t"); list($favServerId, $favServerName) = $db->fetch_row(); echo "<a href='hlstats.php?game={$game}&mode=servers&server_id={$favServerId}'> {$favServerName} </a>"; ?> </td>
<?php $db->query("\r\n\t\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\t\tDATE_FORMAT(eventTime, '%a. %b. %D, %Y @ %T')\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\thlstats_Events_Connects\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\thlstats_Events_Connects.playerId = '{$player}'\r\n\t\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\t\tid desc\r\n\t\t\t\t\t\t\t\tLIMIT\r\n\t\t\t\t\t\t\t\t\t1\r\n\t\t\t\t\t\t\t"); list($lastevent) = $db->fetch_row(); if ($lastevent) { echo $lastevent; } else { echo '(Unknown)'; } ?> </td> </tr> <tr class="bg1"> <td>Total Connection Time:</td> <td> <?php echo timestamp_to_str($playerdata['connection_time']); ?> </td> </tr> <tr class="bg2"> <td>Average Ping:*</td> <td> <?php $db->query("\r\n\t\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\t\tROUND(SUM(hlstats_Events_Latency.ping) / COUNT(hlstats_Events_Latency.ping), 0) AS av_ping,\r\n\t\t\t\t\t\t\t\t\tROUND(ROUND(SUM(hlstats_Events_Latency.ping) / COUNT(ping), 0) / 2, 0) AS av_latency\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\thlstats_Events_Latency\r\n\t\t\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t\t\thlstats_Events_Latency.playerId = '{$player}'\r\n\t\t\t\t\t\t\t"); list($av_ping, $av_latency) = $db->fetch_row(); if ($av_ping) { echo $av_ping . " ms (Latency: {$av_latency} ms)"; } else { echo '-'; } ?>
<td class="fSmall"><?php echo 'Kills per Death'; ?> :</td> <td colspan="2" class="fSmall"><?php if ($clandata['deaths'] != 0) { printf('%0.2f', $clandata['kills'] / $clandata['deaths']); } else { echo '-'; } ?> </td> </tr> <tr class="bg1"> <td class="fSmall"><?php echo 'Total Connection Time'; ?> :</td> <td colspan="2" class="fSmall"><?php echo timestamp_to_str($clandata['connection_time']); ?> </td> </tr> </table> <?php flush(); $tblMembers = new Table(array(new TableColumn('lastName', 'Name', 'width=32&flag=1&link=' . urlencode('mode=statsme&player=%k')), new TableColumn('skill', 'Points', 'width=7&align=right'), new TableColumn('activity', 'Activity', 'width=9&sort=no&type=bargraph'), new TableColumn('connection_time', 'Time', 'width=14&align=right&type=timestamp'), new TableColumn('kills', 'Kills', 'width=7&align=right'), new TableColumn('percent', 'Clan Kills', 'width=5&sort=no&type=bargraph'), new TableColumn('percent', '%', 'width=7&sort=no&align=right&append=' . urlencode('%')), new TableColumn('deaths', 'Deaths', 'width=7&align=right'), new TableColumn('kpd', 'KPD', 'width=7&align=right')), 'playerId', 'skill', 'kpd', true, 20, 'members_page', 'members_sort', 'members_sortorder', 'members'); $result = $db->query("\r\n\t\tSELECT\r\n\t\t\tplayerId,\r\n\t\t\tlastName,\r\n\t\t\tcountry,\r\n\t\t\tflag,\r\n\t\t\tskill,\r\n\t\t\tconnection_time,\r\n\t\t\tkills,\r\n\t\t\tdeaths,\r\n\t\t\tIFNULL(kills/deaths, '-') AS kpd,\r\n\t\t\t(kills/" . $clandata["kills"] . ") * 100 AS percent,\r\n\t\t\tactivity\r\n\t\tFROM\r\n\t\t\thlstats_Players\r\n\t\tWHERE\r\n\t\t\tclan={$clan}\r\n\t\t\tAND hlstats_Players.hideranking = 0\r\n\t\tORDER BY\r\n\t\t\t{$tblMembers->sort} {$tblMembers->sortorder},\r\n\t\t\t{$tblMembers->sort2} {$tblMembers->sortorder},\r\n\t\t\tlastName ASC\r\n\t\tLIMIT {$tblMembers->startitem},{$tblMembers->numperpage}\r\n\t"); $resultCount = $db->query("\r\n\t\tSELECT\r\n\t\t\tCOUNT(*)\r\n\t\tFROM\r\n\t\t\thlstats_Players\r\n\t\tWHERE\r\n\t\t\tclan={$clan}\r\n\t\t\tAND hlstats_Players.hideranking = 0\r\n\t"); list($numitems) = $db->fetch_row($resultCount); $tblMembers->draw($result, $numitems, 100);