Remove libraries/check_user_privileges.inc.php
Replaces with CheckUserPrivileges::getPrivileges Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
85c2d2ce5f
commit
7eb2bbc102
@ -13,6 +13,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Display\CreateTable;
|
||||
use PhpMyAdmin\Message;
|
||||
@ -33,10 +34,8 @@ if (! defined('ROOT_PATH')) {
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* functions implementation for this script
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
// add a javascript file for jQuery functions to handle Ajax actions
|
||||
$response = Response::getInstance();
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
@ -16,10 +18,8 @@ if (! defined('ROOT_PATH')) {
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
/**
|
||||
* Do the magic
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Display\GitRevision;
|
||||
@ -232,7 +233,8 @@ if ($server > 0 || count($cfg['Servers']) > 1
|
||||
* Displays the mysql server related links
|
||||
*/
|
||||
if ($server > 0) {
|
||||
include_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
// Logout for advanced authentication
|
||||
if (($cfg['Server']['auth_type'] != 'config') && $cfg['ShowChgPassword']) {
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Get user's global privileges and some db-specific privileges
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
|
||||
list($username, $hostname) = $GLOBALS['dbi']->getCurrentUserAndHost();
|
||||
if ($username === '') { // MySQL is started with --skip-grant-tables
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
$GLOBALS['dbs_where_create_table_allowed'] = ['*'];
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
$GLOBALS['db_priv'] = true;
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['table_priv'] = true;
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
} else {
|
||||
$checkUserPrivileges->analyseShowGrant();
|
||||
}
|
||||
@ -172,7 +172,7 @@ class CheckUserPrivileges
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function analyseShowGrant(): void
|
||||
private function analyseShowGrant(): void
|
||||
{
|
||||
if (Util::cacheExists('is_create_db_priv')) {
|
||||
$GLOBALS['is_create_db_priv'] = Util::cacheGet(
|
||||
@ -338,5 +338,35 @@ class CheckUserPrivileges
|
||||
Util::cacheSet('table_priv', $GLOBALS['table_priv']);
|
||||
Util::cacheSet('col_priv', $GLOBALS['col_priv']);
|
||||
Util::cacheSet('db_priv', $GLOBALS['db_priv']);
|
||||
} // end function
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user's global privileges and some db-specific privileges
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getPrivileges(): void
|
||||
{
|
||||
$username = '';
|
||||
|
||||
$current = $this->dbi->getCurrentUserAndHost();
|
||||
if (! empty($current)) {
|
||||
list($username, ) = $current;
|
||||
}
|
||||
|
||||
// If MySQL is started with --skip-grant-tables
|
||||
if ($username === '') {
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
$GLOBALS['dbs_where_create_table_allowed'] = ['*'];
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
$GLOBALS['db_priv'] = true;
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['table_priv'] = true;
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
} else {
|
||||
$this->analyseShowGrant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Controllers\Server;
|
||||
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Controllers\Controller;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
@ -57,7 +58,8 @@ class ServerDatabasesController extends Controller
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
include_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Controllers\Table;
|
||||
|
||||
use PhpMyAdmin\CentralColumns;
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Controllers\TableController;
|
||||
use PhpMyAdmin\Core;
|
||||
@ -148,10 +149,8 @@ class TableStructureController extends TableController
|
||||
{
|
||||
PageSettings::showGroup('TableStructure');
|
||||
|
||||
/**
|
||||
* Function implementations for this script
|
||||
*/
|
||||
include_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$this->response->getHeader()->getScripts()->addFiles(
|
||||
[
|
||||
@ -556,7 +555,9 @@ class TableStructureController extends TableController
|
||||
/**
|
||||
* Form for changing properties.
|
||||
*/
|
||||
include_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
include ROOT_PATH . 'libraries/tbl_columns_definition_form.inc.php';
|
||||
}
|
||||
|
||||
|
||||
@ -28,10 +28,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Display;
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Template;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\Display\CreateTable class
|
||||
*
|
||||
@ -48,6 +47,9 @@ class CreateTable
|
||||
*/
|
||||
public static function getHtml($db)
|
||||
{
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$template = new Template();
|
||||
return $template->render('database/create_table', ['db' => $db]);
|
||||
}
|
||||
|
||||
@ -55,7 +55,9 @@ class Import
|
||||
public function __construct()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -12,8 +12,6 @@ namespace PhpMyAdmin;
|
||||
use PhpMyAdmin\ListAbstract;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
/**
|
||||
* handles database lists
|
||||
*
|
||||
@ -34,6 +32,10 @@ class ListDatabase extends ListAbstract
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$this->build();
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation;
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Navigation\Nodes\Node;
|
||||
use PhpMyAdmin\Navigation\Nodes\NodeDatabase;
|
||||
use PhpMyAdmin\Navigation\Nodes\NodeTable;
|
||||
@ -19,8 +20,6 @@ use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
/**
|
||||
* Displays a collapsible of database objects in the navigation frame
|
||||
*
|
||||
@ -94,6 +93,9 @@ class NavigationTree
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
// Save the position at which we are in the database list
|
||||
if (isset($_POST['pos'])) {
|
||||
$this->_pos = (int) $_POST['pos'];
|
||||
|
||||
@ -9,11 +9,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
/**
|
||||
* Represents a container for database nodes in the navigation tree
|
||||
*
|
||||
@ -28,6 +27,9 @@ class NodeDatabaseContainer extends Node
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
parent::__construct($name, Node::CONTAINER);
|
||||
|
||||
if ($GLOBALS['is_create_db_priv']
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Relation;
|
||||
@ -25,10 +26,8 @@ if (! defined('ROOT_PATH')) {
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* functions implementation for this script
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
5
sql.php
5
sql.php
@ -9,6 +9,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\ParseAnalyze;
|
||||
use PhpMyAdmin\Response;
|
||||
@ -24,7 +25,9 @@ if (! defined('ROOT_PATH')) {
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
PageSettings::showGroup('Browse');
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Index;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Partition;
|
||||
@ -20,15 +21,10 @@ if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* functions implementation for this script
|
||||
*/
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
$pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
|
||||
|
||||
|
||||
@ -14,15 +14,6 @@ use PhpMyAdmin\Navigation\NavigationTree;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
use PhpMyAdmin\Theme;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Navigation\NavigationTree class
|
||||
*
|
||||
|
||||
@ -12,12 +12,6 @@ use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Plugins\Import\ImportMediawiki;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Plugins\Import\ImportMediawiki class
|
||||
*
|
||||
@ -39,6 +33,7 @@ class ImportMediawikiTest extends PmaTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['plugin_param'] = 'database';
|
||||
$this->object = new ImportMediawiki();
|
||||
|
||||
|
||||
@ -12,12 +12,6 @@ use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Plugins\Import\ImportOds;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Plugins\Import\ImportOds class
|
||||
*
|
||||
@ -39,6 +33,7 @@ class ImportOdsTest extends PmaTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['plugin_param'] = "csv";
|
||||
$this->object = new ImportOds();
|
||||
|
||||
|
||||
@ -12,12 +12,6 @@ use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Plugins\Import\ImportShp;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Plugins\Import\ImportShp class
|
||||
*
|
||||
@ -43,6 +37,7 @@ class ImportShpTest extends PmaTestCase
|
||||
if (! defined('PMA_IS_WINDOWS')) {
|
||||
define('PMA_IS_WINDOWS', false);
|
||||
}
|
||||
$GLOBALS['server'] = 0;
|
||||
//setting
|
||||
$GLOBALS['plugin_param'] = 'table';
|
||||
$GLOBALS['finished'] = false;
|
||||
|
||||
@ -12,12 +12,6 @@ use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Plugins\Import\ImportSql;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Plugins\Import\ImportSql class
|
||||
*
|
||||
@ -39,6 +33,8 @@ class ImportSqlTest extends PmaTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
$this->object = new ImportSql();
|
||||
|
||||
//setting
|
||||
|
||||
@ -12,12 +12,6 @@ use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Plugins\Import\ImportXml;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.inc.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/**
|
||||
* Tests for PhpMyAdmin\Plugins\Import\ImportXml class
|
||||
*
|
||||
@ -39,6 +33,8 @@ class ImportXmlTest extends PmaTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
$this->object = new ImportXml();
|
||||
|
||||
//setting
|
||||
|
||||
Loading…
Reference in New Issue
Block a user