protected function openCsvFile($offset = false) { $file = $this->excelToCsvFile(Tools::getValue('csv')); $handle = false; if (is_file($file) && is_readable($file)) { if (!mb_check_encoding(file_get_contents($file), 'UTF-8')) { $this->convert = true; } $handle = fopen($file, 'r'); } if (!$handle) { $this->errors[] = $this->trans('Cannot read the .CSV file', array(), 'Admin.Parameters.Notification'); return null; // error case } AdminImportController::rewindBomAware($handle); $toSkip = (int) Tools::getValue('skip'); if ($offset && $offset > 0) { $toSkip += $offset; } for ($i = 0; $i < $toSkip; ++$i) { $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); if ($line === false) { return false; // reached end of file } } return $handle; }
protected function openCsvFile() { $file = AdminImportController::getPath(strval(preg_replace('/\\.{2,}/', '.', Tools::getValue('csv')))); $handle = false; if (is_file($file) && is_readable($file)) { $handle = fopen($file, 'r'); } if (!$handle) { $this->errors[] = Tools::displayError('Cannot read the .CSV file'); } AdminImportController::rewindBomAware($handle); for ($i = 0; $i < (int) Tools::getValue('skip'); ++$i) { $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); } return $handle; }