mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 04:26:03 +00:00
Added D2Strings class to get strings where needed from strings table
This commit is contained in:
parent
ade44ff427
commit
5907c8c8d3
13
index.php
13
index.php
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -49,20 +48,15 @@ error_reporting(E_ALL ^ E_WARNING);
|
|||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
|
|
||||||
include "./_pdo.php";
|
include "./_pdo.php";
|
||||||
|
|
||||||
include "./config.php";
|
include "./config.php";
|
||||||
|
|
||||||
require_once "./vendor/autoload.php";
|
require_once "./vendor/autoload.php";
|
||||||
|
|
||||||
|
|
||||||
if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SESSION['modname'] . ".db"))) {
|
if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SESSION['modname'] . ".db"))) {
|
||||||
// first load, no active mod, go to switchmods to select mod
|
// first load, no active mod, go to switchmods to select mod
|
||||||
header("Location: /switchMods.php");
|
header("Location: /switchMods.php");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
PDO_Connect("sqlite:" . APP_DB);
|
PDO_Connect("sqlite:" . APP_DB);
|
||||||
$sql = "SELECT * FROM D2Modder ORDER BY lastused DESC LIMIT 1";
|
$sql = "SELECT * FROM D2Modder ORDER BY lastused DESC LIMIT 1";
|
||||||
|
|
||||||
$lastUsedMod = PDO_FetchRow($sql);
|
$lastUsedMod = PDO_FetchRow($sql);
|
||||||
|
|
||||||
$_SESSION['modname'] = $lastUsedMod['modname'];
|
$_SESSION['modname'] = $lastUsedMod['modname'];
|
||||||
@ -77,8 +71,6 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
|||||||
$css = '';
|
$css = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
||||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||||
define('TXT_PATH', $_SESSION['path']);
|
define('TXT_PATH', $_SESSION['path']);
|
||||||
@ -91,11 +83,9 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
|||||||
require_once './src/D2Char.php';
|
require_once './src/D2Char.php';
|
||||||
require_once './src/D2CharStructureData.php';
|
require_once './src/D2CharStructureData.php';
|
||||||
|
|
||||||
|
|
||||||
$D2Files = new D2Files();
|
$D2Files = new D2Files();
|
||||||
$charFiles = $D2Files->getSaveFiles();
|
$charFiles = $D2Files->getSaveFiles();
|
||||||
|
|
||||||
|
|
||||||
foreach ($charFiles as $charFile) {
|
foreach ($charFiles as $charFile) {
|
||||||
$charData[] = new D2Char($charFile); // $charData goes into chars.php tab
|
$charData[] = new D2Char($charFile); // $charData goes into chars.php tab
|
||||||
}
|
}
|
||||||
@ -192,7 +182,6 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
|||||||
|
|
||||||
ddump($post);
|
ddump($post);
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT rowid,`index` from `uniqueitems` WHERE `index`=\"{$post['index']}\"";
|
$sql = "SELECT rowid,`index` from `uniqueitems` WHERE `index`=\"{$post['index']}\"";
|
||||||
|
|
||||||
$res = PDO_FetchRow($sql);
|
$res = PDO_FetchRow($sql);
|
||||||
@ -205,8 +194,6 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
|||||||
$sql = rtrim($sql, ",");
|
$sql = rtrim($sql, ",");
|
||||||
$sql .= ' WHERE `index`="' . $post['index'] . '"';
|
$sql .= ' WHERE `index`="' . $post['index'] . '"';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PDO_Execute($sql, [$post['index']]);
|
PDO_Execute($sql, [$post['index']]);
|
||||||
//ddump($x);
|
//ddump($x);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
require_once 'D2CharStructureData.php';
|
require_once 'D2CharStructureData.php';
|
||||||
require_once 'D2Files.php';
|
require_once 'D2Files.php';
|
||||||
require_once 'D2BitReader.php';
|
require_once 'D2BitReader.php';
|
||||||
|
require_once 'D2Strings.php';
|
||||||
|
|
||||||
class D2Char {
|
class D2Char {
|
||||||
|
|
||||||
public $cData; // char data output
|
public $cData; // char data output
|
||||||
|
public $items; // char item data
|
||||||
private $sData; // char file structure data
|
private $sData; // char file structure data
|
||||||
private $bData; // char binary data from d2s
|
private $bData; // char binary data from d2s
|
||||||
private $filePath; // .d2s file path
|
private $filePath; // .d2s file path
|
||||||
@ -23,8 +25,13 @@ class D2Char {
|
|||||||
fseek($this->fp, $k);
|
fseek($this->fp, $k);
|
||||||
$this->bData[$k] = fread($this->fp, $v);
|
$this->bData[$k] = fread($this->fp, $v);
|
||||||
}
|
}
|
||||||
|
$this->strings = new D2Strings();
|
||||||
return $this->parseChar();
|
return $this->parseChar();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parseItems(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseChar() {
|
public function parseChar() {
|
||||||
@ -69,6 +76,8 @@ class D2Char {
|
|||||||
$cData['NPCIntroductions'] = $this->bData[714];
|
$cData['NPCIntroductions'] = $this->bData[714];
|
||||||
$cData['filePath'] = $this->filePath;
|
$cData['filePath'] = $this->filePath;
|
||||||
$this->cData = $cData;
|
$this->cData = $cData;
|
||||||
|
$this->parseItems();
|
||||||
|
|
||||||
return $this->cData;
|
return $this->cData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/D2Strings.php
Normal file
11
src/D2Strings.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class D2Strings {
|
||||||
|
public array $strings;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
$sql = "SELECT * FROM strings";
|
||||||
|
$this->strings = PDO_FetchAssoc($sql);
|
||||||
|
return $this->strings;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user