forked from ghmadalin/Minimanager-for-TrinityCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstances.php
More file actions
165 lines (137 loc) · 6.38 KB
/
instances.php
File metadata and controls
165 lines (137 loc) · 6.38 KB
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
156
157
158
159
160
161
162
163
164
165
<?php
/*
* Copyright (C) 2010-2011 TrinityScripts <http://www.trinityscripts.xe.cx/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// 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 map, level_min, level_max
FROM instance_template JOIN access_requirement ON access_requirement.id = instance_template.access_id
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="30%"><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="30%"><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>
</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>'.get_map_name($instances['map'], $sqlm).' ('.$instances['map'].')</td>
<td>'.$instances['level_min'].'</td>
<td>'.$instances['level_max'].'</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';
?>