In memory images/invfiles, general sql cleanup

This commit is contained in:
color.diff=auto 2021-05-12 22:31:41 -06:00
parent 5eced413cb
commit 016ea0e5d2
6 changed files with 3418 additions and 536 deletions

View File

@ -71,8 +71,8 @@ if ($cmd == "getUniqueItem") {
* *
* */ * */
if ($cmd == "sortBy") { if ($cmd == "sortBy") {
$sql = "SELECT `index`,`$sort` FROM `uniqueitems` WHERE `enabled`='1' ORDER BY `$sort`"; $sql = "SELECT `index`, ? FROM uniqueitems WHERE enabled='1' ORDER BY ?";
$res = PDO_FetchAll($sql); $res = PDO_FetchAll($sql, [$sort]);
$html = ''; $html = '';
foreach ($res as $r) { foreach ($res as $r) {
@ -160,7 +160,9 @@ if ($cmd == 'getString') {
$prop = $_GET['prop']; $prop = $_GET['prop'];
$sql = "SELECT stat1,stat2,stat3,stat4,stat5,stat6,stat7 FROM properties WHERE code = ?"; // stat2,stat3,stat4,stat5,stat6,stat7
$sql = "SELECT stat1 FROM properties WHERE code = ?";
$stat = array_filter(PDO_FetchRow($sql, [$prop])); $stat = array_filter(PDO_FetchRow($sql, [$prop]));
$s = array_filter($idata->getIscStrings($prop)); $s = array_filter($idata->getIscStrings($prop));

View File

@ -44,6 +44,8 @@
.item_stats{ .item_stats{
width: auto; width: auto;
height: auto; height: auto;
background: #111;
min-height: 260px;
} }
.item_desc { .item_desc {
height: auto; height: auto;

File diff suppressed because it is too large Load Diff

View File

@ -119,15 +119,19 @@ $htmltop = <<<EOT
<style> <style>
body{ body{
background: black; background: white;
text-align: $align; font-family: ExocetHeavy;
font-family: Lato;
} }
table, table th, table td, table tr {
background: #111;
color: #ccc;
}
.item { .item {
text-align: left; text-align: center;
position:relative; position:relative;
right:0px; right:0px;
margin: 0 auto;
} }
.item_desc { .item_desc {
@ -146,6 +150,8 @@ $htmltop = <<<EOT
.item_stats{ .item_stats{
width: auto; width: auto;
height: auto; height: auto;
background: #111;
min-height: 260px;
} }
.item_desc { .item_desc {
height: auto; height: auto;
@ -169,6 +175,34 @@ $htmltop = <<<EOT
.blue { .blue {
color: #4169E1; color: #4169E1;
} }
td {
height: 240px;
text-align: center;
vertical-align: middle;
padding: 10px;
}
.uname {
background: #222;
}
.ulvl {
}
.ulvlreq {
}
.utype {
background: #111;
}
.ucode {
}
.uitem {
}
</style> </style>
@ -182,6 +216,7 @@ $htmltop = <<<EOT
$(document).ready(function() { $(document).ready(function() {
$('.cubetable').dataTable(); $('.cubetable').dataTable();
$('.utable').dataTable();
} ); } );
@ -223,6 +258,27 @@ mkdir($dir, 0777, true);
if ($cmd == "genDocUniqueItems") { if ($cmd == "genDocUniqueItems") {
$tableTop = <<<EOT
<table border=1 class="utable">
<thead>
<tr>
<th class="gold uname">Name</th>
<th class="orange ulvl">Lvl</th>
<th class="orange ulvlreq">Lvl Req</th>
<th class="yellow utype">Type</th>
<th class="green ucode">Code</th>
<th class="uitem">Item</th>
</tr>
</thead>
<tbody>
EOT;
$tableBottom = <<<EOT
</tbody>
</table>
EOT;
// grab unique item index only (to save on memory) // grab unique item index only (to save on memory)
$sql = "SELECT `index` FROM `uniqueitems` WHERE `enabled`='1'"; $sql = "SELECT `index` FROM `uniqueitems` WHERE `enabled`='1'";
$uIndex = PDO_FetchAll($sql); $uIndex = PDO_FetchAll($sql);
@ -230,10 +286,14 @@ if ($cmd == "genDocUniqueItems") {
//ddump($uIndex); //ddump($uIndex);
$htmlFinal = ''; $htmlFinal = '';
$htmlFinal .= $htmltop; $htmlFinal .= $htmltop.$tableTop;
echo $htmltop; echo $htmltop;
echo $tableTop;
ob_flush(); ob_flush();
/* /*
@ -243,13 +303,26 @@ if ($cmd == "genDocUniqueItems") {
* *
*/ */
foreach ($uIndex as $u) { foreach ($uIndex as $u) {
//var_dump($item);
//$items[] = $idata->uniqueItems($u['index'], true); //$items[] = $idata->uniqueItems($u['index'], true);
//var_dump($u['index']); //var_dump($u['index']);
$item = $idata->uniqueItems($u['index'], true); $item = $idata->uniqueItems($u['index'], true);
$itemBoxTop = <<<EOT $itemBoxTop = "<tr>";
$itemBoxTop .= "<td class='gold uname' style=''>{$item['index']}</td>";
$itemBoxTop .= "<td class='orange ulvl' style=''>{$item['lvl']}</td>";
$itemBoxTop .= "<td class='orange ulvlreq' style=''>{$item["lvl req"]}</td>";
$itemBoxTop .= "<td class='utype' style=''>{$item["*type"]}</td>";
$itemBoxTop .= "<td class='ucode' style=''>{$item['code']}</td>";
$itemBoxTop .= <<<EOT
<td class='item' style=''>
<div class="center item_desc" style=""> <div class="center item_desc" style="">
<div style="height: 116px;background: url(img/items/bg.png) center top no-repeat;"> <div style="height: 116px;background: url(img/items/bg.png) center top no-repeat;">
@ -264,8 +337,9 @@ EOT;
</div> </div>
</div> </div>
</div> </div>
</td>
EOT; EOT;
$itemBoxBottom .= "</tr>";
echo $itemBoxTop; echo $itemBoxTop;
ob_flush(); ob_flush();
@ -313,7 +387,7 @@ EOT;
echo $itemBoxBottom; echo $itemBoxBottom;
ob_flush(); ob_flush();
$htmlFinal .= $props . $itemBoxBottom; $htmlFinal .= $props . $itemBoxBottom . $tableBottom;
}// end loop }// end loop
echo $htmlbottom; echo $htmlbottom;
@ -1003,54 +1077,85 @@ EOT;
if ($cmd == "getIscStrings") { //if ($cmd == "getIscStrings") {
//
//
//
// $sql = "
// SELECT p.`code` as prop,
// p.stat1,
// i.descstrpos,
// i.descstr2,
// i.descfunc,
// i.descval,
// i.dgrp,
// i.dgrpfunc,
// i.dgrpval,
// i.dgrpstrpos,
// i.dgrpstrneg,
// s1.String as string1,
// s2.String as string2,
// s3.String as gstring1,
// s4.String as gstring2
// FROM properties as p
//
// LEFT JOIN itemstatcost as i
// ON p.stat1 = i.Stat
//
// LEFT JOIN strings as s1
// ON i.descstrpos = s1.Key
// LEFT JOIN strings as s2
// ON i.descstr2 = s2.Key
//
// LEFT JOIN strings as s3
// ON i.dgrpstrpos = s3.Key
// LEFT JOIN strings as s4
// ON i.dgrpstr2= s4.Key
//";
//
// $res = PDO_FetchAll($sql);
//
// $isc = null;
// foreach ($res as $r) {
// $isc[$r['prop']] = $r;
// $isc[$r['prop']]['prop'] = $r['prop'];
// }
//
//
// var_dump($isc);
//}
if ($cmd == "getImages") {
$sql = " $sql = "
SELECT p.`code` as prop, SELECT code,invfile,type,type2 FROM armor
p.stat1, UNION ALL
i.descstrpos, SELECT code,invfile,type,type2 FROM misc
i.descstr2, UNION ALL
i.descfunc, SELECT code,invfile,type,type2 FROM weapons
i.descval,
i.dgrp,
i.dgrpfunc,
i.dgrpval,
i.dgrpstrpos,
i.dgrpstrneg,
s1.String as string1,
s2.String as string2,
s3.String as gstring1,
s4.String as gstring2
FROM properties as p
LEFT JOIN itemstatcost as i
ON p.stat1 = i.Stat
LEFT JOIN strings as s1
ON i.descstrpos = s1.Key
LEFT JOIN strings as s2
ON i.descstr2 = s2.Key
LEFT JOIN strings as s3
ON i.dgrpstrpos = s3.Key
LEFT JOIN strings as s4
ON i.dgrpstr2= s4.Key
"; ";
$res = PDO_FetchAll($sql); $res = PDO_FetchAll($sql);
$isc = null; $isc = null;
foreach ($res as $r) { foreach ($res as $r) {
$isc[$r['prop']] = $r; $isc1[$r['code']] = $r;
$isc[$r['prop']]['prop'] = $r['prop']; $isc1[$r['code']]['code'] = $r['prop'];
$isc2[$r['type']] = $r;
$isc2[$r['type']]['type'] = $r['prop'];
} }
$isc = array_merge($isc1, $isc2);
var_dump($isc); unset($isc1);
unset($isc2);
var_dump(($isc));
} }

View File

@ -82,12 +82,12 @@ ERROR: INVALID PATH</h1></center>';
$_SESSION['tbl'] = $tbl; $_SESSION['tbl'] = $tbl;
// Don't yell at me, security is the least of my considerations atm // Don't yell at me, security is the least of my considerations atm
// check modname in db // check modname in db
$sql = "SELECT * FROM `D2Modder` WHERE `modname`='$modname'"; $sql = "SELECT * FROM D2Modder WHERE modname=?";
$res = PDO_FetchAll($sql); $res = PDO_FetchAll($sql, [$modname]);
if (empty($res)) { if (empty($res)) {
$sql = "INSERT INTO D2Modder(`modname`,`path`,`tbl`,`lastused`) VALUES(\"$modname\",\"$path\",\"$tbl\",$time)"; $sql = "INSERT INTO D2Modder(`modname`,`path`,`tbl`,`lastused`) VALUES(?, ?, ?, ?)";
PDO_Execute($sql); PDO_Execute($sql, [$modname, $path, $tbl, $time]);
} }
header("Location: /processFiles.php"); header("Location: /processFiles.php");
} }
@ -123,11 +123,11 @@ ERROR: INVALID PATH</h1></center>';
$_SESSION['tbl'] = $path; $_SESSION['tbl'] = $path;
// Don't yell at me, security is the least of my considerations atm // Don't yell at me, security is the least of my considerations atm
// check modname in db // check modname in db
$sql = "SELECT * FROM `D2Modder` WHERE modname='$modname'"; $sql = "SELECT * FROM D2Modder WHERE modname=?";
$res = PDO_FetchAll($sql); $res = PDO_FetchAll($sql, [$modname]);
if (empty($res)) { if (empty($res)) {
$sql = "INSERT INTO `D2Modder` (`modname`,`path`,`tbl`,`lastused`) VALUES(\"$modname\",\"$path\",\"$path\",$time)"; $sql = "INSERT INTO D2Modder (`modname`,`path`,`tbl`,`lastused`) VALUES(?, ?, ?, ?)";
PDO_Execute($sql); PDO_Execute($sql, [$modname, $path, $tbl, $time]);
} }
header("Location: /processFiles.php"); header("Location: /processFiles.php");
} }
@ -143,7 +143,7 @@ require_once "head.php";
<body style="background: white;"> <body style="background: white;">
<div class="center container container-top"> <div class="center container container-top">
<img src="/img/Diablo2.png" style="float:left"><h1 syle="display:inline; font-weight: 900"><?php echo $title . " " . $version; ?><span style="font-family: Lato !important; font-size: 14px;"> <?php echo " By" . $author ?></span></h1> <img src="/img/Diablo2.png" style="float:left"><h1 syle="display:inline; font-weight: 900"><?php echo $title . " " . $version; ?><span style="font-family: Lato !important; font-size: 14px;"> <?php echo " By: " . $author ?></span></h1>
<a class="btn btn-outline-danger" style="color:red; font-size: 18px;float:right;" href="/">X</a> <a class="btn btn-outline-danger" style="color:red; font-size: 18px;float:right;" href="/">X</a>
<hr style="margin: 60px;"> <hr style="margin: 60px;">
<div class="offset-2 col-8"> <div class="offset-2 col-8">

View File

@ -3,6 +3,33 @@
class D2ItemData { class D2ItemData {
public $strings; public $strings;
public $images;
public function getImages() {
$sql = "
SELECT code,invfile,type,type2 FROM armor
UNION ALL
SELECT code,invfile,type,type2 FROM misc
UNION ALL
SELECT code,invfile,type,type2 FROM weapons
";
$res = PDO_FetchAll($sql);
$isc = null;
foreach ($res as $r) {
$isc1[$r['code']] = $r;
$isc1[$r['code']]['code'] = $r['prop'];
$isc2[$r['type']] = $r;
$isc2[$r['type']]['type'] = $r['prop'];
}
$this->images = array_merge($isc1, $isc2);
unset($isc1);
unset($isc2);
}
public function uniqueItems($index, $doc = FALSE) { public function uniqueItems($index, $doc = FALSE) {
// This is where we get props for each item // This is where we get props for each item
@ -23,40 +50,50 @@ class D2ItemData {
* *
*/ */
if (empty($res['invfile'])) { if (empty($this->images)) {
$this->getImages();
}
// if (empty($res['invfile'])) {
$res['invfile'] = $this->images[$res['code']]['invfile'];
$return = $res;
// if no invfile, get from other tables // if no invfile, get from other tables
// try to get from armor, weapons, misc // try to get from armor, weapons, misc
$sql = "SELECT invfile FROM armor WHERE code=?"; // $sql = "SELECT invfile FROM armor WHERE code=?";
$invfile[] = PDO_FetchRow($sql, [$res['code']]); // $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
$sql = "SELECT invfile FROM weapons WHERE code=?"; // $sql = "SELECT invfile FROM weapons WHERE code=?";
$invfile[] = PDO_FetchRow($sql, [$res['code']]); // $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
$sql = "SELECT invfile FROM misc WHERE code=?"; // $sql = "SELECT invfile FROM misc WHERE code=?";
$invfile[] = PDO_FetchRow($sql, [$res['code']]); // $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
$invfile = array_filter($invfile); // $invfile = array_filter($invfile);
//
foreach ($invfile as $i) { // foreach ($invfile as $i) {
$x[] = $i; // $x[] = $i;
} // }
//
if (!empty($x[0])) { // if (!empty($x[0])) {
$x[0] = array_filter($x[0]); // $x[0] = array_filter($x[0]);
} // }
$invClean = $x[0]; // $invClean = $x[0];
if (!empty($invClean)) { // if (!empty($invClean)) {
$return = array_merge($res, $invClean); // $return = array_merge($res, $invClean);
} else { // } else {
$return = $res; // $return = $res;
} // }
//$return = array_merge($res, $invClean); //$return = array_merge($res, $invClean);
} else { // } else {
$return = $res; // $return = $res;
} // }
// var_dump($return); // var_dump($return);
/* /*
@ -107,14 +144,12 @@ class D2ItemData {
// //
// //
// ( Also need func1 and val1 for each prop ) // ( Also need func1 and val1 for each prop )
// //
// for each prop, get stat // for each prop, get stat
$counter = 1; $counter = 1;
foreach ($props as $key => $val) { foreach ($props as $key => $val) {
// val = Prop1,Prop2 etc. // val = Prop1,Prop2 etc.
// for each propr, get all 7 stats in ISC // for each propr, get all 7 stats in ISC
// for now only get stat1, and for else, use dgrp // for now only get stat1, and for else, use dgrp
$sql = "SELECT stat1 FROM properties WHERE code = ?"; $sql = "SELECT stat1 FROM properties WHERE code = ?";
@ -289,14 +324,11 @@ class D2ItemData {
public function getIscStrings($iscStat) { public function getIscStrings($iscStat) {
if (empty($this->strings)){ if (empty($this->strings)) {
$this->getStrings(); $this->getStrings();
} }
return ($this->strings[$iscStat]); return ($this->strings[$iscStat]);
} }
public function getStrings() { public function getStrings() {
@ -336,9 +368,8 @@ class D2ItemData {
$strings = PDO_FetchAll($sql); $strings = PDO_FetchAll($sql);
//var_dump($strings); //var_dump($strings);
foreach($strings as $k => $v){ foreach ($strings as $k => $v) {
$this->strings[$v['prop']] = $v; $this->strings[$v['prop']] = $v;
} }
} }