Move phpinfo module to src/Module/Admin

This commit is contained in:
Hypolite Petovan 2019-04-25 23:56:14 -04:00
parent ad02fd140a
commit fa4b42c6dd
4 changed files with 34 additions and 15 deletions

View file

@ -1,14 +0,0 @@
<?php
/**
* @file mod/phpinfo.php
*/
function phpinfo_content()
{
if (!is_site_admin()) {
return false;
}
phpinfo();
exit();
}

View file

@ -140,6 +140,8 @@ class Router
$collector->addRoute(['GET'] , '/logs/view' , Module\Admin\Logs\View::class); $collector->addRoute(['GET'] , '/logs/view' , Module\Admin\Logs\View::class);
$collector->addRoute(['GET', 'POST'], '/logs' , Module\Admin\Logs\Settings::class); $collector->addRoute(['GET', 'POST'], '/logs' , Module\Admin\Logs\Settings::class);
$collector->addRoute(['GET'] , '/phpinfo' , Module\Admin\PhpInfo::class);
$collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class); $collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class);
$collector->addRoute(['GET', 'POST'], '/site' , Module\Admin\Site::class); $collector->addRoute(['GET', 'POST'], '/site' , Module\Admin\Site::class);

View file

@ -0,0 +1,16 @@
<?php
namespace Friendica\Module\Admin;
use Friendica\Module\BaseAdminModule;
class PhpInfo extends BaseAdminModule
{
public static function rawContent()
{
parent::rawContent();
phpinfo();
exit();
}
}

View file

@ -5,6 +5,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
abstract class BaseAdminModule extends BaseModule abstract class BaseAdminModule extends BaseModule
@ -21,6 +22,19 @@ abstract class BaseAdminModule extends BaseModule
} }
} }
public static function rawContent()
{
if (!is_site_admin()) {
System::httpExit(403);
}
if (!empty($_SESSION['submanage'])) {
System::httpExit(403);
}
return '';
}
public static function content() public static function content()
{ {
if (!is_site_admin()) { if (!is_site_admin()) {
@ -71,10 +85,11 @@ abstract class BaseAdminModule extends BaseModule
'deleteitem' => ['admin/item/delete' , L10n::t('Delete Item') , 'deleteitem'], 'deleteitem' => ['admin/item/delete' , L10n::t('Delete Item') , 'deleteitem'],
]], ]],
'logs' => [L10n::t('Logs'), [ 'logs' => [L10n::t('Logs'), [
'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'], 'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'],
'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'], 'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'],
]], ]],
'diagnostics' => [L10n::t('Diagnostics'), [ 'diagnostics' => [L10n::t('Diagnostics'), [
'phpinfo' => ['admin/phpinfo' , L10n::t('PHP Info') , 'phpinfo'],
'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'], 'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'],
]], ]],
]; ];