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


PHP PMA_Util::unQuote方法代码示例

本文整理汇总了PHP中PMA_Util::unQuote方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::unQuote方法的具体用法?PHP PMA_Util::unQuote怎么用?PHP PMA_Util::unQuote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMA_Util的用法示例。


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

示例1: _getSortedColumnMessage

 /**
  * Prepare sorted column message
  *
  * @param integer &$dt_result                  the link id associated to the
  *                                              query which results have to
  *                                              be displayed
  * @param string  $sort_expression_nodirection sort expression without direction
  *
  * @return  string                              html content
  *          null                                if not found sorted column
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _getSortedColumnMessage(&$dt_result, $sort_expression_nodirection)
 {
     $fields_meta = $this->__get('fields_meta');
     // To use array indexes
     if (empty($sort_expression_nodirection)) {
         return null;
     }
     if (mb_strpos($sort_expression_nodirection, '.') === false) {
         $sort_table = $this->__get('table');
         $sort_column = $sort_expression_nodirection;
     } else {
         list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
     }
     $sort_table = PMA_Util::unQuote($sort_table);
     $sort_column = PMA_Util::unQuote($sort_column);
     // find the sorted column index in row result
     // (this might be a multi-table query)
     $sorted_column_index = false;
     foreach ($fields_meta as $key => $meta) {
         if ($meta->table == $sort_table && $meta->name == $sort_column) {
             $sorted_column_index = $key;
             break;
         }
     }
     if ($sorted_column_index === false) {
         return null;
     }
     // fetch first row of the result set
     $row = $GLOBALS['dbi']->fetchRow($dt_result);
     // initializing default arguments
     $default_function = 'PMA_mimeDefaultFunction';
     $transformation_plugin = $default_function;
     $transform_options = array();
     // check for non printable sorted row data
     $meta = $fields_meta[$sorted_column_index];
     if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
         $column_for_first_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta, null);
     } else {
         $column_for_first_row = $row[$sorted_column_index];
     }
     $column_for_first_row = mb_strtoupper(mb_substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']));
     // fetch last row of the result set
     $GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
     $row = $GLOBALS['dbi']->fetchRow($dt_result);
     // check for non printable sorted row data
     $meta = $fields_meta[$sorted_column_index];
     if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
         $column_for_last_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta, null);
     } else {
         $column_for_last_row = $row[$sorted_column_index];
     }
     $column_for_last_row = mb_strtoupper(mb_substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']));
     // reset to first row for the loop in _getTableBody()
     $GLOBALS['dbi']->dataSeek($dt_result, 0);
     // we could also use here $sort_expression_nodirection
     return ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
 }
开发者ID:nkeat12,项目名称:dv,代码行数:72,代码来源:DisplayResults.class.php

示例2: PMA_RTN_parseRoutineDefiner

/**
 * This function looks through the contents of a parsed
 * SHOW CREATE [PROCEDURE | FUNCTION] query and extracts
 * information about the routine's definer.
 *
 * @param array $parsed_query Parsed query, returned by PMA_SQP_parse()
 *
 * @return string  The definer of a routine.
 */
function PMA_RTN_parseRoutineDefiner($parsed_query)
{
    $retval = '';
    $fetching = false;
    for ($i = 0; $i < $parsed_query['len']; $i++) {
        if ($parsed_query[$i]['type'] == 'alpha_reservedWord' && $parsed_query[$i]['data'] == 'DEFINER') {
            $fetching = true;
        } else {
            if ($fetching == true && $parsed_query[$i]['type'] != 'quote_backtick' && substr($parsed_query[$i]['type'], 0, 5) != 'punct') {
                break;
            } else {
                if ($fetching == true && $parsed_query[$i]['type'] == 'quote_backtick') {
                    $retval .= PMA_Util::unQuote($parsed_query[$i]['data']);
                } else {
                    if ($fetching == true && $parsed_query[$i]['type'] == 'punct_user') {
                        $retval .= $parsed_query[$i]['data'];
                    }
                }
            }
        }
    }
    return $retval;
}
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:32,代码来源:rte_routines.lib.php

示例3: elseif

    // run SQL query
    $import_text = $sql_query;
    $import_type = 'query';
    $format = 'sql';
    // refresh navigation and main panels
    if (preg_match('/^(DROP)\\s+(VIEW|TABLE|DATABASE|SCHEMA)\\s+/i', $sql_query)) {
        $GLOBALS['reload'] = true;
    }
    // refresh navigation panel only
    if (preg_match('/^(CREATE|ALTER)\\s+(VIEW|TABLE|DATABASE|SCHEMA)\\s+/i', $sql_query)) {
        $ajax_reload['reload'] = true;
    }
    // do a dynamic reload if table is RENAMED
    // (by sending the instruction to the AJAX response handler)
    if (preg_match('/^RENAME\\s+TABLE\\s+(.*?)\\s+TO\\s+(.*?)($|;|\\s)/i', $sql_query, $rename_table_names)) {
        $ajax_reload['table_name'] = PMA_Util::unQuote($rename_table_names[2]);
        $ajax_reload['reload'] = true;
    }
    $sql_query = '';
} elseif (!empty($sql_localfile)) {
    // run SQL file on server
    $local_import_file = $sql_localfile;
    $import_type = 'queryfile';
    $format = 'sql';
    unset($sql_localfile);
} elseif (!empty($sql_file)) {
    // run uploaded SQL file
    $import_file = $sql_file;
    $import_type = 'queryfile';
    $format = 'sql';
    unset($sql_file);
开发者ID:katopenzz,项目名称:openemr,代码行数:31,代码来源:import.php

示例4: PMA_SQP_analyze


//.........这里部分代码省略.........
                $seen_from = false;
                $previous_was_identifier = false;
                $current_select_expr = -1;
                $seen_end_of_table_ref = false;
            }
            // end if (data == SELECT)
            if ($upper_data == 'FROM' && !$in_extract) {
                $current_table_ref = -1;
                $seen_from = true;
                $previous_was_identifier = false;
                $save_table_ref = true;
            }
            // end if (data == FROM)
            // here, do not 'continue' the loop, as we have more work for
            // reserved words below
        }
        // end if (type == alpha_reservedWord)
        // ==============================
        if ($arr[$i]['type'] == 'quote_backtick' || $arr[$i]['type'] == 'quote_double' || $arr[$i]['type'] == 'quote_single' || $arr[$i]['type'] == 'alpha_identifier' || $arr[$i]['type'] == 'alpha_reservedWord' && $arr[$i]['forbidden'] == false) {
            switch ($arr[$i]['type']) {
                case 'alpha_identifier':
                case 'alpha_reservedWord':
                    /**
                     * this is not a real reservedWord, because it's not
                     * present in the list of forbidden words, for example
                     * "storage" which can be used as an identifier
                     *
                     */
                    $identifier = $arr[$i]['data'];
                    break;
                case 'quote_backtick':
                case 'quote_double':
                case 'quote_single':
                    $identifier = PMA_Util::unQuote($arr[$i]['data']);
                    break;
            }
            // end switch
            if ($subresult['querytype'] == 'SELECT' && !$in_group_concat && !($seen_subquery && $arr[$i - 1]['type'] == 'punct_bracket_close_round')) {
                if (!$seen_from) {
                    if ($previous_was_identifier && isset($chain)) {
                        // found alias for this select_expr, save it
                        // but only if we got something in $chain
                        // (for example, SELECT COUNT(*) AS cnt
                        // puts nothing in $chain, so we avoid
                        // setting the alias)
                        $alias_for_select_expr = $identifier;
                    } else {
                        if (!isset($chain)) {
                            $chain = array();
                        }
                        $chain[] = $identifier;
                        $previous_was_identifier = true;
                    }
                    // end if !$previous_was_identifier
                } else {
                    // ($seen_from)
                    if ($save_table_ref && !$seen_end_of_table_ref) {
                        if ($previous_was_identifier) {
                            // found alias for table ref
                            // save it for later
                            $alias_for_table_ref = $identifier;
                        } else {
                            if (!isset($chain)) {
                                $chain = array();
                            }
                            $chain[] = $identifier;
开发者ID:hewenhao2008,项目名称:phpmyadmin,代码行数:67,代码来源:sqlparser.lib.php

示例5: PMA_analyseShowGrant

/**
 * sets privilege information extracted from SHOW GRANTS result
 *
 * Detection for some CREATE privilege.
 *
 * Since MySQL 4.1.2, we can easily detect current user's grants using $userlink
 * (no control user needed) and we don't have to try any other method for
 * detection
 *
 * @todo fix to get really all privileges, not only explicitly defined for this user
 * from MySQL manual: (http://dev.mysql.com/doc/refman/5.0/en/show-grants.html)
 * SHOW GRANTS displays only the privileges granted explicitly to the named
 * account. Other privileges might be available to the account, but they are not
 * displayed. For example, if an anonymous account exists, the named account
 * might be able to use its privileges, but SHOW GRANTS will not display them.
 *
 * @return void
 */
function PMA_analyseShowGrant()
{
    if (PMA_Util::cacheExists('is_create_db_priv')) {
        $GLOBALS['is_create_db_priv'] = PMA_Util::cacheGet('is_create_db_priv');
        $GLOBALS['is_reload_priv'] = PMA_Util::cacheGet('is_reload_priv');
        $GLOBALS['db_to_create'] = PMA_Util::cacheGet('db_to_create');
        $GLOBALS['dbs_where_create_table_allowed'] = PMA_Util::cacheGet('dbs_where_create_table_allowed');
        $GLOBALS['dbs_to_test'] = PMA_Util::cacheGet('dbs_to_test');
        return;
    }
    // defaults
    $GLOBALS['is_create_db_priv'] = false;
    $GLOBALS['is_reload_priv'] = false;
    $GLOBALS['db_to_create'] = '';
    $GLOBALS['dbs_where_create_table_allowed'] = array();
    $GLOBALS['dbs_to_test'] = $GLOBALS['dbi']->getSystemSchemas();
    $rs_usr = $GLOBALS['dbi']->tryQuery('SHOW GRANTS');
    if (!$rs_usr) {
        return;
    }
    $re0 = '(^|(\\\\\\\\)+|[^\\\\])';
    // non-escaped wildcards
    $re1 = '(^|[^\\\\])(\\\\)+';
    // escaped wildcards
    while ($row = $GLOBALS['dbi']->fetchRow($rs_usr)) {
        // extract db from GRANT ... ON *.* or GRANT ... ON db.*
        $db_name_offset = mb_strpos($row[0], ' ON ') + 4;
        $show_grants_dbname = mb_substr($row[0], $db_name_offset, mb_strpos($row[0], '.', $db_name_offset) - $db_name_offset);
        $show_grants_dbname = PMA_Util::unQuote($show_grants_dbname, '`');
        $show_grants_str = mb_substr($row[0], 6, mb_strpos($row[0], ' ON ') - 6);
        if ($show_grants_dbname == '*') {
            if ($show_grants_str != 'USAGE') {
                $GLOBALS['dbs_to_test'] = false;
            }
        } elseif ($GLOBALS['dbs_to_test'] !== false) {
            $GLOBALS['dbs_to_test'][] = $show_grants_dbname;
        }
        if ($show_grants_str == 'RELOAD') {
            $GLOBALS['is_reload_priv'] = true;
        }
        /**
         * @todo if we find CREATE VIEW but not CREATE, do not offer
         * the create database dialog box
         */
        if ($show_grants_str == 'ALL' || $show_grants_str == 'ALL PRIVILEGES' || $show_grants_str == 'CREATE' || strpos($show_grants_str, 'CREATE,') !== false) {
            if ($show_grants_dbname == '*') {
                // a global CREATE privilege
                $GLOBALS['is_create_db_priv'] = true;
                $GLOBALS['is_reload_priv'] = true;
                $GLOBALS['db_to_create'] = '';
                $GLOBALS['dbs_where_create_table_allowed'][] = '*';
                // @todo we should not break here, cause GRANT ALL *.*
                // could be revoked by a later rule like GRANT SELECT ON db.*
                break;
            } else {
                // this array may contain wildcards
                $GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname;
                $dbname_to_test = PMA_Util::backquote($show_grants_dbname);
                if ($GLOBALS['is_create_db_priv']) {
                    // no need for any more tests if we already know this
                    continue;
                }
                // does this db exist?
                if (preg_match('/' . $re0 . '%|_/', $show_grants_dbname) && !preg_match('/\\\\%|\\\\_/', $show_grants_dbname) || !$GLOBALS['dbi']->tryQuery('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test)) && mb_substr($GLOBALS['dbi']->getError(), 1, 4) != 1044) {
                    /**
                     * Do not handle the underscore wildcard
                     * (this case must be rare anyway)
                     */
                    $GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1', $show_grants_dbname);
                    $GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']);
                    $GLOBALS['is_create_db_priv'] = true;
                    /**
                     * @todo collect $GLOBALS['db_to_create'] into an array,
                     * to display a drop-down in the "Create database" dialog
                     */
                    // we don't break, we want all possible databases
                    //break;
                }
                // end if
            }
            // end elseif
        }
//.........这里部分代码省略.........
开发者ID:nervo,项目名称:phpmyadmin,代码行数:101,代码来源:check_user_privileges.lib.php

示例6: PMA_isTableTransactional

/**
 * Checks if a table is 'InnoDB' or not.
 *
 * @param string $table Table details
 *
 * @return bool
 */
function PMA_isTableTransactional($table)
{
    $table = explode('.', $table);
    if (count($table) == 2) {
        $db = PMA_Util::unQuote($table[0]);
        $table = PMA_Util::unQuote($table[1]);
    } else {
        $db = $GLOBALS['db'];
        $table = PMA_Util::unQuote($table[0]);
    }
    // Query to check if table exists.
    $check_table_query = 'SELECT * FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table) . ' ' . 'LIMIT 1';
    $result = $GLOBALS['dbi']->tryQuery($check_table_query);
    if (!$result) {
        return false;
    }
    // List of Transactional Engines.
    $transactional_engines = array('INNODB', 'FALCON', 'NDB', 'INFINIDB', 'TOKUDB', 'XTRADB', 'SEQUENCE', 'BDB');
    // Query to check if table is 'Transactional'.
    $check_query = 'SELECT `ENGINE` FROM `information_schema`.`tables` ' . 'WHERE `table_name` = "' . $table . '" ' . 'AND `table_schema` = "' . $db . '" ' . 'AND UPPER(`engine`) IN ("' . implode('", "', $transactional_engines) . '")';
    $result = $GLOBALS['dbi']->tryQuery($check_query);
    if ($GLOBALS['dbi']->numRows($result) == 1) {
        return true;
    } else {
        return false;
    }
}
开发者ID:sruthikudaravalli,项目名称:QuickCabs,代码行数:34,代码来源:import.lib.php

示例7: replaceWithAliases

 /**
  * replaces db/table/column names with their aliases
  *
  * @param string $sql_query SQL query in which aliases are to be substituted
  * @param array  $aliases   Alias information for db/table/column
  * @param string $db        the database name
  * @param string $table     the tablename
  * @param string &$flag     the flag denoting whether any replacement was done
  *
  * @return string query replaced with aliases
  */
 public function replaceWithAliases($sql_query, $aliases, $db, $table = '', &$flag = null)
 {
     $flag = false;
     // Return original sql query if no aliases are provided.
     if (!is_array($aliases) || empty($aliases) || empty($sql_query)) {
         return $sql_query;
     }
     $supported_query_types = array('CREATE' => true);
     $supported_query_ons = array('TABLE' => true, 'VIEW' => true, 'TRIGGER' => true, 'FUNCTION' => true, 'PROCEDURE' => true);
     $identifier_types = array('alpha_identifier', 'quote_backtick');
     $query_type = '';
     $query_on = '';
     // Adjustment value for each pos value
     // of token after replacement
     $offset = 0;
     $open_braces = 0;
     $in_create_table_fields = false;
     // flag to force end query parsing
     $query_end = false;
     // Convert all line feeds to Unix style
     $sql_query = str_replace("\r\n", "\n", $sql_query);
     $sql_query = str_replace("\r", "\n", $sql_query);
     $tokens = PMA_SQP_parse($sql_query);
     $ref_seen = false;
     $ref_table_seen = false;
     $old_table = $table;
     $on_seen = false;
     $size = $tokens['len'];
     for ($i = 0; $i < $size && !$query_end; $i++) {
         $type = $tokens[$i]['type'];
         $data = $tokens[$i]['data'];
         $data_next = isset($tokens[$i + 1]['data']) ? $tokens[$i + 1]['data'] : '';
         $data_prev = $i > 0 ? $tokens[$i - 1]['data'] : '';
         $d_unq = PMA_Util::unQuote($data);
         $d_unq_next = PMA_Util::unQuote($data_next);
         $d_unq_prev = PMA_Util::unQuote($data_prev);
         $d_upper = mb_strtoupper($d_unq);
         $d_upper_next = mb_strtoupper($d_unq_next);
         $d_upper_prev = mb_strtoupper($d_unq_prev);
         $pos = $tokens[$i]['pos'] + $offset;
         if ($type === 'alpha_reservedWord') {
             if ($query_type === '' && !empty($supported_query_types[$d_upper])) {
                 $query_type = $d_upper;
             } elseif ($query_on === '' && !empty($supported_query_ons[$d_upper])) {
                 $query_on = $d_upper;
             }
         }
         // CREATE TABLE - Alias replacement
         if ($query_type === 'CREATE' && $query_on === 'TABLE') {
             // replace create table name
             if (!$in_create_table_fields && in_array($type, $identifier_types) && !empty($aliases[$db]['tables'][$table]['alias'])) {
                 $sql_query = $this->substituteAlias($sql_query, $data, $aliases[$db]['tables'][$table]['alias'], $pos, $offset);
                 $flag = true;
             } elseif ($type === 'punct_bracket_open_round') {
                 // CREATE TABLE fields started
                 if (!$in_create_table_fields) {
                     $in_create_table_fields = true;
                 }
                 $open_braces++;
             } elseif ($type === 'punct_bracket_close_round') {
                 // end our parsing after last )
                 // no columns appear after that
                 if ($in_create_table_fields && $open_braces === 0) {
                     $query_end = true;
                 }
                 // End of Foreign key reference
                 if ($ref_seen) {
                     $ref_seen = $ref_table_seen = false;
                     $table = $old_table;
                 }
                 $open_braces--;
                 // handles Foreign key references
             } elseif ($type === 'alpha_reservedWord' && $d_upper === 'REFERENCES') {
                 $ref_seen = true;
             } elseif (in_array($type, $identifier_types) && $ref_seen === true && !$ref_table_seen) {
                 $table = $d_unq;
                 $ref_table_seen = true;
                 if (!empty($aliases[$db]['tables'][$table]['alias'])) {
                     $sql_query = $this->substituteAlias($sql_query, $data, $aliases[$db]['tables'][$table]['alias'], $pos, $offset);
                     $flag = true;
                 }
                 // Replace column names
             } elseif (in_array($type, $identifier_types) && !empty($aliases[$db]['tables'][$table]['columns'][$d_unq])) {
                 $sql_query = $this->substituteAlias($sql_query, $data, $aliases[$db]['tables'][$table]['columns'][$d_unq], $pos, $offset);
                 $flag = true;
             }
             // CREATE TRIGGER - Alias replacement
         } elseif ($query_type === 'CREATE' && $query_on === 'TRIGGER') {
             // Skip till 'ON' in encountered
//.........这里部分代码省略.........
开发者ID:aramisf,项目名称:-,代码行数:101,代码来源:ExportSql.class.php

示例8: testUnQuoteSelectedChar

 /**
  * PMA_Util::unQuote test with chosen quote
  *
  * @param string $param    String
  * @param string $expected Expected output
  *
  * @return void
  *
  * @dataProvider unQuoteSelectedProvider
  */
 public function testUnQuoteSelectedChar($param, $expected)
 {
     $this->assertEquals($expected, PMA_Util::unQuote($param, '"'));
 }
开发者ID:xtreme-jamil-shamy,项目名称:phpmyadmin-cf,代码行数:14,代码来源:PMA_quoting_slashing_test.php

示例9: PMA_lookForUse

/**
 * Looks for the presence of USE to possibly change current db
 *
 * @param string $buffer buffer to examine
 * @param string $db     current db
 * @param bool   $reload reload
 *
 * @return array (current or new db, whether to reload)
 * @access public
 */
function PMA_lookForUse($buffer, $db, $reload)
{
    if (preg_match('@^[\\s]*USE[[:space:]]+([\\S]+)@i', $buffer, $match)) {
        $db = trim($match[1]);
        $db = trim($db, ';');
        // for example, USE abc;
        // $db must not contain the escape characters generated by backquote()
        // ( used in PMA_buildSQL() as: backquote($db_name), and then called
        // in PMA_importRunQuery() which in turn calls PMA_lookForUse() )
        $db = PMA_Util::unQuote($db);
        $reload = true;
    }
    return array($db, $reload);
}
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:24,代码来源:import.lib.php


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