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


PHP PMA_getSqlQueriesForDisplayAndAddUser函数代码示例

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


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

示例1: testPMAGetSqlQueriesForDisplayAndAddUser

 /**
  * Test for PMA_getSqlQueriesForDisplayAndAddUser
  *
  * @return void
  */
 public function testPMAGetSqlQueriesForDisplayAndAddUser()
 {
     $username = "PMA_username";
     $hostname = "PMA_hostname";
     $password = "pma_password";
     $_POST['pred_password'] = 'keep';
     $_REQUEST['authentication_plugin'] = 'mysql_native_password';
     $dbname = "PMA_db";
     list($create_user_real, $create_user_show, $real_sql_query, $sql_query) = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password);
     //validate 1: $create_user_real
     $this->assertEquals("CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED " . "WITH mysql_native_password AS 'pma_password';", $create_user_real);
     //validate 2: $create_user_show
     $this->assertEquals("CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED " . "WITH mysql_native_password AS '***';", $create_user_show);
     //validate 3:$real_sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $real_sql_query);
     //validate 4:$sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $sql_query);
     //test for PMA_addUserAndCreateDatabase
     list($sql_query, $message) = PMA_addUserAndCreateDatabase(false, $real_sql_query, $sql_query, $username, $hostname, $dbname);
     //validate 5: $sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $sql_query);
     //validate 6: $message
     $this->assertEquals("You have added a new user.", $message->getMessage());
 }
开发者ID:netroby,项目名称:phpmyadmin,代码行数:29,代码来源:PMA_server_privileges_test.php

示例2: PMA_addUser

/**
 * update Data for information: Adds a user
 *
 * @param string $dbname      db name
 * @param string $username    user name
 * @param string $hostname    host name
 * @param string $password    password
 * @param bool   $is_menuwork is_menuwork set?
 *
 * @return array
 */
function PMA_addUser($dbname, $username, $hostname, $password, $is_menuwork)
{
    $_add_user_error = false;
    $message = null;
    $queries = null;
    $queries_for_display = null;
    $sql_query = null;
    if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
        $sql_query = '';
        if ($_POST['pred_username'] == 'any') {
            $username = '';
        }
        switch ($_POST['pred_hostname']) {
            case 'any':
                $hostname = '%';
                break;
            case 'localhost':
                $hostname = 'localhost';
                break;
            case 'hosttable':
                $hostname = '';
                break;
            case 'thishost':
                $_user_name = $GLOBALS['dbi']->fetchValue('SELECT USER()');
                $hostname = mb_substr($_user_name, mb_strrpos($_user_name, '@') + 1);
                unset($_user_name);
                break;
        }
        $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';";
        if ($GLOBALS['dbi']->fetchValue($sql) == 1) {
            $message = PMA_Message::error(__('The user %s already exists!'));
            $message->addParam('[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]');
            $_REQUEST['adduser'] = true;
            $_add_user_error = true;
        } else {
            list($create_user_real, $create_user_show, $real_sql_query, $sql_query) = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, isset($password) ? $password : '');
            if (empty($_REQUEST['change_copy'])) {
                $_error = false;
                if (isset($create_user_real)) {
                    if (!$GLOBALS['dbi']->tryQuery($create_user_real)) {
                        $_error = true;
                    }
                    $sql_query = $create_user_show . $sql_query;
                }
                list($sql_query, $message) = PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query, $username, $hostname, isset($dbname) ? $dbname : null);
                if (!empty($_REQUEST['userGroup']) && $is_menuwork) {
                    PMA_setUserGroup($GLOBALS['username'], $_REQUEST['userGroup']);
                }
            } else {
                if (isset($create_user_real)) {
                    $queries[] = $create_user_real;
                }
                $queries[] = $real_sql_query;
                // we put the query containing the hidden password in
                // $queries_for_display, at the same position occupied
                // by the real query in $queries
                $tmp_count = count($queries);
                if (isset($create_user_real)) {
                    $queries_for_display[$tmp_count - 2] = $create_user_show;
                }
                $queries_for_display[$tmp_count - 1] = $sql_query;
            }
            unset($real_sql_query);
        }
    }
    return array($message, $queries, $queries_for_display, $sql_query, $_add_user_error);
}
开发者ID:siddhantsomani,项目名称:phpmyadmin,代码行数:78,代码来源:server_privileges.lib.php

示例3: testPMAGetSqlQueriesForDisplayAndAddUser

 /**
  * Test for PMA_getSqlQueriesForDisplayAndAddUser
  *
  * @return void
  */
 public function testPMAGetSqlQueriesForDisplayAndAddUser()
 {
     $username = "PMA_username";
     $hostname = "PMA_hostname";
     $password = "PMA_password";
     $dbname = "PMA_db";
     list($create_user_real, $create_user_show, $real_sql_query, $sql_query) = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password);
     //validate 1: $create_user_real
     $this->assertEquals("CREATE USER 'PMA_username'@'PMA_hostname';", $create_user_real);
     //validate 2: $create_user_show
     $this->assertEquals("CREATE USER 'PMA_username'@'PMA_hostname';", $create_user_show);
     //validate 3:$real_sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $real_sql_query);
     //validate 4:$sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $sql_query);
     //test for PMA_addUserAndCreateDatabase
     list($sql_query, $message) = PMA_addUserAndCreateDatabase(false, $real_sql_query, $sql_query, $username, $hostname, $dbname);
     //validate 5: $sql_query
     $this->assertEquals("GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;", $sql_query);
     //validate 6: $message
     $this->assertEquals("You have added a new user.", $message->getMessage());
 }
开发者ID:nobodypb,项目名称:phpmyadmin,代码行数:27,代码来源:PMA_server_privileges_test.php

示例4: testPMAGetSqlQueriesForDisplayAndAddUser

    /**
     * Test for PMA_getSqlQueriesForDisplayAndAddUser
     *
     * @return void
     */
    public function testPMAGetSqlQueriesForDisplayAndAddUser()
    {
        $restoreMySQLVersion = "PMANORESTORE";

        if (! PMA_HAS_RUNKIT) {
            $this->markTestSkipped(
                'Cannot redefine constant. Missing runkit extension'
            );
        } else {
            $restoreMySQLVersion = PMA_MYSQL_INT_VERSION;
            runkit_constant_redefine('PMA_MYSQL_INT_VERSION', 50706);
        }

        $username = "PMA_username";
        $hostname = "PMA_hostname";
        $password = "pma_password";
        $_POST['pred_password'] = 'keep';
        $_REQUEST['authentication_plugin'] = 'mysql_native_password';
        $dbname = "PMA_db";

        list($create_user_real, $create_user_show, $real_sql_query, $sql_query)
            = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password);

        //validate 1: $create_user_real
        $this->assertEquals(
            "CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED "
            . "WITH mysql_native_password AS 'pma_password';",
            $create_user_real
        );

        //validate 2: $create_user_show
        $this->assertEquals(
            "CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED "
            . "WITH mysql_native_password AS '***';",
            $create_user_show
        );

        //validate 3:$real_sql_query
        $this->assertEquals(
            "GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
            $real_sql_query
        );

        //validate 4:$sql_query
        $this->assertEquals(
            "GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
            $sql_query
        );

        //test for PMA_addUserAndCreateDatabase
        list($sql_query, $message) = PMA_addUserAndCreateDatabase(
            false, $real_sql_query, $sql_query, $username, $hostname, $dbname
        );

        //validate 5: $sql_query
        $this->assertEquals(
            "GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
            $sql_query
        );

        //validate 6: $message
        $this->assertEquals(
            "You have added a new user.",
            $message->getMessage()
        );

        if ($restoreMySQLVersion !== "PMANORESTORE") {
            runkit_constant_redefine('PMA_MYSQL_INT_VERSION', $restoreMySQLVersion);
        }
    }
开发者ID:nijel,项目名称:phpmyadmin,代码行数:75,代码来源:PMA_server_privileges_test.php

示例5: PMA_DBI_fetch_value

         $hostname = '';
         break;
     case 'thishost':
         $_user_name = PMA_DBI_fetch_value('SELECT USER()');
         $hostname = substr($_user_name, strrpos($_user_name, '@') + 1);
         unset($_user_name);
         break;
 }
 $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';";
 if (PMA_DBI_fetch_value($sql) == 1) {
     $message = PMA_Message::error(__('The user %s already exists!'));
     $message->addParam('[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]');
     $_REQUEST['adduser'] = true;
     $_add_user_error = true;
 } else {
     list($create_user_real, $create_user_show, $real_sql_query, $sql_query) = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, isset($password) ? $password : '');
     if (empty($_REQUEST['change_copy'])) {
         $_error = false;
         if (isset($create_user_real)) {
             if (!PMA_DBI_try_query($create_user_real)) {
                 $_error = true;
             }
             $sql_query = $create_user_show . $sql_query;
         }
         list($sql_query, $message) = PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query, $username, $hostname, isset($dbname) ? $dbname : null);
     } else {
         if (isset($create_user_real)) {
             $queries[] = $create_user_real;
         }
         $queries[] = $real_sql_query;
         // we put the query containing the hidden password in
开发者ID:SashiAsakura,项目名称:AWS_QuikID_website,代码行数:31,代码来源:server_privileges.php

示例6: PMA_DBI_fetch_value

        $_user_name = PMA_DBI_fetch_value('SELECT USER()');
        $hostname = substr($_user_name, (strrpos($_user_name, '@') + 1));
        unset($_user_name);
        break;
    }
    $sql = "SELECT '1' FROM `mysql`.`user`"
        . " WHERE `User` = '" . $common_functions->sqlAddSlashes($username) . "'"
        . " AND `Host` = '" . $common_functions->sqlAddSlashes($hostname) . "';";
    if (PMA_DBI_fetch_value($sql) == 1) {
        $message = PMA_Message::error(__('The user %s already exists!'));
        $message->addParam('[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]');
        $_REQUEST['adduser'] = true;
        $_add_user_error = true;
    } else {
        list($create_user_real, $create_user_show, $real_sql_query, $sql_query)
            = PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password);

        if (empty($_REQUEST['change_copy'])) {
            $_error = false;

            if (isset($create_user_real)) {
                if (! PMA_DBI_try_query($create_user_real)) {
                    $_error = true;
                }
                $sql_query = $create_user_show . $sql_query;
            }
            list($sql_query, $message) = PMA_addUserAndCreateDatabase(
                $_error, $real_sql_query, $sql_query, $username, $hostname
            );

        } else {
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:31,代码来源:server_privileges.php

示例7: substr

        $hostname = substr($_user_name, (strrpos($_user_name, '@') + 1));
        unset($_user_name);
        break;
    }
    $sql = "SELECT '1' FROM `mysql`.`user`"
        . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'"
        . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';";
    if (PMA_DBI_fetch_value($sql) == 1) {
        $message = PMA_Message::error(__('The user %s already exists!'));
        $message->addParam('[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]');
        $_REQUEST['adduser'] = true;
        $_add_user_error = true;
    } else {
        list($create_user_real, $create_user_show, $real_sql_query, $sql_query)
            = PMA_getSqlQueriesForDisplayAndAddUser(
                $username, $hostname, (isset ($password) ? $password : '')
            );

        if (empty($_REQUEST['change_copy'])) {
            $_error = false;

            if (isset($create_user_real)) {
                if (! PMA_DBI_try_query($create_user_real)) {
                    $_error = true;
                }
                $sql_query = $create_user_show . $sql_query;
            }
            list($sql_query, $message) = PMA_addUserAndCreateDatabase(
                $_error, $real_sql_query, $sql_query, $username, $hostname
            );
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:30,代码来源:server_privileges.php


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