mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 04:26:03 +00:00
item search working
This commit is contained in:
parent
3eadaac01e
commit
02527a0d65
@ -49,14 +49,22 @@ if (!empty($_GET['sort']))
|
||||
$sort = $_GET['sort'];
|
||||
if (!empty($_GET['view']))
|
||||
$view = $_GET['view'];
|
||||
|
||||
/*
|
||||
* @cmd = getUniqueItem
|
||||
*
|
||||
*
|
||||
* */
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* @cmd = sortBy
|
||||
*
|
||||
*
|
||||
* */
|
||||
if ($cmd == "sortBy") {
|
||||
$sql = "SELECT `index`,`$sort` FROM `uniqueitems` WHERE `enabled`='1' ORDER BY `$sort`";
|
||||
$res = PDO_FetchAll($sql);
|
||||
@ -66,12 +74,16 @@ if ($cmd == "sortBy") {
|
||||
if ($sort == 'index') {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
|
||||
} else {
|
||||
$html .= "<option value=\"{$r['index']}\">{$r['index']} ($r[$sort])</option>";
|
||||
$html .= "<option value=\"{$r['index']}\">$r[$sort] - {$r['index']}</option>";
|
||||
}
|
||||
}
|
||||
echo $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* @cmd = viewOnly
|
||||
*
|
||||
*
|
||||
* */
|
||||
if ($cmd == "viewOnly") {
|
||||
|
||||
$table = 'misc';
|
||||
@ -93,14 +105,10 @@ 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') {
|
||||
@ -111,3 +119,28 @@ WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code`
|
||||
}
|
||||
echo $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* @cmd = search
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($cmd == 'search'){
|
||||
$search = $_GET['search'];
|
||||
$sql = "SELECT * FROM uniqueitems WHERE `index` LIKE '%$search%' OR `code` LIKE '%$search%' AND `enabled`=1 ORDER BY `index`";
|
||||
$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;
|
||||
|
||||
|
||||
|
||||
}
|
@ -45,3 +45,4 @@ $author = "HashCasper";
|
||||
$version = '<span style="color: #aaa">4.0';
|
||||
|
||||
define('APP_DB', "D2Modder.db");
|
||||
|
||||
|
85
index.php
85
index.php
@ -1,44 +1,45 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
/*
|
||||
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
|
||||
This file is part of D2Modder
|
||||
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:
|
||||
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 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.
|
||||
* 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 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 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.
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
@ -50,13 +51,23 @@ include "./_pdo.php";
|
||||
|
||||
include "./config.php";
|
||||
|
||||
if (!isset($_SESSION['modname'])
|
||||
|| (!file_exists(APP_DB))
|
||||
|| (!file_exists($_SESSION['modname'] . ".db")))
|
||||
{
|
||||
if (empty($_SESSION['modname'])) {
|
||||
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SESSION['modname'] . ".db"))) {
|
||||
// first load, no active mod, go to switchmods to select mod
|
||||
header("Location: /switchMods.php");
|
||||
} else {
|
||||
|
||||
PDO_Connect("sqlite:" . APP_DB);
|
||||
$sql = "SELECT * FROM D2Modder ORDER BY lastused LIMIT 1";
|
||||
|
||||
$lastUsedMod = PDO_FetchRow($sql);
|
||||
|
||||
$_SESSION['modname'] = $lastUsedMod['modname'];
|
||||
$_SESSION['path'] = $lastUsedMod['path'];
|
||||
|
||||
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||
define('TXT_PATH', $_SESSION['path']);
|
||||
@ -74,17 +85,13 @@ if (!isset($_SESSION['modname'])
|
||||
$weapon = PDO_FetchAll('SELECT * FROM weapons WHERE spawnable=1');
|
||||
$uniqueitems = PDO_FetchAll("SELECT `index`,`code` FROM uniqueitems WHERE `enabled`='1' ORDER BY `index` ASC");
|
||||
|
||||
|
||||
|
||||
$prop = $parser->filterProps('Properties.txt');
|
||||
|
||||
|
||||
// If there's data, process it and save
|
||||
if (!empty($_POST)) {
|
||||
|
||||
ddump($_POST);
|
||||
|
||||
|
||||
|
||||
// save db name from post into conf file
|
||||
|
||||
require_once './src/D2SaveFile.php';
|
||||
|
14
res/app.js
14
res/app.js
@ -39,6 +39,14 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
function search() {
|
||||
$.get("/ajax/uniqueitems.php?cmd=search&search=" + searchbox.value, function (data) {
|
||||
$('.uniqueitems-select').html(data)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.form-text').hide();
|
||||
$('.help').click(function () {
|
||||
@ -157,5 +165,11 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
searchbox = document.getElementById('search');
|
||||
searchbox.addEventListener('input', search);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
@ -132,4 +132,35 @@ h1,h2,h3,h4,h5,h6, div > p {
|
||||
top:0px;
|
||||
right: 0px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
select {
|
||||
font-size: 18px;
|
||||
border: 1px solid #CCC;
|
||||
height: 34px;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
background: url(https://stackoverflow.com/favicon.ico) 96% / 15% no-repeat #EEE;
|
||||
}
|
||||
|
||||
|
||||
/* CAUTION: Internet Explorer hackery ahead */
|
||||
|
||||
|
||||
select::-ms-expand {
|
||||
display: none; /* Remove default arrow in Internet Explorer 10 and 11 */
|
||||
}
|
||||
|
||||
/* Target Internet Explorer 9 to undo the custom arrow */
|
||||
@media screen and (min-width:0\0) {
|
||||
select {
|
||||
background: none\9;
|
||||
padding: 5px\9;
|
||||
}
|
||||
}
|
||||
|
||||
option {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
}
|
69
src/head.php
69
src/head.php
@ -1,43 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
Copyright (C) 2021 Hash Borgir
|
||||
|
||||
This file is part of D2Modder
|
||||
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:
|
||||
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 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.
|
||||
* 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 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 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.
|
||||
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.
|
||||
|
||||
*/
|
||||
?>
|
||||
@ -57,11 +57,10 @@
|
||||
|
||||
</style>
|
||||
<script
|
||||
src="/res/jquery-3.6.0.min.js"></script>
|
||||
src="/res/jquery-3.6.0.min.js"></script>
|
||||
<script src="/res/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script src="/res/app.js"></script>
|
||||
|
||||
</script>
|
||||
<title>D2Modder</title>
|
||||
|
||||
</script>
|
||||
<title>D2Modder</title>
|
||||
</head>
|
@ -1,7 +1,13 @@
|
||||
<div style="height: 40px; margin: 40px 10px;"><h2>Unique Item Maker</h2></div>
|
||||
<div class="row" style="">
|
||||
<div class="col-3">
|
||||
|
||||
<div class="row" style="margin:40px;">
|
||||
<div class="col" style="text-align: center;">
|
||||
<p>Search for Item</p>
|
||||
<input style="border: 1px solid #999; padding: 10px;width: 420px;" id="search" type="text custom-control-inline" placeholder="Search item" name="search">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="">
|
||||
<div class="col-4">
|
||||
<select name="uniqueitems" class="custom-select uniqueitems-select">
|
||||
<option value=""></option>
|
||||
<?php foreach ($uniqueitems as $u) { ?>
|
||||
@ -9,7 +15,7 @@
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col-8">
|
||||
<span style="font-family:Exocet;">Sort By: </span>
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input name="sort" id="sort_0" type="radio" class="custom-control-input" value="lvl">
|
||||
@ -28,9 +34,8 @@
|
||||
<label for="sort_3" class="custom-control-label">Item Code</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-bottom: 40px;">
|
||||
<div class="offset-3 col">
|
||||
|
||||
<div class="offset-4 col-8">
|
||||
<span style="font-family:Exocet;">View Only: </span>
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input name="view" id="view_0" type="radio" class="custom-control-input" value="rin">
|
||||
|
@ -64,7 +64,9 @@ if (file_exists(APP_DB)) {
|
||||
unlink($_POST['modname'] . ".db");
|
||||
header("Refresh:0");
|
||||
} else {
|
||||
|
||||
$time = time();
|
||||
$sql = "UPDATE `D2Modder` SET `lastused`=$time WHERE modname='{$_POST['modname']}'";
|
||||
PDO_Execute($sql);
|
||||
$_SESSION['modname'] = $mod['modname'];
|
||||
$_SESSION['path'] = $mod['path'];
|
||||
header("Location: /");
|
||||
|
Loading…
Reference in New Issue
Block a user