Move index.php home logic to libraries/entry_points
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
8bb4a2d725
commit
a482e45137
77
index.php
77
index.php
@ -9,12 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
use FastRoute\Dispatcher;
|
||||
use FastRoute\RouteCollector;
|
||||
use PhpMyAdmin\Controllers\HomeController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function FastRoute\simpleDispatcher;
|
||||
|
||||
@ -22,16 +17,14 @@ if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
global $server;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
if (isset($_GET['route']) || isset($_POST['route'])) {
|
||||
$dispatcher = simpleDispatcher(function (RouteCollector $r) {
|
||||
$r->addRoute([
|
||||
'GET',
|
||||
'POST',
|
||||
], '/server/databases', function () {
|
||||
$dispatcher = simpleDispatcher(function (RouteCollector $routes) {
|
||||
$routes->addRoute(['GET', 'POST'], '[/]', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/home.php';
|
||||
});
|
||||
$routes->addRoute(['GET', 'POST'], '/server/databases', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/server_databases.php';
|
||||
});
|
||||
});
|
||||
@ -83,62 +76,4 @@ if (! empty($_REQUEST['target'])
|
||||
exit;
|
||||
}
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var HomeController $controller */
|
||||
$controller = $containerBuilder->get(HomeController::class);
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['set_theme'])) {
|
||||
$controller->setTheme([
|
||||
'set_theme' => $_POST['set_theme'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
} elseif (isset($_POST['collation_connection'])) {
|
||||
$controller->setCollationConnection([
|
||||
'collation_connection' => $_POST['collation_connection'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
} elseif (! empty($_REQUEST['db'])) {
|
||||
// See FAQ 1.34
|
||||
$page = null;
|
||||
if (! empty($_REQUEST['table'])) {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabTable'],
|
||||
'table'
|
||||
);
|
||||
} else {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'],
|
||||
'database'
|
||||
);
|
||||
}
|
||||
include ROOT_PATH . $page;
|
||||
} elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON($controller->reloadRecentTablesList());
|
||||
} elseif ($GLOBALS['PMA_Config']->isGitRevision()
|
||||
&& isset($_REQUEST['git_revision'])
|
||||
&& $response->isAjax()
|
||||
) {
|
||||
$response->addHTML($controller->gitRevision());
|
||||
} else {
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
if ($server > 0) {
|
||||
include ROOT_PATH . 'libraries/server_common.inc.php';
|
||||
}
|
||||
|
||||
$response->addHTML($controller->index());
|
||||
}
|
||||
require_once ROOT_PATH . 'libraries/entry_points/home.php';
|
||||
|
||||
79
libraries/entry_points/home.php
Normal file
79
libraries/entry_points/home.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles the home page
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\HomeController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $containerBuilder, $server;
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var HomeController $controller */
|
||||
$controller = $containerBuilder->get(HomeController::class);
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['set_theme'])) {
|
||||
$controller->setTheme([
|
||||
'set_theme' => $_POST['set_theme'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
} elseif (isset($_POST['collation_connection'])) {
|
||||
$controller->setCollationConnection([
|
||||
'collation_connection' => $_POST['collation_connection'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
} elseif (! empty($_REQUEST['db'])) {
|
||||
// See FAQ 1.34
|
||||
$page = null;
|
||||
if (! empty($_REQUEST['table'])) {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabTable'],
|
||||
'table'
|
||||
);
|
||||
} else {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'],
|
||||
'database'
|
||||
);
|
||||
}
|
||||
include ROOT_PATH . $page;
|
||||
} elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON($controller->reloadRecentTablesList());
|
||||
} elseif ($GLOBALS['PMA_Config']->isGitRevision()
|
||||
&& isset($_REQUEST['git_revision'])
|
||||
&& $response->isAjax()
|
||||
) {
|
||||
$response->addHTML($controller->gitRevision());
|
||||
} else {
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
if ($server > 0) {
|
||||
include ROOT_PATH . 'libraries/server_common.inc.php';
|
||||
}
|
||||
|
||||
$response->addHTML($controller->index());
|
||||
}
|
||||
@ -25,6 +25,15 @@
|
||||
<severity>4</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration">
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
|
||||
</rule>
|
||||
|
||||
<arg value="sp"/>
|
||||
<arg name="colors"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
{% endif %}
|
||||
|
||||
<div id="navipanellinks">
|
||||
<a href="index.php{{ get_common() }}" title="{% trans 'Home' %}">
|
||||
<a href="{{ get_url_from_route('/') }}" title="{% trans 'Home' %}">
|
||||
{{- get_image('b_home', 'Home'|trans) -}}
|
||||
</a>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user