2021-03-23 08:13:54 +00:00
|
|
|
<?php
|
2021-03-30 19:40:11 +00:00
|
|
|
|
2022-05-05 13:47:20 +00:00
|
|
|
|
2021-03-27 08:53:26 +00:00
|
|
|
session_start();
|
2021-03-23 08:13:54 +00:00
|
|
|
/*
|
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
Copyright (C) 2021 Hash Borgir
|
2021-03-23 08:13:54 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
This file is part of D2Modder
|
2021-03-23 08:13:54 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
Redistribution and use in source and binary forms, with
|
|
|
|
or without modification, are permitted provided that the
|
|
|
|
following conditions are met:
|
2021-03-28 08:12:25 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
2021-03-28 08:12:25 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
2021-03-28 08:12:25 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
* This software must not be used for commercial purposes
|
|
|
|
* without my consent. Any sales or commercial use are prohibited
|
|
|
|
* without my express knowledge and consent.
|
2021-03-28 08:12:25 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY!
|
2021-03-28 08:12:25 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2021-03-23 08:13:54 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-05-07 09:18:29 +00:00
|
|
|
ini_set('display_errors', 1);
|
2021-05-03 10:04:46 +00:00
|
|
|
error_reporting(E_ALL ^ E_WARNING);
|
2021-05-03 10:15:48 +00:00
|
|
|
ini_set('log_errors', 1);
|
2021-03-23 08:13:54 +00:00
|
|
|
|
2021-03-27 08:53:26 +00:00
|
|
|
include "./_pdo.php";
|
2021-03-24 10:26:51 +00:00
|
|
|
|
2021-03-28 09:22:23 +00:00
|
|
|
include "./config.php";
|
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SESSION['modname'] . ".db"))) {
|
2021-03-27 08:53:26 +00:00
|
|
|
// first load, no active mod, go to switchmods to select mod
|
|
|
|
header("Location: /switchMods.php");
|
|
|
|
} else {
|
2021-03-30 19:40:11 +00:00
|
|
|
|
|
|
|
PDO_Connect("sqlite:" . APP_DB);
|
2021-05-03 10:15:48 +00:00
|
|
|
$sql = "SELECT * FROM D2Modder ORDER BY lastused DESC LIMIT 1";
|
2021-03-30 19:40:11 +00:00
|
|
|
|
|
|
|
$lastUsedMod = PDO_FetchRow($sql);
|
2021-05-07 09:18:29 +00:00
|
|
|
|
2021-03-30 19:40:11 +00:00
|
|
|
$_SESSION['modname'] = $lastUsedMod['modname'];
|
2021-05-02 11:35:38 +00:00
|
|
|
$_SESSION['path'] = $lastUsedMod['path'];
|
|
|
|
|
2021-03-31 14:52:20 +00:00
|
|
|
$sql = "SELECT theme FROM `D2Modder` WHERE `modname`='{$_SESSION['modname']}'";
|
|
|
|
$res = PDO_FetchAll($sql);
|
2021-05-02 11:35:38 +00:00
|
|
|
|
|
|
|
if ($res[0]['theme'] == 1) {
|
2021-03-31 14:52:20 +00:00
|
|
|
$css = 'dark.css';
|
|
|
|
} else {
|
|
|
|
$css = '';
|
|
|
|
}
|
2021-05-02 11:35:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-27 08:53:26 +00:00
|
|
|
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
|
|
|
define('DB_FILE', $_SESSION['modname'] . ".db");
|
|
|
|
define('TXT_PATH', $_SESSION['path']);
|
|
|
|
|
|
|
|
require_once "./src/D2Functions.php";
|
|
|
|
require_once "./src/D2Database.php";
|
|
|
|
require_once './src/D2Files.php';
|
|
|
|
require_once './src/D2TxtParser.php';
|
2021-05-02 11:35:38 +00:00
|
|
|
require_once './src/D2ItemDesc.php';
|
2021-05-07 09:18:29 +00:00
|
|
|
|
2021-05-02 11:35:38 +00:00
|
|
|
$idesc = new D2ItemDesc();
|
2021-03-26 14:37:56 +00:00
|
|
|
$db = new D2Database();
|
|
|
|
$parser = new D2TxtParser();
|
2021-03-27 08:53:26 +00:00
|
|
|
|
2021-05-02 11:35:38 +00:00
|
|
|
// $a = ["bighead1","fallen1","corruptrogue1","goatman1","fallenshaman1","fetish1","cr_archer1","cr_lancer1","vulture1","bloodraven","andariel","smith","vulture1","blunderbore1","duriel","fetishshaman1","councilmember1","mephisto","megademon1","regurgitator1","diablo","hephasto","vilemother1","vilechild1","overseer1","imp1","succubus1","succubuswitch1","putriddefiler1","painworm1","minion1","baalcrab"];
|
|
|
|
//
|
|
|
|
//foreach ($a as $x){
|
|
|
|
// $z = (PDO_FetchRow("SELECT `hcIdx`,`NameStr` FROM monstats WHERE `Id`='$x'"));
|
|
|
|
// echo "<pre>".$z['hcIdx']."\t".$z['NameStr']."<br>";
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//die();
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-30 00:47:21 +00:00
|
|
|
$armor = PDO_FetchAll('SELECT * FROM armor WHERE spawnable=1');
|
2022-05-05 13:47:20 +00:00
|
|
|
$misc = PDO_FetchAll('SELECT * FROM misc WHERE spawnable=1
|
|
|
|
AND type <> "stst"
|
|
|
|
AND type <> "sum0"
|
|
|
|
AND type <> "prtl"
|
|
|
|
AND type <> "xfor"
|
|
|
|
AND type <> "rext"
|
|
|
|
AND type <> "gext"
|
|
|
|
AND type <> "ques"
|
|
|
|
AND type <> "key"
|
|
|
|
AND type <> "body"
|
|
|
|
');
|
2021-03-30 00:47:21 +00:00
|
|
|
$weapon = PDO_FetchAll('SELECT * FROM weapons WHERE spawnable=1');
|
|
|
|
$uniqueitems = PDO_FetchAll("SELECT `index`,`code` FROM uniqueitems WHERE `enabled`='1' ORDER BY `index` ASC");
|
2021-03-23 18:35:28 +00:00
|
|
|
|
2021-03-27 04:07:37 +00:00
|
|
|
$prop = $parser->filterProps('Properties.txt');
|
2021-03-27 08:53:26 +00:00
|
|
|
|
2021-03-23 18:35:28 +00:00
|
|
|
// If there's data, process it and save
|
2021-03-23 08:13:54 +00:00
|
|
|
if (!empty($_POST)) {
|
2021-05-07 09:18:29 +00:00
|
|
|
// save db name from post into conf file... why?
|
2021-03-27 08:53:26 +00:00
|
|
|
|
2021-03-23 08:13:54 +00:00
|
|
|
require_once './src/D2SaveFile.php';
|
|
|
|
$saver = new D2SaveFile();
|
|
|
|
|
2021-03-23 18:35:28 +00:00
|
|
|
// process post
|
|
|
|
// combine armor/weapon codes
|
2021-05-02 11:35:38 +00:00
|
|
|
foreach ($_POST as $k => $v) {
|
|
|
|
$x = str_replace("_", " ", $k);
|
|
|
|
$post[$x] = $v;
|
|
|
|
}
|
|
|
|
|
2021-03-23 18:35:28 +00:00
|
|
|
if (!empty($post['code'])) {
|
|
|
|
array_filter($post['code']);
|
|
|
|
|
|
|
|
if (!empty($post['code'][0])) {
|
|
|
|
$post['code'] = $post['code'][0];
|
|
|
|
} else {
|
|
|
|
$post['code'] = $post['code'][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:18:29 +00:00
|
|
|
|
|
|
|
// last 3 items are not in d2 txt, rid of them
|
|
|
|
// why did I set formtype? I can't rememer, need to comment code more
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Unique Items Form was posted here
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-23 08:13:54 +00:00
|
|
|
if ($_POST['formtype'] == "uniqueitems") {
|
2021-03-27 08:53:26 +00:00
|
|
|
|
2021-05-02 11:35:38 +00:00
|
|
|
unset($post['formtype']);
|
|
|
|
unset($post['submit']);
|
|
|
|
unset($post['item']);
|
2021-03-27 08:53:26 +00:00
|
|
|
|
2021-03-24 10:26:51 +00:00
|
|
|
// if ladder or carry1 is 0, set empty field.
|
|
|
|
if (!$post['ladder']) {
|
|
|
|
$post['ladder'] = '';
|
|
|
|
}
|
|
|
|
if (!$post['carry1']) {
|
|
|
|
$post['carry1'] = '';
|
|
|
|
}
|
2021-05-02 11:35:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 09:18:29 +00:00
|
|
|
$sql = "SELECT rowid,`index` from `uniqueitems` WHERE `index`=\"{$post['index']}\"";
|
|
|
|
|
|
|
|
$res = PDO_FetchRow($sql);
|
|
|
|
|
2021-05-02 11:35:38 +00:00
|
|
|
if ($res['index'] == $post['index']) {
|
|
|
|
$sql = "UPDATE `uniqueitems` SET ";
|
|
|
|
foreach ($post as $k => $v) {
|
2021-05-07 09:18:29 +00:00
|
|
|
$sql .= "`$k`=\"$v\",";
|
2021-05-02 11:35:38 +00:00
|
|
|
}
|
|
|
|
$sql = rtrim($sql, ",");
|
2021-05-07 09:18:29 +00:00
|
|
|
$sql .= ' WHERE `index`="'.$post['index'].'"';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PDO_Execute($sql, [$post['index']]);
|
|
|
|
//ddump($x);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Set Items Form was posted here
|
|
|
|
*
|
|
|
|
*/ else {
|
2021-05-02 11:35:38 +00:00
|
|
|
|
|
|
|
$sql = "INSERT INTO `uniqueitems` (";
|
|
|
|
foreach ($post as $k => $v) {
|
|
|
|
$sql .= "`$k`,";
|
|
|
|
}
|
|
|
|
$sql = rtrim($sql, ",");
|
|
|
|
$sql .= ") VALUES (";
|
|
|
|
foreach ($post as $k => $v) {
|
|
|
|
$sql .= "'$v',";
|
|
|
|
}
|
|
|
|
$sql = rtrim($sql, ",");
|
|
|
|
$sql .= ")";
|
|
|
|
ddump($sql);
|
|
|
|
|
|
|
|
// $saver->save($u, $post);
|
|
|
|
// $saver->saveTblEnries("UniqueItems.tbl.txt");
|
|
|
|
}
|
2021-03-23 08:13:54 +00:00
|
|
|
}
|
|
|
|
if ($_POST['formtype'] == "setitems") {
|
2021-03-24 10:26:51 +00:00
|
|
|
$saver->save($s, $post);
|
2021-03-23 08:13:54 +00:00
|
|
|
$saver->saveTblEnries("SetItems.tbl.txt");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-27 08:53:26 +00:00
|
|
|
// load app
|
2021-03-23 08:13:54 +00:00
|
|
|
require_once './src/index.php';
|
|
|
|
}
|
2021-03-22 09:23:04 +00:00
|
|
|
?>
|