当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_getUserSpecificRights函数代码示例

本文整理汇总了PHP中PMA_getUserSpecificRights函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getUserSpecificRights函数的具体用法?PHP PMA_getUserSpecificRights怎么用?PHP PMA_getUserSpecificRights使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PMA_getUserSpecificRights函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_getHtmlForAllTableSpecificRights

/**
 * Get a HTML table for display user's tabel specific or database specific rights
 *
 * @param string $username username
 * @param string $hostname host name
 * @param string $dbname   database name
 *
 * @return array $html_output, $found_rows
 */
function PMA_getHtmlForAllTableSpecificRights($username, $hostname, $dbname)
{
    // table header
    $html_output = PMA_URL_getHiddenInputs('', '') . '<input type="hidden" name="username" ' . 'value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset>' . "\n" . '<legend data-submenu-label="' . (!mb_strlen($dbname) ? __('Database') : __('Table')) . '">' . (!mb_strlen($dbname) ? __('Database-specific privileges') : __('Table-specific privileges')) . '</legend>' . "\n" . '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . (!mb_strlen($dbname) ? __('Database') : __('Table')) . '</th>' . "\n" . '<th>' . __('Privileges') . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th>' . (!mb_strlen($dbname) ? __('Table-specific privileges') : __('Column-specific privileges')) . '</th>' . "\n" . '<th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $user_host_condition = ' WHERE `User`' . ' = \'' . PMA_Util::sqlAddSlashes($username) . "'" . ' AND `Host`' . ' = \'' . PMA_Util::sqlAddSlashes($hostname) . "'";
    // table body
    // get data
    // we also want privileges for this user not in table `db` but in other table
    $tables = $GLOBALS['dbi']->fetchResult('SHOW TABLES FROM `mysql`;');
    /**
     * no db name given, so we want all privs for the given user
     * db name was given, so we want all user specific rights for this db
     */
    $db_rights = PMA_getUserSpecificRights($tables, $user_host_condition, $dbname);
    ksort($db_rights);
    $html_output .= '<tbody>' . "\n";
    // display rows
    list($found_rows, $html_out) = PMA_getHtmlForUserRights($db_rights, $dbname, $hostname, $username);
    $html_output .= $html_out;
    $html_output .= '</tbody>' . "\n";
    $html_output .= '</table>' . "\n";
    return array($html_output, $found_rows);
}
开发者ID:siddhantsomani,项目名称:phpmyadmin,代码行数:32,代码来源:server_privileges.lib.php

示例2: testPMAGetUserSpecificRights

 /**
  * Tests for PMA_getUserSpecificRights
  *
  * @return void
  */
 function testPMAGetUserSpecificRights()
 {
     // Setup for the test
     $GLOBALS['dbi']->expects($this->any())->method('fetchAssoc')->will($this->onConsecutiveCalls(array('Db' => 'y'), false, array('Db' => 'y'), false, false, array('Table_name' => 't')));
     // Test case 1
     $tables = array('columns_priv');
     $user_host_condition = '';
     $dbname = '';
     $expected = array('y' => array('privs' => array('USAGE'), 'Db' => 'y', 'Grant_priv' => 'N', 'Column_priv' => true, 'can_delete' => true));
     $actual = PMA_getUserSpecificRights($tables, $user_host_condition, $dbname);
     $this->assertEquals($expected, $actual);
     // Test case 2
     $dbname = 'db';
     $expected = array('t' => array('Table_name' => 't'));
     $actual = PMA_getUserSpecificRights($tables, $user_host_condition, $dbname);
     $this->assertEquals($expected, $actual);
 }
开发者ID:nobodypb,项目名称:phpmyadmin,代码行数:22,代码来源:PMA_server_privileges_test.php

示例3: PMA_getHtmlForAllTableSpecificRights

/**
 * Get a HTML table for display user's tabel specific or database specific rights
 *
 * @param string $username username
 * @param string $hostname host name
 * @param string $type     database, table or routine
 * @param string $dbname   database name
 *
 * @return array $html_output
 */
function PMA_getHtmlForAllTableSpecificRights($username, $hostname, $type, $dbname = '')
{
    $uiData = array('database' => array('formId' => 'database_specific_priv', 'subMenuLabel' => __('Database'), 'legend' => __('Database-specific privileges'), 'typeLabel' => __('Database')), 'table' => array('formId' => 'table_specific_priv', 'subMenuLabel' => __('Table'), 'legend' => __('Table-specific privileges'), 'typeLabel' => __('Table')), 'routine' => array('formId' => 'routine_specific_priv', 'subMenuLabel' => __('Routine'), 'legend' => __('Routine-specific privileges'), 'typeLabel' => __('Routine')));
    /**
     * no db name given, so we want all privs for the given user
     * db name was given, so we want all user specific rights for this db
     */
    $db_rights = PMA_getUserSpecificRights($username, $hostname, $type, $dbname);
    ksort($db_rights);
    $foundRows = array();
    $privileges = array();
    foreach ($db_rights as $row) {
        $onePrivilege = array();
        $paramDbName = '';
        $paramTableName = '';
        $paramRoutineName = '';
        if ($type == 'database') {
            $name = $row['Db'];
            $onePrivilege['grant'] = $row['Grant_priv'] == 'Y';
            $onePrivilege['tablePrivs'] = !empty($row['Table_priv']) || !empty($row['Column_priv']);
            $onePrivilege['privileges'] = join(',', PMA_extractPrivInfo($row, true));
            $paramDbName = $row['Db'];
        } elseif ($type == 'table') {
            $name = $row['Table_name'];
            $onePrivilege['grant'] = in_array('Grant', explode(',', $row['Table_priv']));
            $onePrivilege['columnPrivs'] = !empty($row['Column_priv']);
            $onePrivilege['privileges'] = join(',', PMA_extractPrivInfo($row, true));
            $paramDbName = $dbname;
            $paramTableName = $row['Table_name'];
        } else {
            // routine
            $name = $row['Routine_name'];
            $onePrivilege['grant'] = in_array('Grant', explode(',', $row['Proc_priv']));
            $privs = array('Alter_routine_priv' => 'N', 'Execute_priv' => 'N', 'Grant_priv' => 'N');
            foreach (explode(',', $row['Proc_priv']) as $priv) {
                if ($priv == 'Alter Routine') {
                    $privs['Alter_routine_priv'] = 'Y';
                } else {
                    $privs[$priv . '_priv'] = 'Y';
                }
            }
            $onePrivilege['privileges'] = join(',', PMA_extractPrivInfo($privs, true));
            $paramDbName = $dbname;
            $paramRoutineName = $row['Routine_name'];
        }
        $foundRows[] = $name;
        $onePrivilege['name'] = $name;
        $onePrivilege['editLink'] = '';
        if ($GLOBALS['is_grantuser']) {
            $onePrivilege['editLink'] = PMA_getUserLink('edit', $username, $hostname, $paramDbName, $paramTableName, $paramRoutineName);
        }
        $onePrivilege['revokeLink'] = '';
        if ($type != 'database' || !empty($row['can_delete'])) {
            $onePrivilege['revokeLink'] = PMA_getUserLink('revoke', $username, $hostname, $paramDbName, $paramTableName, $paramRoutineName);
        }
        $privileges[] = $onePrivilege;
    }
    $data = $uiData[$type];
    $data['privileges'] = $privileges;
    $data['userName'] = $username;
    $data['hostName'] = $hostname;
    $data['database'] = $dbname;
    $data['type'] = $type;
    if ($type == 'database') {
        // we already have the list of databases from libraries/common.inc.php
        // via $pma = new PMA;
        $pred_db_array = $GLOBALS['pma']->databases;
        $databases_to_skip = array('information_schema', 'performance_schema');
        $databases = array();
        if (!empty($pred_db_array)) {
            foreach ($pred_db_array as $current_db) {
                if (in_array($current_db, $databases_to_skip)) {
                    continue;
                }
                $current_db_escaped = PMA_Util::escapeMysqlWildcards($current_db);
                // cannot use array_diff() once, outside of the loop,
                // because the list of databases has special characters
                // already escaped in $foundRows,
                // contrary to the output of SHOW DATABASES
                if (!in_array($current_db_escaped, $foundRows)) {
                    $databases[] = $current_db;
                }
            }
        }
        $data['databases'] = $databases;
    } elseif ($type == 'table') {
        $result = @$GLOBALS['dbi']->tryQuery("SHOW TABLES FROM " . PMA_Util::backquote($dbname), null, PMA_DatabaseInterface::QUERY_STORE);
        $tables = array();
        if ($result) {
            while ($row = $GLOBALS['dbi']->fetchRow($result)) {
//.........这里部分代码省略.........
开发者ID:joshuawatson,项目名称:phpmyadmin,代码行数:101,代码来源:server_privileges.lib.php

示例4: PMA_getTableForDisplayAllTableSpecificRights

/**
 * Get a HTML table for display user's tabel specific or database specific rights
 *
 * @param string $username      username
 * @param string $hostname      host name
 * @param string $dbname        database name
 * @param string $link_edit     standard link to edit privileges
 * @param string $link_revoke   standard link to revoke
 *
 * @return array $html_output, $found_rows
 */
function PMA_getTableForDisplayAllTableSpecificRights($username, $hostname, $link_edit, $link_revoke, $dbname)
{
    // table header
    $html_output = PMA_generate_common_hidden_inputs('', '') . '<input type="hidden" name="username" ' . 'value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset>' . "\n" . '<legend>' . (!strlen($dbname) ? __('Database-specific privileges') : __('Table-specific privileges')) . '</legend>' . "\n" . '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . (!strlen($dbname) ? __('Database') : __('Table')) . '</th>' . "\n" . '<th>' . __('Privileges') . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th>' . (!strlen($dbname) ? __('Table-specific privileges') : __('Column-specific privileges')) . '</th>' . "\n" . '<th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $user_host_condition = ' WHERE `User`' . ' = \'' . PMA_CommonFunctions::getInstance()->sqlAddSlashes($username) . "'" . ' AND `Host`' . ' = \'' . PMA_CommonFunctions::getInstance()->sqlAddSlashes($hostname) . "'";
    // table body
    // get data
    // we also want privielgs for this user not in table `db` but in other table
    $tables = PMA_DBI_fetch_result('SHOW TABLES FROM `mysql`;');
    /**
     * no db name given, so we want all privs for the given user
     * db name was given, so we want all user specific rights for this db
     */
    $db_rights = PMA_getUserSpecificRights($tables, $user_host_condition, $dbname);
    ksort($db_rights);
    $html_output .= '<tbody>' . "\n";
    // display rows
    list($found_rows, $html_out) = PMA_getHtmlForDisplayUserRightsInRows($db_rights, $link_edit, $dbname, $link_revoke, $hostname, $username);
    $html_output .= $html_out;
    $html_output .= '</tbody>' . "\n";
    $html_output .= '</table>' . "\n";
    return array($html_output, $found_rows);
}
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:34,代码来源:server_privileges.lib.php


注:本文中的PMA_getUserSpecificRights函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。