⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server_privileges.php

📁 phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站点下就可以用了
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        PMA_DBI_try_query($local_query)            or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);        $message = PMA_Message::success('strPasswordChanged');        $message->addParam('\'' . $username . '\'@\'' . $hostname . '\'');    }}/** * Deletes users *   (Changes / copies a user, part IV) */$user_host_separator = chr(27);if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4)) {    if (isset($_REQUEST['change_copy'])) {        $selected_usr = array($old_username . $user_host_separator . $old_hostname);    } else {        $selected_usr = $_REQUEST['selected_usr'];        $queries = array();    }    foreach ($selected_usr as $each_user) {        list($this_user, $this_host) = explode($user_host_separator, $each_user);        $queries[] = '# ' . sprintf($GLOBALS['strDeleting'], '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...';        $queries[] = 'DROP USER \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';';        if (isset($_REQUEST['drop_users_db'])) {            $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';';            $GLOBALS['reload'] = TRUE;            PMA_reloadNavigation();        }    }    if (empty($_REQUEST['change_copy'])) {        if (empty($queries)) {            $message = PMA_Message::error('strDeleteNoUsersSelected');        } else {            if ($_REQUEST['mode'] == 3) {                $queries[] = '# ' . $GLOBALS['strReloadingThePrivileges'] . ' ...';                $queries[] = 'FLUSH PRIVILEGES;';            }            $drop_user_error = '';            foreach ($queries as $sql_query) {                if ($sql_query{0} != '#') {                    if (! PMA_DBI_try_query($sql_query, $GLOBALS['userlink'])) {                        $drop_user_error .= PMA_DBI_getError() . "\n";                    }                }            }            $sql_query = join("\n", $queries);            if (! empty($drop_user_error)) {                $message = PMA_Message::rawError($drop_user_error);            } else {                $message = PMA_Message::success('strUsersDeleted');            }        }        unset($queries);    }}/** * Changes / copies a user, part V */if (isset($_REQUEST['change_copy'])) {    $tmp_count = 0;    foreach ($queries as $sql_query) {        if ($sql_query{0} != '#') {            PMA_DBI_query($sql_query);        }        // when there is a query containing a hidden password, take it        // instead of the real query sent        if (isset($queries_for_display[$tmp_count])) {            $queries[$tmp_count] = $queries_for_display[$tmp_count];        }        $tmp_count++;    }    $message = PMA_Message::success();    $sql_query = join("\n", $queries);}/** * Reloads the privilege tables into memory */if (isset($_REQUEST['flush_privileges'])) {    $sql_query = 'FLUSH PRIVILEGES;';    PMA_DBI_query($sql_query);    $message = PMA_Message::success('strPrivilegesReloaded');}/** * Displays the links */if (isset($viewing_mode) && $viewing_mode == 'db') {    $db = $checkprivs;    $url_query .= '&amp;goto=db_operations.php';    // Gets the database structure    $sub_part = '_structure';    require './libraries/db_info.inc.php';    echo "\n";} else {    require './libraries/server_links.inc.php';}/** * defines some standard links */$link_edit = '<a href="server_privileges.php?' . $GLOBALS['url_query']    . '&amp;username=%s'    . '&amp;hostname=%s'    . '&amp;dbname=%s'    . '&amp;tablename=%s">'    . PMA_getIcon('b_usredit.png', $GLOBALS['strEditPrivileges'])    . '</a>';$link_revoke = '<a href="server_privileges.php?' . $GLOBALS['url_query']    . '&amp;username=%s'    . '&amp;hostname=%s'    . '&amp;dbname=%s'    . '&amp;tablename=%s'    . '&amp;revokeall=1">'    . PMA_getIcon('b_usrdrop.png', $GLOBALS['strRevoke'])    . '</a>';/** * Displays the page */if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs))) {    if (! isset($username)) {        // No username is given --> display the overview        echo '<h2>' . "\n"           . PMA_getIcon('b_usrlist.png')           . $GLOBALS['strUserOverview'] . "\n"           . '</h2>' . "\n";        $sql_query =            'SELECT *,' .            "       IF(`Password` = _latin1 '', 'N', 'Y') AS 'Password'" .            '  FROM `mysql`.`user`';        $sql_query .= (isset($initial) ? PMA_RangeOfUsers($initial) : '');        $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';        $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);        if (! $res) {            // the query failed! This may have two reasons:            // - the user does not have enough privileges            // - the privilege tables use a structure of an earlier version.            // so let's try a more simple query            $sql_query = 'SELECT * FROM `mysql`.`user`';            $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);            if (!$res) {                PMA_Message::error('strNoPrivileges')->display();                PMA_DBI_free_result($res);                unset($res);            } else {                // rabus: This message is hardcoded because I will replace it by                // a automatic repair feature soon.                $raw = 'Your privilege table structure seems to be older than'                    . ' this MySQL version!<br />'                    . 'Please run the script <tt>mysql_fix_privilege_tables</tt>'                    . ' that should be included in your MySQL server distribution'                    . ' to solve this problem!';                PMA_Message::rawError($raw)->display();            }        } else {            // we also want users not in table `user` but in other table            $tables = PMA_DBI_fetch_result('SHOW TABLES FROM `mysql`;');            $tables_to_search_for_users = array(                'user', 'db', 'tables_priv', 'columns_priv', 'procs_priv',            );            $db_rights_sqls = array();            foreach ($tables_to_search_for_users as $table_search_in) {                if (in_array($table_search_in, $tables)) {                    $db_rights_sqls[] = 'SELECT DISTINCT `User`, `Host` FROM `mysql`.`' . $table_search_in . '` ' . (isset($initial) ? PMA_RangeOfUsers($initial) : '');                }            }            $user_defaults = array(                'User'      => '',                'Host'      => '%',                'Password'  => '?',                'Grant_priv' => 'N',                'privs'     => array('USAGE'),            );            // for all initials, even non A-Z            $array_initials = array();            // for the rights            $db_rights = array();            $db_rights_sql = '(' . implode(') UNION (', $db_rights_sqls) . ')'                .' ORDER BY `User` ASC, `Host` ASC';            $db_rights_result = PMA_DBI_query($db_rights_sql);            while ($db_rights_row = PMA_DBI_fetch_assoc($db_rights_result)) {                $db_rights_row = array_merge($user_defaults, $db_rights_row);                $db_rights[$db_rights_row['User']][$db_rights_row['Host']] =                    $db_rights_row;            }            PMA_DBI_free_result($db_rights_result);            unset($db_rights_sql, $db_rights_sqls, $db_rights_result, $db_rights_row);            ksort($db_rights);            /**             * Displays the initials             */            // initialize to FALSE the letters A-Z            for ($letter_counter = 1; $letter_counter < 27; $letter_counter++) {                if (! isset($array_initials[chr($letter_counter + 64)])) {                    $array_initials[chr($letter_counter + 64)] = FALSE;                }            }            $initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(`User`,1)) FROM `user` ORDER BY `User` ASC', null, PMA_DBI_QUERY_STORE);            while (list($tmp_initial) = PMA_DBI_fetch_row($initials)) {                $array_initials[$tmp_initial] = TRUE;            }            // Display the initials, which can be any characters, not            // just letters. For letters A-Z, we add the non-used letters            // as greyed out.            uksort($array_initials, "strnatcasecmp");            echo '<table cellspacing="5"><tr>';            foreach ($array_initials as $tmp_initial => $initial_was_found) {                if ($initial_was_found) {                    echo '<td><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;initial=' . urlencode($tmp_initial) . '">' . $tmp_initial . '</a></td>' . "\n";                } else {                    echo '<td>' . $tmp_initial . '</td>';                }            }            echo '<td><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;showall=1">[' . $GLOBALS['strShowAll'] . ']</a></td>' . "\n";            echo '</tr></table>';            /**            * Display the user overview            * (if less than 50 users, display them immediately)            */            if (isset($initial) || isset($showall) || PMA_DBI_num_rows($res) < 50) {                while ($row = PMA_DBI_fetch_assoc($res)) {                    $row['privs'] = PMA_extractPrivInfo($row, true);                    $db_rights[$row['User']][$row['Host']] = $row;                }                @PMA_DBI_free_result($res);                unset($res);                echo '<form name="usersForm" id="usersForm" action="server_privileges.php" method="post">' . "\n"                   . PMA_generate_common_hidden_inputs('', '')                   . '    <table id="tableuserrights" class="data">' . "\n"                   . '    <thead>' . "\n"                   . '        <tr><td></td>' . "\n"                   . '            <th>' . $GLOBALS['strUser'] . '</th>' . "\n"                   . '            <th>' . $GLOBALS['strHost'] . '</th>' . "\n"                   . '            <th>' . $GLOBALS['strPassword'] . '</th>' . "\n"                   . '            <th>' . $GLOBALS['strGlobalPrivileges'] . ' '                   . PMA_showHint($GLOBALS['strEnglishPrivileges']) . '</th>' . "\n"                   . '            <th>' . $GLOBALS['strGrantOption'] . '</th>' . "\n"                   . '            ' . ($GLOBALS['cfg']['PropertiesIconic'] ? '<td></td>' : '<th>' . $GLOBALS['strAction'] . '</th>') . "\n";                echo '        </tr>' . "\n";                echo '    </thead>' . "\n";                echo '    <tbody>' . "\n";                $odd_row = true;                $index_checkbox = -1;                foreach ($db_rights as $user) {                    $index_checkbox++;                    ksort($user);                    foreach ($user as $host) {                        $index_checkbox++;                        echo '        <tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n"                           . '            <td><input type="checkbox" name="selected_usr[]" id="checkbox_sel_users_'                            . $index_checkbox . '" value="'                            . str_replace(chr(27), '&#27;', htmlspecialchars($host['User'] . $user_host_separator . $host['Host']))                            . '"'                            . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')                            . ' /></td>' . "\n"                           . '            <td><label for="checkbox_sel_users_' . $index_checkbox . '">' . (empty($host['User']) ? '<span style="color: #FF0000">' . $GLOBALS['strAny'] . '</span>' : htmlspecialchars($host['User'])) . '</label></td>' . "\n"                           . '            <td>' . htmlspecialchars($host['Host']) . '</td>' . "\n";                        echo '            <td>';                        switch ($host['Password']) {                            case 'Y':                                echo $GLOBALS['strYes'];                                break;     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -