Требование: PHP => 5.3, часть 2
[cswow.git] / module / online / online.php
blob346229fc8a07491e6a80b18f039abdce160e5cf7
1 <?php
2 include_once("conf.php");
3 include_once("include/player_data.php");
4 include_once("include/functions.php");
5 include_once("include/map_data.php");
6 include_once("include/report_generator.php");
8 function onlineMapRenderCallback($data, $x, $y)
10 $imgX = 16;
11 $imgY = 16;
12 $x = round($x-$imgX/2, 0);
13 $y = round($y-$imgY/2, 0);
15 $gender = $data['gender'];
16 $class = $data['class'];
17 $race = $data['race'];
18 $level = $data['level'];
19 $faction = getPlayerFaction($race);
20 $map_name = getMapName($data['map']);
21 $area_name = getAreaNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
23 $img = $faction==0 ? "gps_icon1.png" : "gps_icon.png";
25 $text ="<table class=online_map>";
26 $text.="<tr><td class=".($faction==0?"aname":"hname").">".$data['name']."</td></<tr>";
27 if ($area_name)
28 $text.="<tr><td align=center>$area_name<br>";
29 $text.="<tr><td align=center>";
30 $text.="<img width=20 src=".getRaceImage($race,$gender)."> <img width=20 src=".getClassImage($class)."><br>";
31 $text.=getRace($race)."<br>";
32 $text.=getClass($class)."<br>";
33 $text.="Level - $level<br>";
34 $text.="</td></tr>";
35 $text.="</table>";
36 return '<img src="images/map_points/'.$img.'" class=point style="left: '.$x.'; top: '.$y.';" '.addTooltip($text).'>'."\n";
39 function onoff_realm()
41 global $config;
42 $s = @fsockopen($config['host'], $config['port'], $errno, $errstr, (float)0.5);
43 if($s){@fclose($s);return true;} else return false;
46 $online = @$_REQUEST['online'];
47 $width = isset($_REQUEST['width']) ? $_REQUEST['width'] : 700;
49 if ($online == "gps")
51 $rows = $cDB->selectPage($number, "SELECT * FROM `characters` WHERE `online` <> '0' AND NOT `extra_flags`&".PLAYER_EXTRA_GM_INVISIBLE);
52 renderGPSMap("$number $lang[online_players]", $width, $rows, 'onlineMapRenderCallback');
54 else
56 $baseLink = '?online';
57 $show_fields= array('PL_REPORT_LEVEL', 'PL_REPORT_FACTION', 'PL_REPORT_NAME', 'PL_REPORT_RACE', 'PL_REPORT_CLASS', 'PL_REPORT_POS');
59 $list = new PlayerReportGenerator();
60 $list->disableMark();
61 $list->Init($show_fields, $baseLink, 'onlineLIST', $config['online_limit'], 'name');
62 $list->online();
63 $number = $list->getTotalDataCount();
65 $ap_dateSql = $cDB->selectCell("-- CACHE: 1h
66 SELECT `NextArenaPointDistributionTime` FROM `saved_variables`");
67 $daily_quest_dateSql = $cDB->selectCell("-- CACHE: 1h
68 SELECT `NextDailyQuestResetTime` FROM `saved_variables`");
69 $weekly_quest_dateSql = $cDB->selectCell("-- CACHE: 1h
70 SELECT `NextWeeklyQuestResetTime` FROM `saved_variables`");
71 $monthly_quest_dateSql = $cDB->selectCell("-- CACHE: 1h
72 SELECT `NextMonthlyQuestResetTime` FROM `saved_variables`");
74 $ap_date = date("H:i:s d.m.Y", $ap_dateSql);
75 $daily_quest_date = date("H:i:s d.m.Y", $daily_quest_dateSql);
76 $weekly_quest_date = date("H:i:s d.m.Y", $weekly_quest_dateSql);
77 $monthly_quest_date = date("H:i:s d.m.Y", $monthly_quest_dateSql);
79 echo "<table class=report width=100%>";
80 echo "<tr><td colspan=2 class=head>".$lang['stat_timers']."</td></tr>";
81 echo "<tr><td>".$lang['ap_date']."</td><td>".$ap_date."</td></tr>";
82 echo "<tr><td>".$lang['daily_quest_date']."</td><td>".$daily_quest_date."</td></tr>";
83 echo "<tr><td>".$lang['weekly_quest_date']."</td><td>".$weekly_quest_date."</td></tr>";
84 echo "<tr><td>".$lang['monthly_quest_date']."</td><td>".$monthly_quest_date."</td></tr>";
85 if ($ae = getGameEventActive())
87 echo "<tr><td colspan=2 class=head>".$lang['active_event']."</td></tr>";
88 foreach ($ae as $ae1)
90 if (getGameEventActiveName($ae1['event']))
91 echo "<tr><td colspan=2>".getGameEventName($ae1['event'])."</td></tr>";
94 echo "</table>";
95 if (onoff_realm())
97 if ($number <= 0)
98 echo $lang['online_no_players'];
99 else
100 $list->createReport($number.' '.$lang['online_players']);
102 else
103 echo $lang['offline'];