mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 12:36:03 +00:00
138 lines
3.2 KiB
PHP
138 lines
3.2 KiB
PHP
<?php
|
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
set_time_limit(-1);
|
|
ini_set('max_input_time', '-1');
|
|
ini_set('max_execution_time', '0');
|
|
session_start();
|
|
ob_start();
|
|
|
|
define('DB_FILE', $_SESSION['modname'] . ".db");
|
|
|
|
require_once './config.php';
|
|
require_once './_pdo.php';
|
|
|
|
require_once "./src/D2Functions.php";
|
|
require_once "./src/D2Database.php";
|
|
require_once './src/D2Files.php';
|
|
require_once './src/D2TxtParser.php';
|
|
require_once './src/D2ItemDesc.php';
|
|
require_once './src/D2Char.php';
|
|
require_once './src/D2CharStructureData.php';
|
|
|
|
$dStruct = new D2CharStructureData();
|
|
|
|
|
|
$p = $_POST;
|
|
|
|
// ddump($p);
|
|
|
|
foreach($p['quest'] as $k => $v) {
|
|
$q[$k] = ($dStruct->_qNorm[$k]);
|
|
}
|
|
|
|
foreach($p['wp'] as $k => $v) {
|
|
$w[$k] = ($dStruct->_qNorm[$k]);
|
|
}
|
|
|
|
|
|
$filePath = $p['filePath'];
|
|
$filePath = str_replace("\\", "\\\\", $filePath);
|
|
$fp = fopen($filePath, "rb+");
|
|
|
|
// delete old checksum at offset 0x0C - byte 12
|
|
//fseek($fp, 12);
|
|
// (I) unsigned integer (machine dependent size and byte order)
|
|
//fwrite($fp, pack('I', 0)); // produces 4 bytes
|
|
|
|
// edit quests which are checked, to Just finished FE FF
|
|
foreach ($q as $k => $v) {
|
|
fseek($fp, $v);
|
|
fwrite($fp, pack('C', 0xFE));
|
|
fseek($fp, $v+1);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
}
|
|
|
|
if ($p['wp_all'] == "1") {
|
|
fseek($fp, 643);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 644);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 645);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 646);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 647);
|
|
fwrite($fp, pack('C', 0x7F));
|
|
|
|
fseek($fp, 667);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 668);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 669);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 670);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 671);
|
|
fwrite($fp, pack('C', 0x7F));
|
|
|
|
fseek($fp, 691);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 692);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 693);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 694);
|
|
fwrite($fp, pack('C', 0xFF));
|
|
fseek($fp, 695);
|
|
fwrite($fp, pack('C', 0x7F));
|
|
|
|
}
|
|
else if ($p['wp_all'] == "0")
|
|
{
|
|
fseek($fp, 643);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 644);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 645);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 646);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 647);
|
|
fwrite($fp, pack('C', 0x00));
|
|
|
|
fseek($fp, 667);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 668);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 669);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 670);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 671);
|
|
fwrite($fp, pack('C', 0x00));
|
|
|
|
fseek($fp, 691);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 692);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 693);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 694);
|
|
fwrite($fp, pack('C', 0x00));
|
|
fseek($fp, 695);
|
|
fwrite($fp, pack('C', 0x00));
|
|
}
|
|
|
|
|
|
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
|
|
|
// write NEW checksum at offset 0x0C - byte 12
|
|
//fseek($fp, 12);
|
|
// (I) unsigned integer (machine dependent size and byte order)
|
|
//fwrite($fp, pack('H*', $checksum)); // produces 4 bytes
|
|
|
|
|
|
fclose($fp);
|
|
|
|
header('Location: /');
|