From e153586543155dbca053406bb003725082d57d5e Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 19 Mar 2007 13:09:33 +0000 Subject: [PATCH] some doc and globals --- libraries/import.lib.php | 91 ++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 32a2056b7..2a14cc6d6 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -1,12 +1,19 @@ $read_limit) { - $size = $read_limit; + if ($size > $GLOBALS['read_limit']) { + $size = $GLOBALS['read_limit']; } if (PMA_checkTimeout()) { return FALSE; } - if ($finished) { + if ($GLOBALS['finished']) { return TRUE; } - if ($import_file == 'none') { + if ($GLOBALS['import_file'] == 'none') { // Well this is not yet supported and tested, but should return content of textarea - if (strlen($import_text) < $size) { - $finished = TRUE; - return $import_text; + if (strlen($GLOBALS['import_text']) < $size) { + $GLOBALS['finished'] = TRUE; + return $GLOBALS['import_text']; } else { - $r = substr($import_text, 0, $size); - $offset += $size; - $import_text = substr($import_text, $size); + $r = substr($GLOBALS['import_text'], 0, $size); + $GLOBALS['offset'] += $size; + $GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size); return $r; } } @@ -237,23 +251,23 @@ function PMA_importGetNextChunk($size = 32768) switch ($compression) { case 'application/bzip2': $result = bzread($import_handle, $size); - $finished = feof($import_handle); + $GLOBALS['finished'] = feof($import_handle); break; case 'application/gzip': $result = gzread($import_handle, $size); - $finished = feof($import_handle); + $GLOBALS['finished'] = feof($import_handle); break; case 'application/zip': - $result = substr($import_text, 0, $size); - $import_text = substr($import_text, $size); - $finished = empty($import_text); + $result = substr($GLOBALS['import_text'], 0, $size); + $GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size); + $GLOBALS['finished'] = empty($GLOBALS['import_text']); break; case 'none': $result = fread($import_handle, $size); - $finished = feof($import_handle); + $GLOBALS['finished'] = feof($import_handle); break; } - $offset += $size; + $GLOBALS['offset'] += $size; if ($charset_conversion) { return PMA_convert_string($charset_of_file, $charset, $result); @@ -265,7 +279,7 @@ function PMA_importGetNextChunk($size = 32768) * * @todo BOM could be used for charset autodetection */ - if ($offset == $size) { + if ($GLOBALS['offset'] == $size) { // UTF-8 if (strncmp($result, "\xEF\xBB\xBF", 3) == 0) { $result = substr($result, 3); @@ -277,7 +291,4 @@ function PMA_importGetNextChunk($size = 32768) return $result; } } - - - ?>