diff --git a/featherbb/Controller/Admin/Forums.php b/featherbb/Controller/Admin/Forums.php index f81052ca..5e7a832c 100644 --- a/featherbb/Controller/Admin/Forums.php +++ b/featherbb/Controller/Admin/Forums.php @@ -23,7 +23,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\forums(); + $this->model = new \FeatherBB\Model\Admin\Forums(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/forums.mo'); } diff --git a/featherbb/Controller/Admin/Groups.php b/featherbb/Controller/Admin/Groups.php index 58356e31..3056f809 100644 --- a/featherbb/Controller/Admin/Groups.php +++ b/featherbb/Controller/Admin/Groups.php @@ -22,7 +22,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\groups(); + $this->model = new \FeatherBB\Model\Admin\Groups(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/groups.mo'); } diff --git a/featherbb/Controller/Admin/Index.php b/featherbb/Controller/Admin/Index.php index 3bf3c2bd..419b69af 100644 --- a/featherbb/Controller/Admin/Index.php +++ b/featherbb/Controller/Admin/Index.php @@ -26,21 +26,6 @@ public function __construct() load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/index.mo'); } - public function remove_install_folder($directory) - { - foreach(glob("{$directory}/*") as $file) - { - if(is_dir($file)) { - $this->remove_install_folder($file); - } else { - unlink($file); - } - } - $deleted = rmdir($directory); - - return $deleted; - } - public function display($action = null) { // Check for upgrade @@ -60,24 +45,14 @@ public function display($action = null) Url::redirect($this->feather->urlFor('adminIndex'), sprintf(__('New version available message'), 'FeatherBB.org')); } } - // Remove /install - elseif ($action == 'remove_install_file') { - $deleted = $this->remove_install_folder($this->feather->forum_env['FEATHER_ROOT'].'install'); - - if ($deleted) { - Url::redirect($this->feather->urlFor('adminIndex'), __('Deleted install.php redirect')); - } else { - throw new Error(__('Delete install.php failed'), 500); - } - } AdminUtils::generateAdminMenu('index'); $this->feather->template->setPageInfo(array( - 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Index')), - 'active_page' => 'admin', - 'admin_console' => true - ) - )->addTemplate('admin/index.php')->display(); + 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Index')), + 'active_page' => 'admin', + 'admin_console' => true + ) + )->addTemplate('admin/index.php')->display(); } } diff --git a/featherbb/Controller/Admin/Options.php b/featherbb/Controller/Admin/Options.php index e920e58f..dce5531d 100644 --- a/featherbb/Controller/Admin/Options.php +++ b/featherbb/Controller/Admin/Options.php @@ -21,7 +21,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\options(); + $this->model = new \FeatherBB\Model\Admin\Options(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/options.mo'); } diff --git a/featherbb/Controller/Admin/Parser.php b/featherbb/Controller/Admin/Parser.php index a7d3b6db..842ae80b 100644 --- a/featherbb/Controller/Admin/Parser.php +++ b/featherbb/Controller/Admin/Parser.php @@ -23,7 +23,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\parser(); + $this->model = new \FeatherBB\Model\Admin\Parser(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/parser.mo'); } @@ -53,7 +53,6 @@ public function display() if ($this->request->post('form_sent')) { - // Upload new smiley image to style/img/smilies if ($this->request->post('upload') && isset($_FILES['new_smiley']) && isset($_FILES['new_smiley']['error'])) { $f = $_FILES['new_smiley']; diff --git a/featherbb/Controller/Admin/Permissions.php b/featherbb/Controller/Admin/Permissions.php index f31194d4..f97a6e45 100644 --- a/featherbb/Controller/Admin/Permissions.php +++ b/featherbb/Controller/Admin/Permissions.php @@ -21,7 +21,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\permissions(); + $this->model = new \FeatherBB\Model\Admin\Permissions(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/permissions.mo'); } diff --git a/featherbb/Controller/Admin/Plugins.php b/featherbb/Controller/Admin/Plugins.php index c5a8ea74..f86675e3 100644 --- a/featherbb/Controller/Admin/Plugins.php +++ b/featherbb/Controller/Admin/Plugins.php @@ -73,43 +73,4 @@ public function deactivate($plugin = null) Url::redirect($this->feather->urlFor('adminPlugins'), array('warning', 'Plugin deactivated!')); } - public function display() - { - // The plugin to load should be supplied via GET - $plugin = $this->request->get('plugin') ? $this->request->get('plugin') : ''; - if (!preg_match('%^AM?P_(\w*?)\.php$%i', $plugin)) { - throw new Error(__('Bad request'), 400); - } - - // AP_ == Admins only, AMP_ == admins and moderators - $prefix = substr($plugin, 0, strpos($plugin, '_')); - if ($this->user->g_moderator == '1' && $prefix == 'AP') { - throw new Error(__('No permission'), 403); - } - - // Make sure the file actually exists - if (!file_exists($this->feather->forum_env['FEATHER_ROOT'].'plugins/'.$plugin)) { - throw new Error(sprintf(__('No plugin message'), Utils::escape($plugin)), 400); - } - - // Construct REQUEST_URI if it isn't set TODO? - if (!isset($_SERVER['REQUEST_URI'])) { - $_SERVER['REQUEST_URI'] = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '').'?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''); - } - - // Attempt to load the plugin. We don't use @ here to suppress error messages, - // because if we did and a parse error occurred in the plugin, we would only - // get the "blank page of death" - include $this->feather->forum_env['FEATHER_ROOT'].'plugins/'.$plugin; - if (!defined('FEATHER_PLUGIN_LOADED')) { - throw new Error(sprintf(__('Plugin failed message'), Utils::escape($plugin))); - } - - $this->feather->template->setPageInfo(array( - 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), str_replace('_', ' ', substr($plugin, strpos($plugin, '_') + 1, -4))), - 'active_page' => 'admin', - 'admin_console' => true, - ) - )->addTemplate('admin/loader.php')->display(); - } } diff --git a/featherbb/Controller/Admin/Reports.php b/featherbb/Controller/Admin/Reports.php index 5fb094e2..f941f23b 100644 --- a/featherbb/Controller/Admin/Reports.php +++ b/featherbb/Controller/Admin/Reports.php @@ -11,6 +11,7 @@ use FeatherBB\Core\AdminUtils; use FeatherBB\Core\Utils; +use FeatherBB\Core\Url; class Reports { @@ -21,7 +22,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\reports(); + $this->model = new \FeatherBB\Model\Admin\Reports(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/reports.mo'); } @@ -29,7 +30,10 @@ public function display() { // Zap a report if ($this->feather->request->isPost()) { - $this->model->zap_report(); + $zap_id = intval(key($this->request->post('zap_id'))); + $user_id = $this->user->id; + $this->model->zap_report($zap_id, $user_id); + Url::redirect($this->feather->urlFor('adminReports'), __('Report zapped redirect')); } AdminUtils::generateAdminMenu('reports'); diff --git a/featherbb/Controller/Admin/Statistics.php b/featherbb/Controller/Admin/Statistics.php index a519b231..0d659503 100644 --- a/featherbb/Controller/Admin/Statistics.php +++ b/featherbb/Controller/Admin/Statistics.php @@ -22,7 +22,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\Admin\statistics(); + $this->model = new \FeatherBB\Model\Admin\Statistics(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/index.mo'); } diff --git a/featherbb/Controller/Edit.php b/featherbb/Controller/Edit.php index bc1f5f22..efe742a9 100644 --- a/featherbb/Controller/Edit.php +++ b/featherbb/Controller/Edit.php @@ -22,7 +22,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; - $this->model = new \FeatherBB\Model\edit(); + $this->model = new \FeatherBB\Model\Edit(); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/register.mo'); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/prof_reg.mo'); load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/post.mo'); diff --git a/featherbb/Controller/Install.php b/featherbb/Controller/Install.php index 625c5770..6e9d9ce7 100644 --- a/featherbb/Controller/Install.php +++ b/featherbb/Controller/Install.php @@ -32,7 +32,7 @@ class Install public function __construct() { $this->feather = \Slim\Slim::getInstance(); - $this->model = new \FeatherBB\Model\install(); + $this->model = new \FeatherBB\Model\Install(); $this->available_langs = Lister::getLangs(); $this->feather->template->setStyle('FeatherBB'); } diff --git a/featherbb/Model/Admin/Reports.php b/featherbb/Model/Admin/Reports.php index d06ff7f0..3d9e8f4e 100644 --- a/featherbb/Model/Admin/Reports.php +++ b/featherbb/Model/Admin/Reports.php @@ -10,30 +10,24 @@ namespace FeatherBB\Model\Admin; use DB; -use FeatherBB\Core\Url; class Reports { 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->hook = $this->feather->hooks; } - public function zap_report() + public function zap_report($zap_id, $user_id) { - $zap_id = intval(key($this->request->post('zap_id'))); $zap_id = $this->hook->fire('reports.zap_report.zap_id', $zap_id); $result = DB::for_table('reports')->where('id', $zap_id); $result = $this->hook->fireDB('reports.zap_report.query', $result); $result = $result->find_one_col('zapped'); - $set_zap_report = array('zapped' => time(), 'zapped_by' => $this->user->id); + $set_zap_report = array('zapped' => time(), 'zapped_by' => $user_id); $set_zap_report = $this->hook->fire('reports.zap_report.set_zap_report', $set_zap_report); // Update report to indicate it has been zapped @@ -59,7 +53,7 @@ public function zap_report() ->delete_many(); } - Url::redirect($this->feather->urlFor('adminReports'), __('Report zapped redirect')); + return true; } public function get_reports() diff --git a/featherbb/routes.php b/featherbb/routes.php index a03bc2cb..d6018ba0 100644 --- a/featherbb/routes.php +++ b/featherbb/routes.php @@ -191,7 +191,7 @@ }); // Admin plugins - $feather->group('/plugins', function() use ($feather) { + $feather->group('/plugins', $isAdmin, function() use ($feather) { $feather->map('(/)', '\FeatherBB\Controller\Admin\Plugins:index')->via('GET', 'POST')->name('adminPlugins'); $feather->map('/:name(/)', '\FeatherBB\Controller\Admin\Plugins:index')->via('GET', 'POST')->name('infoPlugin'); $feather->get('/activate/:name(/)', '\FeatherBB\Controller\Admin\Plugins:activate')->conditions(array('name' => '[a-zA-Z\-]+'))->name('activatePlugin');