multiple mod selection and config/db working

This commit is contained in:
color.diff=auto
2021-03-26 12:31:13 -06:00
parent d46cfc04e1
commit d5817446ff
12 changed files with 163 additions and 80 deletions

View File

@@ -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>

View File

@@ -22,7 +22,7 @@
class D2Database {
public function __construct() {
PDO_Connect("sqlite:" . DB_FILE);
PDO_Connect("sqlite:" . DB_FILE);
}
public function createTables($file, $data) {

View File

@@ -1,7 +1,8 @@
<div class="container">
<div class=" row" style="background: none;">
<div class="offset-9 col-3" style="background: none;">
<a style="font-weight: bold;" class="btn btn-info" href="/src/D2Config.php">Reconfigure Mod Path</a>
<div class="col" style="background: none;">
<a style="font-weight: bold;" class="btn btn-info" href="/src/D2Config.php">Setup New Mod</a>
<a style="font-weight: bold;" class="btn btn-warning" href="/switchMods.php">Switch Mods</a>
</div>
</div>
</div>

View File

@@ -1,5 +1,4 @@
<?php
/*
D2UniqueMaker
GPLv2 (C) <2021> <HashCasper>
@@ -27,23 +26,30 @@
require_once "head.php";
?>
<body>
<div class="container container-top">
<div>
<img src="img/Diablo2.png" style="float:right"><h2 syle="font-weight: 900">D2 Item Maker, v3. By HashCasper</h2><br><br>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">UniqueItems.txt</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Set-tab" data-toggle="tab" href="#Set" role="tab" aria-controls="Set" aria-selected="false">SetItems.txt</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Gem-tab" data-toggle="tab" href="#Gem" role="tab" aria-controls="Set" aria-selected="false">Gems.txt</a>
</li>
</ul>
<body>
<div class="container container-top">
<div class="row">
<div class="col">
<img src="img/Diablo2.png" style="float:right"><h2 syle="font-weight: 900">D2 Item Maker, v3. By HashCasper</h2><br><br>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">UniqueItems.txt</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Set-tab" data-toggle="tab" href="#Set" role="tab" aria-controls="Set" aria-selected="false">SetItems.txt</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Gem-tab" data-toggle="tab" href="#Gem" role="tab" aria-controls="Set" aria-selected="false">Gems.txt</a>
</li>
</ul>
</div>
</div>
<div class="tab-content" id="TabContent">
<div style="font-family: Lato !important; text-align:right; color: tomato">
<p style="font-family: Lato !important;">Active Mod: <?php echo $_SESSION['modname']?>
<br><?php echo $_SESSION['path']?></p>
</div>
<div class="tab-pane fade show active" id="Unique" role="tabpanel" aria-labelledby="Unique-tab">
<?php require_once 'D2UM.php'; ?>
</div>
@@ -53,4 +59,4 @@
<div class="tab-pane fade" id="Gem" role="tabpanel" aria-labelledby="Gem-tab">
<?php require_once 'D2Gems.php'; ?>
</div>
</div>
</div>

View File

@@ -1,4 +1,5 @@
<?php
session_start();
require_once 'header.php'; // loads head.php inside. Further loads D2UM/SM
require_once 'footer.php';

View File

@@ -1,5 +1,5 @@
<div class="form-group row options" style="background: none;">
<div class="offset-10 col-3" style="background: none;">
<div class="offset-10 col-2" style="background: none;">
<button style="" name="submit" type="submit" class="btn btn-success">Save Item</button>
<button name="submit" type="reset" class="btn btn-danger">Clear</button>
</div>