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

View File

@ -266,6 +266,9 @@ EOT;
FROM cubemain FROM cubemain
WHERE enabled > 0 WHERE enabled > 0
AND `input 1` <> 'ib3' 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 '%Stone x%'
AND `description` NOT LIKE '%Unstacker%' "; AND `description` NOT LIKE '%Unstacker%' ";
$res = PDO_FetchAll($sql); $res = PDO_FetchAll($sql);
@ -342,7 +345,7 @@ EOT;
] ]
); );
// var_dump($output_codes); //var_dump($output_codes);
// output_codes is an array // output_codes is an array
// output codes of outputs, like output, output b, output c. // 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 // 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); $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)) { if (empty($str)) {
$output_codes[$outputNum][0] = ($oarray[0]); $output_codes[$outputNum][0] = ($oarray[0]);
} else { } else {
@ -377,6 +384,9 @@ EOT;
} else { // else output code is three/four letter code } else { // else output code is three/four letter code
$value .= ","; $value .= ",";
//var_dump($output_codes[$outputNum]);
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3 $output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3 $oarray = explode(",", $value); // hpot,qty=3
$str = $strings[$oarray[0]]; //"SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\""; $str = $strings[$oarray[0]]; //"SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
@ -389,7 +399,7 @@ EOT;
} }
// if empty str == 4-letter code, so just display // if empty, str == 4-letter code, so just display
if (empty($str)) { if (empty($str)) {
$output_codes[$outputNum][0] = ($oarray[0]); $output_codes[$outputNum][0] = ($oarray[0]);
} else { } else {
@ -532,6 +542,8 @@ EOT;
} }
//var_dump($output);
$htmlRow .= "<td class='_output1'>"; // change _output to output $htmlRow .= "<td class='_output1'>"; // change _output to output
if (!empty($output["output"]["img"])) { if (!empty($output["output"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output"]["img"]}'><br>"; $htmlRow .= "<img src='img/items/{$output["output"]["img"]}'><br>";
@ -1051,6 +1063,12 @@ EOT;
$data['name'] = (implode('\n', $data['name'])); $data['name'] = (implode('\n', $data['name']));
} else { } else {
$data['name'] = $strings[$r['namestr']]; $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"; $p = "/ÿc[\d:;\/.]/i";
$data['spelldesc'] = preg_replace($p, "", $data['spelldesc']); $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)); $data['spelldesc'] = (implode('<br>', $spelldesc));
} }