當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PMA_getGrantsArray函數代碼示例

本文整理匯總了PHP中PMA_getGrantsArray函數的典型用法代碼示例。如果您正苦於以下問題:PHP PMA_getGrantsArray函數的具體用法?PHP PMA_getGrantsArray怎麽用?PHP PMA_getGrantsArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了PMA_getGrantsArray函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: PMA_extractPrivInfo

/**
 * Extracts the privilege information of a priv table row
 *
 * @param array   $row        the row
 * @param boolean $enableHTML add <dfn> tag with tooltips
 *
 * @global  resource $user_link the database connection
 *
 * @return array
 */
function PMA_extractPrivInfo($row = '', $enableHTML = false)
{
    $grants = PMA_getGrantsArray();
    if (!empty($row) && isset($row['Table_priv'])) {
        $row1 = PMA_DBI_fetch_single_row('SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';', 'ASSOC', $GLOBALS['userlink']);
        $av_grants = explode('\',\'', substr($row1['Type'], 5, strlen($row1['Type']) - 7));
        unset($row1);
        $users_grants = explode(',', $row['Table_priv']);
        foreach ($av_grants as $current_grant) {
            $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
        }
        unset($current_grant);
    }
    $privs = array();
    $allPrivileges = true;
    foreach ($grants as $current_grant) {
        if (!empty($row) && isset($row[$current_grant[0]]) || empty($row) && isset($GLOBALS[$current_grant[0]])) {
            if (!empty($row) && $row[$current_grant[0]] == 'Y' || empty($row) && ($GLOBALS[$current_grant[0]] == 'Y' || is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $_REQUEST['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))) {
                if ($enableHTML) {
                    $privs[] = '<dfn title="' . $current_grant[2] . '">' . $current_grant[1] . '</dfn>';
                } else {
                    $privs[] = $current_grant[1];
                }
            } elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
                if ($enableHTML) {
                    $priv_string = '<dfn title="' . $current_grant[2] . '">' . $current_grant[1] . '</dfn>';
                } else {
                    $priv_string = $current_grant[1];
                }
                $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
            } else {
                $allPrivileges = false;
            }
        }
    }
    if (empty($privs)) {
        if ($enableHTML) {
            $privs[] = '<dfn title="' . __('No privileges.') . '">USAGE</dfn>';
        } else {
            $privs[] = 'USAGE';
        }
    } elseif ($allPrivileges && (!isset($_POST['grant_count']) || count($privs) == $_POST['grant_count'])) {
        if ($enableHTML) {
            $privs = array('<dfn title="' . __('Includes all privileges except GRANT.') . '">ALL PRIVILEGES</dfn>');
        } else {
            $privs = array('ALL PRIVILEGES');
        }
    }
    return $privs;
}
開發者ID:SashiAsakura,項目名稱:AWS_QuikID_website,代碼行數:60,代碼來源:server_privileges.lib.php

示例2: PMA_extractPrivInfo

/**
 * Extracts the privilege information of a priv table row
 *
 * @param array|null $row        the row
 * @param boolean    $enableHTML add <dfn> tag with tooltips
 * @param boolean    $tablePrivs whether row contains table privileges
 *
 * @global  resource $user_link the database connection
 *
 * @return array
 */
function PMA_extractPrivInfo($row = null, $enableHTML = false, $tablePrivs = false)
{
    if ($tablePrivs) {
        $grants = PMA_getTableGrantsArray();
    } else {
        $grants = PMA_getGrantsArray();
    }
    if (!is_null($row) && isset($row['Table_priv'])) {
        PMA_fillInTablePrivileges($row);
    }
    $privs = array();
    $allPrivileges = true;
    foreach ($grants as $current_grant) {
        if (!is_null($row) && isset($row[$current_grant[0]]) || is_null($row) && isset($GLOBALS[$current_grant[0]])) {
            if (!is_null($row) && $row[$current_grant[0]] == 'Y' || is_null($row) && ($GLOBALS[$current_grant[0]] == 'Y' || is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $_REQUEST['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))) {
                $privs[] = PMA_formatPrivilege($current_grant, $enableHTML);
            } elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
                $privs[] = PMA_formatPrivilege($current_grant, $enableHTML) . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
            } else {
                $allPrivileges = false;
            }
        }
    }
    if (empty($privs)) {
        if ($enableHTML) {
            $privs[] = '<dfn title="' . __('No privileges.') . '">USAGE</dfn>';
        } else {
            $privs[] = 'USAGE';
        }
    } elseif ($allPrivileges && (!isset($_POST['grant_count']) || count($privs) == $_POST['grant_count'])) {
        if ($enableHTML) {
            $privs = array('<dfn title="' . __('Includes all privileges except GRANT.') . '">ALL PRIVILEGES</dfn>');
        } else {
            $privs = array('ALL PRIVILEGES');
        }
    }
    return $privs;
}
開發者ID:siddhantsomani,項目名稱:phpmyadmin,代碼行數:49,代碼來源:server_privileges.lib.php

示例3: testPMAGetGrantsArray

 /**
  * Test for PMA_getGrantsArray
  *
  * @return void
  */
 public function testPMAGetGrantsArray()
 {
     $ret = PMA_getGrantsArray();
     $this->assertEquals(array('Select_priv', 'SELECT', __('Allows reading data.')), $ret[0]);
     $this->assertEquals(array('Insert_priv', 'INSERT', __('Allows inserting and replacing data.')), $ret[1]);
 }
開發者ID:netroby,項目名稱:phpmyadmin,代碼行數:11,代碼來源:PMA_server_privileges_test.php


注:本文中的PMA_getGrantsArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。