d2tools/switchMods.php

58 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2021-03-27 08:53:26 +00:00
session_start();
include "./_pdo.php";
2021-03-27 08:53:26 +00:00
// if config db exists, connect to it and grab list of mods
if (file_exists("d2im.db")) {
PDO_Connect("sqlite:d2im.db");
$sql = "SELECT * FROM d2im";
$mods = PDO_FetchAll($sql);
if (!empty($_POST)) {
$sql = "SELECT * FROM d2im WHERE `modname`='{$_POST['modname']}'";
$mod = PDO_FetchRow($sql);
$_SESSION['modname'] = $mod['modname'];
$_SESSION['path'] = $mod['path'];
header("Location: /");
}
} else {
// if config db does not exist, go to config page
header("Location: /src/D2Config.php");
}
?>
<!doctype html>
<html lang="en">
<?php
/* Require the <head> section */
require_once "src/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</h2>
<div style="margin-top: 20px;" class="ctrl-config">
<form class="" enctype="multipart/form-data" style="font-family: Lato; font-size: 14pt;text-align:center;" action="" method="post">
<p>
<select id="mods" name="modname" required="required" class="custom-select"> <?php foreach ($mods as $mod) { ?>
<option value="<?php echo $mod['modname'] ?>"><?php echo $mod['modname'] ?>: <?php echo $mod['path'] ?></option>
<?php } ?>
</select>
</p>
<p>
<input type="submit" value="Select" name="submit" class="btn-config">
</p>
<p>
<a style="font-weight: bold;" class="btn btn-danger" href="/">Cancel</a>
</p>
</form>
</div>
</div>
</div>
</body>
</html>