source: branches/old/projectonlineplayes/source/PHP - create xml mangos/create_xml.php

Last change on this file was 195, checked in by maron, 17 years ago

Oprava projektu online hráči

File size: 3.7 KB
Line 
1<?php
2$Hostname = 'localhost';
3$Username = 'root';
4$Password = '';
5$Database = 'characters'; // must contains characters table
6$RealmHostname = $Hostname;
7$RealmUsername = $Username;
8$RealmPassword = $Password;
9$RealmDatabase = 'realmd'; // must contains zone_coordinates and accounts table
10$EmuVersion = '4500';
11$Owner = 'Admin';
12$ServerName = 'Free WoW server';
13$ServerAddress = 'realmlist';
14$Patch = '2.3';
15$Registration = 'Open';
16$MaxPlayers = '200';
17$XP = 'blizzlike';
18$DatabaseEncoding = 'utf8';
19
20$Output = MangosStat();
21 Header('Content-Type: text/xml'); // Needed only for direct generation of xml file
22 Header('Content-Length: '.strlen($Output)); // Needed only for direct generation of xml file
23echo($Output);
24
25function MangosStat()
26{
27 global $Hostname, $Username, $Password, $Database, $EmuVersion, $Owner,
28 $ServerName, $ServerAddress, $Patch, $Registration, $MaxPlayers, $XP,
29 $realm_db, $DatabaseEncoding, $RealmHostname, $RealmUsername, $RealmPassword, $RealmDatabase;
30
31 $Result =
32'<?xml version="1.0" encoding="UTF-8"'."?>\r\n".
33'<!DOCTYPE server SYSTEM "http://wow.zdechov.net/projectonlineplayes/onlineplayers.dtd"'.">\r\n".
34" <server>\r\n".
35" <servername>".$ServerName."</servername>\r\n".
36" <serveraddress>".$ServerAddress."</serveraddress>\r\n".
37" <owner>".$Owner."</owner>\r\n".
38" <patch>".$Patch."</patch>\r\n".
39" <uptime>0 weeks 1 days 0 hours 0 mins</uptime>\r\n".
40" <registration>".$Registration."</registration>\r\n".
41" <maxplayers>".$MaxPlayers."</maxplayers>\r\n".
42" <xp>".$XP."</xp>\r\n".
43" <players>\r\n";
44
45 $realm_db = mysql_connect($RealmHostname, $RealmUsername, $RealmPassword);
46 mysql_select_db($RealmDatabase, $realm_db);
47 $db_result = mysql_query("SET NAMES $DatabaseEncoding", $realm_db);
48
49 $mangos_db = mysql_connect($Hostname, $Username, $Password, TRUE);
50 mysql_select_db($Database, $mangos_db);
51 $db_result = mysql_query("SET NAMES $DatabaseEncoding", $mangos_db);
52
53
54 $db_result = mysql_query("SELECT count(*) FROM `character` WHERE `online`='1' ORDER BY `name`", $mangos_db);
55 $PlayersCount = mysql_fetch_row($db_result);
56 $Result .= " <playerscount>".$PlayersCount[0]."</playerscount>\r\n";
57
58
59 $db_result = mysql_query("SELECT * FROM `character` WHERE `online`='1' ORDER BY `name`", $mangos_db);
60 while($result = mysql_fetch_array($db_result))
61 {
62 // Get GM level by character
63 $db_result2 = mysql_query("SELECT gmlevel FROM `account` WHERE `id`='".$result['account']."'", $realm_db);
64 //echo("SELECT `gmlevel` FROM `account` WHERE `id`='".$result['account']."'");
65 $result2 = mysql_fetch_array($db_result2);
66
67 $char_data = explode(' ',$result['data']);
68 $Result .= " <player>\r\n".
69 " <name>".$result['name']."</name>\r\n".
70 " <level>".$char_data[34]."</level>\r\n".
71 " <race>".$result['race']."</race>\r\n".
72 " <class>".$result['class']."</class>\r\n".
73 " <zone>".get_zone_name($result['map'], $result['position_x'], $result['position_y'])."</zone>\r\n".
74 " <map>".$result['map']."</map>\r\n".
75 " <ip>178.12.14.2</ip>\r\n".
76 " <plevel>".$result2['gmlevel']."</plevel>\r\n".
77 " </player>\r\n";
78 }
79 $Result .= " </players>\r\n".
80 " </server>\r\n";
81 return($Result);
82}
83
84function get_zone_name($mapid, $x, $y)
85{
86 global $realm_db;
87 $query = mysql_query("SELECT * FROM `zone_coordinates` ORDER BY `priory`", $realm_db);
88 $zmap = 0;
89 while($result = mysql_fetch_array($query))
90 {
91 if ($result['map']==$mapid AND $result['y_min'] < $x AND $result['y_max'] > $x AND $result['x_max'] < $y AND $result['x_min'] > $y) $zmap=$result['zone_id'];
92 }
93 return $zmap;
94}
95?>
Note: See TracBrowser for help on using the repository browser.