gendoc fixes, cube docs need fixing

This commit is contained in:
Hash Borgir 2023-08-14 01:17:48 -06:00
parent 9dc93cbcbd
commit a60492e230
2 changed files with 31 additions and 20 deletions

View File

@ -43,9 +43,6 @@ if ($result) {
// Define the path to the TSV file
$tsvFilePath = $_SESSION['path'] . "/treasureclassex.txt";
// Open the file for writing
$fileHandle = fopen($tsvFilePath, 'w');
@ -56,22 +53,18 @@ $query = "SELECT * FROM treasureclassex";
$result = $db->query($query);
// Write the column headers to the file
$columnNames = $result->numColumns();
$headers = [];
for ($i = 0; $i < $columnNames; $i++) {
$headers[] = $result->columnName($i);
$columnNames = [];
for ($i = 0; $i < $result->numColumns(); $i++) {
$columnNames[] = $result->columnName($i);
}
fputcsv($fileHandle, $headers, "\t");
fwrite($fileHandle, implode("\t", $columnNames) . "\n");
// Write the rows to the file
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
fputcsv($fileHandle, $row, "\t");
while ($row = $result->fetchArray(SQLITE3_NUM)) {
fwrite($fileHandle, implode("\t", $row) . "\n");
}
// Close the file
fclose($fileHandle);
echo "Successfully updated and written to TSV file!";
// Close the database connection
$db->close();
echo "Successfully updated and written to TSV file!";

View File

@ -266,6 +266,9 @@ EOT;
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 '%Unstacker%' ";
$res = PDO_FetchAll($sql);
@ -342,7 +345,7 @@ EOT;
]
);
// var_dump($output_codes);
//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
@ -366,7 +369,11 @@ EOT;
$str = preg_replace($p, "", $str);
}
// if empty str == 4-letter code, so just display
if ($output_codes[$outputNum] == 'usetype' || $output_codes[$outputNum] == 'useitem') {
$output_codes[$outputNum][0] = $input_codes[1];
}
// if empty, str == 4-letter code, so just display
if (empty($str)) {
$output_codes[$outputNum][0] = ($oarray[0]);
} else {
@ -377,6 +384,9 @@ EOT;
} else { // else output code is three/four letter code
$value .= ",";
//var_dump($output_codes[$outputNum]);
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$str = $strings[$oarray[0]]; //"SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
@ -389,8 +399,8 @@ EOT;
}
// if empty str == 4-letter code, so just display
if (empty($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;
@ -532,6 +542,8 @@ EOT;
}
//var_dump($output);
$htmlRow .= "<td class='_output1'>"; // change _output to output
if (!empty($output["output"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output"]["img"]}'><br>";
@ -540,7 +552,7 @@ EOT;
$output["output"][0] = preg_replace($p, "", $output["output"][0]);
}
$htmlRow .= '<span style="color: #AF833B;">' . $output["output"][0] . "</span><br>";
$htmlRow .= '<span style="color: #AF833B;">' . $output["output"][0] . "</span><br>";
$key1 = array_search($output["input $i"][0], $itemtypesTbl);
if (str_contains($output["output"][1], "ÿc")) {
@ -1051,6 +1063,12 @@ EOT;
$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("<br>", $reversedLines);
}
}
@ -1132,7 +1150,7 @@ EOT;
$p = "/ÿc[\d:;\/.]/i";
$data['spelldesc'] = preg_replace($p, "", $data['spelldesc']);
$spelldesc = array_reverse(explode('}', $data['spelldesc']));
$spelldesc = array_reverse(explode('\n', $data['spelldesc']));
$data['spelldesc'] = (implode('<br>', $spelldesc));
}