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

📄 server_privileges.php

📁 phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站点下就可以用了
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        } else {            $sql_query =                "SELECT `Table_priv`"                ." FROM `mysql`.`tables_priv`"                ." WHERE `User` = '" . PMA_sqlAddslashes($username) . "'"                ." AND `Host` = '" . PMA_sqlAddslashes($hostname) . "'"                ." AND `Db` = '" . PMA_unescape_mysql_wildcards($db) . "'"                ." AND `Table_name` = '" . PMA_sqlAddslashes($table) . "';";        }        $row = PMA_DBI_fetch_single_row($sql_query);    }    if (empty($row)) {        if ($table == '*') {            if ($db == '*') {                $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';            } elseif ($table == '*') {                $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';            }            $res = PMA_DBI_query($sql_query);            while ($row1 = PMA_DBI_fetch_row($res)) {                if (substr($row1[0], 0, 4) == 'max_') {                    $row[$row1[0]] = 0;                } else {                    $row[$row1[0]] = 'N';                }            }            PMA_DBI_free_result($res);        } else {            $row = array('Table_priv' => '');        }    }    if (isset($row['Table_priv'])) {        $row1 = PMA_DBI_fetch_single_row(            'SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';',            'ASSOC', $GLOBALS['userlink']);        // note: in MySQL 5.0.3 we get "Create View', 'Show view';        // the View for Create is spelled with uppercase V        // the view for Show is spelled with lowercase v        // and there is a space between the words        $av_grants = explode('\',\'', substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));        unset($row1);        $users_grants = explode(',', $row['Table_priv']);        foreach ($av_grants as $current_grant) {            $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';        }        unset($row['Table_priv'], $current_grant, $av_grants, $users_grants);        // get collumns        $res = PMA_DBI_try_query('SHOW COLUMNS FROM `' . PMA_unescape_mysql_wildcards($db) . '`.`' . $table . '`;');        $columns = array();        if ($res) {            while ($row1 = PMA_DBI_fetch_row($res)) {                $columns[$row1[0]] = array(                    'Select' => FALSE,                    'Insert' => FALSE,                    'Update' => FALSE,                    'References' => FALSE                );            }            PMA_DBI_free_result($res);        }        unset($res, $row1);    }    // t a b l e - s p e c i f i c    p r i v i l e g e s    if (! empty($columns)) {        $res = PMA_DBI_query(            'SELECT `Column_name`, `Column_priv`'            .' FROM `mysql`.`columns_priv`'            .' WHERE `User`'            .' = \'' . PMA_sqlAddslashes($username) . "'"            .' AND `Host`'            .' = \'' . PMA_sqlAddslashes($hostname) . "'"            .' AND `Db`'            .' = \'' . PMA_unescape_mysql_wildcards($db) . "'"            .' AND `Table_name`'            .' = \'' . PMA_sqlAddslashes($table) . '\';');        while ($row1 = PMA_DBI_fetch_row($res)) {            $row1[1] = explode(',', $row1[1]);            foreach ($row1[1] as $current) {                $columns[$row1[0]][$current] = TRUE;            }        }        PMA_DBI_free_result($res);        unset($res, $row1, $current);        echo '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n"           . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n"           . '<fieldset id="fieldset_user_priv">' . "\n"           . '    <legend>' . $GLOBALS['strTblPrivileges']           . PMA_showHint($GLOBALS['strEnglishPrivileges'])           . '</legend>' . "\n";        // privs that are attached to a specific column        PMA_display_column_privs($columns, $row, 'Select_priv',            'SELECT', 'select', $GLOBALS['strPrivDescSelect'], 'Select');        PMA_display_column_privs($columns, $row, 'Insert_priv',            'INSERT', 'insert', $GLOBALS['strPrivDescInsert'], 'Insert');        PMA_display_column_privs($columns, $row, 'Update_priv',            'UPDATE', 'update', $GLOBALS['strPrivDescUpdate'], 'Update');        PMA_display_column_privs($columns, $row, 'References_priv',            'REFERENCES', 'references', $GLOBALS['strPrivDescReferences'], 'References');        // privs that are not attached to a specific column        echo '    <div class="item">' . "\n";        foreach ($row as $current_grant => $current_grant_value) {            if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)),                    array('Select', 'Insert', 'Update', 'References'))) {                continue;            }            // make a substitution to match the messages variables;            // also we must substitute the grant we get, because we can't generate            // a form variable containing blanks (those would get changed to            // an underscore when receiving the POST)            if ($current_grant == 'Create View_priv') {                $tmp_current_grant = 'CreateView_priv';                $current_grant = 'Create_view_priv';            } elseif ($current_grant == 'Show view_priv') {                $tmp_current_grant = 'ShowView_priv';                $current_grant = 'Show_view_priv';            } else {                $tmp_current_grant = $current_grant;            }            echo '        <div class="item">' . "\n"               . '            <input type="checkbox"'               . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')               . ' name="' . $current_grant . '" id="checkbox_' . $current_grant               . '" value="Y" '               . ($current_grant_value == 'Y' ? 'checked="checked" ' : '')               . 'title="';            echo (isset($GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))])                ? $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))]                : $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)) . 'Tbl']) . '"/>' . "\n";            echo '            <label for="checkbox_' . $current_grant                . '"><tt><dfn title="'                . (isset($GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))])                    ? $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))]                    : $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)) . 'Tbl'])               . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label>' . "\n"               . '        </div>' . "\n";        } // end foreach ()        echo '    </div>' . "\n";        // for Safari 2.0.2        echo '    <div class="clearfloat"></div>' . "\n";    } else {        // g l o b a l    o r    d b - s p e c i f i c        //        // d a t a        $privTable[0] = array(            array('Select', 'SELECT', $GLOBALS['strPrivDescSelect']),            array('Insert', 'INSERT', $GLOBALS['strPrivDescInsert']),            array('Update', 'UPDATE', $GLOBALS['strPrivDescUpdate']),            array('Delete', 'DELETE', $GLOBALS['strPrivDescDelete'])        );        if ($db == '*') {            $privTable[0][] = array('File', 'FILE', $GLOBALS['strPrivDescFile']);        }        // s t r u c t u r e        $privTable[1] = array(            array('Create', 'CREATE', ($table == '*' ? $GLOBALS['strPrivDescCreateDb'] : $GLOBALS['strPrivDescCreateTbl'])),            array('Alter', 'ALTER', $GLOBALS['strPrivDescAlter']),            array('Index', 'INDEX', $GLOBALS['strPrivDescIndex']),            array('Drop', 'DROP', ($table == '*' ? $GLOBALS['strPrivDescDropDb'] : $GLOBALS['strPrivDescDropTbl'])),            array('Create_tmp_table', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']),            array('Show_view', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']),            array('Create_routine', 'CREATE ROUTINE', $GLOBALS['strPrivDescCreateRoutine']),            array('Alter_routine', 'ALTER ROUTINE', $GLOBALS['strPrivDescAlterRoutine']),            array('Execute', 'EXECUTE', $GLOBALS['strPrivDescExecute5']),        );        // this one is for a db-specific priv: Create_view_priv        if (isset($row['Create_view_priv'])) {            $privTable[1][] = array('Create_view', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']);        }        // this one is for a table-specific priv: Create View_priv        if (isset($row['Create View_priv'])) {            $privTable[1][] = array('Create View', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']);        }        if (isset($row['Event_priv'])) {            // MySQL 5.1.6            $privTable[1][] = array('Event', 'EVENT', $GLOBALS['strPrivDescEvent']);            $privTable[1][] = array('Trigger', 'TRIGGER', $GLOBALS['strPrivDescTrigger']);        }        // a d m i n i s t r a t i o n        $privTable[2] = array(            array('Grant', 'GRANT', $GLOBALS['strPrivDescGrant']),        );        if ($db == '*') {            $privTable[2][] = array('Super', 'SUPER', $GLOBALS['strPrivDescSuper']);            $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess']);            $privTable[2][] = array('Reload', 'RELOAD', $GLOBALS['strPrivDescReload']);            $privTable[2][] = array('Shutdown', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']);            $privTable[2][] = array('Show_db', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']);        }        $privTable[2][] = array('Lock_tables', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']);        $privTable[2][] = array('References', 'REFERENCES', $GLOBALS['strPrivDescReferences']);        if ($db == '*') {            $privTable[2][] = array('Repl_client', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']);            $privTable[2][] = array('Repl_slave', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']);            $privTable[2][] = array('Create_user', 'CREATE USER', $GLOBALS['strPrivDescCreateUser']);        }        echo '<input type="hidden" name="grant_count" value="'            . (count($privTable[0]) + count($privTable[1]) + count($privTable[2]) - (isset($row['Grant_priv']) ? 1 : 0))            . '" />' . "\n"           . '<fieldset id="fieldset_user_global_rights">' . "\n"           . '    <legend>' . "\n"           . '        '            . ($db == '*'                ? $GLOBALS['strGlobalPrivileges']                : ($table == '*'                    ? $GLOBALS['strDbPrivileges']                    : $GLOBALS['strTblPrivileges'])) . "\n"           . '        (<a href="server_privileges.php?'            . $GLOBALS['url_query'] . '&amp;checkall=1" onclick="setCheckboxes(\'usersForm\', true); return false;">'            . $GLOBALS['strCheckAll'] . '</a> /' . "\n"           . '        <a href="server_privileges.php?'            . $GLOBALS['url_query'] . '" onclick="setCheckboxes(\'usersForm\', false); return false;">'            . $GLOBALS['strUncheckAll'] . '</a>)' . "\n"           . '    </legend>' . "\n"           . '    <p><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></p>' . "\n"           . '    <fieldset>' . "\n"           . '        <legend>' . $GLOBALS['strData'] . '</legend>' . "\n";        foreach ($privTable[0] as $priv)        {            echo '        <div class="item">' . "\n"               . '            <input type="checkbox"'                . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')                . ' name="' . $priv[0] . '_priv" id="checkbox_' . $priv[0]                . '_priv" value="Y" '                . ($row[$priv[0] . '_priv'] == 'Y' ? 'checked="checked" ' : '')                . 'title="' . $priv[2] . '"/>' . "\n"               . '            <label for="checkbox_' . $priv[0]                . '_priv"><tt><dfn title="' . $priv[2] . '">' . $priv[1]                . '</dfn></tt></label>' . "\n"               . '        </div>' . "\n";        }        echo '    </fieldset>' . "\n"           . '    <fieldset>' . "\n"           . '        <legend>' . $GLOBALS['strStructure'] . '</legend>' . "\n";        foreach ($privTable[1] as $priv)        {            echo '        <div class="item">' . "\n"               . '            <input type="checkbox"'                . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')                . ' name="' . $priv[0] . '_priv" id="checkbox_' . $priv[0]                . '_priv" value="Y" '                . ($row[$priv[0] . '_priv'] == 'Y' ? 'checked="checked" ' : '')                . 'title="' . $priv[2] . '"/>' . "\n"               . '            <label for="checkbox_' . $priv[0]                . '_priv"><tt><dfn title="' . $priv[2] . '">' . $priv[1]                . '</dfn></tt></label>' . "\n"               . '        </div>' . "\n";        }        echo '    </fieldset>' . "\n"           . '    <fieldset>' . "\n"           . '        <legend>' . $GLOBALS['strAdministration'] . '</legend>' . "\n";        foreach ($privTable[2] as $priv)        {            echo '        <div class="item">' . "\n"               . '            <input type="checkbox"'                . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')                . ' name="' . $priv[0] . '_priv" id="checkbox_' . $priv[0]                . '_priv" value="Y" '                . ($row[$priv[0] . '_priv'] == 'Y' ? 'checked="checked" ' : '')                . 'title="' . $priv[2] . '"/>' . "\n"               . '            <label for="checkbox_' . $priv[0]                . '_priv"><tt><dfn title="' . $priv[2] . '">' . $priv[1]                . '</dfn></tt></label>' . "\n"               . '        </div>' . "\n";        }        echo '    </fieldset>' . "\n";        // The "Resource limits" box is not displayed for db-specific privs        if ($db == '*') {            echo '    <fieldset>' . "\n"               . '        <legend>' . $GLOBALS['strResourceLimits'] . '</legend>' . "\n"               . '        <p><small><i>' . $GLOBALS['strZeroRemovesTheLimit'] . '</i></small></p>' . "\n"               . '        <div class="item">' . "\n"               . '            <label for="text_max_questions"><tt><dfn title="'                . $GLOBALS['strPrivDescMaxQuestions'] . '">MAX QUERIES PER HOUR</dfn></tt></label>' . "\n"               . '            <input type="text" name="max_questions" id="text_max_questions" value="'                . $row['max_questions'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxQuestions'] . '" />' . "\n"               . '        </div>' . "\n"               . '        <div class="item">' . "\n"

⌨️ 快捷键说明

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