latest changes, need to debug gendoc runewords. db is corrupted somehow. Older db doesn't have bug.

This commit is contained in:
Hash Borgir
2023-06-23 17:41:06 -06:00
parent ee5769781b
commit 8ec5186cbe
1783 changed files with 147 additions and 825 deletions

View File

@@ -155,7 +155,7 @@ WHERE sk.charclass = '$class' AND sk.skilldesc != 'dummy'";
// readh(offset, numbytes), convert toBits, feed into D2Item
$_items = [];
foreach ($itemOffsets as $offset => $bytes) {
$this->items[] = new D2Item($this->ByteReader->toBits($this->ByteReader->readh($offset, $bytes)), $this->cData['CharacterName']); // Create a new D2Item object and add it to the items array
//$this->items[] = new D2Item($this->ByteReader->toBits($this->ByteReader->readh($offset, $bytes)), $this->cData['CharacterName']); // Create a new D2Item object and add it to the items array
}
}

View File

@@ -48,147 +48,127 @@
class D2Database {
/**
* D2Database constructor.
*
*/
public function __construct() {
PDO_Connect("sqlite:" . DB_FILE); // Connect to the SQLite database using the specified file.
}
PDO_Connect("sqlite:" . DB_FILE);
}
/**
* Create tables based on file and data.
*
* @param string $file The file name.
* @param array $data The data array.
* @param $file
* @param $data
* @return void
*/
public function createTables($file, $data) {
$tableName = basename($file); // Extract the base name of the file.
$tableName = strtolower(substr($tableName, 0, -4)); // Convert the table name to lowercase and remove the file extension.
$sql = '';
if (!empty($data[0])) { // Check if the data array is not empty.
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` ("; // Start building the SQL query to create a table.
foreach ($data[0] as $k => $v) { // Iterate over the columns and their corresponding values.
if (is_numeric($v)) { // Check if the value is numeric.
$dataType = "INT"; // Set the data type as INT.
} else {
$dataType = "VARCHAR(255)"; // Set the data type as VARCHAR(255).
}
$sql .= "`$k` $dataType DEFAULT '',"; // Add the column and its data type to the SQL query.
}
$sql = rtrim($sql, ","); // Remove the trailing comma.
$sql .= ")"; // Close the table creation query.
$res = PDO_Execute($sql); // Execute the query to create the table.
}
}
$tableName = basename($file);
$tableName = strtolower(substr($tableName, 0, -4));
$sql = '';
if (!empty($data[0])) {
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` (";
foreach ($data[0] as $k => $v) {
if (is_numeric($v)) {
$dataType = "INT";
} else {
$dataType = "VARCHAR(255)";
}
$sql .= "`$k` $dataType DEFAULT '',";
}
$sql = rtrim($sql, ",");
$sql .= ")";
$res = PDO_Execute($sql);
}
}
/**
* Fill tables based on file and data.
*
* @param string $file The file name.
* @param array $data The data array.
* @param $file
* @param $data
* @return void
*/
public function fillsTables($file, $data) {
$tableName = basename($file); // Extract the base name of the file.
$tableName = strtolower(substr($tableName, 0, -4)); // Convert the table name to lowercase and remove the file extension.
$sql = '';
$tableName = basename($file);
$tableName = strtolower(substr($tableName, 0, -4));
if (!empty($data)) { // Check if the data array is not empty.
foreach ($data as $d) { // Iterate over the data rows.
if (!empty($d)) { // Check if the row is not empty.
$sql = "INSERT INTO `$tableName` ("; // Start building the SQL query to insert into the table.
$sql = '';
if (!empty($data)) {
foreach ($data as $d) {
foreach ($d as $k => $v) { // Iterate over the column names and values.
$sql .= "`$k`" . ","; // Add the column name to the SQL query.
}
if (!empty($d)) {
$sql = "INSERT INTO `$tableName` (";
foreach ($d as $k => $v) {
$sql .= "`$k`" . ",";
}
$sql = rtrim($sql, ",");
$sql .= ") ";
}
}
}
$sql = rtrim($sql, ","); // Remove the trailing comma.
$sql .= ") ";
}
}
}
if (!empty($data)) {
$sql .= "VALUES ";
foreach ($data as $d) {
if (!empty($d)) {
$sql .= "(";
foreach ($d as $k => $v) {
$sql .= '"' . $v . '"' . ",";
}
$sql = rtrim($sql, ",");
$sql .= "), ";
}
}
$sql = rtrim($sql, ", ");
$sql .= ";";
if (!empty($data)) { // Check if the data array is not empty.
$sql .= "VALUES ";
foreach ($data as $d) { // Iterate over the data rows.
if (!empty($d)) { // Check if the row is not empty.
$sql .= "(";
foreach ($d as $k => $v) { // Iterate over the column values.
$sql .= '"' . $v . '"' . ","; // Add the value to the SQL query.
}
$sql = rtrim($sql, ","); // Remove the trailing comma.
$sql .= "), ";
}
}
$sql = rtrim($sql, ", "); // Remove the trailing comma and space.
$sql .= ";";
$res = PDO_Execute($sql); // Execute the query to insert data into the table.
}
}
$res = PDO_Execute($sql);
}
}
/**
* Write data to the 'strings' table.
*
* @param array $data The data array.
* @param $data
* @return void
*/
public function writeTbl($data) {
$sql = 'CREATE TABLE IF NOT EXISTS `strings` (`Key` VARCHAR(255), `String` VARCHAR(255));'; // Create the 'strings' table if it doesn't exist.
$res = PDO_Execute($sql); // Execute the query to create the table.
$sql = 'CREATE TABLE IF NOT EXISTS `strings` (`Key` VARCHAR(255), `String` VARCHAR(255));';
$res = PDO_Execute($sql);
$sql = "INSERT INTO `strings` (`Key`,`String`) VALUES ";
$sql = "INSERT INTO `strings` (`Key`,`String`) VALUES ";
foreach ($data as $k => $v) {
$sql .= "(\"$k\",\"$v\"),";
}
$sql = rtrim($sql, ", ");
$sql .= ";";
foreach ($data as $k => $v) { // Iterate over the key-value pairs in the data array.
$sql .= "(\"$k\",\"$v\"),"; // Add the key-value pair to the SQL query.
}
$sql = rtrim($sql, ", "); // Remove the trailing comma and space.
$sql .= ";";
$res = PDO_Execute($sql); // Execute the query to insert data into the 'strings' table.
}
$res = PDO_Execute($sql);
}
/**
* Write data to a specific table.
*
* @param string $table The table name.
* @param array $data The data array.
* @param $data
* @return void
*/
public function writeTbls($table, $data) {
$sql = "CREATE TABLE IF NOT EXISTS `$table` (`Key` VARCHAR(255), `String` VARCHAR(255));"; // Create the specified table if it doesn't exist.
$res = PDO_Execute($sql); // Execute the query to create the table.
public function writeTbls($table,$data) {
$sql = "CREATE TABLE IF NOT EXISTS `$table` (`Key` VARCHAR(255), `String` VARCHAR(255));";
$res = PDO_Execute($sql);
$sql = "INSERT INTO `$table` (`Key`,`String`) VALUES ";
foreach ($data as $k => $v) { // Iterate over the key-value pairs in the data array.
$sql .= "(\"$k\",\"$v\"),"; // Add the key-value pair to the SQL query.
}
$sql = rtrim($sql, ", "); // Remove the trailing comma and space.
$sql .= ";";
$res = PDO_Execute($sql); // Execute the query to insert data into the specified table.
}
$sql = "INSERT INTO `$table` (`Key`,`String`) VALUES ";
foreach ($data as $k => $v) {
$sql .= "(\"$k\",\"$v\"),";
}
$sql = rtrim($sql, ", ");
$sql .= ";";
$res = PDO_Execute($sql);
}
/**
* Get a string value based on the key.
*
* @param string $key The key.
* @return mixed The fetched row.
* @param $key
* @return mixed
*/
public function getString($key) {
$sql = "SELECT String FROM `strings` WHERE `Key`='$key'"; // Construct the SQL query to retrieve the string value.
$res = PDO_FetchRow($sql); // Execute the query and fetch the row.
return $res; // Return the fetched row.
}
}
$sql = "SELECT String FROM `strings` WHERE `Key`='$key'";
$res = PDO_FetchRow($sql);
return $res;
}
}

View File

@@ -45,21 +45,25 @@
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="/res/bootstrap.min.css">
<link rel="stylesheet" href="/res/font-awesome.min.css">
<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/lumen/bootstrap.min.css">
<link rel="stylesheet" href="/res/style.css">
<link rel="stylesheet" href="/res/<?php echo $css ?>">
<style>
a {
color: #007bff;
}
</style>
<link rel="stylesheet" href="/res/font-awesome.min.css">
<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/lumen/bootstrap.min.css">
<!-- <link rel="stylesheet" href="/res/win95/assets/win95.css">
<link rel="stylesheet" href="https://unpkg.com/98.css" />
<link rel="stylesheet" href="https://unpkg.com/xp.css" />
<link rel="stylesheet" href="https://khang-nd.github.io/7.css/7.css">-->
<link rel="stylesheet" href="/res/style.css">
<link rel="stylesheet" href="/res/<?php echo $css ?>">
<style>
a {
color: #007bff;
}
</style>
<script src="/res/jquery-3.6.0.min.js"></script>
<script src="/res/bootstrap.bundle.min.js"></script>
<script>
@@ -67,8 +71,8 @@
modname = "<?php echo $_SESSION['modname']; ?>";
docpath = "<?php echo $_SESSION['docpath']; ?>";
</script>
<script src="/res/app.js"></script>
<script src="/res/app.js"></script>

View File

@@ -56,10 +56,17 @@
<img src="/img/Diablo2.png" style="float:right"><h1 syle="display:inline; font-weight: 900;"><?php echo $title . " " . $version; ?><span style="font-family: Lato !important; font-size: 14px;"> <?php echo " By" . $author ?></span></h1>
<div style="font-family: Lato !important; text-align:right; color: tomato">
Active Mod: <span style="color: purple"><?php echo $_SESSION['modname'] ?></span>
<span style="color: #8888FF">[<?php echo $_SESSION['path'] ?>]</span>
<button class="btn btn-success" id="reload-gui-button">Reload GUI</button>
<span class="btn btn-info">
Active Mod: <span style="color: purple"><?php echo $_SESSION['modname'] ?></span>
<span style="color: ">[<?php echo $_SESSION['path'] ?>]</span>
</span>
<button class="btn btn-danger" id="reload-button">Reload TXT Files</button>
</div>
<div style="text-align: right;"><button class="btn btn-info" id="reload-gui-button">Reload GUI</button><button class="btn btn-warning" id="reload-button">Reload TXT Files</button></div>
<div id="loading-spinner" style="display: none; text-align:center;">
<img src="img/loading.gif" alt="Loading...">
</div>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">Unique Items</a>