bug #2973280 [export] Proper handling of temporary directory in XLS export.
This commit is contained in:

committed by
Michal Čihař

parent
1e984375b6
commit
eb5e03880e
@@ -20,6 +20,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
|
|||||||
- patch #2977725 [export] XML wrongly encoded, thanks to Victor Volkov - hanut
|
- patch #2977725 [export] XML wrongly encoded, thanks to Victor Volkov - hanut
|
||||||
- patch #2979234 [import] Create tables with current charset and collation.
|
- patch #2979234 [import] Create tables with current charset and collation.
|
||||||
- patch #2979234, bug #2960105 [import] Properly import unicode text from ODS.
|
- patch #2979234, bug #2960105 [import] Properly import unicode text from ODS.
|
||||||
|
- bug #2973280 [export] Proper handling of temporary directory in XLS export.
|
||||||
|
|
||||||
3.3.1.0 (2010-03-16)
|
3.3.1.0 (2010-03-16)
|
||||||
- bug #2941037 [core] Database structure not sorted by table correctly
|
- bug #2941037 [core] Database structure not sorted by table correctly
|
||||||
|
@@ -59,6 +59,7 @@ function PMA_exportFooter() {
|
|||||||
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
|
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
|
||||||
|
|
||||||
$workbookWriter = new PHPExcel_Writer_Excel5($workbook);
|
$workbookWriter = new PHPExcel_Writer_Excel5($workbook);
|
||||||
|
$workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
|
||||||
$workbookWriter->save($tmp_filename);
|
$workbookWriter->save($tmp_filename);
|
||||||
|
|
||||||
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
|
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
|
||||||
|
@@ -55,18 +55,19 @@ function PMA_exportComment($text) {
|
|||||||
function PMA_exportFooter() {
|
function PMA_exportFooter() {
|
||||||
global $workbook;
|
global $workbook;
|
||||||
global $tmp_filename;
|
global $tmp_filename;
|
||||||
|
|
||||||
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
|
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
|
||||||
|
|
||||||
$workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
|
$workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
|
||||||
|
$workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
|
||||||
$workbookWriter->save($tmp_filename);
|
$workbookWriter->save($tmp_filename);
|
||||||
|
|
||||||
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
|
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink($tmp_filename);
|
unlink($tmp_filename);
|
||||||
|
|
||||||
unset($GLOBALS['workbook']);
|
unset($GLOBALS['workbook']);
|
||||||
unset($GLOBALS['sheet_index']);
|
unset($GLOBALS['sheet_index']);
|
||||||
|
|
||||||
@@ -82,17 +83,17 @@ function PMA_exportFooter() {
|
|||||||
*/
|
*/
|
||||||
function PMA_exportHeader() {
|
function PMA_exportHeader() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
/* Initialize the workbook */
|
/* Initialize the workbook */
|
||||||
$GLOBALS['workbook'] = new PHPExcel();
|
$GLOBALS['workbook'] = new PHPExcel();
|
||||||
$GLOBALS['sheet_index'] = 0;
|
$GLOBALS['sheet_index'] = 0;
|
||||||
global $workbook;
|
global $workbook;
|
||||||
|
|
||||||
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
|
$workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
|
||||||
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
|
$workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
|
||||||
$workbook->getProperties()->setTitle($db);
|
$workbook->getProperties()->setTitle($db);
|
||||||
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
|
$workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +107,8 @@ function PMA_exportHeader() {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportDBHeader($db) {
|
function PMA_exportDBHeader($db) {
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,33 +154,33 @@ function PMA_exportDBCreate($db) {
|
|||||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||||
global $workbook;
|
global $workbook;
|
||||||
global $sheet_index;
|
global $sheet_index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data from the database using the original query
|
* Get the data from the database using the original query
|
||||||
*/
|
*/
|
||||||
$result = PMA_DBI_fetch_result($sql_query);
|
$result = PMA_DBI_fetch_result($sql_query);
|
||||||
$row_cnt = count($result);
|
$row_cnt = count($result);
|
||||||
|
|
||||||
if ($row_cnt > 0) {
|
if ($row_cnt > 0) {
|
||||||
$col_names = array_keys($result[0]);
|
$col_names = array_keys($result[0]);
|
||||||
$fields_cnt = count($result[0]);
|
$fields_cnt = count($result[0]);
|
||||||
$row_offset = 1;
|
$row_offset = 1;
|
||||||
|
|
||||||
/* Only one sheet is created on workbook initialization */
|
/* Only one sheet is created on workbook initialization */
|
||||||
if ($sheet_index > 0) {
|
if ($sheet_index > 0) {
|
||||||
$workbook->createSheet();
|
$workbook->createSheet();
|
||||||
}
|
}
|
||||||
|
|
||||||
$workbook->setActiveSheetIndex($sheet_index);
|
$workbook->setActiveSheetIndex($sheet_index);
|
||||||
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
|
$workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
|
||||||
|
|
||||||
if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
|
if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
|
||||||
for ($i = 0; $i < $fields_cnt; ++$i) {
|
for ($i = 0; $i < $fields_cnt; ++$i) {
|
||||||
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
|
$workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
|
||||||
}
|
}
|
||||||
$row_offset++;
|
$row_offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
|
for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
|
||||||
for ($c = 0; $c < $fields_cnt; ++$c) {
|
for ($c = 0; $c < $fields_cnt; ++$c) {
|
||||||
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
|
if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
|
||||||
@@ -194,10 +195,10 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sheet_index++;
|
$sheet_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user