mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 08:24:24 -05:00
Latest working copy, needs testing on windows
This commit is contained in:
53
ajax/config.php
Normal file
53
ajax/config.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
|
||||
This file is part of D2Modder
|
||||
|
||||
Redistribution and use in source and binary forms, with
|
||||
or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY!
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
session_start();
|
||||
|
||||
include "../_pdo.php";
|
||||
require_once "../src/D2Functions.php";
|
||||
|
||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||
define('TXT_PATH', $_SESSION['path']);
|
||||
|
||||
$db = dirname(getcwd()).DIRECTORY_SEPARATOR.DB_FILE;
|
||||
|
||||
PDO_Connect("sqlite:".$db);
|
113
ajax/uniqueitems.php
Normal file
113
ajax/uniqueitems.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
include "./config.php";
|
||||
/*
|
||||
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
|
||||
This file is part of D2Modder
|
||||
|
||||
Redistribution and use in source and binary forms, with
|
||||
or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY!
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
if (!empty($_GET['cmd']))
|
||||
$cmd = $_GET['cmd'];
|
||||
if (!empty($_GET['sort']))
|
||||
$sort = $_GET['sort'];
|
||||
if (!empty($_GET['view']))
|
||||
$view = $_GET['view'];
|
||||
|
||||
if ($cmd == "getUniqueItem") {
|
||||
$sql = "SELECT * FROM `uniqueitems` WHERE `enabled`='1' AND `index`=\"{$_GET['index']}\"";
|
||||
$res = PDO_FetchRow($sql);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($res, JSON_INVALID_UTF8_IGNORE);
|
||||
}
|
||||
|
||||
if ($cmd == "sortBy") {
|
||||
$sql = "SELECT `index`,`$sort` FROM `uniqueitems` WHERE `enabled`='1' ORDER BY `$sort`";
|
||||
$res = PDO_FetchAll($sql);
|
||||
|
||||
$html = '';
|
||||
foreach ($res as $r) {
|
||||
if ($sort == 'index') {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
|
||||
} else {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']} ($r[$sort])</option>";
|
||||
}
|
||||
}
|
||||
echo $html;
|
||||
}
|
||||
|
||||
if ($cmd == "viewOnly") {
|
||||
|
||||
$table = 'misc';
|
||||
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, misc.`type`
|
||||
FROM uniqueitems
|
||||
LEFT JOIN misc ON uniqueitems.`code` = misc.`code`
|
||||
WHERE `type` IS NOT NULL AND uniqueitems.`code`='$view'";
|
||||
if ($view == 'armo') {
|
||||
$table = 'armor';
|
||||
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
|
||||
FROM uniqueitems
|
||||
LEFT JOIN $table ON uniqueitems.`code` = $table.`code`
|
||||
WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code` != '' ORDER BY `index`";
|
||||
}
|
||||
if ($view == 'weap') {
|
||||
$table = 'weapons';
|
||||
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
|
||||
FROM uniqueitems
|
||||
LEFT JOIN $table ON uniqueitems.`code` = $table.`code`
|
||||
WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code` != '' ORDER BY `index`";
|
||||
}
|
||||
|
||||
|
||||
if ($view == "char") {
|
||||
$sql .= " OR uniqueitems.`code`='cm1' OR uniqueitems.`code`='cm2' OR uniqueitems.`code`='cm3'";
|
||||
}
|
||||
|
||||
$res = PDO_FetchAll($sql);
|
||||
|
||||
$html = '';
|
||||
foreach ($res as $r) {
|
||||
if ($sort == 'index') {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
|
||||
} else {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
|
||||
}
|
||||
}
|
||||
echo $html;
|
||||
}
|
Reference in New Issue
Block a user