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


PHP PMA_DBI_getError函数代码示例

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


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

示例1: PMA_analyseShowGrant

function PMA_analyseShowGrant($rs_usr, &$is_create_priv, &$db_to_create, &$is_reload_priv)
{
    $re0 = '(^|(\\\\\\\\)+|[^\\])';
    // non-escaped wildcards
    $re1 = '(^|[^\\])(\\\\)+';
    // escaped wildcards
    while ($row = PMA_DBI_fetch_row($rs_usr)) {
        $show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4, strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4);
        $show_grants_dbname = ereg_replace('^`(.*)`', '\\1', $show_grants_dbname);
        $show_grants_str = substr($row[0], 6, strpos($row[0], ' ON ') - 6);
        if ($show_grants_str == 'ALL' || $show_grants_str == 'ALL PRIVILEGES' || $show_grants_str == 'CREATE' || strpos($show_grants_str, 'CREATE')) {
            if ($show_grants_dbname == '*') {
                $is_create_priv = TRUE;
                $is_reload_priv = TRUE;
                $db_to_create = '';
                break;
            } else {
                if (ereg($re0 . '%|_', $show_grants_dbname) && !ereg('\\\\%|\\\\_', $show_grants_dbname) || !PMA_DBI_try_query('USE ' . ereg_replace($re1 . '(%|_)', '\\1\\3', $show_grants_dbname)) && substr(PMA_DBI_getError(), 1, 4) != 1044) {
                    $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
                    $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
                    $is_create_priv = TRUE;
                    break;
                }
            }
            // end elseif
        }
        // end if
    }
    // end while
}
开发者ID:mike503,项目名称:phpmyadmin,代码行数:30,代码来源:check_user_privileges.lib.php

示例2: PMA_analyseShowGrant

function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is_reload_priv, &$dbs_where_create_table_allowed)
{
    $re0 = '(^|(\\\\\\\\)+|[^\\])';
    // non-escaped wildcards
    $re1 = '(^|[^\\])(\\\\)+';
    // escaped wildcards
    while ($row = PMA_DBI_fetch_row($rs_usr)) {
        $show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4, strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4);
        $show_grants_dbname = ereg_replace('^`(.*)`', '\\1', $show_grants_dbname);
        $show_grants_str = substr($row[0], 6, strpos($row[0], ' ON ') - 6);
        if ($show_grants_str == 'RELOAD') {
            $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
                $is_create_db_priv = true;
                $is_reload_priv = true;
                $db_to_create = '';
                $dbs_where_create_table_allowed[] = '*';
                break;
            } else {
                // this array may contain wildcards
                $dbs_where_create_table_allowed[] = $show_grants_dbname;
                // before MySQL 4.1.0, we cannot use backquotes around a dbname
                // for the USE command, so the USE will fail if the dbname contains
                // a "-" and we cannot detect if such a db already exists;
                // since 4.1.0, we need to use backquotes if the dbname contains a "-"
                // in a USE command
                if (PMA_MYSQL_INT_VERSION > 40100) {
                    $dbname_to_test = PMA_backquote($show_grants_dbname);
                } else {
                    $dbname_to_test = $show_grants_dbname;
                }
                if (ereg($re0 . '%|_', $show_grants_dbname) && !ereg('\\\\%|\\\\_', $show_grants_dbname) || !PMA_DBI_try_query('USE ' . ereg_replace($re1 . '(%|_)', '\\1\\3', $dbname_to_test), null, PMA_DBI_QUERY_STORE) && substr(PMA_DBI_getError(), 1, 4) != 1044) {
                    $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
                    $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
                    $is_create_db_priv = true;
                    /**
                     * @todo collect $db_to_create into an array, to display a
                     * drop-down in the "Create new database" dialog
                     */
                    // we don't break, we want all possible databases
                    //break;
                }
                // end if
            }
            // end elseif
        }
        // end if
    }
    // end while
}
开发者ID:Kishaaa,项目名称:cs160-website,代码行数:57,代码来源:check_user_privileges.lib.php

示例3: authFails

 /**
  * User is not allowed to login to MySQL -> authentication failed
  *
  * @global string  the MySQL error message PHP returns
  * @global string  the connection type (persistent or not)
  * @global string  the MySQL server port to use
  * @global string  the MySQL socket port to use
  * @global array   the current server settings
  * @global string  the font face to use in case of failure
  * @global string  the default font size to use in case of failure
  * @global string  the big font size to use in case of failure
  * @global boolean tell the "PMA_mysqlDie()" function headers have been
  *                 sent
  *
  * @return boolean   always true (no return indeed)
  */
 public function authFails()
 {
     $conn_error = PMA_DBI_getError();
     if (!$conn_error) {
         $conn_error = __('Cannot connect: invalid settings.');
     }
     /* HTML header */
     $response = PMA_Response::getInstance();
     $response->getFooter()->setMinimal();
     $header = $response->getHeader();
     $header->setTitle(__('Access denied'));
     $header->disableMenu();
     echo '<br /><br />
 <center>
     <h1>';
     echo sprintf(__('Welcome to %s'), ' phpMyAdmin ');
     echo '</h1>
 </center>
 <br />
 <table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%">
     <tr>
         <td>';
     if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
         trigger_error(__('Access denied'), E_USER_NOTICE);
     } else {
         // Check whether user has configured something
         if ($GLOBALS['PMA_Config']->source_mtime == 0) {
             echo '<p>' . sprintf(__('You probably did not create a configuration file.' . ' You might want to use the %1$ssetup script%2$s to' . ' create one.'), '<a href="setup/">', '</a>') . '</p>' . "\n";
         } elseif (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
             // if we display the "Server not responding" error, do not confuse
             // users by telling them they have a settings problem
             // (note: it's true that they could have a badly typed host name,
             // but anyway the current message tells that the server
             //  rejected the connection, which is not really what happened)
             // 2002 is the error given by mysqli
             // 2003 is the error given by mysql
             trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the' . ' server rejected the connection. You should check the' . ' host, username and password in your configuration and' . ' make sure that they correspond to the information given' . ' by the administrator of the MySQL server.'), E_USER_WARNING);
         }
         PMA_Util::mysqlDie($conn_error, '', true, '', false);
     }
     $GLOBALS['error_handler']->dispUserErrors();
     echo '</td>
     </tr>';
     if (count($GLOBALS['cfg']['Servers']) > 1) {
         // offer a chance to login to other servers if the current one failed
         include_once './libraries/select_server.lib.php';
         echo '<tr>' . "\n";
         echo ' <td>' . "\n";
         PMA_selectServer(true, true);
         echo ' </td>' . "\n";
         echo '</tr>' . "\n";
     }
     echo '</table>' . "\n";
     exit;
     return true;
 }
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:72,代码来源:AuthenticationConfig.class.php

示例4: PMA_DBI_get_databases_full

/**
 * returns array with databases containing extended infos about them
 *
 * @todo    move into PMA_List_Database?
 * @param   string      $databases      database
 * @param   boolean     $force_stats    retrieve stats also for MySQL < 5
 * @param   resource    $link           mysql link
 * @param   string      $sort_by        column to order by
 * @param   string      $sort_order     ASC or DESC
 * @param   integer     $limit_offset   starting offset for LIMIT
 * @param   bool|int    $limit_count    row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']
 * @return  array       $databases
 */
function PMA_DBI_get_databases_full($database = null, $force_stats = false, $link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC', $limit_offset = 0, $limit_count = false)
{
    $sort_order = strtoupper($sort_order);
    if (true === $limit_count) {
        $limit_count = $GLOBALS['cfg']['MaxDbList'];
    }
    // initialize to avoid errors when there are no databases
    $databases = array();
    $apply_limit_and_order_manual = true;
    if (!$GLOBALS['cfg']['Server']['DisableIS']) {
        /**
         * if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
         * cause MySQL does not support natural ordering, we have to do it afterward
         */
        if ($GLOBALS['cfg']['NaturalOrder']) {
            $limit = '';
        } else {
            if ($limit_count) {
                $limit = ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
            }
            $apply_limit_and_order_manual = false;
        }
        // get table information from information_schema
        if ($database) {
            $sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . addslashes($database) . '\'';
        } else {
            $sql_where_schema = '';
        }
        // for PMA bc:
        // `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
        $sql = '
             SELECT `information_schema`.`SCHEMATA`.*';
        if ($force_stats) {
            $sql .= ',
                    COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
                        AS `SCHEMA_TABLES`,
                    SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
                        AS `SCHEMA_TABLE_ROWS`,
                    SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
                        AS `SCHEMA_DATA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
                        AS `SCHEMA_MAX_DATA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
                        AS `SCHEMA_INDEX_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
                      + `information_schema`.`TABLES`.`INDEX_LENGTH`)
                        AS `SCHEMA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`DATA_FREE`)
                        AS `SCHEMA_DATA_FREE`';
        }
        $sql .= '
               FROM `information_schema`.`SCHEMATA`';
        if ($force_stats) {
            $sql .= '
          LEFT JOIN `information_schema`.`TABLES`
                 ON BINARY `information_schema`.`TABLES`.`TABLE_SCHEMA`
                  = BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
        }
        $sql .= '
              ' . $sql_where_schema . '
           GROUP BY BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
           ORDER BY BINARY ' . PMA_backquote($sort_by) . ' ' . $sort_order . $limit;
        $databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', null, $link);
        $mysql_error = PMA_DBI_getError($link);
        if (!count($databases) && $GLOBALS['errno']) {
            PMA_mysqlDie($mysql_error, $sql);
        }
        // display only databases also in official database list
        // f.e. to apply hide_db and only_db
        $drops = array_diff(array_keys($databases), (array) $GLOBALS['pma']->databases);
        if (count($drops)) {
            foreach ($drops as $drop) {
                unset($databases[$drop]);
            }
            unset($drop);
        }
        unset($sql_where_schema, $sql, $drops);
    } else {
        foreach ($GLOBALS['pma']->databases as $database_name) {
            // MySQL forward compatibility
            // so pma could use this array as if every server is of version >5.0
            $databases[$database_name]['SCHEMA_NAME'] = $database_name;
            if ($force_stats) {
                require_once './libraries/mysql_charsets.lib.php';
                $databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
                // get additional info about tables
                $databases[$database_name]['SCHEMA_TABLES'] = 0;
//.........这里部分代码省略.........
开发者ID:alexhava,项目名称:elixirjuice,代码行数:101,代码来源:database_interface.lib.php

示例5: _retrieve

    /**
     * retrieves database list from server
     *
     * @todo    we could also search mysql tables if all fail?
     * @uses    PMA_List_Database::$_show_databases_disabled for not retrying if SHOW DATABASES is disabled
     * @uses    PMA_List_Database::$_db_link
     * @uses    PMA_List_Database::$_db_link_control in case of SHOW DATABASES is disabled for userlink
     * @uses    PMA_DBI_fetch_result()
     * @uses    PMA_DBI_getError()
     * @uses    $GLOBALS['error_showdatabases']
     * @uses    $GLOBALS['errno']
     * @param   string  $like_db_name   usally a db_name containing wildcards
     */
    protected function _retrieve($like_db_name = null)
    {
        if ($this->_show_databases_disabled) {
            return array();
        }

        if (null !== $like_db_name) {
            $command = "SHOW DATABASES LIKE '" . $like_db_name . "'";
        } elseif (null === $this->_command) {
            $command = str_replace('#user#', $GLOBALS['cfg']['Server']['user'],
                $GLOBALS['cfg']['Server']['ShowDatabasesCommand']);
            $this->_command = $command;
        } else {
            $command = $this->_command;
        }

        $database_list = PMA_DBI_fetch_result($command, null, null, $this->_db_link);
        PMA_DBI_getError();

        if ($GLOBALS['errno'] !== 0) {
            // failed to get database list, try the control user
            // (hopefully there is one and he has SHOW DATABASES right)
            $this->_db_link = $this->_db_link_control;
            $database_list = PMA_DBI_fetch_result($command, null, null, $this->_db_link);

            PMA_DBI_getError();

            if ($GLOBALS['errno'] !== 0) {
                // failed! we will display a warning that phpMyAdmin could not safely
                // retrieve database list, the admin has to setup a control user or
                // allow SHOW DATABASES
                $GLOBALS['error_showdatabases'] = true;
                $this->_show_databases_disabled = true;
            }
        }

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

示例6: saveToDb

 /**
  * Save recent tables into phpMyAdmin database.
  *
  * @return true|PMA_Message
  */
 public function saveToDb()
 {
     $username = $GLOBALS['cfg']['Server']['user'];
     $sql_query = " REPLACE INTO " . $this->pma_table . " (`username`, `tables`)" . " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes(json_encode($this->tables)) . "')";
     $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
     if (!$success) {
         $message = PMA_Message::error(__('Could not save recent table'));
         $message->addMessage('<br /><br />');
         $message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
         return $message;
     }
     return true;
 }
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:18,代码来源:RecentTable.class.php

示例7: __

            }
        }
    }
    if (empty($_REQUEST['change_copy'])) {
        if (empty($queries)) {
            $message = PMA_Message::error(__('No users selected for deleting!'));
        } else {
            if ($_REQUEST['mode'] == 3) {
                $queries[] = '# ' . __('Reloading the privileges') . ' ...';
                $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";
                    }
                }
            }
            // tracking sets this, causing the deleted db to be shown in navi
            unset($GLOBALS['db']);

            $sql_query = join("\n", $queries);
            if (! empty($drop_user_error)) {
                $message = PMA_Message::rawError($drop_user_error);
            } else {
                $message = PMA_Message::success(__('The selected users have been deleted successfully.'));
            }
        }
        unset($queries);
    }
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:31,代码来源:server_privileges.php

示例8: countRecords

 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the current database name
  * @param   string   the current table name
  * @param   boolean  whether to force an exact count
  *
  * @return  mixed    the number of records if "retain" param is true,
  *                   otherwise true
  *
  * @access  public
  */
 public static function countRecords($db, $table, $force_exact = false, $is_view = null)
 {
     if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
         $row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
     } else {
         $row_count = false;
         if (null === $is_view) {
             $is_view = PMA_Table::isView($db, $table);
         }
         if (!$force_exact) {
             if (!isset(PMA_Table::$cache[$db][$table]['Rows']) && !$is_view) {
                 PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\'');
             }
             $row_count = PMA_Table::$cache[$db][$table]['Rows'];
         }
         // for a VIEW, $row_count is always false at this point
         if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
             if (!$is_view) {
                 $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
             } else {
                 // For complex views, even trying to get a partial record
                 // count could bring down a server, so we offer an
                 // alternative: setting MaxExactCountViews to 0 will bypass
                 // completely the record counting for views
                 if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
                     $row_count = 0;
                 } else {
                     // Counting all rows of a VIEW could be too long, so use
                     // a LIMIT clause.
                     // Use try_query because it can fail (when a VIEW is
                     // based on a table that no longer exists)
                     $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
                     if (!PMA_DBI_getError()) {
                         $row_count = PMA_DBI_num_rows($result);
                         PMA_DBI_free_result($result);
                     }
                 }
             }
             PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;
         }
     }
     return $row_count;
 }
开发者ID:kolbermoorer,项目名称:edugame,代码行数:58,代码来源:Table.class.php

示例9: PMA_TRI_handleEditor

/**
 * Handles editor requests for adding or editing an item
 *
 * @return void
 */
function PMA_TRI_handleEditor()
{
    global $_REQUEST, $_POST, $errors, $db, $table;
    if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
        $sql_query = '';
        $item_query = PMA_TRI_getQueryFromRequest();
        if (!count($errors)) {
            // set by PMA_RTN_getQueryFromRequest()
            // Execute the created query
            if (!empty($_REQUEST['editor_process_edit'])) {
                // Backup the old trigger, in case something goes wrong
                $trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']);
                $create_item = $trigger['create'];
                $drop_item = $trigger['drop'] . ';';
                $result = PMA_DBI_try_query($drop_item);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $result = PMA_DBI_try_query($item_query);
                    if (!$result) {
                        $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        // We dropped the old item, but were unable to create the new one
                        // Try to restore the backup query
                        $result = PMA_DBI_try_query($create_item);
                        if (!$result) {
                            // OMG, this is really bad! We dropped the query,
                            // failed to create a new one
                            // and now even the backup query does not execute!
                            // This should not happen, but we better handle
                            // this just in case.
                            $errors[] = __('Sorry, we failed to restore the dropped trigger.') . '<br />' . __('The backed up query was:') . "\"" . htmlspecialchars($create_item) . "\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        }
                    } else {
                        $message = PMA_Message::success(__('Trigger %1$s has been modified.'));
                        $message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
                        $sql_query = $drop_item . $item_query;
                    }
                }
            } else {
                // 'Add a new item' mode
                $result = PMA_DBI_try_query($item_query);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $message = PMA_Message::success(__('Trigger %1$s has been created.'));
                    $message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
                    $sql_query = $item_query;
                }
            }
        }
        if (count($errors)) {
            $message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>'));
            $message->addString('<ul>');
            foreach ($errors as $string) {
                $message->addString('<li>' . $string . '</li>');
            }
            $message->addString('</ul>');
        }
        $output = PMA_Util::getMessage($message, $sql_query);
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            if ($message->isSuccess()) {
                $items = PMA_DBI_get_triggers($db, $table, '');
                $trigger = false;
                foreach ($items as $value) {
                    if ($value['name'] == $_REQUEST['item_name']) {
                        $trigger = $value;
                    }
                }
                $insert = false;
                if (empty($table) || $trigger !== false && $table == $trigger['table']) {
                    $insert = true;
                    $response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
                    $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
                }
                $response->addJSON('insert', $insert);
                $response->addJSON('message', $output);
            } else {
                $response->addJSON('message', $message);
                $response->isSuccess(false);
            }
            exit;
        }
    }
    /**
     * Display a form used to add/edit a trigger, if necessary
     */
    if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']))) {
        // Get the data for the form (if any)
        if (!empty($_REQUEST['add_item'])) {
            $title = PMA_RTE_getWord('add');
            $item = PMA_TRI_getDataFromRequest();
            $mode = 'add';
        } else {
            if (!empty($_REQUEST['edit_item'])) {
//.........这里部分代码省略.........
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:101,代码来源:rte_triggers.lib.php

示例10: 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.
 *
 * @uses    $_SESSION['is_create_db_priv'] for caching
 * @uses    $_SESSION['is_process_priv'] for caching
 * @uses    $_SESSION['is_reload_priv'] for caching
 * @uses    $_SESSION['db_to_create'] for caching
 * @uses    $_SESSION['dbs_where_create_table_allowed'] for caching
 * @uses    $GLOBALS['is_create_db_priv'] to set it
 * @uses    $GLOBALS['is_process_priv'] to set it
 * @uses    $GLOBALS['is_reload_priv'] to set it
 * @uses    $GLOBALS['db_to_create'] to set it
 * @uses    $GLOBALS['dbs_where_create_table_allowed'] to set it
 * @uses    $GLOBALS['server']
 * @uses    PMA_DBI_try_query()
 * @uses    PMA_DBI_fetch_row()
 * @uses    PMA_DBI_free_result()
 * @uses    PMA_DBI_getError()
 * @uses    PMA_unQuote()
 * @uses    PMA_backquote()
 * @uses    preg_match()
 * @uses    preg_replace()
 * @uses    substr()
 * @uses    strpos()
 */
function PMA_analyseShowGrant()
{
    if (PMA_cacheExists('is_create_db_priv', true)) {
        $GLOBALS['is_create_db_priv'] = PMA_cacheGet('is_create_db_priv', true);
        $GLOBALS['is_process_priv'] = PMA_cacheGet('is_process_priv', true);
        $GLOBALS['is_reload_priv'] = PMA_cacheGet('is_reload_priv', true);
        $GLOBALS['db_to_create'] = PMA_cacheGet('db_to_create', true);
        $GLOBALS['dbs_where_create_table_allowed'] = PMA_cacheGet('dbs_where_create_table_allowed', true);
        return;
    }
    // defaults
    $GLOBALS['is_create_db_priv'] = false;
    $GLOBALS['is_process_priv'] = true;
    $GLOBALS['is_reload_priv'] = false;
    $GLOBALS['db_to_create'] = '';
    $GLOBALS['dbs_where_create_table_allowed'] = array();
    $rs_usr = PMA_DBI_try_query('SHOW GRANTS');
    if (!$rs_usr) {
        return;
    }
    $re0 = '(^|(\\\\\\\\)+|[^\\\\])';
    // non-escaped wildcards
    $re1 = '(^|[^\\\\])(\\\\)+';
    // escaped wildcards
    while ($row = PMA_DBI_fetch_row($rs_usr)) {
        // extract db from GRANT ... ON *.* or GRANT ... ON db.*
        $db_name_offset = strpos($row[0], ' ON ') + 4;
        $show_grants_dbname = substr($row[0], $db_name_offset, strpos($row[0], '.', $db_name_offset) - $db_name_offset);
        $show_grants_dbname = PMA_unQuote($show_grants_dbname, '`');
        $show_grants_str = substr($row[0], 6, strpos($row[0], ' ON ') - 6);
        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_backquote($show_grants_dbname);
                if ($GLOBALS['is_create_db_priv']) {
                    // no need for any more tests if we already know this
                    continue;
                }
                if (preg_match('/' . $re0 . '%|_/', $show_grants_dbname) && !preg_match('/\\\\%|\\\\_/', $show_grants_dbname) || !PMA_DBI_try_query('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test)) && substr(PMA_DBI_getError(), 1, 4) != 1044) {
                    if ($GLOBALS['cfg']['SuggestDBName']) {
                        $GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '_/', '\\1?', $show_grants_dbname);
                        $GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1...', $GLOBALS['db_to_create']);
                        $GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']);
                    }
                    $GLOBALS['is_create_db_priv'] = true;
//.........这里部分代码省略.........
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:101,代码来源:check_user_privileges.lib.php

示例11: array

    if (count($key_fields)) {
        $fields = array();
        foreach ($key_fields as $each_field) {
            if (isset($_REQUEST['field_name'][$each_field]) && strlen($_REQUEST['field_name'][$each_field])) {
                $fields[] = PMA_CommonFunctions::getInstance()->backquote($_REQUEST['field_name'][$each_field]);
            }
        } // end for
        $key_query = ', ADD KEY (' . implode(', ', $fields) . ') ';
    }
     */

    // To allow replication, we first select the db to use and then run queries
    // on this db.
    if (! PMA_DBI_select_db($db)) {
        $common_functions->mysqlDie(
            PMA_DBI_getError(),
            'USE ' . $common_functions->backquote($db) . ';',
            '',
            $err_url
        );
    }
    $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' ';
    $sql_query .= implode(', ', $changes) . $key_query;
    $sql_query .= ';';
    $result    = PMA_DBI_try_query($sql_query);

    if ($result !== false) {
        $message = PMA_Message::success(
            __('Table %1$s has been altered successfully')
        );
        $message->addParam($table);
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:31,代码来源:tbl_alter.php

示例12: PMA_auth_fails

/**
 * User is not allowed to login to MySQL -> authentication failed
 *
 * prepares error message and switches to PMA_auth() which display the error
 * and the login form
 *
 * this function MUST exit/quit the application,
 * currently doen by call to PMA_auth()
 *
 * @access  public
 */
function PMA_auth_fails()
{
    global $conn_error;
    // Deletes password cookie and displays the login form
    $GLOBALS['PMA_Config']->removeCookie('pmaPass-' . $GLOBALS['server']);
    if (!empty($GLOBALS['login_without_password_is_forbidden'])) {
        $conn_error = __('Login without a password is forbidden by configuration (see AllowNoPassword)');
    } elseif (!empty($GLOBALS['allowDeny_forbidden'])) {
        $conn_error = __('Access denied');
    } elseif (!empty($GLOBALS['no_activity'])) {
        $conn_error = sprintf(__('No activity within %s seconds; please log in again'), $GLOBALS['cfg']['LoginCookieValidity']);
        // Remember where we got timeout to return on same place
        if (PMA_getenv('SCRIPT_NAME')) {
            $GLOBALS['target'] = basename(PMA_getenv('SCRIPT_NAME'));
            // avoid "missing parameter: field" on re-entry
            if ('tbl_alter.php' == $GLOBALS['target']) {
                $GLOBALS['target'] = 'tbl_structure.php';
            }
        }
    } elseif (PMA_DBI_getError()) {
        $conn_error = '#' . $GLOBALS['errno'] . ' ' . __('Cannot log in to the MySQL server');
    } else {
        $conn_error = __('Cannot log in to the MySQL server');
    }
    // needed for PHP-CGI (not need for FastCGI or mod-php)
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Pragma: no-cache');
    PMA_auth();
}
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:40,代码来源:cookie.auth.lib.php

示例13: PMA_ChangePassUrlParamsAndSubmitQuery

/**
 * Generate the error url and submit the query
 *
 * @param string  $password
 * @param array   $_url_params
 * @param string  $sql_query
 * @param string  $hashing_function
 *
 * @return void
 */
function PMA_ChangePassUrlParamsAndSubmitQuery($password, $_url_params, $sql_query, $hashing_function)
{
    $common_functions = PMA_CommonFunctions::getInstance();
    $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
    $local_query = 'SET password = ' . (($password == '')
        ? '\'\''
        : $hashing_function . '(\'' . $common_functions->sqlAddSlashes($password) . '\')');
    $result = @PMA_DBI_try_query($local_query)
            or $common_functions->mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
}
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:20,代码来源:user_password.php

示例14: PMA_DBI_fetch_assoc

 // (but a LIMIT would disrupt results in an UNION)
 if (PMA_MYSQL_INT_VERSION >= 40000 && !isset($analyzed_sql[0]['queryflags']['union'])) {
     $count_query .= ' LIMIT 1';
 }
 // run the count query
 if (PMA_MYSQL_INT_VERSION < 40000) {
     if ($cnt_all_result = PMA_DBI_try_query($count_query)) {
         if ($is_group && $count_what == '*') {
             $unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result);
         } else {
             $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result);
             $unlim_num_rows = $unlim_num_rows['count'];
         }
         PMA_DBI_free_result($cnt_all_result);
     } else {
         if (PMA_DBI_getError()) {
             // there are some cases where the generated
             // count_query (for MySQL 3) is wrong,
             // so we get here.
             //TODO: use a big unlimited query to get
             // the correct number of rows (depending
             // on a config variable?)
             $unlim_num_rows = 0;
         }
     }
 } else {
     PMA_DBI_try_query($count_query);
     // if (mysql_error()) {
     // void.
     // I tried the case
     // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
开发者ID:robmat,项目名称:samplebator,代码行数:31,代码来源:sql.php

示例15: exportData

 /**
  * Outputs the content of a table in SQL format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $current_row, $sql_backquotes;
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_Util::backquoteCompat($table, $compat) : '\'' . $table . '\'';
     // Do not export data for a VIEW
     // (For a VIEW, this is called only when exporting a single VIEW)
     if (PMA_Table::isView($db, $table)) {
         $head = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment('VIEW ' . ' ' . $formatted_table_name) . $this->_exportComment(__('Data') . ': ' . __('None')) . $this->_exportComment() . $this->_possibleCRLF();
         if (!PMA_exportOutputHandler($head)) {
             return false;
         }
         return true;
     }
     // analyze the query to get the true column names, not the aliases
     // (this fixes an undefined index, also if Complete inserts
     //  are used, we did not get the true column name in case of aliases)
     $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
     $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     // a possible error: the table has crashed
     $tmp_error = PMA_DBI_getError();
     if ($tmp_error) {
         return PMA_exportOutputHandler($this->_exportComment(__('Error reading data:') . ' (' . $tmp_error . ')'));
     }
     if ($result != false) {
         $fields_cnt = PMA_DBI_num_fields($result);
         // Get field information
         $fields_meta = PMA_DBI_get_fields_meta($result);
         $field_flags = array();
         for ($j = 0; $j < $fields_cnt; $j++) {
             $field_flags[$j] = PMA_DBI_field_flags($result, $j);
         }
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
                 $field_set[$j] = PMA_Util::backquoteCompat($analyzed_sql[0]['select_expr'][$j]['column'], $compat, $sql_backquotes);
             } else {
                 $field_set[$j] = PMA_Util::backquoteCompat($fields_meta[$j]->name, $compat, $sql_backquotes);
             }
         }
         if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
             // update
             $schema_insert = 'UPDATE ';
             if (isset($GLOBALS['sql_ignore'])) {
                 $schema_insert .= 'IGNORE ';
             }
             // avoid EOL blank
             $schema_insert .= PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' SET';
         } else {
             // insert or replace
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'REPLACE') {
                 $sql_command = 'REPLACE';
             } else {
                 $sql_command = 'INSERT';
             }
             // delayed inserts?
             if (isset($GLOBALS['sql_delayed'])) {
                 $insert_delayed = ' DELAYED';
             } else {
                 $insert_delayed = '';
             }
             // insert ignore?
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'INSERT' && isset($GLOBALS['sql_ignore'])) {
                 $insert_delayed .= ' IGNORE';
             }
             //truncate table before insert
             if (isset($GLOBALS['sql_truncate']) && $GLOBALS['sql_truncate'] && $sql_command == 'INSERT') {
                 $truncate = 'TRUNCATE TABLE ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ";";
                 $truncatehead = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('Truncate table before insert') . ' ' . $formatted_table_name) . $this->_exportComment() . $crlf;
                 PMA_exportOutputHandler($truncatehead);
                 PMA_exportOutputHandler($truncate);
             } else {
                 $truncate = '';
             }
             // scheme for inserting fields
             if ($GLOBALS['sql_insert_syntax'] == 'complete' || $GLOBALS['sql_insert_syntax'] == 'both') {
                 $fields = implode(', ', $field_set);
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' (' . $fields . ') VALUES';
             } else {
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' VALUES';
             }
         }
         //\x08\\x09, not required
         $search = array("", "\n", "\r", "");
         $replace = array('\\0', '\\n', '\\r', '\\Z');
         $current_row = 0;
//.........这里部分代码省略.........
开发者ID:fanscky,项目名称:HTPMS,代码行数:101,代码来源:ExportSql.class.php


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