mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-09-18 17:42:09 +00:00
cube doc 90% done
This commit is contained in:
483
genDocs.php
483
genDocs.php
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
set_time_limit(-1);
|
||||
ini_set('max_input_time', '-1');
|
||||
@@ -61,6 +60,16 @@ if (!empty($_GET['cmd']))
|
||||
$cmd = $_GET['cmd'];
|
||||
|
||||
|
||||
if ($cmd == 'genDocCube') {
|
||||
$type = "Cube Recipes";
|
||||
$align = 'left';
|
||||
}
|
||||
if ($cmd == 'genDocUniqueItems') {
|
||||
$type = "Unique Items";
|
||||
$align = 'center';
|
||||
}
|
||||
|
||||
|
||||
$htmltop = <<<EOT
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
@@ -76,13 +85,14 @@ $htmltop = <<<EOT
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://bootswatch.com/4/sketchy/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.css">
|
||||
<link rel="stylesheet" href="res/style.css">
|
||||
<style>
|
||||
|
||||
body{
|
||||
background: black;
|
||||
text-align: center;
|
||||
font-family: ExocetLight;
|
||||
text-align: $align;
|
||||
font-family: Lato;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,23 +124,36 @@ $htmltop = <<<EOT
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="res/jquery-3.6.0.min.js"></script>
|
||||
|
||||
<script src="res/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.js"></script>
|
||||
<script src="res/bootstrap.bundle.min.js"></script>
|
||||
<script src="res/app.js"></script>
|
||||
|
||||
</script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.cubetable').dataTable();
|
||||
} );
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<title>D2Modder</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container container-top">
|
||||
<h1>{$_SESSION['modname']} Unique Items</h1>
|
||||
<h1>{$_SESSION['modname']} $type</h1>
|
||||
<p>Auto generated with D2Modder by Hash Casper</p>
|
||||
|
||||
EOT;
|
||||
|
||||
$htmlbottom = <<<EOT
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
@@ -270,8 +293,124 @@ EOT;
|
||||
*
|
||||
*/
|
||||
|
||||
function getImage($code) {
|
||||
$sql = "SELECT invfile FROM armor WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$img = PDO_FetchOne($sql);
|
||||
|
||||
if (empty($img)) {
|
||||
$sql = "SELECT invfile FROM misc WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$img = PDO_FetchOne($sql);
|
||||
}
|
||||
if (empty($img)) {
|
||||
$sql = "SELECT invfile FROM weapons WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$img = PDO_FetchOne($sql);
|
||||
}
|
||||
|
||||
if (!empty($img)) {
|
||||
return "$img.png";
|
||||
} else {
|
||||
return "1.png";
|
||||
}
|
||||
|
||||
return "$img.png";
|
||||
}
|
||||
|
||||
function getItemName($code) {
|
||||
$sql = "SELECT name FROM armor WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$name = PDO_FetchOne($sql);
|
||||
|
||||
if (empty($name)) {
|
||||
$sql = "SELECT name FROM misc WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$name = PDO_FetchOne($sql);
|
||||
}
|
||||
if (empty($name)) {
|
||||
$sql = "SELECT name FROM weapons WHERE `code`=\"$code\" OR `type`=\"$code\" OR `type2`=\"$code\"";
|
||||
$name = PDO_FetchOne($sql);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
if ($cmd == "genDocCube") {
|
||||
|
||||
echo $htmltop;
|
||||
echo <<<EOT
|
||||
<style>
|
||||
|
||||
body{
|
||||
background: white;
|
||||
color: black;
|
||||
font-family: ExocetLight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
table, table th, table td, table tr {
|
||||
background: #000;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.item_stats{
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
.item_desc {
|
||||
height: auto;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.green {
|
||||
color: #00FF00; /*Set items*/
|
||||
}
|
||||
.gold{
|
||||
color: #A59263; /*Set items*/
|
||||
}
|
||||
.orange{
|
||||
color: #FFA500; /*Set items*/
|
||||
}
|
||||
.yellow {
|
||||
color: #FFFF00; /*Set items*/
|
||||
}
|
||||
|
||||
.blue {
|
||||
color: #4169E1;
|
||||
}
|
||||
|
||||
table {
|
||||
font-family: Lato;
|
||||
}
|
||||
|
||||
|
||||
td {
|
||||
width: 200px;
|
||||
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
EOT;
|
||||
|
||||
echo <<<EOT
|
||||
<table border=1 class="cubetable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Recipe</th>
|
||||
<th>Input 1</th>
|
||||
<th>Input 2</th>
|
||||
<th>Input 3</th>
|
||||
<th>Input 4</th>
|
||||
<th>Input 5</th>
|
||||
<th>Input 6</th>
|
||||
<th>Input 7</th>
|
||||
<th>Output 1</th>
|
||||
<th>Output 2</th>
|
||||
<th>Output 3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
EOT;
|
||||
|
||||
$item_quality_params = [
|
||||
"any" => "Any item (*Not Advised)",
|
||||
@@ -306,9 +445,8 @@ if ($cmd == "genDocCube") {
|
||||
];
|
||||
|
||||
// get all cube rows
|
||||
$sql = "SELECT * FROM cubemain WHERE enabled=1";
|
||||
$sql = "SELECT * FROM cubemain WHERE enabled=1 LIMIT 1500";
|
||||
$res = PDO_FetchAll($sql);
|
||||
$desc = $res['description'];
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -319,8 +457,8 @@ if ($cmd == "genDocCube") {
|
||||
|
||||
|
||||
foreach ($res as $r) {
|
||||
|
||||
//ddump($r);
|
||||
$desc = $r['description'];
|
||||
//var_dump($r);
|
||||
// grab all inputs
|
||||
$input_codes = array_filter(
|
||||
[
|
||||
@@ -334,7 +472,7 @@ if ($cmd == "genDocCube") {
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($input_codes as $inputNum => $value) {
|
||||
foreach ($input_codes as $inputNum => $value) {
|
||||
|
||||
if (str_contains($value, ',')) {
|
||||
$input_codes[$inputNum] = explode(",", $value); // hpot,qty=3
|
||||
@@ -345,42 +483,59 @@ if ($cmd == "genDocCube") {
|
||||
// first find the item code in either armor, misc, or weapons
|
||||
// then get spelldesc/spelldescstr
|
||||
|
||||
$sql = "SELECT spelldescstr FROM `misc` WHERE `code`=\"{$oarray[0]}\"";
|
||||
$spelldescstr = PDO_FetchOne($sql);
|
||||
|
||||
if (!empty($spelldescstr)) { // spelldescstr has value then grab it from tbl
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"$spelldescstr\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
} else { // grab item code's tbl string
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
}
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
|
||||
// if empty str == 4-letter code, so just display
|
||||
// if empty str == 4-letter code, call getItemName()
|
||||
if (empty($str)) {
|
||||
$input_codes[$inputNum][0] = $oarray[0];
|
||||
$input_codes[$inputNum][0] = ($oarray[0]);
|
||||
} else {
|
||||
$input_codes[$inputNum][0] = $str;
|
||||
}
|
||||
|
||||
// get image
|
||||
$input_codes[$inputNum]["img"] = getImage($oarray[0]);
|
||||
} else {
|
||||
$value .= ",";
|
||||
$input_codes[$inputNum] = explode(",", $value); // hpot,qty=3
|
||||
|
||||
$sql = "SELECT spelldescstr FROM `misc` WHERE `code`=\"$value\"";
|
||||
$spelldescstr = PDO_FetchOne($sql);
|
||||
$oarray = explode(",", $value); // hpot,qty=3
|
||||
// For each input code // hpot,qty=3 like mpot/hpot/magharv
|
||||
// if spelldescstr is set, use it. Else use item string tbl
|
||||
// first find the item code in either armor, misc, or weapons
|
||||
// then get spelldesc/spelldescstr
|
||||
|
||||
if (!empty($spelldescstr)) { // spelldescstr has value then grab it from tbl
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"$spelldescstr\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
} else { // grab item code's tbl string
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"$value\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
}
|
||||
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
|
||||
// if empty str == 4-letter code, so just display
|
||||
if (empty($str)) {
|
||||
$input_codes[$inputNum] = $value;
|
||||
$input_codes[$inputNum][0] = ($oarray[0]);
|
||||
} else {
|
||||
$input_codes[$inputNum] = $str;
|
||||
$input_codes[$inputNum][0] = $str;
|
||||
}
|
||||
|
||||
// get image
|
||||
$input_codes[$inputNum]["img"] = getImage($oarray[0]);
|
||||
|
||||
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"$value\"";
|
||||
// $str = PDO_FetchOne($sql).",";
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// // if empty str == 4-letter code, so just display
|
||||
// if (empty($str)) {
|
||||
// $input_codes[$inputNum][0] = $value;
|
||||
// } else {
|
||||
// $input_codes[$inputNum][0] = $str;
|
||||
// }
|
||||
//
|
||||
// // get image
|
||||
// $img = getImage($value);
|
||||
// $input_codes[$inputNum . "_img"] = $img;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,24 +566,85 @@ if ($cmd == "genDocCube") {
|
||||
|
||||
// if empty str == 4-letter code, so just display
|
||||
if (empty($str)) {
|
||||
$output_codes[$outputNum][0] = $oarray[0];
|
||||
$output_codes[$outputNum][0] = ($oarray[0]);
|
||||
} else {
|
||||
$output_codes[$outputNum][0] = $str;
|
||||
}
|
||||
|
||||
$output_codes[$outputNum]["img"] = getImage($oarray[0]);
|
||||
} else { // else output code is three/four letter code
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"$value\"";
|
||||
$value .= ",";
|
||||
|
||||
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
|
||||
$oarray = explode(",", $value); // hpot,qty=3
|
||||
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
|
||||
$str = PDO_FetchOne($sql);
|
||||
|
||||
// if empty str == 4-letter code, so just display
|
||||
if (empty($str)) {
|
||||
$output_codes[$outputNum] = $value;
|
||||
$output_codes[$outputNum][0] = ($oarray[0]);
|
||||
} else {
|
||||
$output_codes[$outputNum] = $str;
|
||||
$output_codes[$outputNum][0] = $str;
|
||||
}
|
||||
|
||||
$output_codes[$outputNum]["img"] = getImage($oarray[0]);
|
||||
|
||||
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"$value\"";
|
||||
// $str = PDO_FetchOne($sql);
|
||||
//
|
||||
// // if empty str == 4-letter code, so just display
|
||||
// if (empty($str)) {
|
||||
// $output_codes[$outputNum] = $value;
|
||||
// } else {
|
||||
// $output_codes[$outputNum] = $str;
|
||||
// }
|
||||
// // get image
|
||||
// $img = getImage($value);
|
||||
// $output_codes[$outputNum . "_img"] = $img;
|
||||
}
|
||||
|
||||
|
||||
// if output[1] or output[2], output[3], output[4] contains `=' sign
|
||||
// parse_str or explode at = to get modifer and value
|
||||
// if modifier = pre or suf, find ID in magic prefix/suffix line.
|
||||
// if output is array we know it contains modifers and values
|
||||
|
||||
if (is_array($output_codes[$outputNum])) {
|
||||
// 0 will always be item code.
|
||||
// 1,2,3 can be mods, either can have =
|
||||
// if 1,2,3 have = sign, explode and get mod = value
|
||||
|
||||
$itemcode = $output_codes[0];
|
||||
|
||||
$mod = array_filter([$output_codes[$outputNum][1], $output_codes[$outputNum][2], $output_codes[$outputNum][3]]);
|
||||
|
||||
//var_dump($mod);
|
||||
|
||||
foreach ($mod as $m) {
|
||||
if (str_contains($m, '=')) {
|
||||
$e = explode("=", $m);
|
||||
$output_codes[$outputNum]['code'] = $e[0];
|
||||
$output_codes[$outputNum]['value'] = $e[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var_dump($output_codes);
|
||||
|
||||
$output = array_merge($input_codes, $output_codes);
|
||||
|
||||
// Set description
|
||||
$output['desc'] = $desc;
|
||||
|
||||
//var_dump($output);
|
||||
//var_dump($output);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* TODO: process mods for each output
|
||||
@@ -461,7 +677,192 @@ if ($cmd == "genDocCube") {
|
||||
}
|
||||
$output['mods'] = array_filter($m);
|
||||
|
||||
var_dump($output);
|
||||
unset($output);
|
||||
}// end each row loop
|
||||
}
|
||||
/*
|
||||
* Echo out each row as HTML with all the data it may have
|
||||
*
|
||||
*/
|
||||
|
||||
// echo "<tr>";
|
||||
// foreach ($output as $k => $v) {
|
||||
//
|
||||
// // if input 1, input 2 is an array
|
||||
//
|
||||
// if (is_array($v)){
|
||||
// echo "<td><img src=\"/img/items/{$v['img']}\">{$v[0]}: {$v[1]}</td>";
|
||||
// echo "<td><img src=\"/img/items/{$v['img']}\">{$v[0]}: {$v[1]}</td>";
|
||||
// } else {
|
||||
//
|
||||
// $img = "";
|
||||
// // if input 1, input 2 ... etc. are not arrays
|
||||
// echo '<td><img src="'.$o.'"></td>';
|
||||
// }
|
||||
// }
|
||||
// echo "</tr>";
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="desc">
|
||||
<?php echo $output['desc'] ?>
|
||||
</td>
|
||||
<td class="input1">
|
||||
<?php
|
||||
if (!empty($output["input 1"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 1"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 1"][0] ?><br>
|
||||
<?php echo $output["input 1"][1] ?><br>
|
||||
</td>
|
||||
<td class="input2">
|
||||
<?php
|
||||
if (!empty($output["input 2"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 2"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 2"][0] ?><br>
|
||||
<?php echo $output["input 2"][1] ?><br>
|
||||
</td>
|
||||
<td class="input3">
|
||||
<?php
|
||||
if (!empty($output["input 3"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 3"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 3"][0] ?><br>
|
||||
<?php echo $output["input 3"][1] ?><br>
|
||||
</td>
|
||||
<td class="input4">
|
||||
<?php
|
||||
if (!empty($output["input 4"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 4"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 4"][0] ?><br>
|
||||
<?php echo $output["input 4"][1] ?><br>
|
||||
</td>
|
||||
<td class="input5">
|
||||
<?php
|
||||
if (!empty($output["input 5"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 5"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 5"][0] ?><br>
|
||||
<?php echo $output["input 5"][1] ?><br>
|
||||
</td>
|
||||
<td class="input6">
|
||||
<?php
|
||||
if (!empty($output["input 6"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 6"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 6"][0] ?><br>
|
||||
<?php echo $output["input 6"][1] ?><br>
|
||||
</td>
|
||||
<td class="input7">
|
||||
<?php
|
||||
if (!empty($output["input 7"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["input 7"]["img"]}'><br>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["input 7"][0] ?><br>
|
||||
<?php echo $output["input 7"][1] ?><br>
|
||||
</td>
|
||||
<td class="output1">
|
||||
<?php
|
||||
if (!empty($output["output"]["img"])) {
|
||||
echo "<img src='/img/items/{$output["output"]["img"]}'>";
|
||||
}
|
||||
?>
|
||||
<?php echo $output["output"][0] ?>
|
||||
<?php echo $output["output"][1] ?><br>
|
||||
|
||||
<?php
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
|
||||
if ($output["mods"][0]["mod $i"]) {
|
||||
echo "{$output["mods"][0]["mod $i"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][0]["mod $i chance"]) {
|
||||
echo "Chance:{$output["mods"][0]["mod $i chance"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][0]["mod $i min"]) {
|
||||
echo "Min:{$output["mods"][0]["mod $i min"]}<br>";
|
||||
}
|
||||
if ($output["mods"][0]["mod $i max"]) {
|
||||
echo "Max:{$output["mods"][0]["mod $i max"]}";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class="output2">
|
||||
<?php
|
||||
if (!empty($output["output 2"]["img"])) {
|
||||
echo "<p><img src='/img/items/{$output["output 2"]["img"]}'></p>";
|
||||
}
|
||||
?>
|
||||
<p><?php echo $output["output b"][0] ?></p>
|
||||
<p><?php echo $output["output b"][1] ?></p>
|
||||
<?php
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
|
||||
if ($output["mods"][1]["b mod $i"]) {
|
||||
echo "{$output["mods"][1]["b mod $i"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][1]["b mod $i chance"]) {
|
||||
echo "Chance:{$output["mods"][1]["b mod $i chance"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][1]["b mod $i min"]) {
|
||||
echo "Min:{$output["mods"][1]["b mod $i min"]}<br>";
|
||||
}
|
||||
if ($output["mods"][1]["b mod $i max"]) {
|
||||
echo "Max:{$output["mods"][1]["b mod $i max"]}";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class="output3">
|
||||
<?php
|
||||
if (!empty($output["output 3"]["img"])) {
|
||||
echo "<p><img src='/img/items/{$output["output 3"]["img"]}'></p>";
|
||||
}
|
||||
?>
|
||||
<p><?php echo $output["output c"][2] ?></p>
|
||||
<p><?php echo $output["output c"][1] ?></p>
|
||||
<?php
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
|
||||
if ($output["mods"][2]["c mod $i"]) {
|
||||
echo "{$output["mods"][2]["c mod $i"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][2]["c mod $i chance"]) {
|
||||
echo "Chance:{$output["mods"][2]["c mod $i chance"]}<br>";
|
||||
}
|
||||
|
||||
if ($output["mods"][2]["c mod $i min"]) {
|
||||
echo ">Min:{$output["mods"][2]["c mod $i min"]}<br>";
|
||||
}
|
||||
if ($output["mods"][2]["c mod $i max"]) {
|
||||
echo "Max:{$output["mods"][2]["c mod $i max"]}";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
//var_dump($output);
|
||||
unset($output);
|
||||
}// end each row loop
|
||||
|
||||
echo <<<EOT
|
||||
</tbody>
|
||||
<table>
|
||||
EOT;
|
||||
echo $htmlbottom;
|
||||
}
|
Reference in New Issue
Block a user