Skip to content

Commit 63c09c6

Browse files
committed
Use utils::
1 parent 35098a0 commit 63c09c6

File tree

283 files changed

+1569
-12821
lines changed

Some content is hidden

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

283 files changed

+1569
-12821
lines changed

extern.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function featherbb_write_cache_file($file, $content)
8787
{
8888
$fh = @fopen(FORUM_CACHE_DIR.$file, 'wb');
8989
if (!$fh) {
90-
error('Unable to write cache file '.$feather->utils->escape($file).' to cache directory. Please make sure PHP has write access to the directory \''.$feather->utils->escape(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
90+
die('Unable to write cache file '.Utils::escape($file).' to cache directory. Please make sure PHP has write access to the directory \''.Utils::escape(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
9191
}
9292

9393
flock($fh, LOCK_EX);
@@ -224,7 +224,7 @@ function authenticate_user($user, $password, $password_is_hash = false)
224224

225225
if (!isset($feather->user->id) ||
226226
($password_is_hash && $password != $feather->user->password) ||
227-
(!$password_is_hash && \FeatherBB\Utils::feather_hash($password) != $feather->user->password)) {
227+
(!$password_is_hash && \FeatherBB\Utils::hash($password) != $feather->user->password)) {
228228
set_default_user();
229229
} else {
230230
$feather->user->is_guest = false;
@@ -286,9 +286,9 @@ function output_rss($feed)
286286
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
287287
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
288288
echo "\t".'<channel>'."\n";
289-
echo "\t\t".'<atom:link href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$feather->utils->escape(get_current_url()).'" rel="self" type="application/rss+xml" />'."\n";
289+
echo "\t\t".'<atom:link href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Utils::escape(get_current_url()).'" rel="self" type="application/rss+xml" />'."\n";
290290
echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
291-
echo "\t\t".'<link>'.$feather->utils->escape($feed['link']).'</link>'."\n";
291+
echo "\t\t".'<link>'.Utils::escape($feed['link']).'</link>'."\n";
292292
echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\n";
293293
echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\n";
294294

@@ -301,11 +301,11 @@ function output_rss($feed)
301301
foreach ($feed['items'] as $item) {
302302
echo "\t\t".'<item>'."\n";
303303
echo "\t\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
304-
echo "\t\t\t".'<link>'.$feather->utils->escape($item['link']).'</link>'."\n";
304+
echo "\t\t\t".'<link>'.Utils::escape($item['link']).'</link>'."\n";
305305
echo "\t\t\t".'<description><![CDATA['.escape_cdata($item['description']).']]></description>'."\n";
306306
echo "\t\t\t".'<author><![CDATA['.(isset($item['author']['email']) ? escape_cdata($item['author']['email']) : '[email protected]').' ('.escape_cdata($item['author']['name']).')]]></author>'."\n";
307307
echo "\t\t\t".'<pubDate>'.gmdate('r', $item['pubdate']).'</pubDate>'."\n";
308-
echo "\t\t\t".'<guid>'.$feather->utils->escape($item['link']).'</guid>'."\n";
308+
echo "\t\t\t".'<guid>'.Utils::escape($item['link']).'</guid>'."\n";
309309

310310
echo "\t\t".'</item>'."\n";
311311
}
@@ -330,8 +330,8 @@ function output_atom($feed)
330330
echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
331331

332332
echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
333-
echo "\t".'<link rel="self" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$feather->utils->escape(get_current_url()).'"/>'."\n";
334-
echo "\t".'<link href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$feather->utils->escape($feed['link']).'"/>'."\n";
333+
echo "\t".'<link rel="self" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Utils::escape(get_current_url()).'"/>'."\n";
334+
echo "\t".'<link href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Utils::escape($feed['link']).'"/>'."\n";
335335
echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\n";
336336

337337
if ($feather->forum_settings['o_show_version'] == '1') {
@@ -340,14 +340,14 @@ function output_atom($feed)
340340
echo "\t".'<generator>FluxBB</generator>'."\n";
341341
}
342342

343-
echo "\t".'<id>'.$feather->utils->escape($feed['link']).'</id>'."\n";
343+
echo "\t".'<id>'.Utils::escape($feed['link']).'</id>'."\n";
344344

345345
$content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary';
346346

347347
foreach ($feed['items'] as $item) {
348348
echo "\t".'<entry>'."\n";
349349
echo "\t\t".'<title type="html"><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
350-
echo "\t\t".'<link rel="alternate" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$feather->utils->escape($item['link']).'"/>'."\n";
350+
echo "\t\t".'<link rel="alternate" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Utils::escape($item['link']).'"/>'."\n";
351351
echo "\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($item['description']).']]></'.$content_tag.'>'."\n";
352352
echo "\t\t".'<author>'."\n";
353353
echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
@@ -357,13 +357,13 @@ function output_atom($feed)
357357
}
358358

359359
if (isset($item['author']['uri'])) {
360-
echo "\t\t\t".'<uri>'.$feather->utils->escape($item['author']['uri']).'</uri>'."\n";
360+
echo "\t\t\t".'<uri>'.Utils::escape($item['author']['uri']).'</uri>'."\n";
361361
}
362362

363363
echo "\t\t".'</author>'."\n";
364364
echo "\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).'</updated>'."\n";
365365

366-
echo "\t\t".'<id>'.$feather->utils->escape($item['link']).'</id>'."\n";
366+
echo "\t\t".'<id>'.Utils::escape($item['link']).'</id>'."\n";
367367
echo "\t".'</entry>'."\n";
368368
}
369369

@@ -384,15 +384,15 @@ function output_xml($feed)
384384

385385
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
386386
echo '<source>'."\n";
387-
echo "\t".'<url>'.$feather->utils->escape($feed['link']).'</url>'."\n";
387+
echo "\t".'<url>'.Utils::escape($feed['link']).'</url>'."\n";
388388

389389
$forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
390390

391391
foreach ($feed['items'] as $item) {
392392
echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n";
393393

394394
echo "\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
395-
echo "\t\t".'<link>'.$feather->utils->escape($item['link']).'</link>'."\n";
395+
echo "\t\t".'<link>'.Utils::escape($item['link']).'</link>'."\n";
396396
echo "\t\t".'<content><![CDATA['.escape_cdata($item['description']).']]></content>'."\n";
397397
echo "\t\t".'<author>'."\n";
398398
echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
@@ -402,7 +402,7 @@ function output_xml($feed)
402402
}
403403

404404
if (isset($item['author']['uri'])) {
405-
echo "\t\t\t".'<uri>'.$feather->utils->escape($item['author']['uri']).'</uri>'."\n";
405+
echo "\t\t\t".'<uri>'.Utils::escape($item['author']['uri']).'</uri>'."\n";
406406
}
407407

408408
echo "\t\t".'</author>'."\n";
@@ -428,12 +428,12 @@ function output_html($feed)
428428

429429
foreach ($feed['items'] as $item) {
430430
if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH) {
431-
$subject_truncated = $feather->utils->escape($feather->utils->trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'';
431+
$subject_truncated = Utils::escape($feather->utils->trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'';
432432
} else {
433-
$subject_truncated = $feather->utils->escape($item['title']);
433+
$subject_truncated = Utils::escape($item['title']);
434434
}
435435

436-
echo '<li><a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$feather->utils->escape($item['link']).'" title="'.$feather->utils->escape($item['title']).'">'.$subject_truncated.'</a></li>'."\n";
436+
echo '<li><a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Utils::escape($item['link']).'" title="'.Utils::escape($item['title']).'">'.$subject_truncated.'</a></li>'."\n";
437437
}
438438
}
439439

@@ -700,7 +700,7 @@ function output_html($feed)
700700

701701
foreach ($result as $feather_user_online) {
702702
if ($feather_user_online['user_id'] > 1) {
703-
$users[] = ($feather->user->g_view_users == '1') ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-en">get('user/'.$feather_user_online['user_id'].'/').'">'.$feather->utils->escape($feather_user_online['ident']).'</a>' : $feather->utils->escape($feather_user_online['ident']);
703+
$users[] = ($feather->user->g_view_users == '1') ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-en">get('user/'.$feather_user_online['user_id'].'/').'">'.Utils::escape($feather_user_online['ident']).'</a>' : Utils::escape($feather_user_online['ident']);
704704
++$num_users;
705705
} else {
706706
++$num_guests;
@@ -713,12 +713,12 @@ function output_html($feed)
713713
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
714714
header('Pragma: public');
715715

716-
echo sprintf(__('Guests online'), $feather->utils->forum_number_format($num_guests)).'<br />'."\n";
716+
echo sprintf(__('Guests online'), Utils::forum_number_format($num_guests)).'<br />'."\n";
717717

718718
if ($action == 'online_full' && !empty($users)) {
719719
echo sprintf(__('Users online'), implode(', ', $users)).'<br />'."\n";
720720
} else {
721-
echo sprintf(__('Users online'), $feather->utils->forum_number_format($num_users)).'<br />'."\n";
721+
echo sprintf(__('Users online'), Utils::forum_number_format($num_users)).'<br />'."\n";
722722
}
723723

724724
exit;
@@ -747,10 +747,10 @@ function output_html($feed)
747747
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
748748
header('Pragma: public');
749749

750-
echo sprintf(__('No of users'), $feather->utils->forum_number_format($stats['total_users'])).'<br />'."\n";
751-
echo sprintf(__('Newest user'), (($feather->user->g_view_users == '1') ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-en">get('user/'.$stats['last_user']['id'].'/').'">'.$feather->utils->escape($stats['last_user']['username']).'</a>' : $feather->utils->escape($stats['last_user']['username']))).'<br />'."\n";
752-
echo sprintf(__('No of topics'), $feather->utils->forum_number_format($stats['total_topics'])).'<br />'."\n";
753-
echo sprintf(__('No of posts'), $feather->utils->forum_number_format($stats['total_posts'])).'<br />'."\n";
750+
echo sprintf(__('No of users'), Utils::forum_number_format($stats['total_users'])).'<br />'."\n";
751+
echo sprintf(__('Newest user'), (($feather->user->g_view_users == '1') ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-en">get('user/'.$stats['last_user']['id'].'/').'">'.Utils::escape($stats['last_user']['username']).'</a>' : Utils::escape($stats['last_user']['username']))).'<br />'."\n";
752+
echo sprintf(__('No of topics'), Utils::forum_number_format($stats['total_topics'])).'<br />'."\n";
753+
echo sprintf(__('No of posts'), Utils::forum_number_format($stats['total_posts'])).'<br />'."\n";
754754

755755
exit;
756756
}

featherbb/Controller/Admin/Bans.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace FeatherBB\Controller\Admin;
1111

12+
use FeatherBB\Utils;
13+
1214
class Bans
1315
{
1416
public function __construct()
@@ -48,7 +50,7 @@ public function display()
4850
$this->feather->view2->setPageInfo(array(
4951
'admin_console' => true,
5052
'page' => $p,
51-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Bans'), __('Results head')),
53+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans'), __('Results head')),
5254
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . $this->feather->url->paginate_old($num_pages, $p, '?find_ban=&amp;' . implode('&amp;', $ban_info['query_str'])),
5355
'ban_data' => $ban_data['data'],
5456
)
@@ -60,7 +62,7 @@ public function display()
6062
$this->feather->view2->setPageInfo(array(
6163
'admin_console' => true,
6264
'focus_element' => array('bans', 'new_ban_user'),
63-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Bans')),
65+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans')),
6466
)
6567
)->addTemplate('admin/bans/admin_bans.php')->display();
6668
}
@@ -77,7 +79,7 @@ public function add($id = null)
7779
$this->feather->view2->setPageInfo(array(
7880
'admin_console' => true,
7981
'focus_element' => array('bans2', 'ban_user'),
80-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Bans')),
82+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans')),
8183
'ban' => $this->model->add_ban_info($id),
8284
)
8385
)->addTemplate('admin/bans/add_ban.php')->display();
@@ -99,7 +101,7 @@ public function edit($id)
99101
$this->feather->view2->setPageInfo(array(
100102
'admin_console' => true,
101103
'focus_element' => array('bans2', 'ban_user'),
102-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Bans')),
104+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans')),
103105
'ban' => $this->model->edit_ban_info($id),
104106
)
105107
)->addTemplate('admin/bans/add_ban.php')->display();

featherbb/Controller/Admin/Categories.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace FeatherBB\Controller\Admin;
1111

12+
use FeatherBB\Utils;
13+
1214
class Categories
1315
{
1416
public function __construct()
@@ -29,7 +31,7 @@ public function __autoload($class_name)
2931

3032
public function add_category()
3133
{
32-
$cat_name = $this->feather->utils->trim($this->request->post('cat_name'));
34+
$cat_name = Utils::trim($this->request->post('cat_name'));
3335
if ($cat_name == '') {
3436
redirect($this->feather->url->get('admin/categories/'), __('Must enter name message'));
3537
}
@@ -49,7 +51,7 @@ public function edit_categories()
4951

5052
foreach ($this->request->post('cat') as $cat_id => $properties) {
5153
$category = array('id' => (int) $cat_id,
52-
'name' => $this->feather->utils->escape($properties['name']),
54+
'name' => Utils::escape($properties['name']),
5355
'order' => (int) $properties['order'], );
5456
if ($category['name'] == '') {
5557
redirect($this->feather->url->get('admin/categories/'), __('Must enter name message'));
@@ -87,7 +89,7 @@ public function display()
8789
\FeatherBB\AdminUtils::generateAdminMenu('categories');
8890

8991
$this->feather->view2->setPageInfo(array(
90-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Categories')),
92+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Categories')),
9193
'active_page' => 'admin',
9294
'admin_console' => true,
9395
'cat_list' => $this->model->get_cat_list(),

featherbb/Controller/Admin/Censoring.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace FeatherBB\Controller\Admin;
1111

12+
use FeatherBB\Utils;
13+
1214
class Censoring
1315
{
1416
public function __construct()
@@ -47,7 +49,7 @@ public function display()
4749
\FeatherBB\AdminUtils::generateAdminMenu('censoring');
4850

4951
$this->feather->view2->setPageInfo(array(
50-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Censoring')),
52+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Censoring')),
5153
'focus_element' => array('censoring', 'new_search_for'),
5254
'active_page' => 'admin',
5355
'admin_console' => true,

featherbb/Controller/Admin/Forums.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace FeatherBB\Controller\Admin;
1111

12+
use FeatherBB\Utils;
13+
1214
class Forums
1315
{
1416
public function __construct()
@@ -54,11 +56,11 @@ public function edit_forum($forum_id)
5456
if ($this->request->post('save') && $this->request->post('read_forum_old')) {
5557

5658
// Forums parameters / TODO : better handling of wrong parameters
57-
$forum_data = array('forum_name' => $this->feather->utils->escape($this->request->post('forum_name')),
58-
'forum_desc' => $this->request->post('forum_desc') ? $this->feather->utils->linebreaks($this->feather->utils->trim($this->request->post('forum_desc'))) : NULL,
59+
$forum_data = array('forum_name' => Utils::escape($this->request->post('forum_name')),
60+
'forum_desc' => $this->request->post('forum_desc') ? Utils::linebreaks(Utils::trim($this->request->post('forum_desc'))) : NULL,
5961
'cat_id' => (int) $this->request->post('cat_id'),
6062
'sort_by' => (int) $this->request->post('sort_by'),
61-
'redirect_url' => $this->feather->url->is_valid($this->request->post('redirect_url')) ? $this->feather->utils->escape($this->request->post('redirect_url')) : NULL);
63+
'redirect_url' => $this->feather->url->is_valid($this->request->post('redirect_url')) ? Utils::escape($this->request->post('redirect_url')) : NULL);
6264

6365
if ($forum_data['forum_name'] == '') {
6466
redirect($this->feather->url->get('admin/forums/edit/'.$forum_id.'/'), __('Must enter name message'));
@@ -115,7 +117,7 @@ public function edit_forum($forum_id)
115117
\FeatherBB\AdminUtils::generateAdminMenu('forums');
116118

117119
$this->feather->view2->setPageInfo(array(
118-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Forums')),
120+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Forums')),
119121
'active_page' => 'admin',
120122
'admin_console' => true,
121123
'perm_data' => $this->model->get_permissions($forum_id),
@@ -141,7 +143,7 @@ public function delete_forum($forum_id)
141143
\FeatherBB\AdminUtils::generateAdminMenu('forums');
142144

143145
$this->feather->view2->setPageInfo(array(
144-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Forums')),
146+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Forums')),
145147
'active_page' => 'admin',
146148
'admin_console' => true,
147149
'cur_forum' => $this->model->get_forum_info($forum_id),
@@ -155,7 +157,7 @@ public function delete_forum($forum_id)
155157
public function edit_positions()
156158
{
157159
foreach ($this->request->post('position') as $forum_id => $position) {
158-
$position = (int) $this->feather->utils->trim($position);
160+
$position = (int) Utils::trim($position);
159161
$this->model->update_positions($forum_id, $position);
160162
}
161163

@@ -175,7 +177,7 @@ public function display()
175177

176178
$categories_model = new \FeatherBB\Model\Admin\Categories();
177179
$this->feather->view2->setPageInfo(array(
178-
'title' => array($this->feather->utils->escape($this->config['o_board_title']), __('Admin'), __('Forums')),
180+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Forums')),
179181
'active_page' => 'admin',
180182
'admin_console' => true,
181183
'cat_list' => $categories_model->get_cat_list(),

0 commit comments

Comments
 (0)