1 | <?php
|
---|
2 |
|
---|
3 |
|
---|
4 | // page header, and any additional required libraries
|
---|
5 | require_once 'header.php';
|
---|
6 | // minimum permission to view page
|
---|
7 | valid_login($action_permission['read']);
|
---|
8 |
|
---|
9 | //#############################################################################
|
---|
10 | // EVENTS
|
---|
11 | //#############################################################################
|
---|
12 | function events()
|
---|
13 | {
|
---|
14 | global $output, $lang_events,
|
---|
15 | $realm_id, $world_db,
|
---|
16 | $itemperpage;
|
---|
17 |
|
---|
18 | $sqlw = new SQL;
|
---|
19 | $sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
|
---|
20 |
|
---|
21 | //-------------------SQL Injection Prevention--------------------------------
|
---|
22 | // this page has multipage support and field ordering, so we need these
|
---|
23 | $start = (isset($_GET['start'])) ? $sqlw->quote_smart($_GET['start']) : 0;
|
---|
24 | if (is_numeric($start)); else $start=0;
|
---|
25 |
|
---|
26 | $order_by = (isset($_GET['order_by'])) ? $sqlw->quote_smart($_GET['order_by']) : 'description';
|
---|
27 | if (preg_match('/^[_[:lower:]]{1,11}$/', $order_by)); else $order_by='description';
|
---|
28 |
|
---|
29 | $dir = (isset($_GET['dir'])) ? $sqlw->quote_smart($_GET['dir']) : 1;
|
---|
30 | if (preg_match('/^[01]{1}$/', $dir)); else $dir=1;
|
---|
31 |
|
---|
32 | $order_dir = ($dir) ? 'ASC' : 'DESC';
|
---|
33 | $dir = ($dir) ? 0 : 1;
|
---|
34 |
|
---|
35 | // for multipage support
|
---|
36 | $all_record = $sqlw->result($sqlw->query('SELECT count(*) FROM game_event WHERE start_time <> end_time'),0);
|
---|
37 |
|
---|
38 | // main data that we need for this page, game events
|
---|
39 | $result = $sqlw->query('SELECT description, start_time, occurence, length
|
---|
40 | FROM game_event WHERE start_time <> end_time ORDER BY '.$order_by.' '.$order_dir.' LIMIT '.$start.', '.$itemperpage.'');
|
---|
41 |
|
---|
42 | //---------------Page Specific Data Starts Here--------------------------
|
---|
43 | // we start with a lead of 10 spaces,
|
---|
44 | // because last line of header is an opening tag with 8 spaces
|
---|
45 | // keep html indent in sync, so debuging from browser source would be easy to read
|
---|
46 | $output .= '
|
---|
47 | <!-- start of events.php -->
|
---|
48 | <center>
|
---|
49 | <table class="top_hidden">
|
---|
50 | <tr>
|
---|
51 | <td width="25%" align="right">';
|
---|
52 |
|
---|
53 | // multi page links
|
---|
54 | $output .=
|
---|
55 | $lang_events['total'].' : '.$all_record.'<br /><br />'.
|
---|
56 | generate_pagination('events.php?order_by='.$order_by.'&dir='.(($dir) ? 0 : 1), $all_record, $itemperpage, $start);
|
---|
57 |
|
---|
58 | // column headers, with links for sorting
|
---|
59 | $output .= '
|
---|
60 | </td>
|
---|
61 | </tr>
|
---|
62 | </table>
|
---|
63 | <table class="lined">
|
---|
64 | <tr>
|
---|
65 | <th width="35%"><a href="events.php?order_by=description&start='.$start.'&dir='.$dir.'"'.($order_by==='description' ? ' class="'.$order_dir.'"' : '').'>'.$lang_events['descr'].'</a></th>
|
---|
66 | <th width="25%"><a href="events.php?order_by=start_time&start='.$start.'&dir='.$dir.'"'.($order_by==='start_time' ? ' class="'.$order_dir.'"' : '').'>'.$lang_events['start'].'</a></th>
|
---|
67 | <th width="20%"><a href="events.php?order_by=occurence&start='.$start.'&dir='.$dir.'"'.($order_by==='occurence' ? ' class="'.$order_dir.'"' : '').'>'.$lang_events['occur'].'</a></th>
|
---|
68 | <th width="20%"><a href="events.php?order_by=length&start='.$start.'&dir='.$dir.'"'.($order_by==='length' ? ' class="'.$order_dir.'"' : '').'>'.$lang_events['length'].'</a></th>
|
---|
69 | </tr>';
|
---|
70 |
|
---|
71 | while ($events = $sqlw->fetch_assoc($result))
|
---|
72 | {
|
---|
73 | $days = floor(round($events['occurence'] / 60) / 24);
|
---|
74 | $hours = round($events['occurence'] / 60) - ($days * 24);
|
---|
75 | $event_occurance = '';
|
---|
76 | if ($days)
|
---|
77 | $event_occurance .= $days.' days ';
|
---|
78 | if ($hours)
|
---|
79 | $event_occurance .= $hours.' hours';
|
---|
80 | $days = floor(round($events['length'] / 60) / 24);
|
---|
81 | $hours = round($events['length'] / 60) - ($days * 24);
|
---|
82 | $event_duration = '';
|
---|
83 | if ($days)
|
---|
84 | $event_duration .= $days.' days ';
|
---|
85 | if ($hours)
|
---|
86 | $event_duration .= $hours.' hours';
|
---|
87 |
|
---|
88 | $output .= '
|
---|
89 | <tr valign="top">
|
---|
90 | <td align="left">'.$events['description'].'</td>
|
---|
91 | <td>'.$events['start_time'].'</td>
|
---|
92 | <td>'.$event_occurance.'</td>
|
---|
93 | <td>'.$event_duration.'</td>
|
---|
94 | </tr>';
|
---|
95 | }
|
---|
96 | unset($event_duration);
|
---|
97 | unset($event_occurance);
|
---|
98 | unset($hours);
|
---|
99 | unset($days);
|
---|
100 | unset($events);
|
---|
101 | unset($result);
|
---|
102 |
|
---|
103 | $output .= '
|
---|
104 | <tr>
|
---|
105 | <td colspan="4" class="hidden" align="right" width="25%">';
|
---|
106 | // multi page links
|
---|
107 | $output .= generate_pagination('events.php?order_by='.$order_by.'&dir='.(($dir) ? 0 : 1), $all_record, $itemperpage, $start);
|
---|
108 | unset($start);
|
---|
109 | $output .= '
|
---|
110 | </td>
|
---|
111 | </tr>
|
---|
112 | <tr>
|
---|
113 | <td colspan="4" class="hidden" align="right">'.$lang_events['total'].' : '.$all_record.'</td>
|
---|
114 | </tr>
|
---|
115 | </table>
|
---|
116 | </center>
|
---|
117 | <!-- end of events.php -->';
|
---|
118 |
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | //#############################################################################
|
---|
123 | // MAIN
|
---|
124 | //#############################################################################
|
---|
125 |
|
---|
126 | // error variable reserved for future use
|
---|
127 | //$err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
|
---|
128 |
|
---|
129 | //unset($err);
|
---|
130 |
|
---|
131 | $lang_events = lang_events();
|
---|
132 |
|
---|
133 | $output .= '
|
---|
134 | <div class="top">
|
---|
135 | <h1>'.$lang_events['events'].'</h1>
|
---|
136 | </div>';
|
---|
137 |
|
---|
138 | // action variable reserved for future use
|
---|
139 | //$action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
140 |
|
---|
141 | events();
|
---|
142 |
|
---|
143 | //unset($action);
|
---|
144 | unset($action_permission);
|
---|
145 | unset($lang_events);
|
---|
146 |
|
---|
147 | require_once 'footer.php';
|
---|
148 |
|
---|
149 |
|
---|
150 | ?>
|
---|