This file is part of D2IM. D2IM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. D2IM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with D2IM. If not, see . This is a generic D2 Txt Parser */ class D2TxtParser { public $path = TXT_PATH; public $db; public function __construct() { $this->db = new D2Database(); } public function parseFile($file) { if ($file == "Properties.txt") { return $this->filterProps($file); } return $this->parseData($file); } function filterProps($file) { $data = $this->parseData($file); $propsToFilter = file(FILTER_PROPERTIES_FILE, FILE_IGNORE_NEW_LINES); foreach ($data as $d) { $allProps[] = $d['code']; } $filteredProps = array_diff($allProps, $propsToFilter); return $filteredProps; } public function parseData($file) { $file = $this->path . $file; $rows = array_map(function ($v) { return str_getcsv($v, "\t"); } , file($file)); $header = array_shift($rows); foreach ($rows as $row) { $data[] = @array_combine($header, $row); } $this->db->createTables($file, $data); $this->db->fillsTables($file, $data); return $data; } } ?>