source: branches/posledni/inc/server.php

Last change on this file was 697, checked in by george, 15 years ago
  • Upraveno: Systém výběru světů pomocí indexů a cookies předělán na výběr pomocí URL.
File size: 16.4 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/module.php');
4
5function NullErrorHandler()
6{
7}
8
9class Server extends Module
10{
11 function __construct($System, $Id)
12 {
13 parent::__construct($System);
14 $this->Id = $Id;
15 $DbResult = $this->Database->query('SELECT * FROM Logon WHERE Id='.$Id.' AND Enabled=1' );
16 $this->Data = $DbResult->fetch_assoc();
17 $this->ServerDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseRealmd']);
18 $this->ServerDatabase->select_db($this->Data['DatabaseRealmd']);
19 if($this->ServerDatabase->connect_error)
20 {
21 die('Přihlášení k databázi serveru '.$this->Id.' selhalo: '.$this->ServerDatabase->connect_error);
22 }
23 $this->ServerDatabase->charset($this->Config['Database']['Charset']);
24 }
25
26 function HumanDate($date, $time = 1)
27 {
28 // input date is 0000-00-00 00:00:00
29 $date_arr = explode(' ', $date);
30 $date = explode('-', $date_arr[0]);
31 if(count($date_arr) > 1) $time_stp = explode(':', $date_arr[1]);
32 else $time_stp = array(0, 0, 0);
33 $time = mktime($time_stp[0], $time_stp[1], $time_stp[2], $date[1], $date[2], $date[0]);
34 if($time == 1) $human_date = date('d.m.Y H:i:s', $time);
35 else $human_date = date('d.m.Y', $time);
36 return($human_date);
37 }
38
39 function ParseCopper($copper_in)
40 {
41 global $html;
42
43 $copper = $copper_in;
44 $golds = floor($copper / 10000);
45 $num = $copper - $golds * 10000;
46 $silver = floor($num / 100);
47 $copper = $num - $silver * 100;
48 $show_golds = '<font size="4">'.$golds.'</font>&nbsp;<img src="'.$html->Link('/imgs/inc/g.gif').'">';
49 $show_silver = '<font size="4">'.$silver.'</font>&nbsp;<img src="'.$html->Link('/imgs/inc/s.gif').'">';
50 $show_copper = '<font size="4">'.$copper.'</font>&nbsp;<img src="'.$html->Link('/imgs/inc/c.gif').'">';
51 return($show_golds.'&nbsp;'.$show_silver.'&nbsp;'.$show_copper);
52 }
53
54 function OnlineCharactersCount()
55 {
56 $TotalCount = 0;
57 $DbResult = $this->Database->query('SELECT Id FROM Realm WHERE Enabled=1');
58 while($DbRow = $DbResult->fetch_assoc())
59 {
60 $Realm = new Realm($this->System, $DbRow['Id']);
61 $TotalCount += $Realm->OnlineCharactersCount();
62 }
63 return($TotalCount);
64 }
65
66 function OnlineStateImage($Status)
67 {
68 global $html;
69
70 if($Status) return('<img src="'.$html->Link('/imgs/inc/on.gif').'" alt="online" />&nbsp;<span style="text-color: #234303; text-size: 4;">Online</span>');
71 else return('<img src="'.$html->Link('/imgs/inc/off.gif').'" alt="offline" />&nbsp;<span style="text-color: #990000; text-size: 4;">Offline</span>');
72 }
73
74 function CharacterCount()
75 {
76 $TotalCount = 0;
77 $DbResult = $this->Database->query('SELECT Id FROM Realm WHERE Enabled=1');
78 while($DbRow = $DbResult->fetch_assoc())
79 {
80 $Realm = new Realm($this->System, $DbRow['Id']);
81 $TotalCount += $Realm->CharacterCount($DbRow['Id']);
82 }
83 return($TotalCount);
84 }
85
86 public function AccountCount()
87 {
88 $row = $this->ServerDatabase->query('SELECT COUNT(*) FROM account')->fetch_row();
89 return($row[0]);
90 }
91
92 public function MapName($id)
93 {
94 $map_id = Array
95 (
96 0 => array(0,"Azeroths"),
97 1 => array(1,"Kalimdor"),
98 13 => array(13,"Testing"),
99 17 => array(17,"Kalidar"),
100 25 => array(25,"Scott Test"),
101 30 => array(30,"Alterac Valley"),
102 33 => array(33,"Shadowfang Keep Instance"),
103 34 => array(34,"The Stockade Instance"),
104 35 => array(35,"Stormwind Prison"),
105 36 => array(36,"Deadmines Instance"),
106 37 => array(37,"Azshara Crater"),
107 42 => array(42,"Collins Test"),
108 43 => array(43,"Wailing Caverns Instance"),
109 44 => array(44,"Monastery Interior"),
110 47 => array(47,"Razorfen Kraul Instance"),
111 48 => array(48,"Blackfathom Deeps Instance"),
112 70 => array(70,"Uldaman Instance"),
113 90 => array(90,"Gnomeregan Instance"),
114 109 => array(109,"Sunken Temple Instance"),
115 129 => array(129,"Razorfen Downs Instance"),
116 169 => array(169,"Emerald Forest"),
117 189 => array(189,"Scarlet Monastery Instance"),
118 209 => array(209,"Zul Farrak Instance"),
119 229 => array(229,"Blackrock Spire Instance"),
120 230 => array(230,"Blackrock Depths Instance"),
121 249 => array(249,"Onyxias Lair Instance"),
122 269 => array(269,"Opening of the Dark Portal Instance"),
123 289 => array(289,"Scholomance Instance"),
124 309 => array(309,"ZulGurub Instance"),
125 329 => array(329,"Stratholme Instance"),
126 349 => array(349,"Maraudon Instance"),
127 369 => array(369,"Deeprun Tram"),
128 389 => array(389,"Ragefire Chasm Instance"),
129 409 => array(409,"The Molten Core Instance"),
130 429 => array(429,"Dire Maul Instance"),
131 449 => array(449,"Alliance PvP Barracks"),
132 450 => array(450,"Horde PvP Barracks"),
133 451 => array(451,"Development Land"),
134 469 => array(469,"BlackwingLair Instance"),
135 489 => array(489,"PvP Warsong Gulch"),
136 509 => array(509,"Ruins of Ahn Qiraj Instance"),
137 529 => array(529,"PvP Arathi Basin"),
138 530 => array(530,"Outland"),
139 531 => array(531,"Temple of Ahn Qiraj Instance"),
140 532 => array(532,"Karazhan Instance"),
141 533 => array(533,"Naxxramas Instance"),
142 534 => array(534,"The Battle for Mount Hyjal Instance"),
143 540 => array(540,"Hellfire Citadel The Shattered Halls Instance"),
144 542 => array(542,"Hellfire Citadel The Blood Furnace Instance"),
145 543 => array(543,"Hellfire Citadel Ramparts Instance"),
146 544 => array(544,"Maghtheridons Lair Instance"),
147 545 => array(545,"Coilfang The Steamvault Instance"),
148 546 => array(546,"Coilfang The Underbog Instance"),
149 547 => array(547,"Coilfang The Slave Pens Instance"),
150 548 => array(548,"Coilfang Serpentshrine Cavern Instance"),
151 550 => array(550,"Tempest Keep Instance"),
152 552 => array(552,"Tempest Keep The Alcatraz Instance"),
153 553 => array(553,"Tempest Keep The Botanica Instance"),
154 554 => array(554,"Tempest Keep The Mechanar Instance"),
155 555 => array(555,"Auchindoun Shadow Labyrinth Instance"),
156 556 => array(556,"Auchindoun Sethekk Halls Instance"),
157 557 => array(557,"Auchindoun Mana Tombs Instance"),
158 558 => array(558,"Auchindoun Auchenai Crypts Instance"),
159 559 => array(559,"Nagrand Arena"),
160 560 => array(560,"The Escape From Durnholde Instance"),
161 562 => array(562,"Blades Edge Arena"),
162 564 => array(564,"Black Temple Instance"),
163 565 => array(565,"Gruuls Lair Instance"),
164 566 => array(566,"Netherstorm Arena"),
165 568 => array(568,"ZulAman Instance"),
166 571 => array(571,"Northrend"),
167 572 => array(572,"PvP Ruins of Lordaeron"),
168 573 => array(573,"ExteriorTest"),
169 574 => array(574,"Utgarde Keep Instance"),
170 575 => array(575,"Utgarde Pinnacle Instance"),
171 576 => array(576,"The Nexus Instance"),
172 578 => array(578,"The Oculus Instance"),
173 580 => array(580,"The Sunwell Instance"),
174 585 => array(585,"Magisters Terrace Instance"),
175 595 => array(595,"The Culling of Stratholme Instance"),
176 597 => array(597,"Craig Test"),
177 599 => array(599,"Halls of Stone Instance"),
178 600 => array(600,"Drak Tharon Keep Instance"),
179 601 => array(601,"Azjol-Nerub Instance"),
180 602 => array(602,"Halls of Lightning Instance"),
181 603 => array(603,"Ulduar Instance"),
182 604 => array(604,"Gundrak Instance"),
183 605 => array(605,"Development Land"),
184 606 => array(606,"QA and DVD"),
185 607 => array(607,"PvP Strand of the Ancients"),
186 608 => array(608,"Violet Hold Instance"),
187 609 => array(609,"Ebon Hold"),
188 615 => array(615,"Obsidian Sanctum Instance"),
189 616 => array(616,"The Eye of Eternity Instance"),
190 617 => array(617,"PvP Dalaran Sewers"),
191 618 => array(618,"PvP The Ring of Valor"),
192 619 => array(619,"Ahn kahet The Old Kingdom Instance"),
193 624 => array(624,"Vault of Archavon Instance"),
194 650 => array(650,"Trial of the Champion Instance")
195 );
196 if(isset($map_id[$id])) return($map_id[$id][1]);
197 else return("Neznámá");
198 }
199
200 public function ZoneName($id)
201 {
202 $zone_id = Array
203 (
204 1 => Array("Dun Morogh",1),
205 3 => Array("Badlands",3),
206 4 => Array("Blasted Lands",4),
207 8 => Array("Swamp of Sorrows",8),
208 10 => Array("Duskwood",10),
209 11 => Array("Wetlands",11),
210 12 => Array("Elwynn Forest",12),
211 14 => Array("Durotar",14),
212 15 => Array("Dustwallow Marsh",15),
213 16 => Array("Azshara",16),
214 17 => Array("The Barrens",17),
215 19 => Array("Zul Gurub",19),
216 25 => Array("Blackrock Mountain",25),
217 28 => Array("Western Plaguelands",28),
218 33 => Array("Stranglethorn Vale",33),
219 36 => Array("Alterac Mountains",36),
220 38 => Array("Loch Modan",38),
221 40 => Array("Westfall",40),
222 41 => Array("Deadwind Pass",41),
223 44 => Array("Redridge Mountains",44),
224 45 => Array("Arathi Highlands",45),
225 46 => Array("Burning Steppes",46),
226 47 => Array("The Hinterlands",47),
227 51 => Array("Searing Gorge",51),
228 65 => Array("Dragonblight",65),
229 66 => Array("Zul Drak",66),
230 67 => Array("The Storm Peaks",67),
231 85 => Array("Tirisfal Glades",85),
232 130 => Array("Silverpine Forest",130),
233 133 => Array("Gnomeregan",133),
234 139 => Array("Eastern Plaguelands",139),
235 141 => Array("Teldrassil",141),
236 148 => Array("Darkshore",148),
237 206 => Array("Utgarde Keep",206),
238 209 => Array("Shadowfang Keep",209),
239 210 => Array("Icecrown",210),
240 215 => Array("Mulgore",215),
241 267 => Array("Hillsbrad Foothills",267),
242 331 => Array("Ashenvale",331),
243 357 => Array("Feralas",357),
244 361 => Array("Felwood",361),
245 394 => Array("Grizzly Hills",394),
246 400 => Array("Thousand Needles",400),
247 405 => Array("Desolace",405),
248 406 => Array("Stonetalon Mountains",406),
249 440 => Array("Tanaris",440),
250 457 => Array("The Veiled Sea",457),
251 490 => Array("Un Goro Crater",490),
252 491 => Array("Razorfen Kraul",491),
253 493 => Array("Moonglade",493),
254 495 => Array("Howling Fjord",495),
255 618 => Array("Winterspring",618),
256 717 => Array("The Stockade",717),
257 718 => Array("Wailing Caverns",718),
258 719 => Array("Blackfathom Deeps",719),
259 722 => Array("Razorfen Downs",722),
260 796 => Array("Scarlet Monastery",796),
261 978 => Array("Zul Farrak",978),
262 1176 => Array("Zul Farrak",1176),
263 1196 => Array("Utgarde Pinnacle",1196),
264 1337 => Array("Uldaman",1337),
265 1377 => Array("Silithus",1377),
266 1417 => Array("Sunken Temple",1417),
267 1497 => Array("Undercity",1497),
268 1519 => Array("Stormwind City",1519),
269 1537 => Array("Ironforge",1537),
270 1581 => Array("The Deadmines",1581),
271 1583 => Array("Blackrock Spire",1583),
272 1584 => Array("Blackrock Depths",1584),
273 1637 => Array("Orgrimmar",1637),
274 1638 => Array("Thunder Bluff",1638),
275 1657 => Array("Darnassus",1657),
276 2017 => Array("Stratholme",2017),
277 2057 => Array("Scholomance",2057),
278 2100 => Array("Maraudon",2100),
279 2158 => Array("Onyxias Lair",2158),
280 2257 => Array("Deeprun Tram",2257),
281 2366 => Array("The Black Morass",2366),
282 2367 => Array("Old Hillsbrad Foothills",2367),
283 2557 => Array("Dire Maul",2557),
284 2562 => Array("Karazhan",2562),
285 2597 => Array("PvP Alterac Valley",2597),
286 2677 => Array("Blackwing Lair",2677),
287 2717 => Array("Molten Core",2717),
288 2817 => Array("Crystalsong Forest",2817),
289 3277 => Array("PvP Warsong Gulch",3277),
290 3358 => Array("PvP Arathi Basin",3358),
291 3428 => Array("Temple of Ahn Qiraj",3428),
292 3429 => Array("Ruins of Ahn Qiraj",3429),
293 3430 => Array("Eversong Woods",3430),
294 3433 => Array("Ghostlands",3433),
295 3437 => Array("Ragefire Chasm",3437),
296 3456 => Array("Naxxramas",3456),
297 3477 => Array("Azjol Nerub",3477),
298 3483 => Array("Hellfire Peninsula",3483),
299 3487 => Array("Silvermoon city",3487),
300 3518 => Array("Nagrand",3518),
301 3519 => Array("Terokkar Forest",3519),
302 3520 => Array("Shadowmoon Valley",3520),
303 3521 => Array("Zangarmarsh",3521),
304 3522 => Array("Blades Edge Mountains",3522),
305 3523 => Array("Netherstorm",3523),
306 3524 => Array("Azuremyst Isle",3524),
307 3525 => Array("Bloodmyst Isle",3525),
308 3537 => Array("Borean Tundra",3537),
309 3557 => Array("The Exodar",3557),
310 3562 => Array("Hellfire Ramparts",3562),
311 3606 => Array("Hyjal Summit",3606),
312 3607 => Array("Serpentshrine Cavern",3607),
313 3618 => Array("Gruuls Lair",3618),
314 3698 => Array("The Ring of Trials",3698),
315 3702 => Array("PvP The Circle of Blood",3702),
316 3703 => Array("Shattrath City",3703),
317 3711 => Array("Sholazar Basin",3711),
318 3713 => Array("The Blood Furnace",3713),
319 3714 => Array("The Shattered Halls",3714),
320 3715 => Array("The Steamvault",3715),
321 3716 => Array("The Underbog",3716),
322 3717 => Array("The Slave Pens",3717),
323 3789 => Array("Shadow Labyrinth",3789),
324 3790 => Array("Auchenai Crypts",3790),
325 3791 => Array("Sethekk Halls",3791),
326 3792 => Array("Mana Tombs",3792),
327 3805 => Array("Zul Aman",3805),
328 3817 => Array("Testing",3817),
329 3820 => Array("PvP Eye of the Storm",3820),
330 3836 => Array("Magtheridons Lair",3836),
331 3842 => Array("The Eye",3842),
332 3846 => Array("The Arcatraz",3846),
333 3847 => Array("The Botanica",3847),
334 3849 => Array("The Mechanar",3849),
335 3959 => Array("Black Temple",3959),
336 3968 => Array("PvP Ruins of Lordaeron",3968),
337 4075 => Array("Sunwell Plateau",4075),
338 4080 => Array("Isle of Quel Danas",4080),
339 4095 => Array("Magisters Terrace",4095),
340 4100 => Array("The Culling of Stratholme",4100),
341 4120 => Array("The Nexus",4120),
342 4131 => Array("Magisters Terrace",4131),
343 4196 => Array("Drak Tharon Keep",4196),
344 4197 => Array("Wintergrasp",4197),
345 4228 => Array("The Oculus",4228),
346 4264 => Array("Halls of Stone",4264),
347 4272 => Array("Halls of Lightning",4272),
348 4273 => Array("Ulduar",4273),
349 4277 => Array("Azjol-Nerub",4277),
350 4298 => Array("The Scarlet Enclave",4298),
351 4375 => Array("Gundrak",4375),
352 4378 => Array("PvP Dalaran Sewers",4378),
353 4384 => Array("PvP Strand of the Ancients",4384),
354 4395 => Array("Dalaran",4395),
355 4406 => Array("PvP The Ring of Valor",4406),
356 4415 => Array("The Violet Hold Instance",4415),
357 4416 => Array("Gundrak Instance",4416),
358 4493 => Array("The Obsidian Sanctum",4493),
359 4494 => Array("Ahn kahet The Old Kingdom",4494),
360 4500 => Array("The Eye of Eternity",4500),
361 4603 => Array("Vault of Archavon",4603),
362 4710 => Array("PvP Isle of Conquest",4710),
363 4722 => Array("Trial of the Crusader",4722),
364 4723 => Array("Trial of the Champion",4723),
365 4742 => Array("Hrothgars Landing",4742),
366 4809 => Array("The Forge of Souls",4809),
367 4812 => Array("Icecrown Citadel",4812),
368 4813 => Array("Pit of Saron",4813),
369 4820 => Array("Halls of Reflection",4820)
370 );
371 if(isset($zone_id[$id])) return($zone_id[$id][0]);
372 else return('-');
373 }
374
375 function RealmSelection($FormNameSufix = '')
376 {
377 global $html, $QueryItems, $System;
378
379 $Output = '';
380 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Realm WHERE Enabled=1');
381 $DbRow = $DbResult->fetch_row();
382 $RealmCount = $DbRow[0];
383
384 if($RealmCount > 1)
385 {
386 if(array_key_exists('page', $_GET)) $Target = '?page='.$_GET['page'];
387 else $Target = '';
388 $Output .= '<div style="text-align: center;"><form name="realm_selection">'.
389 '<div>Výběr světa <select onchange="loadPage(this.form.elements[0])">';
390
391 $DbResult = $this->Database->query('SELECT *, '.$System->SQLURLName('Name').' AS URLName FROM Realm WHERE Enabled=1');
392 while($Realm = $DbResult->fetch_assoc())
393 {
394 if($QueryItems[1] == $Realm['URLName']) $Selected = ' selected="selected"';
395 else $Selected = '';
396 $NewQueryItems = $QueryItems;
397 $NewQueryItems[0] = 'svety';
398 $NewQueryItems[1] = $Realm['URLName'];
399 $NewURL = $html->Link('/'.implode('/', $NewQueryItems).'/');
400 $Output .= '<option value="'.$NewURL.'"'.$Selected.'>'.$Realm['Name'].'</option>';
401 }
402 $Output .= '</select></div>'.
403 '</form></div>';
404 }
405 return($Output);
406 }
407}
408
409?>
Note: See TracBrowser for help on using the repository browser.