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


PHP PMA_unescape_mysql_wildcards函数代码示例

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


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

示例1: PMA_displayPrivTable

/**
 * Displays the privileges form table
 *
 * @param string  $db     the database
 * @param string  $table  the table
 * @param boolean $submit wheather to display the submit button or not
 *
 * @global  array      $cfg         the phpMyAdmin configuration
 * @global  ressource  $user_link   the database connection
 *
 * @return void
 */
function PMA_displayPrivTable($db = '*', $table = '*', $submit = true)
{
    global $random_n;

    if ($db == '*') {
        $table = '*';
    }

    if (isset($GLOBALS['username'])) {
        $username = $GLOBALS['username'];
        $hostname = $GLOBALS['hostname'];
        if ($db == '*') {
            $sql_query = "SELECT * FROM `mysql`.`user`"
                ." WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'"
                ." AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "';";
        } elseif ($table == '*') {
            $sql_query = "SELECT * FROM `mysql`.`db`"
                ." WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'"
                ." AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "'"
                ." AND '" . PMA_unescape_mysql_wildcards($db) . "'"
                ." LIKE `Db`;";
        } 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_backquote(PMA_unescape_mysql_wildcards($db))
            . '.' . PMA_backquote($table) . ';'
        );
        $columns = array();
        if ($res) {
            while ($row1 = PMA_DBI_fetch_row($res)) {
                $columns[$row1[0]] = array(
//.........这里部分代码省略.........
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:101,代码来源:server_privileges.php

示例2: PMA_getDbLink

/**
 * returns html code for db link to default db page
 *
 * @param string $database database
 *
 * @return  string  html link to default db page
 */
function PMA_getDbLink($database = null)
{
    if (!strlen($database)) {
        if (!strlen($GLOBALS['db'])) {
            return '';
        }
        $database = $GLOBALS['db'];
    } else {
        $database = PMA_unescape_mysql_wildcards($database);
    }
    return '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($database) . '" title="' . sprintf(__('Jump to database &quot;%s&quot;.'), htmlspecialchars($database)) . '">' . htmlspecialchars($database) . '</a>';
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:19,代码来源:common.lib.php

示例3: PMA_displayPrivTable

/**
 * Displays the privileges form table
 *
 * @param   string  $db     the database
 * @param   string  $table  the table
 * @param   boolean $submit wheather to display the submit button or not
 * @param   int     $indent the indenting level of the code
 *
 * @global  array      $cfg         the phpMyAdmin configuration
 * @global  ressource  $user_link   the database connection
 *
 * @return  void
 */
function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
{
    if ($db == '*') {
        $table = '*';
    }
    $spaces = str_repeat('    ', $indent);
    if (isset($GLOBALS['username'])) {
        $username = $GLOBALS['username'];
        $hostname = $GLOBALS['hostname'];
        if ($db == '*') {
            $sql_query = 'SELECT * FROM `mysql`.`user`' . ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';';
        } elseif ($table == '*') {
            $sql_query = 'SELECT * FROM `mysql`.`db`' . ' WHERE ' . PMA_convert_using('`User`') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('`Host`') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted') . ' LIKE ' . PMA_convert_using('`Db`') . ';';
        } else {
            $sql_query = 'SELECT `Table_priv`' . ' FROM `mysql`.`tables_priv`' . ' WHERE ' . PMA_convert_using('`User`') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('`Host`') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('`Db`') . ' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted') . ' AND ' . PMA_convert_using('`Table_name`') . ' = ' . PMA_convert_using($table, 'quoted') . ';';
        }
        $res = PMA_DBI_query($sql_query);
        $row = PMA_DBI_fetch_assoc($res);
        PMA_DBI_free_result($res);
    }
    if (empty($row)) {
        if ($table == '*') {
            if ($db == '*') {
                $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
            } else {
                if ($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'])) {
        $res = PMA_DBI_query('SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';', $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
        $row1 = PMA_DBI_fetch_assoc($res);
        PMA_DBI_free_result($res);
        $av_grants = explode('\',\'', substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
        unset($res, $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 ' . PMA_convert_using('`User`') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('`Host`') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('`Db`') . ' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted') . ' AND ' . PMA_convert_using('`Table_name`') . ' = ' . PMA_convert_using($table, 'quoted') . ';');
        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 $spaces . '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n" . $spaces . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n" . $spaces . '<fieldset id="fieldset_user_priv">' . "\n" . $spaces . '    <legend>' . $GLOBALS['strTblPrivileges'] . '</legend>' . "\n" . $spaces . '    <p><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></p>' . "\n";
        // privs that are attached to a specific column
        PMA_display_column_privs($spaces, $columns, $row, 'Select_priv', 'SELECT', 'select', $GLOBALS['strPrivDescSelect'], 'Select');
        PMA_display_column_privs($spaces, $columns, $row, 'Insert_priv', 'INSERT', 'insert', $GLOBALS['strPrivDescInsert'], 'Insert');
        PMA_display_column_privs($spaces, $columns, $row, 'Update_priv', 'UPDATE', 'update', $GLOBALS['strPrivDescUpdate'], 'Update');
        PMA_display_column_privs($spaces, $columns, $row, 'References_priv', 'REFERENCES', 'references', $GLOBALS['strPrivDescReferences'], 'References');
        // privs that are not attached to a specific column
        echo $spaces . '    <div class="item">' . "\n";
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:101,代码来源:server_privileges.php

示例4: _checkOnlyDatabase

    /**
     * checks the only_db configuration
     *
     * @uses    PMA_List_Database::$_show_databases_disabled
     * @uses    PMA_List_Database::$items
     * @uses    PMA_List_Database::_retrieve()
     * @uses    PMA_unescape_mysql_wildcards()
     * @uses    preg_match()
     * @uses    array_diff()
     * @uses    array_merge()
     * @uses    is_array()
     * @uses    strlen()
     * @uses    is_string()
     * @uses    $cfg['Server']['only_db']
     * @return  boolean false if there is no only_db, otherwise true
     */
    protected function _checkOnlyDatabase()
    {
        if (is_string($GLOBALS['cfg']['Server']['only_db'])
         && strlen($GLOBALS['cfg']['Server']['only_db'])) {
            $GLOBALS['cfg']['Server']['only_db'] = array(
                $GLOBALS['cfg']['Server']['only_db']
            );
        }

        if (! is_array($GLOBALS['cfg']['Server']['only_db'])) {
            return false;
        }

        $items = array();

        foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
            if ($each_only_db === '*' && ! $this->_show_databases_disabled) {
                // append all not already listed dbs to the list
                $items = array_merge($items,
                    array_diff($this->_retrieve(), $items));
                // there can only be one '*', and this can only be last
                break;
            }

            // check if the db name contains wildcard,
            // thus containing not escaped _ or %
            if (! preg_match('/(^|[^\\\\])(_|%)/', $each_only_db)) {
                // ... not contains wildcard
                $items[] = PMA_unescape_mysql_wildcards($each_only_db);
                continue;
            }

            if (! $this->_show_databases_disabled) {
                $items = array_merge($items, $this->_retrieve($each_only_db));
                continue;
            }

            // @todo induce error, about not using wildcards with SHOW DATABASE disabled?
        }

        $this->exchangeArray($items);

        return true;
    }
开发者ID:blumenbach,项目名称:blumenbach-online.de,代码行数:60,代码来源:List_Database.class.php

示例5: testUnEscape

    /**
     * PMA_unescape_mysql_wildcards tests
     * @dataProvider escapeDataProvider
     */

    public function testUnEscape($a, $b)
    {
        $this->assertEquals($b, PMA_unescape_mysql_wildcards($a));
    }
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:9,代码来源:PMA_escapeMySqlWildcards_test.php


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