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


PHP Message::error方法代码示例

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


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

示例1: PMA_RTE_handleExport

/**
 * This function is called from one of the other functions in this file
 * and it completes the handling of the export functionality.
 *
 * @param string $export_data The SQL query to create the requested item
 *
 * @return void
 */
function PMA_RTE_handleExport($export_data)
{
    global $db;
    $item_name = htmlspecialchars(PMA\libraries\Util::backquote($_GET['item_name']));
    if ($export_data !== false) {
        $export_data = htmlspecialchars(trim($export_data));
        $title = sprintf(PMA_RTE_getWord('export'), $item_name);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA\libraries\Response::getInstance();
            $response->addJSON('message', $export_data);
            $response->addJSON('title', $title);
            exit;
        } else {
            $export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . $export_data . '</textarea>';
            echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
        }
    } else {
        $_db = htmlspecialchars(PMA\libraries\Util::backquote($db));
        $message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
        $response = Message::error($message);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA\libraries\Response::getInstance();
            $response->setRequestStatus(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $response->display();
        }
    }
}
开发者ID:netroby,项目名称:phpmyadmin,代码行数:38,代码来源:rte_export.lib.php

示例2: PMA_RTE_sendEditor

/**
 * Send TRI or EVN editor via ajax or by echoing.
 *
 * @param string $type      TRI or EVN
 * @param string $mode      Editor mode 'add' or 'edit'
 * @param array  $item      Data necessary to create the editor
 * @param string $title     Title of the editor
 * @param string $db        Database
 * @param string $operation Operation 'change' or ''
 *
 * @return void
 */
function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null)
{
    if ($item !== false) {
        // Show form
        if ($type == 'TRI') {
            $editor = PMA_TRI_getEditorForm($mode, $item);
        } else {
            // EVN
            $editor = PMA_EVN_getEditorForm($mode, $operation, $item);
        }
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA\libraries\Response::getInstance();
            $response->addJSON('message', $editor);
            $response->addJSON('title', $title);
        } else {
            echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
            unset($_POST);
        }
        exit;
    } else {
        $message = __('Error in processing request:') . ' ';
        $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA\libraries\Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA\libraries\Util::backquote($db)));
        $message = Message::error($message);
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA\libraries\Response::getInstance();
            $response->setRequestStatus(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $message->display();
        }
    }
}
开发者ID:pjiahao,项目名称:phpmyadmin,代码行数:45,代码来源:rte_general.lib.php

示例3: doImport

 /**
  * Handles the whole import logic
  *
  * @param array &$sql_data 2-element array with sql data
  *
  * @return void
  */
 public function doImport(&$sql_data = array())
 {
     global $finished, $import_file, $charset_conversion, $table;
     global $ldi_local_option, $ldi_replace, $ldi_ignore, $ldi_terminated, $ldi_enclosed, $ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
     $compression = $GLOBALS['import_handle']->getCompression();
     if ($import_file == 'none' || $compression != 'none' || $charset_conversion) {
         // We handle only some kind of data!
         $GLOBALS['message'] = PMA\libraries\Message::error(__('This plugin does not support compressed imports!'));
         $GLOBALS['error'] = true;
         return;
     }
     $sql = 'LOAD DATA';
     if (isset($ldi_local_option)) {
         $sql .= ' LOCAL';
     }
     $sql .= ' INFILE \'' . $GLOBALS['dbi']->escapeString($import_file) . '\'';
     if (isset($ldi_replace)) {
         $sql .= ' REPLACE';
     } elseif (isset($ldi_ignore)) {
         $sql .= ' IGNORE';
     }
     $sql .= ' INTO TABLE ' . PMA\libraries\Util::backquote($table);
     if (strlen($ldi_terminated) > 0) {
         $sql .= ' FIELDS TERMINATED BY \'' . $ldi_terminated . '\'';
     }
     if (strlen($ldi_enclosed) > 0) {
         $sql .= ' ENCLOSED BY \'' . $GLOBALS['dbi']->escapeString($ldi_enclosed) . '\'';
     }
     if (strlen($ldi_escaped) > 0) {
         $sql .= ' ESCAPED BY \'' . $GLOBALS['dbi']->escapeString($ldi_escaped) . '\'';
     }
     if (strlen($ldi_new_line) > 0) {
         if ($ldi_new_line == 'auto') {
             $ldi_new_line = PMA\libraries\Util::whichCrlf() == "\n" ? '\\n' : '\\r\\n';
         }
         $sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
     }
     if ($skip_queries > 0) {
         $sql .= ' IGNORE ' . $skip_queries . ' LINES';
         $skip_queries = 0;
     }
     if (strlen($ldi_columns) > 0) {
         $sql .= ' (';
         $tmp = preg_split('/,( ?)/', $ldi_columns);
         $cnt_tmp = count($tmp);
         for ($i = 0; $i < $cnt_tmp; $i++) {
             if ($i > 0) {
                 $sql .= ', ';
             }
             /* Trim also `, if user already included backquoted fields */
             $sql .= PMA\libraries\Util::backquote(trim($tmp[$i], " \t\r\n\v`"));
         }
         // end for
         $sql .= ')';
     }
     PMA_importRunQuery($sql, $sql, $sql_data);
     PMA_importRunQuery('', '', $sql_data);
     $finished = true;
 }
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:66,代码来源:ImportLdi.php

示例4: PMA_getHtmlForSchemaExport

/**
 * Function to get html for displaying the schema export
 *
 * @param string $db   database name
 * @param int    $page the page to be exported
 *
 * @return string
 */
function PMA_getHtmlForSchemaExport($db, $page)
{
    /* Scan for schema plugins */
    /* @var $export_list SchemaPlugin[] */
    $export_list = PMA_getPlugins("schema", 'libraries/plugins/schema/', null);
    /* Fail if we didn't find any schema plugin */
    if (empty($export_list)) {
        return Message::error(__('Could not load schema plugins, please check your installation!'))->getDisplay();
    }
    return PMA\libraries\Template::get('database/designer/schema_export')->render(array('db' => $db, 'page' => $page, 'export_list' => $export_list));
}
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:19,代码来源:db_designer.lib.php

示例5: indexAction

 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     $request = Request::getInstance();
     if ($request->isAjax() && isset($_REQUEST['type']) && $_REQUEST['type'] === 'getval') {
         $this->getValueAction();
         return;
     }
     if ($request->isAjax() && isset($_REQUEST['type']) && $_REQUEST['type'] === 'setval') {
         $this->setValueAction();
         return;
     }
     include 'libraries/server_common.inc.php';
     $header = $this->response->getHeader();
     $scripts = $header->getScripts();
     $scripts->addFile('server_variables.js');
     /**
      * Displays the sub-page heading
      */
     $doc_link = Util::showMySQLDocu('server_system_variables');
     $this->response->addHtml(PMA_getHtmlForSubPageHeader('variables', $doc_link));
     /**
      * Sends the queries and buffers the results
      */
     $serverVarsResult = $this->dbi->tryQuery('SHOW SESSION VARIABLES;');
     if ($serverVarsResult !== false) {
         $serverVarsSession = array();
         while ($arr = $this->dbi->fetchRow($serverVarsResult)) {
             $serverVarsSession[$arr[0]] = $arr[1];
         }
         $this->dbi->freeResult($serverVarsResult);
         $serverVars = $this->dbi->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
         /**
          * Link templates
          */
         $this->response->addHtml($this->_getHtmlForLinkTemplates());
         /**
          * Displays the page
          */
         $this->response->addHtml($this->_getHtmlForServerVariables($serverVars, $serverVarsSession));
     } else {
         /**
          * Display the error message
          */
         $this->response->addHTML(Message::error(sprintf(__('Not enough privilege to view server variables and ' . 'settings. %s'), Util::showMySQLDocu('server-system-variables', false, 'sysvar_show_compatibility_56')))->getDisplay());
     }
 }
开发者ID:nijel,项目名称:phpmyadmin,代码行数:51,代码来源:ServerVariablesController.php

示例6: getDisplay

 /**
  * Renders the navigation tree, or part of it
  *
  * @return string The navigation tree
  */
 public function getDisplay()
 {
     /* Init */
     $retval = '';
     if (!Response::getInstance()->isAjax()) {
         $header = new NavigationHeader();
         $retval = $header->getDisplay();
     }
     $tree = new NavigationTree();
     if (!Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) {
         if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
             // provide database tree in navigation
             $navRender = $tree->renderState();
         } else {
             // provide legacy pre-4.0 navigation
             $navRender = $tree->renderDbSelect();
         }
     } else {
         $navRender = $tree->renderPath();
     }
     if (!$navRender) {
         $retval .= Message::error(__('An error has occurred while loading the navigation display'))->getDisplay();
     } else {
         $retval .= $navRender;
     }
     if (!Response::getInstance()->isAjax()) {
         // closes the tags that were opened by the navigation header
         $retval .= '</div>';
         // pma_navigation_tree
         $retval .= '<div id="pma_navi_settings_container">';
         if (!defined('PMA_DISABLE_NAVI_SETTINGS')) {
             $retval .= PageSettings::getNaviSettings();
         }
         $retval .= '</div>';
         //pma_navi_settings_container
         $retval .= '</div>';
         // pma_navigation_content
         $retval .= $this->_getDropHandler();
         $retval .= '</div>';
         // pma_navigation
     }
     return $retval;
 }
开发者ID:poush,项目名称:phpmyadmin,代码行数:48,代码来源:Navigation.php

示例7: authForm

 /**
  * Displays authentication form
  *
  * @return boolean
  */
 public function authForm()
 {
     if (empty($GLOBALS['cfg']['Server']['auth_http_realm'])) {
         if (empty($GLOBALS['cfg']['Server']['verbose'])) {
             $server_message = $GLOBALS['cfg']['Server']['host'];
         } else {
             $server_message = $GLOBALS['cfg']['Server']['verbose'];
         }
         $realm_message = 'phpMyAdmin ' . $server_message;
     } else {
         $realm_message = $GLOBALS['cfg']['Server']['auth_http_realm'];
     }
     $response = Response::getInstance();
     // remove non US-ASCII to respect RFC2616
     $realm_message = preg_replace('/[^\\x20-\\x7e]/i', '', $realm_message);
     $response->header('WWW-Authenticate: Basic realm="' . $realm_message . '"');
     $response->header('HTTP/1.0 401 Unauthorized');
     if (php_sapi_name() !== 'cgi-fcgi') {
         $response->header('status: 401 Unauthorized');
     }
     /* HTML header */
     $footer = $response->getFooter();
     $footer->setMinimal();
     $header = $response->getHeader();
     $header->setTitle(__('Access denied!'));
     $header->disableMenuAndConsole();
     $header->setBodyId('loginform');
     $response->addHTML('<h1>');
     $response->addHTML(sprintf(__('Welcome to %s'), ' phpMyAdmin'));
     $response->addHTML('</h1>');
     $response->addHTML('<h3>');
     $response->addHTML(Message::error(__('Wrong username/password. Access denied.')));
     $response->addHTML('</h3>');
     if (@file_exists(CUSTOM_FOOTER_FILE)) {
         include CUSTOM_FOOTER_FILE;
     }
     if (!defined('TESTSUITE')) {
         exit;
     } else {
         return false;
     }
 }
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:47,代码来源:AuthenticationHttp.php

示例8: PMA_RTN_handleRequestCreateOrEdit

/**
 * Handle request to create or edit a routine
 *
 * @param array  $errors Errors
 * @param string $db     DB name
 *
 * @return array
 */
function PMA_RTN_handleRequestCreateOrEdit($errors, $db)
{
    if (empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit'])) {
        return $errors;
    }
    $sql_query = '';
    $routine_query = PMA_RTN_getQueryFromRequest();
    if (!count($errors)) {
        // set by PMA_RTN_getQueryFromRequest()
        // Execute the created query
        if (!empty($_REQUEST['editor_process_edit'])) {
            $isProcOrFunc = in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION'));
            if (!$isProcOrFunc) {
                $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_original_type']));
            } else {
                // Backup the old routine, in case something goes wrong
                $create_routine = $GLOBALS['dbi']->getDefinition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']);
                $privilegesBackup = PMA_RTN_backupPrivileges();
                $drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA\libraries\Util::backquote($_REQUEST['item_original_name']) . ";\n";
                $result = $GLOBALS['dbi']->tryQuery($drop_routine);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_routine)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
                } else {
                    list($newErrors, $message) = PMA_RTN_createRoutine($routine_query, $create_routine, $privilegesBackup);
                    if (empty($newErrors)) {
                        $sql_query = $drop_routine . $routine_query;
                    } else {
                        $errors = array_merge($errors, $newErrors);
                    }
                    unset($newErrors);
                    if (null === $message) {
                        unset($message);
                    }
                }
            }
        } else {
            // 'Add a new routine' mode
            $result = $GLOBALS['dbi']->tryQuery($routine_query);
            if (!$result) {
                $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
            } else {
                $message = PMA\libraries\Message::success(__('Routine %1$s has been created.'));
                $message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name']));
                $sql_query = $routine_query;
            }
        }
    }
    if (count($errors)) {
        $message = PMA\libraries\Message::error(__('One or more errors have occurred while' . ' processing your request:'));
        $message->addString('<ul>');
        foreach ($errors as $string) {
            $message->addString('<li>' . $string . '</li>');
        }
        $message->addString('</ul>');
    }
    $output = PMA\libraries\Util::getMessage($message, $sql_query);
    if (!$GLOBALS['is_ajax_request']) {
        return $errors;
    }
    $response = PMA\libraries\Response::getInstance();
    if (!$message->isSuccess()) {
        $response->setRequestStatus(false);
        $response->addJSON('message', $output);
        exit;
    }
    $routines = $GLOBALS['dbi']->getRoutines($db, $_REQUEST['item_type'], $_REQUEST['item_name']);
    $routine = $routines[0];
    $response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name'])));
    $response->addJSON('new_row', PMA_RTN_getRowForList($routine));
    $response->addJSON('insert', !empty($routine));
    $response->addJSON('message', $output);
    exit;
}
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:81,代码来源:rte_routines.lib.php

示例9:

                } else {
                    $error = $result;
                }
                exit;
            }
        }
    }
}
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('config.js');
require 'libraries/user_preferences.inc.php';
if ($error) {
    if (!$error instanceof Message) {
        $error = Message::error($error);
    }
    $error->display();
}
?>
<script type="text/javascript">
<?php 
PMA_printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@'));
?>
</script>
<div id="maincontainer">
    <div id="main_pane_left">
        <div class="group">
<?php 
echo '<h2>', __('Import'), '</h2>', '<form class="group-cnt prefs-form disableAjax" name="prefs_import"', ' action="prefs_manage.php" method="post" enctype="multipart/form-data">', Util::generateHiddenMaxFileSize($GLOBALS['max_upload_size']), PMA_URL_getHiddenInputs(), '<input type="hidden" name="json" value="" />', '<input type="radio" id="import_text_file" name="import_type"', ' value="text_file" checked="checked" />', '<label for="import_text_file">' . __('Import from file') . '</label>', '<div id="opts_import_text_file" class="prefsmanage_opts">', '<label for="input_import_file">', __('Browse your computer:'), '</label>', '<input type="file" name="import_file" id="input_import_file" />', '</div>', '<input type="radio" id="import_local_storage" name="import_type"', ' value="local_storage" disabled="disabled" />', '<label for="import_local_storage">', __('Import from browser\'s storage'), '</label>', '<div id="opts_import_local_storage" class="prefsmanage_opts disabled">', '<div class="localStorage-supported">', __('Settings will be imported from your browser\'s local storage.'), '<br />', '<div class="localStorage-exists">', __('Saved on: @DATE@'), '</div>', '<div class="localStorage-empty">';
Message::notice(__('You have no saved settings!'))->display();
开发者ID:Dhrumil1808,项目名称:phpmyadmin,代码行数:31,代码来源:prefs_manage.php

示例10: list

         */
        include_once 'libraries/parse_analyze.lib.php';
        list($analyzed_sql_results, $db, $table) = PMA_parseAnalyze($sql_query, $db);
        // @todo: possibly refactor
        extract($analyzed_sql_results);
        PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, false, $db, $table, null, null, null, null, null, null, $goto, $pmaThemeImage, null, null, $query_type, $sql_query, $selected, null);
    } elseif (!$run_parts) {
        $GLOBALS['dbi']->selectDb($db);
        $result = $GLOBALS['dbi']->tryQuery($sql_query);
        if ($result && !empty($sql_query_views)) {
            $sql_query .= ' ' . $sql_query_views . ';';
            $result = $GLOBALS['dbi']->tryQuery($sql_query_views);
            unset($sql_query_views);
        }
        if (!$result) {
            $message = Message::error($GLOBALS['dbi']->getError());
        }
    }
    if ($query_type == 'drop_tbl' || $query_type == 'empty_tbl' || $query_type == 'row_delete') {
        PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check_value);
    }
    if ($rebuild_database_list) {
        // avoid a problem with the database list navigator
        // when dropping a db from server_databases
        $GLOBALS['pma']->databases->build();
    }
} else {
    if (isset($submit_mult) && ($submit_mult == 'sync_unique_columns_central_list' || $submit_mult == 'delete_unique_columns_central_list' || $submit_mult == 'add_to_central_columns' || $submit_mult == 'remove_from_central_columns' || $submit_mult == 'make_consistent_with_central_list')) {
        if (isset($centralColsError) && $centralColsError !== true) {
            $message = $centralColsError;
        } else {
开发者ID:netroby,项目名称:phpmyadmin,代码行数:31,代码来源:mult_submits.inc.php

示例11: PMA_fatalError

/**
 * displays the given error message on phpMyAdmin error page in foreign language,
 * ends script execution and closes session
 *
 * loads language file if not loaded already
 *
 * @param string       $error_message  the error message or named error message
 * @param string|array $message_args   arguments applied to $error_message
 * @param boolean      $delete_session whether to delete session cookie
 *
 * @return void
 */
function PMA_fatalError($error_message, $message_args = null, $delete_session = true)
{
    /* Use format string if applicable */
    if (is_string($message_args)) {
        $error_message = sprintf($error_message, $message_args);
    } elseif (is_array($message_args)) {
        $error_message = vsprintf($error_message, $message_args);
    }
    $response = Response::getInstance();
    if ($response->isAjax()) {
        $response->setRequestStatus(false);
        $response->addJSON('message', PMA\libraries\Message::error($error_message));
    } else {
        $error_message = strtr($error_message, array('<br />' => '[br]'));
        // these variables are used in the included file libraries/error.inc.php
        //first check if php-mbstring is available
        if (function_exists('mb_detect_encoding')) {
            //If present use gettext
            $error_header = __('Error');
        } else {
            $error_header = 'Error';
        }
        $lang = isset($GLOBALS['lang']) ? $GLOBALS['lang'] : 'en';
        $dir = isset($GLOBALS['text_dir']) ? $GLOBALS['text_dir'] : 'ltr';
        // on fatal errors it cannot hurt to always delete the current session
        if ($delete_session && isset($GLOBALS['session_name']) && isset($_COOKIE[$GLOBALS['session_name']])) {
            $GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
        }
        // Displays the error message
        include './libraries/error.inc.php';
    }
    if (!defined('TESTSUITE')) {
        exit;
    }
}
开发者ID:nijel,项目名称:phpmyadmin,代码行数:47,代码来源:core.lib.php

示例12: doImport

 /**
  * Handles the whole import logic
  *
  * @param array &$sql_data 2-element array with sql data
  *
  * @return void
  */
 public function doImport(&$sql_data = array())
 {
     global $db, $table, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line, $csv_columns, $err_url;
     // $csv_replace and $csv_ignore should have been here,
     // but we use directly from $_POST
     global $error, $timeout_passed, $finished, $message;
     $replacements = array('\\n' => "\n", '\\t' => "\t", '\\r' => "\r");
     $csv_terminated = strtr($csv_terminated, $replacements);
     $csv_enclosed = strtr($csv_enclosed, $replacements);
     $csv_escaped = strtr($csv_escaped, $replacements);
     $csv_new_line = strtr($csv_new_line, $replacements);
     $param_error = false;
     if (mb_strlen($csv_terminated) < 1) {
         $message = PMA\libraries\Message::error(__('Invalid parameter for CSV import: %s'));
         $message->addParam(__('Columns terminated with'), false);
         $error = true;
         $param_error = true;
         // The default dialog of MS Excel when generating a CSV produces a
         // semi-colon-separated file with no chance of specifying the
         // enclosing character. Thus, users who want to import this file
         // tend to remove the enclosing character on the Import dialog.
         // I could not find a test case where having no enclosing characters
         // confuses this script.
         // But the parser won't work correctly with strings so we allow just
         // one character.
     } elseif (mb_strlen($csv_enclosed) > 1) {
         $message = PMA\libraries\Message::error(__('Invalid parameter for CSV import: %s'));
         $message->addParam(__('Columns enclosed with'), false);
         $error = true;
         $param_error = true;
         // I could not find a test case where having no escaping characters
         // confuses this script.
         // But the parser won't work correctly with strings so we allow just
         // one character.
     } elseif (mb_strlen($csv_escaped) > 1) {
         $message = PMA\libraries\Message::error(__('Invalid parameter for CSV import: %s'));
         $message->addParam(__('Columns escaped with'), false);
         $error = true;
         $param_error = true;
     } elseif (mb_strlen($csv_new_line) != 1 && $csv_new_line != 'auto') {
         $message = PMA\libraries\Message::error(__('Invalid parameter for CSV import: %s'));
         $message->addParam(__('Lines terminated with'), false);
         $error = true;
         $param_error = true;
     }
     // If there is an error in the parameters entered,
     // indicate that immediately.
     if ($param_error) {
         PMA\libraries\Util::mysqlDie($message->getMessage(), '', false, $err_url);
     }
     $buffer = '';
     $required_fields = 0;
     if (!$this->_getAnalyze()) {
         $sql_template = 'INSERT';
         if (isset($_POST['csv_ignore'])) {
             $sql_template .= ' IGNORE';
         }
         $sql_template .= ' INTO ' . PMA\libraries\Util::backquote($table);
         $tmp_fields = $GLOBALS['dbi']->getColumns($db, $table);
         if (empty($csv_columns)) {
             $fields = $tmp_fields;
         } else {
             $sql_template .= ' (';
             $fields = array();
             $tmp = preg_split('/,( ?)/', $csv_columns);
             foreach ($tmp as $key => $val) {
                 if (count($fields) > 0) {
                     $sql_template .= ', ';
                 }
                 /* Trim also `, if user already included backquoted fields */
                 $val = trim($val, " \t\r\n\v`");
                 $found = false;
                 foreach ($tmp_fields as $field) {
                     if ($field['Field'] == $val) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $message = PMA\libraries\Message::error(__('Invalid column (%s) specified! Ensure that columns' . ' names are spelled correctly, separated by commas' . ', and not enclosed in quotes.'));
                     $message->addParam($val);
                     $error = true;
                     break;
                 }
                 $fields[] = $field;
                 $sql_template .= PMA\libraries\Util::backquote($val);
             }
             $sql_template .= ') ';
         }
         $required_fields = count($fields);
         $sql_template .= ' VALUES (';
     }
     // Defaults for parser
//.........这里部分代码省略.........
开发者ID:pboutin44,项目名称:maintest,代码行数:101,代码来源:ImportCsv.php

示例13: PMA_fatalError

/**
 * displays the given error message on phpMyAdmin error page in foreign language,
 * ends script execution and closes session
 *
 * loads language file if not loaded already
 *
 * @param string       $error_message  the error message or named error message
 * @param string|array $message_args   arguments applied to $error_message
 * @param boolean      $delete_session whether to delete session cookie
 *
 * @return void
 */
function PMA_fatalError($error_message, $message_args = null, $delete_session = true)
{
    /* Use format string if applicable */
    if (is_string($message_args)) {
        $error_message = sprintf($error_message, $message_args);
    } elseif (is_array($message_args)) {
        $error_message = vsprintf($error_message, $message_args);
    }
    if (!empty($GLOBALS['is_ajax_request']) && $GLOBALS['is_ajax_request']) {
        $response = PMA\libraries\Response::getInstance();
        $response->setRequestStatus(false);
        $response->addJSON('message', PMA\libraries\Message::error($error_message));
    } else {
        $error_message = strtr($error_message, array('<br />' => '[br]'));
        /* Load gettext for fatal errors */
        if (!function_exists('__')) {
            // It is possible that PMA_fatalError() is called before including
            // vendor_config.php which defines GETTEXT_INC. See bug #4557
            if (defined(GETTEXT_INC)) {
                include_once GETTEXT_INC;
            } else {
                include_once './libraries/php-gettext/gettext.inc';
            }
        }
        // these variables are used in the included file libraries/error.inc.php
        //first check if php-mbstring is available
        if (function_exists('mb_detect_encoding')) {
            //If present use gettext
            $error_header = __('Error');
        } else {
            $error_header = 'Error';
        }
        $lang = $GLOBALS['lang'];
        $dir = $GLOBALS['text_dir'];
        // on fatal errors it cannot hurt to always delete the current session
        if ($delete_session && isset($GLOBALS['session_name']) && isset($_COOKIE[$GLOBALS['session_name']])) {
            $GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
        }
        // Displays the error message
        include './libraries/error.inc.php';
    }
    if (!defined('TESTSUITE')) {
        exit;
    }
}
开发者ID:shashank19gaurav,项目名称:phpmyadmin,代码行数:57,代码来源:core.lib.php

示例14: moveColumns

 /**
  * Moves columns in the table's structure based on $_REQUEST
  *
  * @return void
  */
 protected function moveColumns()
 {
     $this->dbi->selectDb($this->db);
     /*
      * load the definitions for all columns
      */
     $columns = $this->dbi->getColumnsFull($this->db, $this->table);
     $column_names = array_keys($columns);
     $changes = array();
     // move columns from first to last
     for ($i = 0, $l = count($_REQUEST['move_columns']); $i < $l; $i++) {
         $column = $_REQUEST['move_columns'][$i];
         // is this column already correctly placed?
         if ($column_names[$i] == $column) {
             continue;
         }
         // it is not, let's move it to index $i
         $data = $columns[$column];
         $extracted_columnspec = Util::extractColumnSpec($data['Type']);
         if (isset($data['Extra']) && $data['Extra'] == 'on update CURRENT_TIMESTAMP') {
             $extracted_columnspec['attribute'] = $data['Extra'];
             unset($data['Extra']);
         }
         $current_timestamp = ($data['Type'] == 'timestamp' || $data['Type'] == 'datetime') && $data['Default'] == 'CURRENT_TIMESTAMP';
         if ($data['Null'] === 'YES' && $data['Default'] === null) {
             $default_type = 'NULL';
         } elseif ($current_timestamp) {
             $default_type = 'CURRENT_TIMESTAMP';
         } elseif ($data['Default'] === null) {
             $default_type = 'NONE';
         } else {
             $default_type = 'USER_DEFINED';
         }
         $virtual = array('VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED');
         $data['Virtuality'] = '';
         $data['Expression'] = '';
         if (isset($data['Extra']) && in_array($data['Extra'], $virtual)) {
             $data['Virtuality'] = str_replace(' GENERATED', '', $data['Extra']);
             $expressions = $this->table->getColumnGenerationExpression($column);
             $data['Expression'] = $expressions[$column];
         }
         $changes[] = 'CHANGE ' . Table::generateAlter($column, $column, mb_strtoupper($extracted_columnspec['type']), $extracted_columnspec['spec_in_brackets'], $extracted_columnspec['attribute'], isset($data['Collation']) ? $data['Collation'] : '', $data['Null'] === 'YES' ? 'NULL' : 'NOT NULL', $default_type, $current_timestamp ? '' : $data['Default'], isset($data['Extra']) && $data['Extra'] !== '' ? $data['Extra'] : false, isset($data['COLUMN_COMMENT']) && $data['COLUMN_COMMENT'] !== '' ? $data['COLUMN_COMMENT'] : false, $data['Virtuality'], $data['Expression'], $i === 0 ? '-first' : $column_names[$i - 1]);
         // update current column_names array, first delete old position
         for ($j = 0, $ll = count($column_names); $j < $ll; $j++) {
             if ($column_names[$j] == $column) {
                 unset($column_names[$j]);
             }
         }
         // insert moved column
         array_splice($column_names, $i, 0, $column);
     }
     if (empty($changes)) {
         // should never happen
         $this->response->setRequestStatus(false);
         return;
     }
     // move columns
     $this->dbi->tryQuery(sprintf('ALTER TABLE %s %s', Util::backquote($this->table), implode(', ', $changes)));
     $tmp_error = $this->dbi->getError();
     if ($tmp_error) {
         $this->response->setRequestStatus(false);
         $this->response->addJSON('message', Message::error($tmp_error));
     } else {
         $message = Message::success(__('The columns have been moved successfully.'));
         $this->response->addJSON('message', $message);
         $this->response->addJSON('columns', $column_names);
     }
 }
开发者ID:Gemorroj,项目名称:phpmyadmin,代码行数:73,代码来源:TableStructureController.php

示例15: PMA_saveUserprefs

/**
 * Saves user preferences
 *
 * @param array $config_array configuration array
 *
 * @return true|PMA\libraries\Message
 */
function PMA_saveUserprefs(array $config_array)
{
    $cfgRelation = PMA_getRelationsParam();
    $server = isset($GLOBALS['server']) ? $GLOBALS['server'] : $GLOBALS['cfg']['ServerDefault'];
    $cache_key = 'server_' . $server;
    if (!$cfgRelation['userconfigwork']) {
        // no pmadb table, use session storage
        $_SESSION['userconfig'] = array('db' => $config_array, 'ts' => time());
        if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
            unset($_SESSION['cache'][$cache_key]['userprefs']);
        }
        return true;
    }
    // save configuration to pmadb
    $query_table = PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['userconfig']);
    $query = 'SELECT `username` FROM ' . $query_table . ' WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($cfgRelation['user']) . '\'';
    $has_config = $GLOBALS['dbi']->fetchValue($query, 0, 0, $GLOBALS['controllink']);
    $config_data = json_encode($config_array);
    if ($has_config) {
        $query = 'UPDATE ' . $query_table . ' SET `timevalue` = NOW(), `config_data` = \'' . $GLOBALS['dbi']->escapeString($config_data) . '\'' . ' WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($cfgRelation['user']) . '\'';
    } else {
        $query = 'INSERT INTO ' . $query_table . ' (`username`, `timevalue`,`config_data`) ' . 'VALUES (\'' . $GLOBALS['dbi']->escapeString($cfgRelation['user']) . '\', NOW(), ' . '\'' . $GLOBALS['dbi']->escapeString($config_data) . '\')';
    }
    if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
        unset($_SESSION['cache'][$cache_key]['userprefs']);
    }
    if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
        $message = Message::error(__('Could not save configuration'));
        $message->addMessage('<br /><br />');
        $message->addMessage(Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink'])));
        return $message;
    }
    return true;
}
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:41,代码来源:user_preferences.lib.php


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