Требование: PHP => 5.3, часть 2
[cswow.git] / module / arenateam / teams.php
blob95405b0285b8dc047eb6431692fd46e433b224fb
1 <?php
2 include_once("include/functions.php");
4 function count_days( $a, $b ) {
5 $gd_a = getdate( $a );
6 $gd_b = getdate( $b );
7 $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] );
8 $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] );
9 return round( abs( $a_new - $b_new ) / 86400 );
12 $id= intval(@$_REQUEST['arenateam']);
14 $arenateam_data = $cDB->selectRow("SELECT * FROM `arena_team` WHERE arenateamid = ?d", $id);
15 $arenateam_stats = $cDB->selectRow("SELECT * FROM `arena_team_stats` WHERE arenateamid = ?d", $id);
16 $arenateam_member = $cDB->selectPage($total_members, "SELECT * FROM `arena_team_member` WHERE arenateamid = ?d", $id);
17 if (!$arenateam_data)
19 echo "$lang[not_found]";
22 if ($arenateam_data AND $arenateam_stats AND $arenateam_member)
24 $losses_week = $arenateam_stats['games_week'] - $arenateam_stats['wins_week'];
25 $winperc_week = $arenateam_stats['games_week'] ? round(($arenateam_stats['wins_week']/$arenateam_stats['games_week']) * 100) : 0;
26 $losses_season = $arenateam_stats['games_season'] - $arenateam_stats['wins_season'];
27 $winperc_season = $arenateam_stats['games_season'] ? round(($arenateam_stats['wins_season']/$arenateam_stats['games_season']) * 100) : 0;
29 $type = $arenateam_data['type'];
30 $back = ($arenateam_data['BackgroundColor']+0)&0xFFFFFF;
31 $emblem = $arenateam_data['EmblemStyle'];
32 $ecolor = ($arenateam_data['EmblemColor']+0)&0xFFFFFF;
33 $border = $arenateam_data['BorderStyle'];
34 $bcolor = ($arenateam_data['BorderColor']+0)&0xFFFFFF;
35 $emblem_image = "images/player_info/arena_ico.php?type=$type&back=$back&emblem=$emblem&ecolor=$ecolor&border=$border&bcolor=$bcolor";
36 echo "
37 <table class=report width=100%>
38 <tr>
39 <td colspan=10 class=head>$arenateam_data[name] - $arenateam_stats[rating]</td>
40 </tr>
41 <tr>
42 <td colspan=2>".$lang['arena_this_week']."</td>
43 <td colspan=2>".$lang['arena_played'].": $arenateam_stats[games_week]</td>
44 <td colspan=2>".$lang['arena_wins'].": $arenateam_stats[wins_week]</td>
45 <td colspan=2>".$lang['arena_lose'].": $losses_week</td>
46 <td colspan=2>".$lang['arena_win_pct'].": $winperc_week %</td>
47 </tr>
48 <tr>
49 <td colspan=2>".$lang['arena_total_stat']."</td>
50 <td colspan=2>".$lang['arena_played'].": $arenateam_stats[games_season]</td>
51 <td colspan=2>".$lang['arena_wins'].": $arenateam_stats[wins_season]</td>
52 <td colspan=2>".$lang['arena_lose'].": $losses_season</td>
53 <td colspan=2>".$lang['arena_win_pct'].": $winperc_season %</td>
54 </tr>
55 <tr>
56 <td colspan=5 align=center>".$lang['arena_team_leader'].": ".getCharacterName($arenateam_data['captainguid'])."</td>
57 <td colspan=5 align=center>".$lang['arena_members_count'].": $total_members</td>
58 </tr>
59 <tr>
60 <th>".$lang['player_level']."</th>
61 <th>".$lang['player_name']."</th>
62 <th>".$lang['player_race']."</th>
63 <th>".$lang['player_class']."</th>
64 <th>".$lang['last_login']."</th>
65 <th>".$lang['online']."</th>
66 <th>".$lang['arena_week_games']."</th>
67 <th>".$lang['arena_wins']."</th>
68 <th>".$lang['arena_season_games']."</th>
69 <th>".$lang['arena_wins']."</th>
70 </tr>
72 foreach ($arenateam_member as $player)
74 $fields = "`name`,
75 `race`,
76 `class`,
77 `online`,
78 `account`,
79 `logout_time`,
80 SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', ".(UNIT_FIELD_LEVEL+1)."), ' ', -1) AS level,
81 (SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', ".(UNIT_FIELD_BYTES_0+1)."),' ',-1)/(256*256)) & 255 AS gender";
82 if ($char = getCharacter($player['guid'], $fields))
84 $llogin = count_days($char['logout_time'], time());
85 echo "
86 <tr>
87 <td align=center>$char[level]</td>
88 <td><a href=\"?player=$player[guid]\">$char[name]</a></td>
89 <td class=prace><img width=32 src='".getRaceImage($char['race'], $char['gender'])."'/></td>
90 <td class=pclass><img width=32 src='".getClassImage($char['class'])."'/></td>
91 <td align=center>$llogin</td>
92 <td align=center>".(($char['online'] > 0) ? "+" : "-")."</td>
93 <td align=center>$player[played_week]</td>
94 <td align=center>$player[wons_week]</td>
95 <td align=center>$player[played_season]</td>
96 <td align=center>$player[wons_season]</td>
97 </tr>";
100 echo "</table>";
101 echo "
102 <table width=100% border=0 cellspacing=0 cellpadding=0>
103 <tr>
104 <td>&nbsp;&nbsp;&nbsp;<img src=$emblem_image></td>
105 <td align=right><img src=$emblem_image>&nbsp;</td>
106 </tr>
107 </table>";