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


PHP PMA_getListOfPrivilegesAndComparedPrivileges函数代码示例

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


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

示例1: PMA_getPrivMap

/**
 * gets privilege map
 *
 * @param string $db the database
 *
 * @return array $privMap the privilege map
 */
function PMA_getPrivMap($db)
{
    list($listOfPrivs, $listOfComparedPrivs) = PMA_getListOfPrivilegesAndComparedPrivileges();
    $sql_query = "(" . " SELECT " . $listOfPrivs . ", '*' AS `Db`, 'g' AS `Type`" . " FROM `mysql`.`user`" . " WHERE NOT (" . $listOfComparedPrivs . ")" . ")" . " UNION " . "(" . " SELECT " . $listOfPrivs . ", `Db`, 'd' AS `Type`" . " FROM `mysql`.`db`" . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . "     AND NOT (" . $listOfComparedPrivs . ")" . ")" . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC;";
    $res = $GLOBALS['dbi']->query($sql_query);
    $privMap = array();
    PMA_mergePrivMapFromResult($privMap, $res);
    return $privMap;
}
开发者ID:siddhantsomani,项目名称:phpmyadmin,代码行数:16,代码来源:server_privileges.lib.php

示例2: PMA_getHtmlForSpecificDbPrivileges

/**
 * Get the HTML for user form and check the privileges for a particular database.
 *
 * @param string $link_edit         standard link for edit
 * @param string $conditional_class if ajaxable 'Ajax' otherwise ''
 *
 * @return string $html_output
 */
function PMA_getHtmlForSpecificDbPrivileges($link_edit, $conditional_class)
{
    // check the privileges for a particular database.
    $html_output = '<form id="usersForm" action="server_privileges.php">' . '<fieldset>' . "\n";
    $html_output .= '<legend>' . "\n" . PMA_Util::getIcon('b_usrcheck.png') . '    ' . sprintf(__('Users having access to &quot;%s&quot;'), '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($_REQUEST['checkprivs']) . '">' . htmlspecialchars($_REQUEST['checkprivs']) . '</a>') . "\n" . '</legend>' . "\n";
    $html_output .= '<table id="dbspecificuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Type') . '</th>' . "\n" . '<th>' . __('Privileges') . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th>' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $odd_row = true;
    // now, we build the table...
    list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges();
    $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' . ' FROM `mysql`.`db`' . ' WHERE \'' . PMA_Util::sqlAddSlashes($_REQUEST['checkprivs']) . "'" . ' LIKE `Db`' . ' AND NOT (' . $list_of_compared_privileges . ')) ' . 'UNION ' . '(SELECT ' . $list_of_privileges . ', \'*\' AS `Db`' . ' FROM `mysql`.`user` ' . ' WHERE NOT (' . $list_of_compared_privileges . ')) ' . ' ORDER BY `User` ASC,' . '  `Host` ASC,' . '  `Db` ASC;';
    $res = PMA_DBI_query($sql_query);
    $row = PMA_DBI_fetch_assoc($res);
    if ($row) {
        $found = true;
    }
    $html_output .= PMA_getHtmlTableBodyForSpecificDbPrivs($found, $row, $odd_row, $link_edit, $res);
    $html_output .= '</table>' . '</fieldset>' . '</form>' . "\n";
    if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request'])) {
        $message = PMA_Message::success(__('User has been added.'));
        $response = PMA_Response::getInstance();
        $response->addJSON('message', $message);
        $response->addJSON('user_form', $html_output);
        exit;
    } else {
        // Offer to create a new user for the current database
        $html_output .= '<fieldset id="fieldset_add_user">' . "\n" . '<legend>' . _pgettext('Create new user', 'New') . '</legend>' . "\n";
        $html_output .= '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1&amp;' . 'dbname=' . htmlspecialchars($_REQUEST['checkprivs']) . '" rel="' . 'checkprivs=' . htmlspecialchars($_REQUEST['checkprivs']) . '&amp;' . $GLOBALS['url_query'] . '" class="' . $conditional_class . '" name="db_specific">' . "\n" . PMA_Util::getIcon('b_usradd.png') . '        ' . __('Add user') . '</a>' . "\n";
        $html_output .= '</fieldset>' . "\n";
    }
    return $html_output;
}
开发者ID:SashiAsakura,项目名称:AWS_QuikID_website,代码行数:39,代码来源:server_privileges.lib.php

示例3: testPMAGetListOfPrivilegesAndComparedPrivileges

 /**
  * Test for PMA_getListOfPrivilegesAndComparedPrivileges
  *
  * @return void
  */
 public function testPMAGetListOfPrivilegesAndComparedPrivileges()
 {
     list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges();
     $expect = "`User`, `Host`, `Select_priv`, `Insert_priv`";
     $this->assertContains($expect, $list_of_privileges);
     $expect = "`Select_priv` = 'N' AND `Insert_priv` = 'N'";
     $this->assertContains($expect, $list_of_compared_privileges);
     $expect = "`Create_routine_priv` = 'N' AND `Alter_routine_priv` = 'N'";
     $this->assertContains($expect, $list_of_compared_privileges);
 }
开发者ID:netroby,项目名称:phpmyadmin,代码行数:15,代码来源:PMA_server_privileges_test.php

示例4: PMA_getHtmlForSpecificTablePrivileges

/**
 * Get the HTML for user form and check the privileges for a particular table.
 *
 * @param string $db    database name
 * @param string $table table name
 *
 * @return string $html_output
 */
function PMA_getHtmlForSpecificTablePrivileges($db, $table)
{
    // check the privileges for a particular table.
    $html_output = '<form id="usersForm" action="server_privileges.php">';
    $html_output .= '<fieldset>';
    $html_output .= '<legend>' . PMA_Util::getIcon('b_usrcheck.png') . sprintf(__('Users having access to "%s"'), '<a href="' . $GLOBALS['cfg']['DefaultTabTable'] . PMA_URL_getCommon(array('db' => $db, 'table' => $table)) . '">' . htmlspecialchars($db) . '.' . htmlspecialchars($table) . '</a>') . '</legend>';
    $html_output .= '<table id="tablespecificuserrights" class="data">';
    $html_output .= '<thead>' . '<tr><th>' . __('User') . '</th>' . '<th>' . __('Host') . '</th>' . '<th>' . __('Type') . '</th>' . '<th>' . __('Privileges') . '</th>' . '<th>' . __('Grant') . '</th>' . '<th>' . __('Action') . '</th>' . '</tr>' . '</thead>';
    list($listOfPrivs, $listOfComparedPrivs) = PMA_getListOfPrivilegesAndComparedPrivileges();
    $sql_query = "(" . " SELECT " . $listOfPrivs . ", '*' AS `Db`, 'g' AS `Type`" . " FROM `mysql`.`user`" . " WHERE NOT (" . $listOfComparedPrivs . ")" . ")" . " UNION " . "(" . " SELECT " . $listOfPrivs . ", `Db`, 'd' AS `Type`" . " FROM `mysql`.`db`" . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . "     AND NOT (" . $listOfComparedPrivs . ")" . ")" . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC;";
    $res = $GLOBALS['dbi']->query($sql_query);
    $privMap = array();
    while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
        $user = $row['User'];
        $host = $row['Host'];
        if (!isset($privMap[$user])) {
            $privMap[$user] = array();
        }
        if (!isset($privMap[$user][$host])) {
            $privMap[$user][$host] = array();
        }
        $privMap[$user][$host][] = $row;
    }
    $sql_query = "SELECT `User`, `Host`, `Db`," . " 't' AS `Type`, `Table_name`, `Table_priv`" . " FROM `mysql`.`tables_priv`" . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . "     AND '" . PMA_Util::sqlAddSlashes($table) . "' LIKE `Table_name`" . "     AND NOT (`Table_priv` = '' AND Column_priv = '')" . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC, `Table_priv` ASC;";
    $res = $GLOBALS['dbi']->query($sql_query);
    while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
        $user = $row['User'];
        $host = $row['Host'];
        if (!isset($privMap[$user])) {
            $privMap[$user] = array();
        }
        if (!isset($privMap[$user][$host])) {
            $privMap[$user][$host] = array();
        }
        $privMap[$user][$host][] = $row;
    }
    $html_output .= PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db);
    $html_output .= '</table>';
    $html_output .= '</fieldset>';
    $html_output .= '</form>';
    // Offer to create a new user for the current database
    $html_output .= '<fieldset id="fieldset_add_user">' . '<legend>' . _pgettext('Create new user', 'New') . '</legend>';
    $html_output .= '<a href="server_privileges.php' . PMA_URL_getCommon(array('adduser' => 1, 'dbname' => $db, 'tablename' => $table)) . '" rel="' . PMA_URL_getCommon(array('checkprivsdb' => $db, 'checkprivstable' => $table)) . '" class="ajax" name="table_specific">' . PMA_Util::getIcon('b_usradd.png') . __('Add user') . '</a>';
    $html_output .= '</fieldset>';
    return $html_output;
}
开发者ID:JaRomero95,项目名称:dwes,代码行数:54,代码来源:server_privileges.lib.php


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