"; $idata = new D2ItemData(); $idesc = new D2ItemDesc(); // $idoc = new D2DocGenerator(); define('DB_FILE', $_SESSION['modname'] . ".db"); PDO_Connect("sqlite:" . DB_FILE); $idata = new D2ItemData(); // set $cmd if (!empty($_GET['cmd'])) $cmd = $_GET['cmd']; // create mod doc directory $dir = getcwd() . "/docs/{$_SESSION['modname']}"; mkdir($dir, 0777, true); $idoc = new D2DocGenerator(); $isc = $idoc->getIscProps(); $strings = $idoc->getStrings(); $itemtypesTbl = $idoc->getItemTypesTbl(); $namestr = $idoc->getNameStr(); $query = "SELECT ROWID,* FROM magicprefix"; $mpre = PDO_FetchAll($query); $query = "SELECT ROWID,* FROM magicsuffix"; $spre = PDO_FetchAll($query); // htmlTop was huge, so put it into another file and just include it require_once 'templates/htmlTop.php'; $htmlbottom = ""; // genDocUniqueItems if ($cmd == "genDocUniqueItems") { $tableTop = ''; $tableBottom = '
Name Lvl Lvl Req Type Code Item
'; // Grab unique item index only (to save on memory) $sql = "SELECT `index` FROM `uniqueitems` WHERE `enabled`='1'"; $uIndex = PDO_FetchAll($sql); $htmlFinal = ''; $htmlFinal .= $htmltop . $tableTop; echo $htmltop; echo $tableTop; ob_flush(); // Main loop: grab the data for each uIndex (index from uniqueitems.txt) foreach ($uIndex as $u) { $item = $idata->uniqueItems($u['index'], true); $itemBoxTop = ''; $itemBoxTop .= '' . $item['index'] . ''; $itemBoxTop .= '' . $item['lvl'] . ''; $itemBoxTop .= '' . $item["lvl req"] . ''; $itemBoxTop .= '' . $item["*type"] . ''; $itemBoxTop .= '' . $item['code'] . ''; $itemBoxTop .= <<

HTML; $itemBoxBottom = <<

HTML; echo $itemBoxTop; ob_flush(); $htmlFinal .= $itemBoxTop; // Index $props = ''; echo $props; echo $itemBoxBottom; ob_flush(); $htmlFinal .= $props . $itemBoxBottom; } $htmlFinal .= $tableBottom; echo $htmlbottom; $htmlFinal .= $htmlbottom; file_put_contents("$dir/uniqueitems.html", $htmlFinal); header("Location: /docs/{$_SESSION['modname']}/uniqueitems.html"); } // genDocCube if ($cmd == "genDocCube") { $htmlFinal = ''; $htmlFinal .= $htmltop; echo $htmltop; ob_flush(); $table = << Recipe Input 1 2 3 4 5 6 7 Output 1 2 3 EOT; echo $table; $htmlFinal .= $table; ob_flush(); $i_params = [ "any" => "Any Item", "low" => "Low Quality", "hiq" => "Superior Quality", "nor" => "Normal Quality", "mag" => "Magic item", "rar" => "Rare item", "set" => "Set item", "uni" => "Unique item", "crf" => "Crafted item", "tmp" => "Tempered item", "eth" => "Etherealitem ", "noe" => "Not Ethereal", "nos" => "No Socket (for input1)", "sock" => "Sockets", "pre" => "Prefix (ID from magicprefix.txt) - ID => (Row Number - 2)", "suf" => "Suffix (ID from magicsuffix.txt) - ID => (Row Number - 2)", "rep" => "Repair item durability", "rch" => "Recharge all of the skill charges on the Item", "qty" => 'Quantity', "upg" => "For inputs only, Item is upgraded.", "bas" => "Base item", "exc" => "Exceptional", "eli" => "Elite", "usetype" => "Uses base type of input1 for output", "useitem" => "Uses item from input1", "uns" => "Unsocket Item(destroys gems)", "rem" => "Unsocket Item(removes gems)", "reg" => "Reroll the item", "mod" => "Transfers properties from input1 to output item.", ]; // get all cube rows // changed enabled=1 to enabled > 0 for CubeOps.dll users $sql = "SELECT * FROM cubemain WHERE enabled > 0 AND `input 1` <> 'ib3' AND `input 1` <> 'ib2' AND `input 1` <> 'ib1' AND `input 2` <> 'ooc' AND `description` NOT LIKE '%Stone x%' AND `description` NOT LIKE 'Rune%' AND `description` NOT LIKE '%Unstacker%' "; $res = PDO_FetchAll($sql); // process each cube row here foreach ($res as $r) { $desc = str_replace('+', '
+
', $r['description']); $desc = str_replace('->', '
=
', $desc); $desc .= "
"; // grab all inputs $input_codes = array_filter([ "input 1" => $r["input 1"], "input 2" => $r["input 2"], "input 3" => $r["input 3"], "input 4" => $r["input 4"], "input 5" => $r["input 5"], "input 6" => $r["input 6"], "input 7" => $r["input 7"], ]); $input1_code = explode(',', $r['input 1'])[0]; foreach ($input_codes as $inputNum => $value) { if (str_contains($value, ',')) { $input_codes[$inputNum] = explode(",", $value); // hpot,qty=3 $iarray = 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 // $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\""; // $str = PDO_FetchOne($sql); $str = $strings[$iarray[0]]; // Assuming $strings array is defined // if empty str == 4-letter code, call $idoc->getItemName() if (empty($str)) { $input_codes[$inputNum][0] = $iarray[0]; } else { $input_codes[$inputNum][0] = $str; } // get image $input_codes[$inputNum]["img"] = $idoc->getImage($iarray[0]); $input_codes[$inputNum]['code'] = $iarray[0]; } else { $value .= ","; $input_codes[$inputNum] = explode(",", $value); // hpot,qty=3 $iarray = 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 // $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\""; // $str = PDO_FetchOne($sql); $str = $strings[$iarray[0]]; // Assuming $strings array is defined // if empty str == 4-letter code, so just display if (empty($str)) { $input_codes[$inputNum][0] = $iarray[0]; $input_codes[$inputNum]['code'] = $iarray[0]; } else { $input_codes[$inputNum][0] = $str; } // get image $input_codes[$inputNum]["img"] = $idoc->getImage($iarray[0]); } } // processs output, output b, output c // grab all inputs $output_codes = array_filter( [ "output" => str_replace('"', "", $r["output"]), "output b" => str_replace('"', "", $r["output b"]), "output c" => str_replace('"', "", $r["output c"]) ] ); //var_dump(array_filter($r)); //var_dump($r['input 1']); //var_dump($input1_code); //var_dump($output_codes); // output_codes is an array // output codes of outputs, like output, output b, output c. // each output can have 3 or 4 level item code or a amu,mag,pre=331 code // outputNum is output a, or output b, or output c, should have been called outputLetter whatever $oarray = []; foreach ($output_codes as $outputNum => $value) { //outputNum will be output, or output b, or c // value will be 3/4 letter code or sometimes 'Cow Portal' or words // or rin,mag,pre=353 // if value contains a comma, e.g., rin,mag,pre=353 // then explode it at the comma $output_codes[$outputNum] = explode(",", $value); // hpot,qty=3 $oarray = explode(",", $value); // hpot,qty=3 if ($oarray[0] == 'usetype' || $oarray[0] == 'useitem') { $oarray[0] = $input1_code; $oarray[2] = $i_params[$oarray[2]]; } //var_dump($oarray); //if (in_array($oarray[0], $strings)) { $str = $strings[$oarray[0]]; //} // "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\""; // clean str // $str = PDO_FetchOne($sql); if (str_contains($str, "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $str = preg_replace($p, "", $str); } // what if we set it to input codes 1 code //var_dump($strings[$oarray[0]]); // var_dump($oarray[0]); // var_dump($str); // if empty, str == 4-letter code, so just display if (empty($str)) { $output_codes[$outputNum][0] = ($oarray[0]); } else { $output_codes[$outputNum][0] = $str; } $output_codes[$outputNum]["img"] = $idoc->getImage($oarray[0]); //var_dump($oarray); //echo "Generated Output Codes Array"; //echo "input code: ". $input_codes['intput 1'][0]; //var_dump($output_codes); // 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); $e = explode("=", $mod[1]); $output_codes[$outputNum]['code'] = $e[0]; $output_codes[$outputNum]['value'] = $e[1]; // if ($e[0] == 'pre') { // $e[1]++; // // $pre = $mpre[$e[1]]; // // for ($i = 1; $i <= 3; $i++) { // // $mods = array_filter([ // "mod{$i}code" => $pre["mod{$i}code"], // "mod{$i}param" => $pre["mod{$i}param"], // "mod{$i}min" => $pre["mod{$i}min"], // "mod{$i}max" => $pre["mod{$i}max"], // ]); // } // // // var_dump($output['mods']); // foreach ($mods as $k => $v) { // $prop = ($v["mod " . $k + 1]); // $par = ($v["mod{$k}param"]) ?? ""; // $min = ($v["mod{$k}min"]) ?? $max; // $max = ($v["mod{$k}max"]) ?? $min; // // //var_dump($isc[$prop]); // // $pre['mods'][$k]["isc"] = $isc[$prop]; // // // // $params = [ // 'string1' => $pre['mods'][$k]["isc"]['string1'], // 'string2' => $pre['mods'][$k]["isc"]['string2'], // 'descfunc' => $pre['mods'][$k]["isc"]['descfunc'], // 'descval' => $pre['mods'][$k]["isc"]['descval'], // "prop" => $prop, // "par" => $par, // "min" => $min, // "max" => $max, // // "val1" => $funcval['val1'], // // "func1" => $funcval['func1'] // // 'item' => $return // ]; // // //var_dump($idesc->getDesc($params)); // // $output['pre']['mods'][$k]["str"] = $idesc->getDesc($params); // } // } } } $output = array_merge($input_codes, $output_codes); // Set description $output['desc'] = $desc; // process mods for each output $m = null; for ($counter = 1; $counter <= 5; $counter++) { $mods = array_filter([ "mod $counter" => $r["mod $counter"], "mod $counter chance" => $r["mod $counter chance"], "mod $counter param" => $r["mod $counter param"], "mod $counter min" => $r["mod $counter min"], "mod $counter max" => $r["mod $counter max"], "b mod $counter" => $r["b mod $counter"], "b mod $counter chance" => $r["b mod $counter chance"], "b mod $counter param" => $r["b mod $counter param"], "b mod $counter min" => $r["b mod $counter min"], "b mod $counter max" => $r["b mod $counter max"], "c mod $counter" => $r["c mod $counter"], "c mod $counter chance" => $r["c mod $counter chance"], "c mod $counter param" => $r["c mod $counter param"], "c mod $counter min" => $r["c mod $counter min"], "c mod $counter max" => $r["c mod $counter max"], ]); $m[] = array_filter($mods); } $output['mods'] = array_filter($m); //var_dump($output['mods']); $result = []; // var_dump($output['mods']); foreach ($output['mods'] as $k => $v) { $prop = ($v["mod " . $k + 1]); $par = ($v["mod " . $k + 1 . " param"]) ?? ""; $min = ($v["mod " . $k + 1 . " min"]) ?? $max; $max = ($v["mod " . $k + 1 . " max"]) ?? $min; //var_dump($isc[$prop]); $output['mods'][$k]["isc"] = $isc[$prop]; $params = [ 'string1' => $output['mods'][$k]["isc"]['string1'], 'string2' => $output['mods'][$k]["isc"]['string2'], 'descfunc' => $output['mods'][$k]["isc"]['descfunc'], 'descval' => $output['mods'][$k]["isc"]['descval'], "prop" => $prop, "par" => $par, "min" => $min, "max" => $max, // "val1" => $funcval['val1'], // "func1" => $funcval['func1'] // 'item' => $return ]; //var_dump($idesc->getDesc($params)); $output['mods'][$k]["str"] = $idesc->getDesc($params); } //var_dump($output); // At this point, $output contains raw accurte data // TODO: build output correctly // input1-input7,output a,b,c item codes can be found in $strings // However, if the codes are 4 letter codes, they are types // Type code sare not in $strings (tbl files) // Type codes are in ItemTypes in itemtypes.Code // Type code's string name entry is in itemtypes.ItemType table-- // first find in $strings. if not there, look in itemtypes // $htmlRow = ""; $htmlRow .= "" . $output['desc'] . ""; for ($i = 1; $i <= 7; $i++) { $htmlRow .= ""; // replace _input with input to get grey td bg colors back if (!empty($output["input $i"]["img"])) { $htmlRow .= "
"; if (str_contains($output["input $i"][0], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["input $i"][0] = preg_replace($p, "", $output["input $i"][0]); } // if the item is in itemtypes grab it, it's 4 letter code fron itemtypes $key1 = array_search($output["input $i"][0], $itemtypesTbl); // if the key's value is in itemtypes if ($itemtypesTbl[$key1] == $output["input $i"][0]) { $ostr = implode("
", (array_reverse(explode('\n', $key1)))); } else { $ostr = implode("
", (array_reverse(explode('\n', $output["input $i"][0])))); } $htmlRow .= $ostr . "
"; if (str_contains($output["input $i"][1], "=")) { $htmlRow .= $output["input $i"][1] . "
"; } else { $htmlRow .= $i_params[$output["input $i"][1]] . "
"; } } $htmlRow .= ""; } //var_dump($output); $htmlRow .= ""; // change _output to output if (!empty($output["output"]["img"])) { $htmlRow .= "
"; if (str_contains($output["output"][0], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output"][0] = preg_replace($p, "", $output["output"][0]); } $htmlRow .= '' . $output["output"][0] . "
"; $key1 = array_search($output["input $i"][0], $itemtypesTbl); if (str_contains($output["output"][1], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output"][1] = preg_replace($p, "", $output["output"][1]); } if ($i_params[$output["output"][0]]) { $htmlRow .= '' . $i_params[$output["output"][0]] . "
"; } else { $htmlRow .= $i_params[$output["output"][0]] . "
"; } if ($i_params[$output["output"][1]]) { $htmlRow .= $i_params[$output["output"][1]] . "
"; } else { $htmlRow .= $output["output"][1] . "
"; } $htmlRow .= $i_params[$output["output"][2]] . "
"; for ($i = 1; $i <= 5; $i++) { if ($output["mods"][0]["mod $i"]) { if (str_contains($output["mods"][0]["str"], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["mods"][0]["str"] = preg_replace($p, "", $output["mods"][0]["str"]); } $htmlRow .= str_replace("\n", "
", "{$output["mods"][0]["str"]}

"); } if ($output["mods"][0]["mod $i chance"]) { $htmlRow .= "Chance:{$output["mods"][0]["mod $i chance"]}
"; } } } $htmlRow .= ""; $htmlRow .= ""; // change _output2 to output if (!empty($output["output b"]["img"])) { $htmlRow .= "
"; if (str_contains($output["output b"][0], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output b"][0] = preg_replace($p, "", $output["output b"][0]); } if (str_contains($output["output b"][1], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output b"][1] = preg_replace($p, "", $output["output b"][1]); } $htmlRow .= $output["output b"][0] . "
"; $htmlRow .= $output["output b"][1] . "
"; for ($i = 1; $i <= 5; $i++) { if ($output["mods"][1]["mod $i"]) { $htmlRow .= "{$output["mods"][1]["mod $i"]}
"; } if ($output["mods"][1]["mod $i chance"]) { $htmlRow .= "Chance:{$output["mods"][1]["mod $i chance"]}
"; } if ($output["mods"][1]["mod $i min"]) { $htmlRow .= "Min:{$output["mods"][1]["mod $i min"]}
"; } if ($output["mods"][1]["mod $i max"]) { $htmlRow .= "Max:{$output["mods"][1]["mod $i max"]}"; } } } $htmlRow .= ""; $htmlRow .= ""; // change _output3 to normal if (!empty($output["output c"]["img"])) { $htmlRow .= "
"; if (str_contains($output["output c"][0], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output c"][0] = preg_replace($p, "", $output["output c"][0]); } if (str_contains($output["output c"][1], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $output["output c"][1] = preg_replace($p, "", $output["output c"][1]); } $htmlRow .= $output["output c"][0] . "
"; $htmlRow .= $output["output c"][1] . "
"; for ($i = 1; $i <= 5; $i++) { if ($output["mods"][2]["mod $i"]) { $htmlRow .= "{$output["mods"][2]["mod $i"]}
"; } if ($output["mods"][2]["mod $i chance"]) { $htmlRow .= "Chance:{$output["mods"][2]["mod $i chance"]}
"; } if ($output["mods"][2]["mod $i min"]) { $htmlRow .= "Min:{$output["mods"][2]["mod $i min"]}
"; } if ($output["mods"][2]["mod $i max"]) { $htmlRow .= "Max:{$output["mods"][2]["mod $i max"]}"; } } } $htmlRow .= ""; $htmlRow .= ""; echo $htmlRow; ob_flush(); $htmlFinal .= $htmlRow; ob_flush(); unset($output); }// end each row loop $tableBottom = ''; echo $tableBottom; echo $htmlbottom; ob_flush(); $htmlFinal .= $tableBottom . $htmlbottom; // echo $htmlFinal; // save file and redirect to it file_put_contents("$dir/cubemain.html", $htmlFinal); header("Location: docs/{$_SESSION['modname']}/cubemain.html"); } if ($cmd == "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']; } $isc = array_merge($isc1, $isc2); unset($isc1); unset($isc2); } // gem doc generator if ($cmd == "genDocGems") { $sql = " SELECT g.*,m.invfile,m.type,m.type2,s.String FROM gems as g LEFT JOIN misc as m ON g.code = m.code LEFT JOIN strings as s ON g.code = s.Key"; $res = array_filter(PDO_FetchAll($sql)); foreach ($res as $r) { for ($i = 1; $i <= 3; $i++) { $params = [ 'string1' => $isc[$r["weaponMod{$i}Code"]]['string1'], 'string2' => $isc[$r["weaponMod{$i}Code"]]['string2'], 'gstring1' => $isc[$r["weaponMod{$i}Code"]]['gstring'], 'gstring2' => $isc[$r["weaponMod{$i}Code"]]['gstring2'], 'descfunc' => $isc[$r["weaponMod{$i}Code"]]['descfunc'], 'descval' => $isc[$r["weaponMod{$i}Code"]]['descval'], 'dgrp' => $isc[$r["weaponMod{$i}Code"]]['dgrp'], 'dgrpfunc' => $isc[$r["weaponMod{$i}Code"]]['dgrpfunc'], 'dgrpval' => $isc[$r["weaponMod{$i}Code"]]['dgrpval'], "prop" => $isc[$r["weaponMod{$i}Code"]]['prop'] ]; // weapons $params["par"] = $r["weaponMod{$i}Param"]; $params["min"] = $r["weaponMod{$i}Min"]; $params["max"] = $r["weaponMod{$i}Max"]; if ($r["weaponMod{$i}Code"]) { $r["weaponMod{$i}Code"] = $idesc->getDesc($params); } $params = [ 'string1' => $isc[$r["helmMod{$i}Code"]]['string1'], 'string2' => $isc[$r["helmMod{$i}Code"]]['string2'], 'gstring1' => $isc[$r["helmMod{$i}Code"]]['gstring'], 'gstring2' => $isc[$r["helmMod{$i}Code"]]['gstring2'], 'descfunc' => $isc[$r["helmMod{$i}Code"]]['descfunc'], 'descval' => $isc[$r["helmMod{$i}Code"]]['descval'], 'dgrp' => $isc[$r["helmMod{$i}Code"]]['dgrp'], 'dgrpfunc' => $isc[$r["helmMod{$i}Code"]]['dgrpfunc'], 'dgrpval' => $isc[$r["helmMod{$i}Code"]]['dgrpval'], "prop" => $isc[$r["helmMod{$i}Code"]]['prop'] ]; // helms $params["par"] = $r["helmMod{$i}Param"]; $params["min"] = $r["helmMod{$i}Min"]; $params["max"] = $r["helmMod{$i}Max"]; if ($r["helmMod{$i}Code"]) { $r["helmMod{$i}Code"] = $idesc->getDesc($params); } $params = [ 'string1' => $isc[$r["helmMod{$i}Code"]]['string1'], 'string2' => $isc[$r["helmMod{$i}Code"]]['string2'], 'gstring1' => $isc[$r["helmMod{$i}Code"]]['gstring'], 'gstring2' => $isc[$r["helmMod{$i}Code"]]['gstring2'], 'descfunc' => $isc[$r["helmMod{$i}Code"]]['descfunc'], 'descval' => $isc[$r["helmMod{$i}Code"]]['descval'], 'dgrp' => $isc[$r["helmMod{$i}Code"]]['dgrp'], 'dgrpfunc' => $isc[$r["helmMod{$i}Code"]]['dgrpfunc'], 'dgrpval' => $isc[$r["helmMod{$i}Code"]]['dgrpval'], "prop" => $isc[$r["helmMod{$i}Code"]]['prop'] ]; //shields $params["par"] = $r["shieldMod{$i}Param"]; $params["min"] = $r["shieldMod{$i}Min"]; $params["max"] = $r["shieldMod{$i}Max"]; if ($r["shieldMod{$i}Code"]) { $r["shieldMod{$i}Code"] = $idesc->getDesc($params); } if (str_contains($r['String'], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $r['String'] = preg_replace($p, "", $r['String']); } } $gems[] = array_filter($r); } $htmlFinal = ''; $htmlFinal .= $htmltop; //echo $htmltop; //ob_flush(); $table = '
'; //echo $table; $htmlFinal .= $table; //ob_flush(); // $gems are all the gems, processed, now display them foreach ($gems as $g) { if ($g['name'] == "Expansion") { continue; } $htmlRow = ""; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= " "; $htmlRow .= ""; $htmlFinal .= $htmlRow; //echo $htmlRow; // ob_flush(); } $htmlFinal .= $tableBottom . $htmlbottom; //echo $tableBottom . $htmlbottom; //ob_flush(); //ob_start(); file_put_contents("$dir/gems.html", $htmlFinal); header("Location: /docs/{$_SESSION['modname']}/gems.html", TRUE, 301); } // generate runewords if ($cmd == 'genDocRunewords') { $sql = 'SELECT * FROM runes'; $runes = array_filter(PDO_FetchAll($sql)); $sql = 'SELECT code,invfile from misc'; $rune_inv_codes = array_filter(PDO_FetchAssoc($sql)); $sql = 'SELECT * FROM strings'; $strings = array_filter(PDO_FetchAssoc($sql)); $sql = 'SELECT Itemtype,Code,Equiv1 FROM itemtypes'; $itypes = array_flip(array_filter(PDO_FetchAssoc($sql))); $tableTop = << EOT; foreach ($runes as $rune) { // Grab Rune Names $name = $strings[$rune['Name']]; $itype1 = $itypes[$rune['itype1']]; $itype2 = $itypes[$rune['itype2']]; $itype3 = $itypes[$rune['itype3']]; $itype4 = $itypes[$rune['itype4']]; $itype5 = $itypes[$rune['itype5']]; $itype6 = $itypes[$rune['itype6']]; $rr_img[1] = $rune_inv_codes[$rune['Rune1']]; $rr_img[2] = $rune_inv_codes[$rune['Rune2']]; $rr_img[3] = $rune_inv_codes[$rune['Rune3']]; $rr_img[4] = $rune_inv_codes[$rune['Rune4']]; $rr_img[5] = $rune_inv_codes[$rune['Rune5']]; $rr_img[6] = $rune_inv_codes[$rune['Rune6']]; $rr[1] = str_replace('', '', $strings[$rune['Rune1']]); $rr[2] = str_replace('', '', $strings[$rune['Rune2']]); $rr[3] = str_replace('', '', $strings[$rune['Rune3']]); $rr[4] = str_replace('', '', $strings[$rune['Rune4']]); $rr[5] = str_replace('', '', $strings[$rune['Rune5']]); $rr[6] = str_replace('', '', $strings[$rune['Rune6']]); for ($i = 1; $i <= 6; $i++) { if (str_contains($rr[$i], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $rr[$i] = preg_replace($p, "", $rr[$i]); } } $rr = array_filter($rr); $rune_count = count($rr); $rune_count_duplicates = array_count_values($rr); $rcd = null; foreach ($rune_count_duplicates as $k => $v) { // rune * count $rcd[] = "$k x$v"; } for ($i = 1; $i <= 7; $i++) { if ($rune["T1Code{$i}"] != '') { $params = [ "string1" => $isc[$rune["T1Code{$i}"]]["string1"], "string2" => $isc[$rune["T1Code{$i}"]]["string2"], "gstring1" => $isc[$rune["T1Code{$i}"]]["gstring"], "gstring2" => $isc[$rune["T1Code{$i}"]]["gstring2"], "descfunc" => $isc[$rune["T1Code{$i}"]]["descfunc"], "descval" => $isc[$rune["T1Code{$i}"]]["descval"], "dgrp" => $isc[$rune["T1Code{$i}"]]["dgrp"], "dgrpfunc" => $isc[$rune["T1Code{$i}"]]["dgrpfunc"], "dgrpval" => $isc[$rune["T1Code{$i}"]]["dgrpval"], "prop" => $isc[$rune["T1Code{$i}"]]["prop"] ]; $params["par"] = $rune["T1Param{$i}"]; $params["min"] = $rune["T1Min{$i}"]; $params["max"] = $rune["T1Max{$i}"]; $props[$i] = $idesc->getDesc($params); } } $props = array_unique($props); $rr_img = array_filter($rr_img); $img_s = ''; foreach ($rr_img as $k) { $img_s .= ""; } $tableRowsRunes .= << EOT; } echo $htmltop; echo $tableTop; echo $tableRowsRunes; echo "
Name Code Type Mods Weapons Helms Shields

{$g['String']}
{$g['code']} {$g['type']} Mods: {$g['nummods']}
{$g['weaponMod1Code']}
{$g['weaponMod2Code']}
{$g['weaponMod3Code']}

{$g['helmMod1Code']}
{$g['helmMod2Code']}
{$g['helmMod3Code']}

{$g['shieldMod1Code']}
{$g['shieldMod2Code']}
{$g['shieldMod3Code']}
Name Runes Properties

$name

$itype1
$itype2
$itype3
$itype4
$itype5
$itype6

$img_s

$rcd[0]
$rcd[1]
$rcd[2]
$rcd[3]
$rcd[4]
$rcd[5]

  • $name
  • $props[1]
  • $props[2]
  • $props[3]
  • $props[4]
  • $props[5]
  • $props[6]
  • $props[7]
"; echo $htmlbottom; $htmlFinal = $htmltop . $tableTop . $tableRowsRunes . $tableBottom; file_put_contents("$dir/runewords.html", $htmlFinal); header("Location: docs/{$_SESSION['modname']}/runewords.html"); } // generate item list page if ($cmd == "genDocMisc") { $filter = "smh"; $sql = "SELECT DISTINCT * FROM misc WHERE spawnable='1'"; // LEFT JOIN gems ON misc.code = gems.code //WHERE gems.code IS NULL AND misc.spawnable=1 // ";// AND misc.namestr NOT LIKE '%$filter%' $res = PDO_FetchAll($sql); $res = array_reverse($res); //$sql = "SELECT * FROM armor WHERE spawnable=1"; //$res = array_merge(PDO_FetchAll($sql), $res); //$sql = "SELECT * FROM weapons WHERE spawnable=1"; //$res = array_merge(PDO_FetchAll($sql), $res); // ddump(array_keys($res[0])); $tableTop = << Name Lvl Lvl Req Item EOT; $htmlFinal = null; $htmlFinal = $htmltop . $tableTop; $tr = null; foreach ($res as $r) { $data = null; $stats = null; //ddump($r); // if hammers, then get itemcode's string if ($r['namestr'] == 'smh') { $data['name'] = $strings[$r['namestr']] . "
" . $strings[$r['code']]; $p = "/ÿc[\d:;\/.]/i"; $data['name'] = preg_replace($p, "", $data['name']); $data['name'] = array_reverse(explode('\n', $data['name'])); $data['name'] = (implode('\n', $data['name'])); } else { $data['name'] = $strings[$r['namestr']]; if (strpos($data['name'], '\n') !== false) { $lines = explode('\n', $data['name']); $reversedLines = array_reverse($lines); $data['name'] = implode("
", $reversedLines); } } if (str_contains($data['name'], "ÿc")) { $p = "/ÿc[\d:;\/.]/i"; $data['name'] = preg_replace($p, "", $data['name']); } $name = array_reverse(explode('}', $data['name'])); $data['name'] = (implode('
', $name)); // later display these in a li $img = "img/items/{$r['invfile']}.png"; $data['level'] = "Level: {$r['level']}"; $data['levelreq'] = "Level Required: {$r['levelreq']}"; if ($r['rarity']) { $data['rarity'] = $armorRack = "Can drop from Armor Racks"; } if ($r['speed'] > 0) { $data['speed'] = "Slows your character down"; } if ($r['durability']) { $data['durability'] = "Base durability: {$r['durability']}"; } if ($r['hasinv']) { $sql = "SELECT MaxSock40 FROM itemtypes WHERE `Code`='{$r['type']}'"; $data["maxsock"] = PDO_FetchOne($sql); if ($r['gemapplytype'] == "0") { $data['gemapplytype'] = "Socketing gives Weapon stats"; } else if ($r['gemapplytype'] == "1") { $data['gemapplytype'] = "Socketing gives Armor/Helm stats"; } else if ($r['gemapplytype'] == "2") { $data['gemapplytype'] = "Socketing gives Shield stats"; } $data['hasinv'] = "Sockets ({$data['maxsock']})"; } if ($r['Transmogrify']) { $tmogtype = ($strings[$r['TMogType']]); $data['Transmogrify'] = "Can right click transmogrify into "; $p = "/ÿc[\d:;\/.]/i"; $data['Transmogrify'] = preg_replace($p, "", $data['Transmogrify']); $tmogtype = preg_replace($p, "", $tmogtype); $tmogtype = array_reverse(explode('\n', $tmogtype)); $tmogtype = (implode(' ', $tmogtype)); $tmogtype = str_replace(" Ess", '
Ess', $tmogtype); $tmogtype = str_replace(" Cube", '
Cube', $tmogtype); $data['tmogtype'] = $tmogtype; $transmogrify = array_reverse(explode('\n', $data['Transmogrify'])); $data['Transmogrify'] = (implode('
', $transmogrify)); } if (!empty($r['useable'])) { $data['useable'] = "Can be right clicked"; } if ($r['throwable']) { $data['throwable'] = "Can be thrown"; } if ($r['unique']) { $data['unique'] = "Can only spawn as a unique item."; } if ($r['stackable']) { $data['stackable'] = "Can be stacked"; } if ($r['quest']) { $data['quest'] = "Quest Item"; } if ($r['spelldesc']) { $data['spelldesc'] = $strings[$r['spelldescstr']]; $p = "/ÿc[\d:;\/.]/i"; $data['spelldesc'] = preg_replace($p, "", $data['spelldesc']); $spelldesc = array_reverse(explode('\n', $data['spelldesc'])); $data['spelldesc'] = (implode('
', $spelldesc)); } if ($r['nameable']) { $data['nameable'] = "Can be personalized by Anya"; } $statFields = ['stat1', 'stat2', 'stat3']; $calcFields = ['calc1', 'calc2', 'calc3']; foreach ($statFields as $field) { if (isset($r[$field])) { $stats[$field] = "{$r[$field]}"; } } foreach ($calcFields as $field) { if (isset($r[$field])) { $stats[$field] = "{$r[$field]}"; } } $data = array_filter($data); if ($stats) $stat = array_filter($stats); $tr .= << {$data['name']} {$data['level']} {$data['levelreq']}

{$data['name']}

  • Item {$data['level']}
  • {$data['levelreq']}
  • {$data['rarity']}
  • {$data['speed']}
  • {$data['durability']}
  • {$data['hasinv']}
  • {$data['gemapplytype']}
  • {$data['throwable']}
  • {$data['useable']}
  • {$data['unique']}
  • {$data['stackable']}
  • {$data['Transmogrify']}{$data['tmogtype']}
  • {$data['quest']}
  • {$data['nameable']}
  • {$data['spelldesc']}
  • {$stats['stat1']} {$stats['calc1']}
  • {$stats['stat2']} {$stats['calc2']}
  • {$stats['stat3']} {$stats['calc3']}

EOT; } $htmlFinal = $htmltop . $tableTop . $tr . $tableBottom . $htmlbottom; file_put_contents("$dir/misc.html", $htmlFinal); header("Location: docs/{$_SESSION['modname']}/misc.html"); } // Armor.txt docs generator if ($cmd == 'genDocArmor') { $tableTop = << body { font-family: Tahoma,Arial,Sans-Serif} table { font-family: ;} EOT; $tableBottom = '
Name Lvl Required Lvl Required Str Min AC Max AC Block Chance
'; $sql = "SELECT * FROM armor WHERE spawnable=1 AND namestr != ''"; $res = PDO_FetchAll($sql); foreach ($res as $r) { $name = (!empty($strings[$r['namestr']])) ? $strings[$r['namestr']] : $r['name']; if ($r['indestructible'] == '1') { $indestructable = "Yes"; } else { $indestructable = "No"; } $imgUnique = (!empty($r['uniqueinvfile'])) ? "
" : ""; $imgSet = (!empty($r['setinvfile'])) ? "
" : ""; if (!empty($r['auto prefix'])) { $sql = "SELECT * FROM automagic WHERE `group` = ?"; $ret = PDO_FetchRow($sql, [$r['auto prefix']]); // ddump($isc[$ret['mod1code']]); for ($i = 1; $i <= 3; $i++) { if ($ret["mod{$i}code"] != '') { // ddump($isc[$ret["mod{$i}code"]]['string1']); $params = [ "string1" => $isc[$ret["mod{$i}code"]]["string1"], "string2" => $isc[$ret["mod{$i}code"]]["string2"], "gstring1" => $isc[$ret["mod{$i}code"]]["gstring"], "gstring2" => $isc[$ret["mod{$i}code"]]["gstring2"], "descfunc" => $isc[$ret["mod{$i}code"]]["descfunc"], "descval" => $isc[$ret["mod{$i}code"]]["descval"], "dgrp" => $isc[$ret["mod{$i}code"]]["dgrp"], "dgrpfunc" => $isc[$ret["mod{$i}code"]]["dgrpfunc"], "dgrpval" => $isc[$ret["mod{$i}code"]]["dgrpval"], "prop" => $isc[$ret["mod{$i}code"]]["prop"] ]; $params["par"] = $ret["mod{$i}param"]; $params["min"] = $ret["mod{$i}min"]; $params["max"] = $ret["mod{$i}max"]; $props[$i] = $idesc->getDesc($params); } } // dump($props); $autoprefix = "Automagic/Auto prefix Mods"; } $strbonus = (!empty($r['StrBonus'])) ? "Strength Bonus: {$r['StrBonus']}" : ""; $block = (!empty($r['block'])) ? "Block: {$r['block']}" : ""; $tr .= <<
  • $name
  • $imgC
  • Defense: [{$r['minac']} - {$r['maxac']}]
  • Weight: {$r['speed']}
  • Level: {$r['level']}
  • Required Level: {$r['levelreq']}
  • Required Strength: {$r['reqstr']}
  • Indestructable: $indestructable
  • Durability: {$r['durability']}
  • Cost: {$r['cost']}
  • Normal: {$strings[$r['normcode']]}
  • Exceptional:
    {$strings[$r['ubercode']]} $imgSet
  • Elite:
    {$strings[$r['ultracode']]} $imgUnique
  • Sockets: {$r['gemsockets']}
  • $autoprefix{$props[0]}
  • {$props[1]}
  • {$props[2]}
  • $strbonus
  • $block
Level:
{$r['level']} Level Required:
{$r['levelreq']} Requird Strength:
{$r['reqstr']} Min AC:
{$r['minac']} Max AC:
{$r['maxac']} Block:
{$r['block']} EOT; } $htmlFinal = $htmltop . $tableTop . $tr . $tableBottom . $htmlbottom; ob_flush(); echo $htmlFinal; file_put_contents("$dir/armor.html", $htmlFinal); header("Location: docs/{$_SESSION['modname']}/armor.html"); } // Generate weapons.txt docs if ($cmd == 'genDocWeapons') { $tableTop = << body { font-family: Tahoma,Arial,Sans-Serif} table { font-family: ;} EOT; $tableBottom = '
Name Lvl Required Lvl Required Str Min AC Max AC
'; $sql = "SELECT * FROM weapons WHERE spawnable=1 AND namestr != ''"; $res = PDO_FetchAll($sql); foreach ($res as $r) { $name = (!empty($strings[$r['namestr']])) ? $strings[$r['namestr']] : $r['name']; if ($r['indestructible'] == '1') { $indestructable = "Yes"; } else { $indestructable = "No"; } $imgUnique = (!empty($r['uniqueinvfile'])) ? "
" : ""; $imgSet = (!empty($r['setinvfile'])) ? "
" : ""; if (!empty($r['auto prefix'])) { $sql = "SELECT * FROM automagic WHERE `group` = ?"; $ret = PDO_FetchRow($sql, [$r['auto prefix']]); // ddump($isc[$ret['mod1code']]); for ($i = 1; $i <= 3; $i++) { if ($ret["mod{$i}code"] != '') { // ddump($isc[$ret["mod{$i}code"]]['string1']); $params = [ "string1" => $isc[$ret["mod{$i}code"]]["string1"], "string2" => $isc[$ret["mod{$i}code"]]["string2"], "gstring1" => $isc[$ret["mod{$i}code"]]["gstring"], "gstring2" => $isc[$ret["mod{$i}code"]]["gstring2"], "descfunc" => $isc[$ret["mod{$i}code"]]["descfunc"], "descval" => $isc[$ret["mod{$i}code"]]["descval"], "dgrp" => $isc[$ret["mod{$i}code"]]["dgrp"], "dgrpfunc" => $isc[$ret["mod{$i}code"]]["dgrpfunc"], "dgrpval" => $isc[$ret["mod{$i}code"]]["dgrpval"], "prop" => $isc[$ret["mod{$i}code"]]["prop"] ]; $params["par"] = $ret["mod{$i}param"]; $params["min"] = $ret["mod{$i}min"]; $params["max"] = $ret["mod{$i}max"]; $props[$i] = $idesc->getDesc($params); } } // dump($props); $autoprefix = "Automagic/Auto prefix Mods"; } $strbonus = (!empty($r['StrBonus'])) ? "Strength Bonus: {$r['StrBonus']}" : ""; if (empty($r['mindmg']) OR empty($r['maxdmg'])) { $mindmg = $r['2handmindam']; $maxdmg = $r['2handmaxdam']; } else { $mindmg = $r['mindmg']; $maxdmg = $r['maxdmg']; } $tr .= <<
  • $name
  • Damage: [$mindmg - $maxdmg]
  • Weight: {$r['speed']}
  • Level: {$r['level']}
  • Required Level: {$r['levelreq']}
  • Required Strength: {$r['reqstr']}
  • Indestructable: $indestructable
  • Durability: {$r['durability']}
  • Cost: {$r['cost']}
  • Normal: {$strings[$r['normcode']]}
  • Exceptional: {$strings[$r['ubercode']]} $imgSet
  • Elite: {$strings[$r['ultracode']]} $imgUnique
  • Sockets: {$r['gemsockets']}
  • $autoprefix{$props[0]}
  • {$props[1]}
  • {$props[2]}
  • $strbonus
  • $block
Level:
{$r['level']} Level Required:
{$r['levelreq']} Requird Strength:
{$r['reqstr']} Min Dmg:
{$mindmg} Max Dmg:
{$maxdmg} EOT; } $htmlFinal = $htmltop . $tableTop . $tr . $tableBottom . $htmlbottom; ob_flush(); echo $htmlFinal; file_put_contents("$dir/weapons.html", $htmlFinal); header("Location: docs/{$_SESSION['modname']}/weapons.html"); }