Skip to content

Commit 53451f7

Browse files
committed
Massive rewrite
1 parent 384c7ab commit 53451f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+134
-150
lines changed

extern.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,13 +671,13 @@ function output_html($feed)
671671
}
672672

673673
// Prepend the current base URL onto some links. Done after caching to handle http/https correctly
674-
$feed['link'] = $feather->url->base(true).$feed['link'];
674+
$feed['link'] = Container::get('url')->base(true).$feed['link'];
675675

676676
foreach ($feed['items'] as $key => $item) {
677-
$feed['items'][$key]['link'] = $feather->url->base(true).$item['link'];
677+
$feed['items'][$key]['link'] = Container::get('url')->base(true).$item['link'];
678678

679679
if (isset($item['author']['uri'])) {
680-
$feed['items'][$key]['author']['uri'] = $feather->url->base(true).$item['author']['uri'];
680+
$feed['items'][$key]['author']['uri'] = Container::get('url')->base(true).$item['author']['uri'];
681681
}
682682
}
683683

featherbb/Controller/Admin/Maintenance.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function display()
2626
Container::get('hooks')->fire('controller.admin.maintenance.display');
2727

2828
$action = '';
29-
if ($this->feather->request->post('action')) {
30-
$action = $this->feather->request->post('action');
29+
if (Input::post('action')) {
30+
$action = Input::post('action');
3131
} elseif ($this->feather->request->get('action')) {
3232
$action = $this->feather->request->get('action');
3333
}
@@ -43,12 +43,12 @@ public function display()
4343
}
4444

4545
if ($action == 'prune') {
46-
$prune_from = Utils::trim($this->feather->request->post('prune_from'));
47-
$prune_sticky = intval($this->feather->request->post('prune_sticky'));
46+
$prune_from = Utils::trim(Input::post('prune_from'));
47+
$prune_sticky = intval(Input::post('prune_sticky'));
4848

4949
AdminUtils::generateAdminMenu('maintenance');
5050

51-
if ($this->feather->request->post('prune_comply')) {
51+
if (Input::post('prune_comply')) {
5252
$this->model->prune_comply($prune_from, $prune_sticky);
5353
}
5454

featherbb/Controller/Auth.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function login($req, $res, $args)
3232

3333
if (Request::isPost()) {
3434
Container::get('hooks')->fire('controller.login');
35-
$form_username = Utils::trim($this->feather->request->post('req_username'));
36-
$form_password = Utils::trim($this->feather->request->post('req_password'));
37-
$save_pass = (bool) $this->feather->request->post('save_pass');
35+
$form_username = Utils::trim(Input::post('req_username'));
36+
$form_password = Utils::trim(Input::post('req_password'));
37+
$save_pass = (bool) Input::post('save_pass');
3838

3939
$user = ModelAuth::get_user_from_name($form_username);
4040

@@ -48,7 +48,7 @@ public function login($req, $res, $args)
4848
}
4949
}
5050

51-
ModelAuth::delete_online_by_ip($this->feather->request->getIp());
51+
ModelAuth::delete_online_by_ip(Utils::getIp());
5252
// Reset tracked topics
5353
Track::set_tracked_topics(null);
5454

@@ -75,7 +75,7 @@ public function logout($req, $res, $args)
7575
{
7676
$token = Container::get('hooks')->fire('controller.logout', $args['token']);
7777

78-
if (Container::get('user')->is_guest || !isset($token) || $token != Random::hash(Container::get('user')->id.Random::hash($this->feather->request->getIp()))) {
78+
if (Container::get('user')->is_guest || !isset($token) || $token != Random::hash(Container::get('user')->id.Random::hash(Utils::getIp()))) {
7979
Router::redirect(Router::pathFor('home'), 'Not logged in');
8080
}
8181

@@ -100,8 +100,8 @@ public function forget($req, $res, $args)
100100

101101
if (Request::isPost()) {
102102
// Validate the email address
103-
$email = strtolower(Utils::trim($this->feather->request->post('req_email')));
104-
if (!$this->feather->email->is_valid_email($email)) {
103+
$email = strtolower(Utils::trim(Input::post('req_email')));
104+
if (!Container::get('email')->is_valid_email($email)) {
105105
throw new Error(__('Invalid email'), 400);
106106
}
107107
$user = ModelAuth::get_user_from_email($email);
@@ -138,7 +138,7 @@ public function forget($req, $res, $args)
138138
$cur_mail_message = str_replace('<new_password>', $new_password, $cur_mail_message);
139139
$cur_mail_message = Container::get('hooks')->fire('controller.cur_mail_message_password_forgotten', $cur_mail_message);
140140

141-
$this->feather->email->feather_mail($email, $mail_subject, $cur_mail_message);
141+
Container::get('email')->feather_mail($email, $mail_subject, $cur_mail_message);
142142

143143
Router::redirect(Router::pathFor('home'), __('Forget mail').' <a href="mailto:'.Utils::escape(Config::get('forum_settings')['o_admin_email']).'">'.Utils::escape(Config::get('forum_settings')['o_admin_email']).'</a>.', 200);
144144
} else {

featherbb/Controller/Forum.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ public function dealposts($req, $res, $args)
179179
$topicModel = new \FeatherBB\Model\Topic();
180180

181181
// Move one or more topics
182-
if ($this->feather->request->post('move_topics') || $this->feather->request->post('move_topics_to')) {
183-
$topics = $this->feather->request->post('topics') ? $this->feather->request->post('topics') : array();
182+
if (Input::post('move_topics') || Input::post('move_topics_to')) {
183+
$topics = Input::post('topics') ? Input::post('topics') : array();
184184
if (empty($topics)) {
185185
throw new Error(__('No topics selected'), 400);
186186
}
187187

188-
if ($new_fid = $this->feather->request->post('move_to_forum')) {
188+
if ($new_fid = Input::post('move_to_forum')) {
189189
$topics = explode(',', $topics);
190190
$topicModel->move_to($args['fid'], $new_fid, $topics);
191191
Router::redirect(Router::pathFor('Forum', ['id' => $new_fid]), __('Move topics redirect'));
@@ -208,13 +208,13 @@ public function dealposts($req, $res, $args)
208208
}
209209

210210
// Merge two or more topics
211-
elseif ($this->feather->request->post('merge_topics') || $this->feather->request->post('merge_topics_comply')) {
212-
if ($this->feather->request->post('merge_topics_comply')) {
211+
elseif (Input::post('merge_topics') || Input::post('merge_topics_comply')) {
212+
if (Input::post('merge_topics_comply')) {
213213
$this->model->merge_topics($args['fid']);
214214
Router::redirect(Router::pathFor('Forum', array('id' => $args['fid'])), __('Merge topics redirect'));
215215
}
216216

217-
$topics = $this->feather->request->post('topics') ? $this->feather->request->post('topics') : array();
217+
$topics = Input::post('topics') ? Input::post('topics') : array();
218218
if (count($topics) < 2) {
219219
throw new Error(__('Not enough topics selected'), 400);
220220
}
@@ -229,13 +229,13 @@ public function dealposts($req, $res, $args)
229229
}
230230

231231
// Delete one or more topics
232-
elseif ($this->feather->request->post('delete_topics') || $this->feather->request->post('delete_topics_comply')) {
233-
$topics = $this->feather->request->post('topics') ? $this->feather->request->post('topics') : array();
232+
elseif (Input::post('delete_topics') || Input::post('delete_topics_comply')) {
233+
$topics = Input::post('topics') ? Input::post('topics') : array();
234234
if (empty($topics)) {
235235
throw new Error(__('No topics selected'), 400);
236236
}
237237

238-
if ($this->feather->request->post('delete_topics_comply')) {
238+
if (Input::post('delete_topics_comply')) {
239239
$this->model->delete_topics($topics, $args['fid']);
240240
Router::redirect(Router::pathFor('Forum', array('id' => $args['fid'])), __('Delete topics redirect'));
241241
}
@@ -251,12 +251,12 @@ public function dealposts($req, $res, $args)
251251

252252

253253
// Open or close one or more topics
254-
elseif ($this->feather->request->post('open') || $this->feather->request->post('close')) {
255-
$action = ($this->feather->request->post('open')) ? 0 : 1;
254+
elseif (Input::post('open') || Input::post('close')) {
255+
$action = (Input::post('open')) ? 0 : 1;
256256

257257
// There could be an array of topic IDs in $_POST
258-
if ($this->feather->request->post('open') || $this->feather->request->post('close')) {
259-
$topics = $this->feather->request->post('topics') ? @array_map('intval', @array_keys($this->feather->request->post('topics'))) : array();
258+
if (Input::post('open') || Input::post('close')) {
259+
$topics = Input::post('topics') ? @array_map('intval', @array_keys(Input::post('topics'))) : array();
260260
if (empty($topics)) {
261261
throw new Error(__('No topics selected'), 400);
262262
}

featherbb/Controller/Post.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function newpost($fid = null, $tid = null, $qid = null)
4444
$index_questions = rand(0, count($lang_antispam_questions)-1);
4545

4646
// If $_POST['username'] is filled, we are facing a bot
47-
if ($this->feather->request->post('username')) {
47+
if (Input::post('username')) {
4848
throw new Error(__('Bad request'), 400);
4949
}
5050

@@ -79,14 +79,14 @@ public function newpost($fid = null, $tid = null, $qid = null)
7979
if ($this->feather->request()->isPost()) {
8080

8181
// Include $pid and $page if needed for confirm_referrer function called in check_errors_before_post()
82-
if ($this->feather->request->post('pid')) {
83-
$pid = $this->feather->request->post('pid');
82+
if (Input::post('pid')) {
83+
$pid = Input::post('pid');
8484
} else {
8585
$pid = '';
8686
}
8787

88-
if ($this->feather->request->post('page')) {
89-
$page = $this->feather->request->post('page');
88+
if (Input::post('page')) {
89+
$page = Input::post('page');
9090
} else {
9191
$page = '';
9292
}
@@ -98,7 +98,7 @@ public function newpost($fid = null, $tid = null, $qid = null)
9898
$post = $this->model->setup_variables($errors, $is_admmod);
9999

100100
// Did everything go according to plan?
101-
if (empty($errors) && !$this->feather->request->post('preview')) {
101+
if (empty($errors) && !Input::post('preview')) {
102102
// If it's a reply
103103
if ($tid) {
104104
// Insert the reply, get the new_pid
@@ -298,7 +298,7 @@ public function editpost($id)
298298
$post = $this->model->setup_edit_variables($cur_post, $is_admmod, $can_edit_subject, $errors);
299299

300300
// Did everything go according to plan?
301-
if (empty($errors) && !$this->feather->request->post('preview')) {
301+
if (empty($errors) && !Input::post('preview')) {
302302
Container::get('hooks')->fire('controller.post.edit.valid', $id);
303303
// Edit the post
304304
$this->model->edit_post($id, $can_edit_subject, $post, $cur_post, $is_admmod);
@@ -309,7 +309,7 @@ public function editpost($id)
309309
$post = '';
310310
}
311311

312-
if ($this->feather->request->post('preview')) {
312+
if (Input::post('preview')) {
313313
$preview_message = $this->feather->parser->parse_message($post['message'], $post['hide_smilies']);
314314
$preview_message = Container::get('hooks')->fire('controller.post.edit.preview', $preview_message);
315315
} else {

featherbb/Controller/Topic.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function move($tid, $name = '', $fid)
172172
{
173173
$tid = Container::get('hooks')->fire('controller.topic.move', $tid);
174174

175-
if ($new_fid = $this->feather->request->post('move_to_forum')) {
175+
if ($new_fid = Input::post('move_to_forum')) {
176176
$this->model->move_to($fid, $new_fid, $tid);
177177
Router::redirect(Router::pathFor('Topic', array('id' => $tid, 'name' => $name)), __('Move topic redirect'));
178178
}
@@ -215,7 +215,7 @@ public function moderate($id = null, $fid = null, $page = null)
215215
$start_from = Container::get('user')->disp_posts * ($p - 1);
216216

217217
// Delete one or more posts
218-
if ($this->feather->request->post('delete_posts') || $this->feather->request->post('delete_posts_comply')) {
218+
if (Input::post('delete_posts') || Input::post('delete_posts_comply')) {
219219
$posts = $this->model->delete_posts($id, $fid);
220220

221221
View::setPageInfo(array(
@@ -225,7 +225,7 @@ public function moderate($id = null, $fid = null, $page = null)
225225
)
226226
)->addTemplate('moderate/delete_posts.php')->display();
227227
}
228-
if ($this->feather->request->post('split_posts') || $this->feather->request->post('split_posts_comply')) {
228+
if (Input::post('split_posts') || Input::post('split_posts_comply')) {
229229

230230
View::setPageInfo(array(
231231
'title' => array(Utils::escape($this->feather->config['o_board_title']), __('Moderate')),

featherbb/Core/Email.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class Email
1313
{
1414
public function __construct()
1515
{
16-
$this->feather = \Slim\Slim::getInstance();
17-
$this->config = $this->feather->config;
1816
require Config::get('forum_env')['FEATHER_ROOT'] . 'featherbb/Helpers/utf8/utils/ascii.php';
1917
}
2018

featherbb/Core/Utils.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,20 @@ public static function generate_avatar_markup($user_id)
313313
$path = Container::get('config')['o_avatars_dir'].'/'.$user_id.'.'.$cur_type;
314314

315315
if (file_exists(Config::get('forum_env')['FEATHER_ROOT'].$path) && $img_size = getimagesize(Config::get('forum_env')['FEATHER_ROOT'].$path)) {
316-
//$avatar_markup = '<img src="proxy.php?url=https%3A%2F%2Fgithub.com%2F%27.%5CFeatherBB%5CCore%5CUtils%3A%3Aescape%28%3Cspan+class%3D"x x-first x-last">$feather->url->base(true).'/'.$path.'?m='.filemtime(Config::get('forum_env')['FEATHER_ROOT'].$path)).'" '.$img_size[3].' alt="" />'; TODO
316+
$avatar_markup = '<img src="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%5C%3Cspan+class%3D"pl-v">FeatherBB\Core\Utils::escape(Container::get('url')->base(true).'/'.$path.'?m='.filemtime(Config::get('forum_env')['FEATHER_ROOT'].$path)).'" '.$img_size[3].' alt="" />';
317317
break;
318318
}
319319
}
320320

321321
return $avatar_markup;
322322
}
323+
324+
//
325+
// Get IP Address
326+
//
327+
public static function getIp()
328+
{
329+
// TODO: IP proxy
330+
return Request::getServerParams()['REMOTE_ADDR'];
331+
}
323332
}

featherbb/Model/Admin/Bans.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct()
2525
$this->user = Container::get('user');
2626
$this->request = $this->feather->request;
2727
Container::get('hooks') = $this->feather->hooks;
28-
$this->email = $this->feather->email;
28+
$this->email = Container::get('email');
2929
}
3030

3131
public function add_ban_info($id = null)

featherbb/Model/Admin/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct()
2525
$this->user = Container::get('user');
2626
$this->request = $this->feather->request;
2727
Container::get('hooks') = $this->feather->hooks;
28-
$this->email = $this->feather->email;
28+
$this->email = Container::get('email');
2929
}
3030

3131
public function update_options()

0 commit comments

Comments
 (0)