1 | <?php
|
---|
2 | /*
|
---|
3 | * Project Name: Event Module for MiniManager for Mangos Server
|
---|
4 | * Date: 17.11.2007 version (0.0.2)
|
---|
5 | * Author: Den Wailhorn
|
---|
6 | * Edited by Shnappie to
|
---|
7 | * show days/hours instead of hours only
|
---|
8 | * make clickable orderings
|
---|
9 | * remove events with same start and end date
|
---|
10 | */
|
---|
11 | require_once("header.php");
|
---|
12 | valid_login(1);
|
---|
13 |
|
---|
14 | /*--------------------------------------------------*/
|
---|
15 |
|
---|
16 | function do_search() {
|
---|
17 | global $lang_global, $lang_events, $output, $mangos_db, $realm_id;
|
---|
18 |
|
---|
19 | $sql = new SQL;
|
---|
20 | $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
21 |
|
---|
22 | $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0;
|
---|
23 | $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) :"description";
|
---|
24 | $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1;
|
---|
25 | $order_dir = ($dir) ? "ASC" : "DESC";
|
---|
26 | $dir = ($dir) ? 0 : 1;
|
---|
27 |
|
---|
28 | $result = $sql->query("SELECT `description`, `start`, `end`, `occurence`, `length` FROM `game_event` WHERE `start` <> `end` ORDER BY $order_by $order_dir");
|
---|
29 | $total_found = $sql->num_rows($result);
|
---|
30 |
|
---|
31 | $output .= "<center><table class=\"top_hidden\">
|
---|
32 | <tr><td>";
|
---|
33 | $output .= "</td>
|
---|
34 | <td align=\"right\">{$lang_events['total']}: $total_found</td>
|
---|
35 | </tr></table>";
|
---|
36 |
|
---|
37 | $output .= "<table class=\"lined\">
|
---|
38 | <tr>
|
---|
39 | <th width=\"35%\"><a href=\"events.php?order_by=description&start=$start&dir=$dir\">".($order_by=='description' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_events['descr']}</a></th>
|
---|
40 | <th width=\"25%\"><a href=\"events.php?order_by=start&start=$start&dir=$dir\">".($order_by=='start' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_events['start']}</a></th>
|
---|
41 | <th width=\"20%\"><a href=\"events.php?order_by=occurence&start=$start&dir=$dir\">".($order_by=='occurence' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_events['occur']}</a></th>
|
---|
42 | <th width=\"20%\"><a href=\"events.php?order_by=length&start=$start&dir=$dir\">".($order_by=='length' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_events['length']}</a></th>
|
---|
43 | </tr>";
|
---|
44 |
|
---|
45 | for ($i=1; $i<=$total_found; $i++){
|
---|
46 | $events = $sql->fetch_array($result);
|
---|
47 |
|
---|
48 | $days = floor(round($events['occurence'] / 60)/24);
|
---|
49 | $hours = round($events['occurence'] / 60) - ($days * 24);
|
---|
50 | $event_occurance = "";
|
---|
51 | if ($days > 0) {
|
---|
52 | $event_occurance .= $days;
|
---|
53 | $event_occurance .= " days ";
|
---|
54 | }
|
---|
55 | if ($hours > 0){
|
---|
56 | $event_occurance .= $hours;
|
---|
57 | $event_occurance .= " hours";
|
---|
58 | }
|
---|
59 |
|
---|
60 | $days = floor(round($events['length'] / 60)/24);
|
---|
61 | $hours = round($events['length'] / 60) - ($days * 24);
|
---|
62 | $event_duration = "";
|
---|
63 | if ($days > 0) {
|
---|
64 | $event_duration .= $days;
|
---|
65 | $event_duration .= " days ";
|
---|
66 | }
|
---|
67 | if ($hours > 0){
|
---|
68 | $event_duration .= $hours;
|
---|
69 | $event_duration .= " hours";
|
---|
70 | }
|
---|
71 |
|
---|
72 | $output .= "<tr valign=top>
|
---|
73 | <td align=left>$events[description]</td>
|
---|
74 | <td>".$events['start']."</td>
|
---|
75 | <td>$event_occurance</td>
|
---|
76 | <td>$event_duration</td>
|
---|
77 | </tr>";
|
---|
78 | }
|
---|
79 | $output .= "</table></center><br />";
|
---|
80 |
|
---|
81 | $sql->close();
|
---|
82 | }
|
---|
83 |
|
---|
84 | /*--------------------------------------------------*/
|
---|
85 |
|
---|
86 | $err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
|
---|
87 |
|
---|
88 | $output .= "<div class=\"top\"><h1>$lang_events[events]</h1></div>";
|
---|
89 |
|
---|
90 | $action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
91 |
|
---|
92 | switch ($action) {
|
---|
93 | case "do_search":
|
---|
94 | do_search();
|
---|
95 | break;
|
---|
96 | default:
|
---|
97 | do_search();
|
---|
98 | }
|
---|
99 |
|
---|
100 | require_once("footer.php");
|
---|
101 | ?>
|
---|