function parse_import_act($file_name, $delimiter, $max_lines, $has_header) { global $locale; if (empty($locale)) { require_once 'include/Localization/Localization.php'; $locale = new Localization(); } $line_count = 0; $field_count = 0; $rows = array(); if (!file_exists($file_name)) { return -1; } $fh = fopen($file_name, "r"); if (!$fh) { return -1; } while (($line = fgets($fh, 4096)) && ($max_lines == -1 || $line_count < $max_lines)) { $line = trim($line); $line = substr_replace($line, "", 0, 1); $line = substr_replace($line, "", -1); $fields = explode("\",\"", $line); $this_field_count = count($fields); if ($this_field_count > $field_count) { $field_count = $this_field_count; } array_push($rows, $fields); $line_count++; } // got no rows if (count($rows) == 0) { return -3; } else { //// cn: bug 6712 - need to translate to UTF-8 foreach ($rows as $rowKey => $row) { foreach ($row as $k => $v) { $row[$k] = $locale->translateCharset($v, $locale->getExportCharset()); } $rows[$rowKey] = $row; } } $ret_array = array("rows" => &$rows, "field_count" => $field_count); return $ret_array; }