mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
Db generation working on linux/windows
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
GPLv2 (C) <2021> <HashCasper>
|
||||
|
||||
This file is part of D2IM.
|
||||
@@ -20,19 +20,18 @@
|
||||
*/
|
||||
|
||||
if (!empty($_POST)) {
|
||||
|
||||
// write the d2um.conf file and replace \ with \\
|
||||
// write the d2im.conf file and replace \ with \\
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$path = rtrim($_POST['path'], "\\");
|
||||
$path = rtrim($_POST['path'], "\\");
|
||||
$path = str_replace("\\", "\\\\", $path);
|
||||
$path .= '\\\\data\\\\global\\\\excel\\\\';
|
||||
file_put_contents("../d2im.conf", $path);
|
||||
} else {
|
||||
|
||||
file_put_contents("../d2im.conf", $_POST['path'].DIRECTORY_SEPARATOR);
|
||||
|
||||
file_put_contents("../d2im.conf", $_POST['path'] . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
header('Location: /');
|
||||
header('Location: /wait.php');
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
@@ -50,13 +49,19 @@ if (!empty($_POST)) {
|
||||
<p style="font-family: lato">Example: D:\Diablo II\MODS\you-mod-name\</p>
|
||||
<p style="font-family: lato">Input path to D2 Mod Directory.</p>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<div style="margin-top: 20px;" class="ctrl-config">
|
||||
<form enctype="multipart/form-data" style="font-family: Lato; font-size: 14pt;" action="" method="post">
|
||||
<label for="path">Choose PATH</label>
|
||||
<input id="path" style="width: 420px;" required="required" name="path" type="text">
|
||||
<input type="submit" value="Save" name="submit">
|
||||
|
||||
<input type="submit" value="Save" name="submit" class="btn-config">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div id="loading" style="">
|
||||
<p style="font-family: Lato;">After saving path, app will convert txt files to SQL database.</p>
|
||||
<p style="font-family: Lato;">This may take a few minutes depending on the size of your txt files. <br>Please be patient. Once done, app will load. <br>Each time you set a new mod path, txt files will be processed.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
include "../_pdo.php";
|
||||
/*
|
||||
GPLv2 (C) <2021> <HashCasper>
|
||||
|
||||
@@ -41,7 +41,7 @@ class D2Database {
|
||||
$sql .= ")";
|
||||
$res = PDO_Execute($sql);
|
||||
}
|
||||
|
||||
|
||||
public function fillsTables($file, $data) {
|
||||
$tableName = basename($file);
|
||||
$tableName = strtolower(substr($tableName, 0, -4));
|
||||
@@ -65,8 +65,7 @@ class D2Database {
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ");";
|
||||
|
||||
var_dump($sql);
|
||||
|
||||
PDO_Execute($sql);
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ class D2TxtParser {
|
||||
public $db;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = new D2Database();
|
||||
}
|
||||
|
||||
public function parseFile($file) {
|
||||
@@ -58,9 +57,7 @@ class D2TxtParser {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user