mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-09-18 01:22:08 +00:00
multiple mod selection and config/db working
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
/*
|
||||
*
|
||||
GPLv2 (C) <2021> <HashCasper>
|
||||
@@ -20,61 +22,88 @@
|
||||
*/
|
||||
|
||||
require_once './D2Functions.php';
|
||||
require_once './D2Database.php';
|
||||
require_once '../_pdo.php';
|
||||
|
||||
if (!empty($_POST)) {
|
||||
|
||||
|
||||
$modname = str_replace(' ', '', $_POST['modname']);
|
||||
|
||||
$_SESSION['modname'] = $modname;
|
||||
|
||||
// write the d2im.conf file and replace \ with \\
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$path = rtrim($_POST['path'], "\\");
|
||||
$path = str_replace("\\", "\\\\", $path);
|
||||
$path = str_replace("\\", "\\\\", $path);
|
||||
$path .= '\\\\data\\\\global\\\\excel\\\\';
|
||||
|
||||
$conf['path'] = $path;
|
||||
$conf['modname'] = $modname;
|
||||
|
||||
file_put_contents("../d2im.conf", serialize($path));
|
||||
|
||||
$conf[$modname]['path'] = $path;
|
||||
$conf[$modname]['modname'] = $modname;
|
||||
|
||||
file_put_contents("../d2im.db", serialize($conf));
|
||||
} else {
|
||||
$conf['path'] = $_POST['path'].DIRECTORY_SEPARATOR;
|
||||
$conf['modname'] = $modname;
|
||||
|
||||
file_put_contents("../d2im.conf", serialize($conf));
|
||||
PDO_Connect("sqlite:../d2im.db");
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS d2im (
|
||||
modname VARCHAR(255),
|
||||
path VARCHAR(255)
|
||||
)";
|
||||
PDO_Execute($sql);
|
||||
|
||||
$sql = '';
|
||||
$path = $_POST['path'];
|
||||
$path = rtrim($_POST['path'], "/");
|
||||
$path = $path . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!is_dir($path)) {
|
||||
echo '<center><h1 style="font-family:Lato; color:#880000;"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
|
||||
ERROR: INVALID PATH</h1></center>';
|
||||
} else {
|
||||
$_SESSION['path'] = $path;
|
||||
// Don't yell at me, security is the least of my considerations atm
|
||||
// check modname in db
|
||||
$sql = "SELECT * FROM d2im WHERE modname='$modname'";
|
||||
$res = PDO_FetchAll($sql);
|
||||
if (empty($res)) {
|
||||
$sql = "INSERT INTO d2im(modname,path) VALUES(\"$modname\",\"$path\")";
|
||||
PDO_Execute($sql);
|
||||
}
|
||||
header("Location: /processFiles.php");
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: /processFiles.php");
|
||||
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<?php
|
||||
/* Require the <head> section */
|
||||
require_once "head.php";
|
||||
?>
|
||||
<?php
|
||||
/* Require the <head> section */
|
||||
require_once "head.php";
|
||||
?>
|
||||
<body style="background: white;">
|
||||
<div class="center container container-top">
|
||||
|
||||
|
||||
<h1><img src="/img/Diablo2.png" style="float:left">D2 Item Maker, v3. By HashCasper</h1>
|
||||
<a class="btn btn-outline-danger" style="color:red; font-size: 18px;float:right;" href="/">X</a>
|
||||
<hr style="margin: 60px;">
|
||||
<div class="offset-2 col-8">
|
||||
<h2>Select Mod folder</h2>
|
||||
<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>
|
||||
<h2>Select Mod folder</h2>
|
||||
<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;" class="ctrl-config">
|
||||
<form enctype="multipart/form-data" style="font-family: Lato; font-size: 14pt;" action="" method="post">
|
||||
<p>
|
||||
<label for="path">Enter Mod Name</label><br>
|
||||
<input id="path" style="width: 220px;" required="required" name="modname" type="text">
|
||||
</p>
|
||||
<p>
|
||||
<label for="path">Enter PATH </label><br>
|
||||
<input id="path" style="width: 420px;" required="required" name="path" type="text">
|
||||
<input type="submit" value="Save" name="submit" class="btn-config">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<div style="margin-top: 20px;" class="ctrl-config">
|
||||
<form enctype="multipart/form-data" style="font-family: Lato; font-size: 14pt;" action="" method="post">
|
||||
<p>
|
||||
<label for="path">Enter Mod Name</label><br>
|
||||
<input id="path" style="width: 220px;" required="required" name="modname" type="text">
|
||||
</p>
|
||||
<p>
|
||||
<label for="path">Enter PATH </label><br>
|
||||
<input id="path" style="width: 420px;" required="required" name="path" type="text">
|
||||
<input type="submit" value="Save" name="submit" class="btn-config">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="loading" class="offset-2 col-8 alert alert-primary">
|
||||
<p style="font-family: Lato;">After saving path, app will convert txt files to SQL database.</p>
|
||||
|
Reference in New Issue
Block a user