public static function createDatabase() { try { if (file_exists(self::$path . self::$databaseTextPlain) == false) { throw new Exception("The file " . self::$path . self::$databaseTextPlain . " not exists."); } self::$handleDatabase = file(self::$path . self::$databaseTextPlain, FILE_SKIP_EMPTY_LINES); $items = NULL; $tempWait = self::WAIT_CATEGORIE; $counts = array("section" => -1, "index" => -1); $items["fileHash"] = md5_file(self::$path . self::$databaseTextPlain); foreach (self::$handleDatabase as $line) { $arrayResult = self::getBytesFromLine($line); switch ($tempWait) { case self::WAIT_CATEGORIE: if (is_numeric($arrayResult[0]) == false) { continue; } $items[$arrayResult[0]] = array(); $counts["section"] += 1; $tempWait = self::WAIT_ITEM; break; case self::WAIT_ITEM: if ($arrayResult[0] == "end") { $tempWait = self::WAIT_CATEGORIE; continue; } if (is_numeric($arrayResult[0]) == false) { continue; } $arrayResult = str_replace("'", "", $arrayResult); switch ($counts["section"]) { case 0: case 1: case 2: case 3: case 4: case 5: // 29 season 2 // 19 97d switch (sizeof($arrayResult)) { case 30: case 29: case 28: case 25: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 19: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 6: //25 season 2 // 16 97d switch (sizeof($arrayResult)) { case 27: case 26: case 25: case 22: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 16: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 7: case 8: case 9: case 10: case 11: //25 season 2 // 17 97d switch (sizeof($arrayResult)) { case 27: case 26: case 25: case 21: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 17: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 12: //23 season 2 //20 97d switch (sizeof($arrayResult)) { case 25: case 24: case 23: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 20: case 19: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "}."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 13: //24 season 2 //17 97d switch (sizeof($arrayResult)) { case 26: case 25: case 24: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 17: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 14: //11 season 2 //9 97d switch (sizeof($arrayResult)) { case 11: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 9: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; case 15: switch (sizeof($arrayResult)) { case 20: case 19: case 18: $key = array("Index" => 0, "X" => 3, "Y" => 4, "Name" => 8); break; case 15: $key = array("Index" => 0, "X" => 1, "Y" => 2, "Name" => 6); break; default: throw new Exception("O item(kor) não é compativel com o sistema ou esta danificado (Categoria: {$counts["section"]}, Index: {$arrayResult[0]} {" . sizeof($arrayResult) . "})."); } //18 season 2 //15 97d $items[$counts["section"]][$arrayResult[0]] = array("Index" => $arrayResult[$key["Index"]], "X" => $arrayResult[$key["X"]], "Y" => $arrayResult[$key["Y"]], "Name" => $arrayResult[$key["Name"]]); break; } break; } //print_r($arrayResult); } //print_r($items); $handle = fopen(self::$path . self::$databaseSerialized, "w"); fwrite($handle, serialize($items)); fclose($handle); if (file_exists(self::$path . self::$databaseSerialized) == false) { throw new Exception("Não foi possivel criar o banco de dados!<br />Verifique as permissões de escrita na pasta: modules/classes/ldItemClass/data/."); } } catch (Exception $msg) { exit($msg->getMessage()); } }