Feature #272 - The php function fgetcsv() has been replaced by api_fgetcsv(), see the internationalization library. The replacement function is binary safe, it does not depend on OS locale settings.

skala
Ivan Tcholakov 15 years ago
parent b1437e7b30
commit b271159724
  1. 33
      main/inc/lib/import.lib.php
  2. 6
      main/link/linkfunctions.php

@ -46,26 +46,31 @@ class Import
* @return array An array with all data from the CSV-file
*/
function csv_to_array($filename) {
$result = array ();
$handle = fopen($filename, "r");
if($handle === false) {
$result = array();
$handle = fopen($filename, 'r');
if ($handle === false) {
return $result;
}
$keys = fgetcsv($handle, 4096, ";");
while (($row_tmp = fgetcsv($handle, 4096, ";")) !== FALSE) {
$row = array ();
//avoid empty lines in csv
if (is_array($row_tmp) && count($row_tmp)>0 && $row_tmp[0]!= '') {
if (!is_null($row_tmp[0])) {
foreach ($row_tmp as $index => $value) {
$row[$keys[$index]] = $value;
}
// Modified by Ivan Tcholakov, 01-FEB-2010.
//$keys = fgetcsv($handle, 4096, ";");
$keys = api_fgetcsv($handle, null, ';');
//
// Modified by Ivan Tcholakov, 01-FEB-2010.
//while (($row_tmp = fgetcsv($handle, 4096, ";")) !== FALSE) {
while (($row_tmp = api_fgetcsv($handle, null, ';')) !== false) {
//
$row = array();
//avoid empty lines in csv
if (is_array($row_tmp) && count($row_tmp) > 0 && $row_tmp[0] != '') {
if (!is_null($row_tmp[0])) {
foreach ($row_tmp as $index => $value) {
$row[$keys[$index]] = $value;
}
$result[] = $row;
}
}
}
}
fclose($handle);
return $result;
}
}
?>

@ -870,7 +870,10 @@ function import_csvfile()
{
$stats = array (0, 0, 0); // fails, updates, inserts
while (($data = fgetcsv($myFile, 32768, $listsep)))
// Modified by Ivan Tcholakov, 01-FEB-2010.
//while (($data = fgetcsv($myFile, 32768, $listsep)))
while (($data = api_fgetcsv($myFile, null, $listsep)))
//
{
foreach ($data as $i => $text)
$linkdata[$columns[$i]] = $text;
@ -899,4 +902,3 @@ function import_csvfile()
else
$catlinkstatus = get_lang('CsvFileNotFound');
}
?>

Loading…
Cancel
Save