forked from featherbb/featherbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbans.php
More file actions
186 lines (133 loc) · 6.37 KB
/
Copy pathbans.php
File metadata and controls
186 lines (133 loc) · 6.37 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/**
* Copyright (C) 2015 FeatherBB
* based on code by (C) 2008-2012 FluxBB
* and Rickard Andersson (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
namespace controller\admin;
class bans
{
public function __construct()
{
$this->feather = \Slim\Slim::getInstance();
$this->start = $this->feather->start;
$this->config = $this->feather->config;
$this->user = $this->feather->user;
$this->request = $this->feather->request;
$this->header = new \controller\header();
$this->footer = new \controller\footer();
$this->model = new \model\admin\bans();
}
public function __autoload($class_name)
{
require FEATHER_ROOT . $class_name . '.php';
}
public function display()
{
global $lang_common, $lang_admin_common, $lang_admin_bans;
define('FEATHER_ADMIN_CONSOLE', 1);
require FEATHER_ROOT . 'include/common_admin.php';
if ($this->user->g_id != FEATHER_ADMIN && ($this->user->g_moderator != '1' || $this->user->g_mod_ban_users == '0')) {
message($lang_common['No permission'], '403');
}
// Load the admin_bans.php language file
require FEATHER_ROOT . 'lang/' . $admin_language . '/bans.php';
// Display bans
if ($this->request->get('find_ban')) {
$ban_info = $this->model->find_ban();
// Determine the ban offset (based on $_GET['p'])
$num_pages = ceil($ban_info['num_bans'] / 50);
$p = (!$this->request->get('p') || $this->request->get('p') <= 1 || $this->request->get('p') > $num_pages) ? 1 : intval($this->request->get('p'));
$start_from = 50 * ($p - 1);
// Generate paging links
$paging_links = '<span class="pages-label">' . $lang_common['Pages'] . ' </span>' . paginate_old($num_pages, $p, '?find_ban=&' . implode('&', $ban_info['query_str']));
$page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans'], $lang_admin_bans['Results head']);
define('FEATHER_ACTIVE_PAGE', 'admin');
$this->header->setTitle($page_title)->setPage($p)->setPagingLinks($paging_links)->display();
$ban_data = $this->model->find_ban($start_from);
$this->feather->render('admin/bans/search_ban.php', array(
'lang_admin_bans' => $lang_admin_bans,
'lang_admin_common' => $lang_admin_common,
'ban_data' => $ban_data['data'],
)
);
$this->footer->display();
}
$page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']);
$focus_element = array('bans', 'new_ban_user');
define('FEATHER_ACTIVE_PAGE', 'admin');
$this->header->setTitle($page_title)->setFocusElement($focus_element)->display();
generate_admin_menu('bans');
$this->feather->render('admin/bans/admin_bans.php', array(
'lang_admin_bans' => $lang_admin_bans,
'lang_admin_common' => $lang_admin_common,
)
);
$this->footer->display();
}
public function add($id = null)
{
global $lang_common, $lang_admin_common, $lang_admin_bans;
define('FEATHER_ADMIN_CONSOLE', 1);
require FEATHER_ROOT . 'include/common_admin.php';
if ($this->user->g_id != FEATHER_ADMIN && ($this->user->g_moderator != '1' || $this->user->g_mod_ban_users == '0')) {
message($lang_common['No permission'], '403');
}
// Load the admin_bans.php language file
require FEATHER_ROOT . 'lang/' . $admin_language . '/bans.php';
if ($this->request->post('add_edit_ban')) {
$this->model->insert_ban();
}
$page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']);
$focus_element = array('bans2', 'ban_user');
define('FEATHER_ACTIVE_PAGE', 'admin');
$this->header->setTitle($page_title)->setFocusElement($focus_element)->display();
generate_admin_menu('bans');
$this->feather->render('admin/bans/add_ban.php', array(
'lang_admin_bans' => $lang_admin_bans,
'lang_admin_common' => $lang_admin_common,
'ban' => $this->model->add_ban_info($id),
)
);
$this->footer->display();
}
public function delete($id)
{
global $lang_common, $lang_admin_common, $lang_admin_bans;
require FEATHER_ROOT . 'include/common_admin.php';
if ($this->user->g_id != FEATHER_ADMIN && ($this->user->g_moderator != '1' || $this->user->g_mod_ban_users == '0')) {
message($lang_common['No permission'], '403');
}
// Load the admin_bans.php language file
require FEATHER_ROOT . 'lang/' . $admin_language . '/bans.php';
// Remove the ban
$this->model->remove_ban($id);
}
public function edit($id)
{
global $lang_common, $lang_admin_common, $lang_admin_bans;
define('FEATHER_ADMIN_CONSOLE', 1);
require FEATHER_ROOT . 'include/common_admin.php';
if ($this->user->g_id != FEATHER_ADMIN && ($this->user->g_moderator != '1' || $this->user->g_mod_ban_users == '0')) {
message($lang_common['No permission'], '403');
}
// Load the admin_bans.php language file
require FEATHER_ROOT . 'lang/' . $admin_language . '/bans.php';
if ($this->request->post('add_edit_ban')) {
$this->model->insert_ban();
}
$page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']);
$focus_element = array('bans2', 'ban_user');
define('FEATHER_ACTIVE_PAGE', 'admin');
$this->header->setTitle($page_title)->setFocusElement($focus_element)->display();
generate_admin_menu('bans');
$this->feather->render('admin/bans/add_ban.php', array(
'lang_admin_bans' => $lang_admin_bans,
'lang_admin_common' => $lang_admin_common,
'ban' => $this->model->edit_ban_info($id),
)
);
$this->footer->display();
}
}