source: branches/beta/pages/events.php@ 448

Last change on this file since 448 was 407, checked in by zork, 16 years ago
File size: 6.1 KB
Line 
1<?php
2
3$EventsLinks = array(
4 1 => array("http://wwpw.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{
41include("inc/db.php");
42
43 global $db, $EventsLinks;
44 $Events = array("Running" => array(), "Planned" => array());
45 $db -> select_db("$db_mangos");
46
47
48 $DbResult = $db->query("SELECT *, UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE end_time > NOW() AND start_time < NOW()");
49 while($Row = $DbResult->fetch_array())
50 {
51 if(!array_key_exists($Row["entry"], $EventsLinks)) $EventsLinks[$Row["entry"]] = array("", "");
52 $Start = (floor((time() - $Row["start"]) / ($Row["occurence"] * 60))) * $Row["occurence"] * 60 + $Row["start"];
53 $End = $Start + $Row["length"] * 60;
54 if((time() > $Start) and (time() < $End)) $EventState = "Running";
55 else
56 {
57 $EventState = "Planned";
58 $Start += $Row["occurence"] * 60;
59 $End += $Row["occurence"] * 60;
60 }
61 $Events[$EventState][$Row["start"]] = array("StartTime" => $Start, "EndTime" => $End, "Title" => $Row["description"], "WoWWiki" => $EventsLinks[$Row["entry"]][0], "Official" => $EventsLinks[$Row["entry"]][1]);
62 }
63
64 // Add events not started so far
65 //$DbResult = $db->select("game_event", "*, UNIX_TIMESTAMP(start_time) as start", "start_time > NOW()");
66 $DbResult = $db->query("SELECT * , UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE start_time > NOW()");
67 while($Row = $DbResult->fetch_array())
68 {
69 if(!array_key_exists($Row["entry"], $EventsLinks)) $EventsLinks[$Row["entry"]] = array("", "");
70 $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]);
71 }
72
73 sort($Events["Running"]);
74 sort($Events["Planned"]);
75
76 return($Events);
77}
78
79function ShowEventList($Events)
80{
81 foreach($Events as $Event)
82 {
83 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>");
84 if($Event["WoWWiki"] != "") echo("<td><a href=\"".$Event["WoWWiki"]."\">wowwiki</a></td>");
85else echo("<td>&nbsp;</td>");
86 if($Event["Official"] != "") echo("<td><a href=\"".$Event["Official"]."\">worldofwarcraft</a></td>"); else echo("<td>&nbsp;</td>");
87 echo("</tr>");
88 }
89}
90
91
92
93
94echo"<center><h3>Události ve hře :</h3></center>";
95
96$Events = Events();
97echo "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"540\" align=\"center\">";
98echo"<tr><th>Název</th><th>Začátek</th><th>Konec</th><th>Informace</th><th>Informace</th></tr>";
99echo"<tr><td colspan=\"5\"><b>Probíhající akce</b></td></tr>";
100ShowEventList($Events["Running"]);
101echo"<tr><td colspan=\"5\"><b>Plánované akce</b></td></tr>";
102ShowEventList($Events["Planned"]);
103echo"</table>";
104
105
106
107?>
108
109
110
111
112
Note: See TracBrowser for help on using the repository browser.