Skip to content

Commit 2a48243

Browse files
committed
Massive rewrite
1 parent 77de69c commit 2a48243

File tree

17 files changed

+42
-49
lines changed

17 files changed

+42
-49
lines changed

extern.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function set_default_user()
143143
// Get Slim current session
144144
$feather = \Slim\Slim::getInstance();
145145

146-
$remote_addr = $feather->request->getIp();
146+
$remote_addr = Utils::getIp();
147147

148148
// Fetch guest user
149149
$select_set_default_user = array('u.*', 'g.*', 'o.logged', 'o.last_post', 'o.last_search');
@@ -437,7 +437,7 @@ function output_html($feed)
437437

438438
foreach ($feed['items'] as $item) {
439439
if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH) {
440-
$subject_truncated = Utils::escape($feather->utils->trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'';
440+
$subject_truncated = Utils::escape(Utils::trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'';
441441
} else {
442442
$subject_truncated = Utils::escape($item['title']);
443443
}
@@ -547,7 +547,7 @@ function output_html($feed)
547547

548548
// Were any forum IDs supplied?
549549
if (isset($_GET['fid']) && is_scalar($_GET['fid']) && $_GET['fid'] != '') {
550-
$fids = explode(',', $feather->utils->trim($_GET['fid']));
550+
$fids = explode(',', Utils::trim($_GET['fid']));
551551
$fids = array_map('intval', $fids);
552552

553553
if (!empty($fids)) {
@@ -576,7 +576,7 @@ function output_html($feed)
576576

577577
// Any forum IDs to exclude?
578578
if (isset($_GET['nfid']) && is_scalar($_GET['nfid']) && $_GET['nfid'] != '') {
579-
$nfids = explode(',', $feather->utils->trim($_GET['nfid']));
579+
$nfids = explode(',', Utils::trim($_GET['nfid']));
580580
$nfids = array_map('intval', $nfids);
581581

582582
if (!empty($nfids)) {
@@ -734,11 +734,11 @@ function output_html($feed)
734734
// Show board statistics
735735
elseif ($action == 'stats') {
736736

737-
if (!$feather->cache->isCached('users_info')) {
738-
$feather->cache->store('users_info', Cache::get_users_info());
737+
if (!Container::get('cache')->isCached('users_info')) {
738+
Container::get('cache')->store('users_info', Cache::get_users_info());
739739
}
740740

741-
$stats = $feather->cache->retrieve('users_info');
741+
$stats = Container::get('cache')->retrieve('users_info');
742742

743743
$stats_query = \DB::for_table('forums')
744744
->select_expr('SUM(num_topics)', 'total_topics')

featherbb/Controller/Admin/Statistics.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@ public function phpinfo($req, $res, $args)
5454
}
5555

5656
phpinfo();
57-
$this->feather->stop();
5857
}
5958
}

featherbb/Controller/Auth.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace FeatherBB\Controller;
1111

1212
use FeatherBB\Core\Error;
13+
use FeatherBB\Core\Interfaces\Container;
1314
use FeatherBB\Core\Random;
1415
use FeatherBB\Core\Track;
1516
use FeatherBB\Core\Url;
@@ -52,7 +53,7 @@ public function login($req, $res, $args)
5253
// Reset tracked topics
5354
Track::set_tracked_topics(null);
5455

55-
$expire = ($save_pass) ? $this->feather->now + 1209600 : $this->feather->now + Config::get('forum_settings')['o_timeout_visit'];
56+
$expire = ($save_pass) ? Container::get('now') + 1209600 : Container::get('now') + Config::get('forum_settings')['o_timeout_visit'];
5657
$expire = Container::get('hooks')->fire('controller.expire_login', $expire);
5758
ModelAuth::feather_setcookie($user->id, $form_password_hash, $expire);
5859

featherbb/Core/AdminUtils.php

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

1010
namespace FeatherBB\Core;
1111

12+
use FeatherBB\Core\Interfaces\Container;
1213
use RecursiveDirectoryIterator;
1314
use RecursiveIteratorIterator;
1415

@@ -18,14 +19,12 @@ class AdminUtils
1819

1920
public static function generateAdminMenu($page = '')
2021
{
21-
self::$feather = \Slim\Slim::getInstance();
22-
23-
$is_admin = (self::Container::get('user')->g_id == self::$feather->forum_env['FEATHER_ADMIN']) ? true : false;
22+
$is_admin = (Container::get('user')->g_id == Container::get('forum_env')['FEATHER_ADMIN']) ? true : false;
2423

2524
// See if there are any plugins that want to display in the menu
2625
$plugins = self::adminPluginsMenu($is_admin);
2726

28-
self::$feather->template->setPageInfo(array(
27+
View::setPageInfo(array(
2928
'page' => $page,
3029
'is_admin' => $is_admin,
3130
'plugins' => $plugins,
@@ -38,10 +37,8 @@ public static function generateAdminMenu($page = '')
3837
*/
3938
public static function adminPluginsMenu($isAdmin = false)
4039
{
41-
self::$feather = \Slim\Slim::getInstance();
42-
4340
$menuItems = [];
44-
$menuItems = self::$feather->hooks->fire('admin.plugin.menu', $menuItems);
41+
$menuItems = Container::get('hooks')->fire('admin.plugin.menu', $menuItems);
4542

4643
return $menuItems;
4744
}
@@ -85,13 +82,11 @@ public static function delete_folder($dirPath) {
8582
*/
8683
public static function get_admin_ids()
8784
{
88-
self::$feather = \Slim\Slim::getInstance();
89-
90-
if (!self::$feather->cache->isCached('admin_ids')) {
91-
self::$feather->cache->store('admin_ids', \FeatherBB\Model\Cache::get_admin_ids());
85+
if (!Container::get('cache')->isCached('admin_ids')) {
86+
Container::get('cache')->store('admin_ids', \FeatherBB\Model\Cache::get_admin_ids());
9287
}
9388

94-
return self::$feather->cache->retrieve('admin_ids');
89+
return Container::get('cache')->retrieve('admin_ids');
9590
}
9691

9792
/**

featherbb/Core/parser/bbcd_compile.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@
181181
$feather = \Slim\Slim::getInstance();
182182
// Validate and compute replacement texts for smilies array.
183183
$re_keys = array(); // Array of regex-safe smiley texts.
184-
$file_path = $feather->forum_env['FEATHER_ROOT'] . 'style/img/smilies/'; // File system path to smilies.
185-
$url_path = $feather->request->getScriptName(); // Convert abs URL to relative URL.
184+
$file_path = Container::get('forum_env')['FEATHER_ROOT'] . 'style/img/smilies/'; // File system path to smilies.
185+
$url_path = Request::getServerParams()['SCRIPT_NAME']; // Convert abs URL to relative URL.
186186
$url_path = preg_replace('%^https?://[^/]++(.*)$%i', '$1', $url_path) . '/style/img/smilies/';
187187
foreach ($smilies as $smiley_text => $smiley_img) { // Loop through all smilieys in array.
188188
$file = $file_path . $smiley_img['file']; // Local file system address of smiley.
@@ -419,7 +419,7 @@ function file2title($file)
419419
$s .= ";\n";
420420

421421
$s .= "?>";
422-
file_put_contents($feather->forum_env['FEATHER_ROOT'].'cache/cache_parser_data.php', $s);
422+
file_put_contents(Container::get('forum_env')['FEATHER_ROOT'].'cache/cache_parser_data.php', $s);
423423

424424
// Clean up our global variables.
425425
unset($all_tags); unset($all_block_tags);

featherbb/Model/Admin/Groups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function add_edit_group($groups)
203203
$new_group_id = Container::get('hooks')->fire('model.admin.groups.add_edit_group.new_group_id', (int) $add->id());
204204

205205
// Set new preferences
206-
$this->feather->prefs->setGroup($new_group_id, array('post.min_interval' => (int) $post_flood));
206+
Container::get('prefs')->setGroup($new_group_id, array('post.min_interval' => (int) $post_flood));
207207

208208
// Now lets copy the forum specific permissions from the group which this group is based on
209209
$select_forum_perms = array('forum_id', 'read_forum', 'post_replies', 'post_topics');

featherbb/Model/Admin/Reports.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ public function zap_report($zap_id)
5252

5353
public static function has_reports()
5454
{
55-
$feather = \Slim\Slim::getInstance();
56-
57-
$feather->hooks->fire('get_reports_start');
55+
Container::get('hooks')->fire('get_reports_start');
5856

5957
$result_header = DB::for_table('reports')->where_null('zapped');
60-
$result_header = $feather->hooks->fireDB('get_reports_query', $result_header);
58+
$result_header = Container::get('hooks')->hooks->fireDB('get_reports_query', $result_header);
6159

6260
return (bool) $result_header->find_one();
6361
}

featherbb/Model/Cache.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public static function get_users_info()
4949
$stats = array();
5050
$select_get_users_info = array('id', 'username');
5151
$stats['total_users'] = DB::for_table('users')
52-
->where_not_equal('group_id', $feather->forum_env['FEATHER_UNVERIFIED'])
52+
->where_not_equal('group_id', Container::get('forum_env')['FEATHER_UNVERIFIED'])
5353
->where_not_equal('id', 1)
5454
->count();
5555
$stats['last_user'] = DB::for_table('users')->select_many($select_get_users_info)
56-
->where_not_equal('group_id', $feather->forum_env['FEATHER_UNVERIFIED'])
56+
->where_not_equal('group_id', Container::get('forum_env')['FEATHER_UNVERIFIED'])
5757
->order_by_desc('registered')
5858
->limit(1)
5959
->find_array()[0];
@@ -65,7 +65,7 @@ public static function get_admin_ids()
6565
$feather = \Slim\Slim::getInstance();
6666
return DB::for_table('users')
6767
->select('id')
68-
->where('group_id', $feather->forum_env['FEATHER_ADMIN'])
68+
->where('group_id', Container::get('forum_env')['FEATHER_ADMIN'])
6969
->find_array();
7070
}
7171

featherbb/Model/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public function check_errors_before_post($fid, $tid, $qid, $pid, $page, $errors)
132132
}
133133

134134
// Flood protection
135-
if (Input::post('preview') != '' && Container::get('user')->last_post != '' && (time() - Container::get('user')->last_post) < $this->feather->prefs->get(Container::get('user'), 'post.min_interval')) {
136-
$errors[] = sprintf(__('Flood start'), $this->feather->prefs->get(Container::get('user'), 'post.min_interval'), $this->feather->prefs->get(Container::get('user'), 'post.min_interval') - (time() - Container::get('user')->last_post));
135+
if (Input::post('preview') != '' && Container::get('user')->last_post != '' && (time() - Container::get('user')->last_post) < Container::get('prefs')->get(Container::get('user'), 'post.min_interval')) {
136+
$errors[] = sprintf(__('Flood start'), Container::get('prefs')->get(Container::get('user'), 'post.min_interval'), Container::get('prefs')->get(Container::get('user'), 'post.min_interval') - (time() - Container::get('user')->last_post));
137137
}
138138

139139
// If it's a new topic

featherbb/View/admin/groups/add_edit_group.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
<th scope="row"><?php _e('User title label') ?></th>
4545
<td>
4646
<input type="text" name="user_title" size="25" maxlength="50" value="<?= Utils::escape($group['info']['g_user_title']) ?>" tabindex="2" />
47-
<span><?php printf(__('User title help'), ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST'] ? __('Member') : __('Guest'))) ?></span>
47+
<span><?php printf(__('User title help'), ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST'] ? __('Member') : __('Guest'))) ?></span>
4848
</td>
4949
</tr>
50-
<?php if ($group['info']['g_id'] != $feather->forum_env['FEATHER_ADMIN']): if ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST']): ?> <tr>
50+
<?php if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_ADMIN']): if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST']): ?> <tr>
5151
<th scope="row"><?php _e('Promote users label') ?></th>
5252
<td>
5353
<select name="promote_next_group" tabindex="3">
@@ -178,7 +178,7 @@
178178
<span class="clearb"><?php _e('Post topics help') ?></span>
179179
</td>
180180
</tr>
181-
<?php if ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST']): ?> <tr>
181+
<?php if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST']): ?> <tr>
182182
<th scope="row"><?php _e('Edit posts label') ?></th>
183183
<td>
184184
<label class="conl"><input type="radio" name="edit_posts" value="1"<?php if ($group['info']['g_edit_posts'] == '1') {
@@ -226,7 +226,7 @@
226226
<span class="clearb"><?php _e('Post links help') ?></span>
227227
</td>
228228
</tr>
229-
<?php if ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST']): ?> <tr>
229+
<?php if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST']): ?> <tr>
230230
<th scope="row"><?php _e('Set own title label') ?></th>
231231
<td>
232232
<label class="conl"><input type="radio" name="set_title" value="1"<?php if ($group['info']['g_set_title'] == '1') {
@@ -262,7 +262,7 @@
262262
<span class="clearb"><?php _e('User list search help') ?></span>
263263
</td>
264264
</tr>
265-
<?php if ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST']): ?> <tr>
265+
<?php if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST']): ?> <tr>
266266
<th scope="row"><?php _e('Send e-mails label') ?></th>
267267
<td>
268268
<label class="conl"><input type="radio" name="send_email" value="1"<?php if ($group['info']['g_send_email'] == '1') {
@@ -288,7 +288,7 @@
288288
<span><?php _e('Search flood help') ?></span>
289289
</td>
290290
</tr>
291-
<?php if ($group['info']['g_id'] != $feather->forum_env['FEATHER_GUEST']): ?> <tr>
291+
<?php if ($group['info']['g_id'] != Container::get('forum_env')['FEATHER_GUEST']): ?> <tr>
292292
<th scope="row"><?php _e('E-mail flood label') ?></th>
293293
<td>
294294
<input type="text" name="email_flood" size="5" maxlength="4" value="<?= $group['info']['g_email_flood'] ?>" tabindex="43" />

0 commit comments

Comments
 (0)