Bugfixing. Adding sanity checks

This commit is contained in:
color.diff=auto
2021-03-27 02:53:26 -06:00
parent b85fbf02b3
commit 9bc941faea
8 changed files with 187 additions and 68 deletions

View File

@@ -1,16 +1,25 @@
<?php
include "includes.php";
PDO_Connect("sqlite:" . "d2im.db");
$sql = "SELECT * FROM d2im";
$mods = PDO_FetchAll($sql);
session_start();
include "./_pdo.php";
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: /");
// 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>