public function exportHeader()
{
global $crlf, $cfg;
if (isset($GLOBALS['sql_compatibility'])) {
$tmp_compat = $GLOBALS['sql_compatibility'];
if ($tmp_compat == 'NONE') {
$tmp_compat = '';
}
$GLOBALS['dbi']->tryQuery('SET SQL_MODE="' . $tmp_compat . '"');
unset($tmp_compat);
}
$head = $this->_exportComment('phpMyAdmin SQL Dump') . $this->_exportComment('version ' . PMA_VERSION) . $this->_exportComment('https://www.phpmyadmin.net/') . $this->_exportComment();
$host_string = __('Host:') . ' ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$host_string .= ':' . $cfg['Server']['port'];
}
$head .= $this->_exportComment($host_string);
$head .= $this->_exportComment(__('Generation Time:') . ' ' . Util::localisedDate()) . $this->_exportComment(__('Server version:') . ' ' . PMA_MYSQL_STR_VERSION) . $this->_exportComment(__('PHP Version:') . ' ' . phpversion()) . $this->_possibleCRLF();
if (isset($GLOBALS['sql_header_comment']) && !empty($GLOBALS['sql_header_comment'])) {
// '\n' is not a newline (like "\n" would be), it's the characters
// backslash and n, as explained on the export interface
$lines = explode('\\n', $GLOBALS['sql_header_comment']);
$head .= $this->_exportComment();
foreach ($lines as $one_line) {
$head .= $this->_exportComment($one_line);
}
$head .= $this->_exportComment();
}
if (isset($GLOBALS['sql_disable_fk'])) {
$head .= 'SET FOREIGN_KEY_CHECKS=0;' . $crlf;
}
// We want exported AUTO_INCREMENT columns to have still same value,
// do this only for recent MySQL exports
if (!isset($GLOBALS['sql_compatibility']) || $GLOBALS['sql_compatibility'] == 'NONE') {
$head .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . $crlf;
}
if (isset($GLOBALS['sql_use_transaction'])) {
$head .= 'SET AUTOCOMMIT = 0;' . $crlf . 'START TRANSACTION;' . $crlf;
}
/* Change timezone if we should export timestamps in UTC */
if (isset($GLOBALS['sql_utc_time']) && $GLOBALS['sql_utc_time']) {
$head .= 'SET time_zone = "+00:00";' . $crlf;
$GLOBALS['old_tz'] = $GLOBALS['dbi']->fetchValue('SELECT @@session.time_zone');
$GLOBALS['dbi']->query('SET time_zone = "+00:00"');
}
$head .= $this->_possibleCRLF();
if (!empty($GLOBALS['asfile'])) {
// we are saving as file, therefore we provide charset information
// so that a utility like the mysql client can interpret
// the file correctly
if (isset($GLOBALS['charset']) && isset(Charsets::$mysql_charset_map[$GLOBALS['charset']])) {
// we got a charset from the export dialog
$set_names = Charsets::$mysql_charset_map[$GLOBALS['charset']];
} else {
// by default we use the connection charset
$set_names = Charsets::$mysql_charset_map['utf-8'];
}
if ($set_names == 'utf8' && PMA_MYSQL_INT_VERSION > 50503) {
$set_names = 'utf8mb4';
}
$head .= $crlf . '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=' . '@@CHARACTER_SET_CLIENT */;' . $crlf . '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=' . '@@CHARACTER_SET_RESULTS */;' . $crlf . '/*!40101 SET @OLD_COLLATION_CONNECTION=' . '@@COLLATION_CONNECTION */;' . $crlf . '/*!40101 SET NAMES ' . $set_names . ' */;' . $crlf . $crlf;
$this->_sent_charset = true;
}
return PMA_exportOutputHandler($head);
}