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