source: branches/posledni/pages/akce.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: 6.1 KB
Line 
1<?php
2
3$EventsLinks = array
4(
5 1 => array('http://wwpw.wowwiki.com/Midsummer_Fire_Festival', 'http://www.worldofwarcraft.com/info/events/midsummer/'),
6 2 => array('http://www.wowwiki.com/Feast_of_Winter_Veil', 'http://www.worldofwarcraft.com/info/events/winterveil/'),
7 3 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
8 4 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
9 5 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
10 6 => array('http://www.wowwiki.com/New_Year', 'http://www.worldofwarcraft.com/info/events/newyears/'),
11 7 => array('http://www.wowwiki.com/Lunar_Festival', 'http://www.worldofwarcraft.com/info/events/lunarnewyears/'),
12 8 => array('http://www.wowwiki.com/Love_is_in_the_Air', 'http://www.worldofwarcraft.com/info/events/loveisintheair/'),
13 9 => array('http://www.wowwiki.com/Noblegarden', 'http://www.worldofwarcraft.com/community/ingameevents.html#noblegarden'),
14 10 => array('http://www.wowwiki.com/Children%27s_Week', 'http://www.worldofwarcraft.com/info/events/childrensweek/'),
15 11 => array('http://www.wowwiki.com/Harvest_Festival', 'http://www.worldofwarcraft.com/info/events/harvestfestival/'),
16 12 => array('http://www.wowwiki.com/Hallow%27s_End', 'http://www.worldofwarcraft.com/info/events/hallowsend/'),
17 13 => array('http://www.wowwiki.com/Elemental_Invasions', 'http://www.worldofwarcraft.com/community/ingameevents.html#elemental'),
18 14 => array('http://www.wowwiki.com/Stranglethorn_Fishing_Extravaganza', 'http://www.worldofwarcraft.com/info/events/fishing/'),
19 15 => array('http://www.wowwiki.com/Stranglethorn_Fishing_Extravaganza', 'http://www.worldofwarcraft.com/info/events/fishing/'),
20 16 => array('http://www.wowwiki.com/Gurubashi_Arena#Gurubashi_Arena_Booty_Run', 'http://www.worldofwarcraft.com/community/ingameevents.html#gurubashi'),
21 17 => array('http://www.wowwiki.com/The_Scourge_Invasion', 'http://www.worldofwarcraft.com/info/events/scourgeinvasion/'),
22 18 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
23 19 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
24 20 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
25 21 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
26 22 => array('http://www.wowwiki.com/Ahn%27Qiraj_War_Effort', 'http://www.worldofwarcraft.com/wareffort/servers.html'),
27 23 => array('', ''),
28 24 => array('', ''),
29 25 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
30 26 => array('http://www.wowwiki.com/Brewfest', 'http://www.worldofwarcraft.com/info/events/brewfest/'),
31 27 => array('', ''),
32 28 => array('http://www.wowwiki.com/Noblegarden', 'http://www.worldofwarcraft.com/community/ingameevents.html#noblegarden'),
33 29 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
34 30 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
35 31 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
36 32 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
37 34 => array('http://www.wowwiki.com/L70ETC', ''),
38);
39
40function Events()
41{
42 global $db, $EventsLinks, $Config, $System;
43
44 $Events = array('Running' => array(), 'Planned' => array());
45 $Realm = new Realm($System, $_COOKIE['RealmIndex']);
46
47 $DbResult = $Realm->MangosDatabase->query('SELECT *, UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE end_time > NOW() AND start_time < NOW()');
48 while($Row = $DbResult->fetch_array())
49 {
50 if(!array_key_exists($Row['entry'], $EventsLinks)) $EventsLinks[$Row['entry']] = array('', '');
51 $Start = (floor((time() - $Row['start']) / ($Row['occurence'] * 60))) * $Row['occurence'] * 60 + $Row['start'];
52 $End = $Start + $Row['length'] * 60;
53 if((time() > $Start) and (time() < $End)) $EventState = 'Running';
54 else
55 {
56 $EventState = 'Planned';
57 $Start += $Row['occurence'] * 60;
58 $End += $Row['occurence'] * 60;
59 }
60 $Events[$EventState][$Row['start']] = array('StartTime' => $Start, 'EndTime' => $End, 'Title' => $Row['description'], 'WoWWiki' => $EventsLinks[$Row['entry']][0], 'Official' => $EventsLinks[$Row['entry']][1]);
61 }
62
63 // Add events not started so far
64 //$DbResult = $db->select('game_event', '*, UNIX_TIMESTAMP(start_time) as start', 'start_time > NOW()');
65 $DbResult = $db->query('SELECT * , UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE start_time > NOW()');
66 while($Row = $DbResult->fetch_array())
67 {
68 if(!array_key_exists($Row['entry'], $EventsLinks)) $EventsLinks[$Row['entry']] = array('', '');
69 $Events['Planned'][$Row['start']] = array('StartTime' => $Row['start'], 'EndTime' => ($Row['start'] + $Row['length'] * 60), 'Title' => $Row['description'], 'WoWWiki' => $EventsLinks[$Row['entry']][0], 'Official' => $EventsLinks[$Row['entry']][1]);
70 }
71
72 sort($Events['Running']);
73 sort($Events['Planned']);
74
75 return($Events);
76}
77
78function ShowEventList($Events)
79{
80 foreach($Events as $Event)
81 {
82 echo('<tr><td>'.$Event['Title'].'</td><td>'.date('j.n.Y H:i', $Event['StartTime']).'</td><td>'.date('j.n.Y H:i', $Event['EndTime']).'</td>');
83 if($Event['WoWWiki'] != '') echo('<td><a href="'.$Event['WoWWiki'].'">wowwiki</a>');
84else echo('<td>&nbsp;');
85 if($Event['Official'] != '') echo(' <a href="'.$Event['Official'].'">worldofwarcraft</a></td>'); else echo(' &nbsp;</td>');
86 echo('</tr>');
87 }
88}
89
90echo('<h3 class="PageTitle">Události ve hře</h3>');
91$Realm = new Realm($System, $_COOKIE['RealmIndex']);
92$db = $Realm->MangosDatabase;
93
94$Events = Events();
95echo('<table class="BaseTable">');
96echo('<tr><th>Název</th><th>Začátek</th><th>Konec</th><th>Informace</th></tr>');
97echo('<tr><td colspan="5"><b>Probíhající akce</b></td></tr>');
98ShowEventList($Events['Running']);
99echo('<tr><td colspan="5"><b>Plánované akce</b></td></tr>');
100ShowEventList($Events['Planned']);
101echo('</table>');
102
103?>
Note: See TracBrowser for help on using the repository browser.