source: beta/pages/events.php@ 405

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