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


PHP PMA_wildcardEscapeForGrant函數代碼示例

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


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

示例1: PMA_updatePrivileges

/**
 * Update the privileges and return the success or error message
 *
 * @param string $username  username
 * @param string $hostname  host name
 * @param string $tablename table name
 * @param string $dbname    database name
 *
 * @return PMA_message success message or error message for update
 */
function PMA_updatePrivileges($username, $hostname, $tablename, $dbname)
{
    $db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
    $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';';
    if (!isset($_POST['Grant_priv']) || $_POST['Grant_priv'] != 'Y') {
        $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';';
    } else {
        $sql_query1 = '';
    }
    // Should not do a GRANT USAGE for a table-specific privilege, it
    // causes problems later (cannot revoke it)
    if (!(mb_strlen($tablename) && 'USAGE' == implode('', PMA_extractPrivInfo()))) {
        $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\'';
        if (!mb_strlen($dbname)) {
            // add REQUIRE clause
            $sql_query2 .= PMA_getRequireClause();
        }
        if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y' || !mb_strlen($dbname) && (isset($_POST['max_questions']) || isset($_POST['max_connections']) || isset($_POST['max_updates']) || isset($_POST['max_user_connections']))) {
            $sql_query2 .= PMA_getWithClauseForAddUserAndUpdatePrivs();
        }
        $sql_query2 .= ';';
    }
    if (!$GLOBALS['dbi']->tryQuery($sql_query0)) {
        // This might fail when the executing user does not have
        // ALL PRIVILEGES himself.
        // See https://sourceforge.net/p/phpmyadmin/bugs/3270/
        $sql_query0 = '';
    }
    if (!empty($sql_query1) && !$GLOBALS['dbi']->tryQuery($sql_query1)) {
        // this one may fail, too...
        $sql_query1 = '';
    }
    if (!empty($sql_query2)) {
        $GLOBALS['dbi']->query($sql_query2);
    } else {
        $sql_query2 = '';
    }
    $sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
    $message = PMA_Message::success(__('You have updated the privileges for %s.'));
    $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
    return array($sql_query, $message);
}
開發者ID:siddhantsomani,項目名稱:phpmyadmin,代碼行數:52,代碼來源:server_privileges.lib.php

示例2: testPMAWildcardEscapeForGrant

 /**
  * Test for PMA_wildcardEscapeForGrant
  *
  * @return void
  */
 public function testPMAWildcardEscapeForGrant()
 {
     $dbname = '';
     $tablename = '';
     $db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
     $this->assertEquals('*.*', $db_and_table);
     $dbname = 'dbname';
     $tablename = '';
     $db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
     $this->assertEquals('`dbname`.*', $db_and_table);
     $dbname = 'dbname';
     $tablename = 'tablename';
     $db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
     $this->assertEquals('`dbname`.`tablename`', $db_and_table);
 }
開發者ID:netroby,項目名稱:phpmyadmin,代碼行數:20,代碼來源:PMA_server_privileges_test.php

示例3: PMA_DBI_query

    if (isset($sql_query2)) {
        PMA_DBI_query($sql_query2);
    } else {
        $sql_query2 = '';
    }
    $sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
    $message = PMA_Message::success(__('You have updated the privileges for %s.'));
    $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
}


/**
 * Revokes Privileges
 */
if (isset($_REQUEST['revokeall'])) {
    $db_and_table = PMA_wildcardEscapeForGrant($dbname, isset($tablename) ? $tablename : '');

    $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table
        . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
    $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table
        . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';

    PMA_DBI_query($sql_query0);
    if (! PMA_DBI_try_query($sql_query1)) {
        // this one may fail, too...
        $sql_query1 = '';
    }
    $sql_query = $sql_query0 . ' ' . $sql_query1;
    $message = PMA_Message::success(__('You have revoked the privileges for %s'));
    $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
    if (! isset($tablename)) {
開發者ID:nicokaiser,項目名稱:phpmyadmin,代碼行數:31,代碼來源:server_privileges.php

示例4: PMA_updatePrivileges

/**
 * Update the privileges and return the success or error message
 *
 * @param string $dbname        database name
 * @param string $tablename     table name
 * @param string $username      username
 * @param string $hostname      host name
 *
 * @return PMA_message success message or error message for update
 */
function PMA_updatePrivileges($username, $hostname, $tablename, $dbname)
{
    $common_functions = PMA_CommonFunctions::getInstance();
    $db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
    $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
    if (!isset($_POST['Grant_priv']) || $_POST['Grant_priv'] != 'Y') {
        $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
    } else {
        $sql_query1 = '';
    }
    // Should not do a GRANT USAGE for a table-specific privilege, it
    // causes problems later (cannot revoke it)
    if (!(strlen($tablename) && 'USAGE' == implode('', PMA_extractPrivInfo()))) {
        $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\'';
        if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y' || !strlen($dbname) && (isset($_POST['max_questions']) || isset($_POST['max_connections']) || isset($_POST['max_updates']) || isset($_POST['max_user_connections']))) {
            $sql_query2 .= PMA_getWithClauseForAddUserAndUpdatePrivs();
        }
        $sql_query2 .= ';';
    }
    if (!PMA_DBI_try_query($sql_query0)) {
        // This might fail when the executing user does not have ALL PRIVILEGES himself.
        // See https://sourceforge.net/tracker/index.php?func=detail&aid=3285929&group_id=23067&atid=377408
        $sql_query0 = '';
    }
    if (isset($sql_query1) && !PMA_DBI_try_query($sql_query1)) {
        // this one may fail, too...
        $sql_query1 = '';
    }
    if (isset($sql_query2)) {
        PMA_DBI_query($sql_query2);
    } else {
        $sql_query2 = '';
    }
    $sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
    $message = PMA_Message::success(__('You have updated the privileges for %s.'));
    $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
    return array($sql_query, $message);
}
開發者ID:rajatsinghal,項目名稱:phpmyadmin,代碼行數:48,代碼來源:server_privileges.lib.php


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