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


PHP PMA_setUserGroup函数代码示例

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


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

示例1: 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

示例2: foreach

 */
if (!empty($_POST['update_privs'])) {
    if (is_array($dbname)) {
        foreach ($dbname as $key => $db_name) {
            list($sql_query[$key], $message) = PMA_updatePrivileges(isset($username) ? $username : '', isset($hostname) ? $hostname : '', isset($tablename) ? $tablename : '', isset($db_name) ? $db_name : '');
        }
        $sql_query = implode("\n", $sql_query);
    } else {
        list($sql_query, $message) = PMA_updatePrivileges(isset($username) ? $username : '', isset($hostname) ? $hostname : '', isset($tablename) ? $tablename : '', isset($dbname) ? $dbname : '');
    }
}
/**
 * Assign users to user groups
 */
if (!empty($_REQUEST['changeUserGroup']) && $cfgRelation['menuswork'] && $GLOBALS['is_superuser'] && $GLOBALS['is_createuser']) {
    PMA_setUserGroup($username, $_REQUEST['userGroup']);
    $message = PMA_Message::success();
}
/**
 * Revokes Privileges
 */
if (isset($_REQUEST['revokeall'])) {
    list($message, $sql_query) = PMA_getMessageAndSqlQueryForPrivilegesRevoke(isset($dbname) ? $dbname : '', isset($tablename) ? $tablename : '', $username, $hostname);
}
/**
 * Updates the password
 */
if (isset($_REQUEST['change_pw'])) {
    $message = PMA_updatePassword($err_url, $username, $hostname);
}
/**
开发者ID:xtreme-jamil-shamy,项目名称:phpmyadmin-cf,代码行数:31,代码来源:server_privileges.php


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