d2tools/processFiles.php

66 lines
2.0 KiB
PHP
Raw Normal View History

<?php
2021-03-27 08:53:26 +00:00
// Second step after D2Config. If we made it here, d2im.db should
// have been created. Config writes active mod to session.
2021-03-27 08:53:26 +00:00
session_start();
include "./_pdo.php";
2021-03-27 13:06:10 +00:00
function processCubeMain(){
$bin = getcwd().DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."sqlite3.exe ";
$dbfile = getcwd().DIRECTORY_SEPARATOR.DB_FILE;
$cubemain = TXT_PATH."cubemain.txt";
// D:\Documents\D2IM\www\bin\sqlite3.exe D:\Documents\D2IM\www\ZyEl4.5.db ".separator \"\t"\" ".import \"D:\\Diablo II\\MODS\\D2SE_Zy-El mod v4.5 HiRes\\data\\global\\excel\\cubemain.txt\" cubemain"
2021-03-27 13:06:10 +00:00
exec("$bin $dbfile \".separator \\\"\\t\\\"\" \".import \\\"$cubemain\\\" cubemain\"");
}
2021-03-27 08:53:26 +00:00
// check to see if config db exists or if for some reason it doesn't exist
if (file_exists("d2im.db")) {
if (file_exists($_SESSION['modname'] . ".db")) {
unlink($_SESSION['modname'] . ".db"); // delete old mod db file
}
// Set CONSTANTS (if d2im.db exists, D2Config set the session mod correctly)
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
define('DB_FILE', $_SESSION['modname'] . ".db");
define('TXT_PATH', $_SESSION['path']);
// require D2IM src
require_once "./src/D2Functions.php";
require_once "./src/D2Database.php";
require_once './src/D2Files.php';
require_once './src/D2TxtParser.php';
// Create D2IM objects
$files = new D2Files();
$parser = new D2TxtParser();
$db = new D2Database();
2021-03-27 08:53:26 +00:00
// Parse all files
foreach ($files->files as $k => $v) {
$data[$v] = $parser->parseFile($v);
}
2021-03-27 08:53:26 +00:00
// Write all parse data to mod db
foreach ($data as $k => $v) {
$db->createTables($k, $v);
$db->fillsTables($k, $v);
}
2021-03-27 08:53:26 +00:00
2021-03-27 13:06:10 +00:00
processCubeMain('cubemain.txt');
2021-03-27 08:53:26 +00:00
// put in html redirect as backup, because
// for some odd reason windows gives
// an error on header() but linux does not.
} else {
// if config db does not exist, go to configure page
header("Location: /src/D2Config.php");
}
?>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; URL=/" />
</head>
<body>
</body>
</html>