forked from featherbb/featherbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.php
More file actions
232 lines (170 loc) · 6.7 KB
/
misc.php
File metadata and controls
232 lines (170 loc) · 6.7 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?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;
class misc
{
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\misc();
}
public function __autoload($class_name)
{
require FEATHER_ROOT . $class_name . '.php';
}
public function rules()
{
global $lang_common;
if ($this->config['o_rules'] == '0' || ($this->user->is_guest && $this->user->g_read_board == '0' && $this->config['o_regs_allow'] == '0')) {
message($lang_common['Bad request'], '404');
}
// Load the register.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/register.php';
$page_title = array(feather_escape($this->config['o_board_title']), $lang_register['Forum rules']);
define('FEATHER_ACTIVE_PAGE', 'rules');
$this->feather->render('misc/rules.php', array(
'lang_register' => $lang_register,
'feather_config' => $this->config,
)
);
$this->footer->display();
}
public function markread()
{
global $lang_common;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$this->model->update_last_visit();
// Reset tracked topics
set_tracked_topics(null);
redirect(get_base_url(), $lang_misc['Mark read redirect']);
}
public function markforumread($id)
{
global $lang_common;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$tracked_topics = get_tracked_topics();
$tracked_topics['forums'][$id] = time();
set_tracked_topics($tracked_topics);
redirect(get_link('forum/'.$id.'/'), $lang_misc['Mark forum read redirect']);
}
public function subscribeforum($id)
{
global $lang_common, $lang_misc;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$this->model->subscribe_forum($id);
}
public function subscribetopic($id)
{
global $lang_common, $lang_misc;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$this->model->subscribe_topic($id);
}
public function unsubscribeforum($id)
{
global $lang_common, $lang_misc;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$this->model->unsubscribe_forum($id);
}
public function unsubscribetopic($id)
{
global $lang_common, $lang_misc;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$this->model->unsubscribe_topic($id);
}
public function email($id)
{
global $lang_common;
if ($this->user->is_guest || $this->user->g_send_email == '0') {
message($lang_common['No permission'], '403');
}
if ($id < 2) {
message($lang_common['Bad request'], '404');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
$mail = $this->model->get_info_mail($id);
if ($mail['email_setting'] == 2 && !$this->user->is_admmod) {
message($lang_misc['Form email disabled']);
}
if ($this->feather->request()->isPost()) {
$this->model->send_email($mail, $id);
}
$page_title = array(feather_escape($this->config['o_board_title']), $lang_misc['Send email to'].' '.feather_escape($mail['recipient']));
$required_fields = array('req_subject' => $lang_misc['Email subject'], 'req_message' => $lang_misc['Email message']);
$focus_element = array('email', 'req_subject');
define('FEATHER_ACTIVE_PAGE', 'email');
$this->header->setTitle($page_title)->setFocusElement($focus_element)->setRequiredFields($required_fields)->display();
$this->feather->render('misc/email.php', array(
'lang_misc' => $lang_misc,
'id' => $id,
'mail' => $mail,
)
);
$this->footer->display();
}
public function report($id)
{
global $lang_common;
if ($this->user->is_guest) {
message($lang_common['No permission'], '403');
}
// Load the misc.php language file
require FEATHER_ROOT.'lang/'.$this->user->language.'/misc.php';
if ($this->feather->request()->isPost()) {
$this->model->insert_report($id);
}
// Fetch some info about the post, the topic and the forum
$cur_post = $this->model->get_info_report($id);
if ($this->config['o_censoring'] == '1') {
$cur_post['subject'] = censor_words($cur_post['subject']);
}
$page_title = array(feather_escape($this->config['o_board_title']), $lang_misc['Report post']);
$required_fields = array('req_reason' => $lang_misc['Reason']);
$focus_element = array('report', 'req_reason');
define('FEATHER_ACTIVE_PAGE', 'report');
$this->header->setTitle($page_title)->setFocusElement($focus_element)->setRequiredFields($required_fields)->display();
$this->feather->render('misc/report.php', array(
'lang_misc' => $lang_misc,
'id' => $id,
'lang_common' => $lang_common,
'cur_post' => $cur_post,
)
);
$this->footer->display();
}
}