d2tools/tmp/code.php

169 lines
4.4 KiB
PHP
Raw Permalink Normal View History

2021-05-10 07:15:44 +00:00
<?php
foreach ($input_codes as $key => $val) {
// if contains comma, explode
if (str_contains($val, ',')) {
/*
* array (size=3)
'input 1' => string 'hpot,qty=3' (length=10)
'input 2' => string 'mpot,qty=3' (length=10)
'input 3' => string 'gem0' (length=4)
*
*/
$e = explode(",", $val); // hpot,qty=3
//var_dump($e);
//$sql = "SELECT `String` FROM strings WHERE Key = \"{$e[0]}\"";
//$r = PDO_FetchOne($sql);
//var_dump($r);
//var_dump($r);
// if item code has a string, it's an item. else it's type
if (!empty($r)) {
$input_codes[$key] = $e;
} else {
$sql = "SELECT `name` FROM misc WHERE `type` = \"{$e[0]}\"";
$r = PDO_FetchOne($sql);
if (empty($r)) {
$sql = "SELECT `name` FROM armor WHERE `type` = \"{$e[0]}\"";
$r = PDO_FetchOne($sql);
}
if (empty($r)) {
$sql = "SELECT `name` FROM weapons WHERE `type` = \"{$e[0]}\"";
$r = PDO_FetchOne($sql);
}
$input_codes[$key] = $e;
}
$input_codes[$key . "_param2"] = $e[1];
$input_codes[$key . "_param3"] = $e[2];
}
var_dump($input_codes);
//
// if it doesn't contain a comma, get string from TBL
$sql = "SELECT `String` FROM strings WHERE Key = \"$val\"";
$r = PDO_FetchOne($sql);
if (!empty($r)) {
$input_codes[$key] = $r;
} else {
$sql = "SELECT `name` FROM armor WHERE `type` = \"$val\"";
$str = PDO_FetchOne($sql);
if (empty($str)) {
$sql = "SELECT `name` FROM misc WHERE `type` = \"$val\"";
$str = PDO_FetchOne($sql);
}
if (empty($str)) {
$sql = "SELECT `name` FROM weapons WHERE `type` = \"$val\"";
$str = PDO_FetchOne($sql);
}
$input_codes[$key] = $str;
}
}
//var_dump($input_codes);
// foreach ($input_codes as $input) {
// $sql = "SELECT `String` FROM strings WHERE Key = \"{$e[0]}\"";
// $r = PDO_FetchOne($sql);
// $input_codes[$key] = $r;
// }
//var_dump($input_codes);
// for each input,
// check to see if it has comma
// if comma, then explode
// else get string for code
// if string not found, display code
// if string is found, display item string from tbl
// foreach ($input_codes as $key => $val) {
//
// // if contains comma, explode
// if (str_contains($val, ',')) {
//
//
// /*
// * array (size=3)
// 'input 1' => string 'hpot,qty=3' (length=10)
// 'input 2' => string 'mpot,qty=3' (length=10)
// 'input 3' => string 'gem0' (length=4)
// *
// */
//
//
// $e = explode(",", $val); // hpot,qty=3
//
// //var_dump($e);
// //$sql = "SELECT `String` FROM strings WHERE Key = \"{$e[0]}\"";
// //$r = PDO_FetchOne($sql);
// //var_dump($r);
// //var_dump($r);
// // if item code has a string, it's an item. else it's type
// if (!empty($r)) {
// $input_codes[$key] = $e;
// } else {
// $sql = "SELECT `name` FROM misc WHERE `type` = \"{$e[0]}\"";
// $r = PDO_FetchOne($sql);
//
// if (empty($r)) {
// $sql = "SELECT `name` FROM armor WHERE `type` = \"{$e[0]}\"";
// $r = PDO_FetchOne($sql);
// }
// if (empty($r)) {
// $sql = "SELECT `name` FROM weapons WHERE `type` = \"{$e[0]}\"";
// $r = PDO_FetchOne($sql);
// }
//
// $input_codes[$key] = $r;
// }
// $input_codes[$key . "_param2"] = $e[1];
// $input_codes[$key . "_param3"] = $e[2];
// }
// //var_dump($input_codes);
// //
// // if it doesn't contain a comma, get string from TBL
//
// $sql = "SELECT `String` FROM strings WHERE Key = \"$val\"";
// $r = PDO_FetchOne($sql);
// if (!empty($r)) {
// $input_codes[$key] = $r;
// } else {
// $sql = "SELECT `name` FROM armor WHERE `type` = \"$val\"";
// $str = PDO_FetchOne($sql);
//
// if (empty($str)) {
// $sql = "SELECT `name` FROM misc WHERE `type` = \"$val\"";
// $str = PDO_FetchOne($sql);
// }
// if (empty($str)) {
// $sql = "SELECT `name` FROM weapons WHERE `type` = \"$val\"";
// $str = PDO_FetchOne($sql);
// }
//
// $input_codes[$key] = $str;
// }
// }
//var_dump($input_codes);
// foreach ($input_codes as $input) {
// $sql = "SELECT `String` FROM strings WHERE Key = \"{$e[0]}\"";
// $r = PDO_FetchOne($sql);
// $input_codes[$key] = $r;
// }
// grab each item code's string
// foreach ($inputs_codes as $i) {
// $sql = "SELECT `String` FROM strings WHERE Key = \"$i\"";
// $r = PDO_FetchOne($sql);
// $inputs[$i] = $r;
// }
//
// $output = $res["output"];
//ddump($inputs);
//file_put_contents("$dir/cube.html", $htmlFinal);
//header("Location: /docs/{$_SESSION['modname']}/cube.html");