• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient Auto updater checksum error

jeffaklumpen

Member
Joined
Jan 20, 2022
Messages
76
Solutions
2
Reaction score
15
GitHub
jeffaklumpen
I'm having some issues getting the auto updater working. It connects and finds the files to download but when trying to download I get this error message:

Namnlös.png

I've searched around the forums but can't find any solution. Some help would be much appreciated :)

I'm using Windows and here's the code for updater.php:

PHP:
<?php
// CONFIG
$files_dir = "C:\Users\******\Desktop\***********\UniServerZ\www\clientfiles";
$files_url = "http://**********.com/updater/files";
$files_and_dirs = array("init.lua", "data", "modules", "layouts");
$checksum_file = "checksums.txt";
$checksum_update_interval = 60; // seconds
$binaries = array(
    "WIN32-WGL" => "otclient_gl.exe",
    "WIN32-EGL" => "otclient_dx.exe",
    "WIN32-WGL-GCC" => "otclient_gcc_gl.exe",
    "WIN32-EGL-GCC" => "otclient_gcc_dx.exe",
    "X11-GLX" => "otclient_linux",
    "X11-EGL" => "otclient_linux",
    "ANDROID-EGL" => "", // we can't update android binary
    "ANDROID64-EGL" => "" // we can't update android binary
);
// CONFIG END

function sendError($error) {
    echo(json_encode(array("error" => $error)));
    die();  
}

$data = json_decode(file_get_contents("php://input"));
//if(!$data) {
//    sendError("Invalid input data");
//}

$version = $data->version ?: 0; // APP_VERSION from init.lua
$build = $data->build ?: ""; // 2.4, 2.4.1, 2.5, etc
$os = $data->os ?: "unknown"; // android, windows, mac, linux, unknown
$platform = $data->platform ?: ""; // WIN32-WGL, X11-GLX, ANDROID-EGL, etc
$args = $data->args; // custom args when calling Updater.check()
$binary = $binaries[$platform] ?: "";

$cache = null;
$cache_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $checksum_file;
if (file_exists($cache_file) && (filemtime($cache_file) + $checksum_update_interval > time())) {
    $cache = json_decode(file_get_contents($cache_file), true);
}
if(!$cache) { // update cache
    $dir = realpath($files_dir);
    $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
    $cache = array();
    foreach ($rii as $file) {
        if (!$file->isFile())
            continue;
        $path = str_replace($dir, '', $file->getPathname());
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        $cache[$path] = hash_file("crc32b", $file->getPathname());
    }
    file_put_contents($cache_file . ".tmp", json_encode($cache));
    rename($cache_file . ".tmp", $cache_file);
}
$ret = array("url" => $files_url, "files" => array(), "keepFiles" => false);
foreach($cache as $file => $checksum) {
    $base = trim(explode("/", ltrim($file, "/"))[0]);
    if(in_array($base, $files_and_dirs)) {
        $ret["files"][$file] = $checksum;
    }
    if($base == $binary && !empty($binary)) {
        $ret["binary"] = array("file" => $file, "checksum" => $checksum);
    }
}

echo(json_encode($ret, JSON_PRETTY_PRINT));

?>
 
Can you help me im trying to enable this in windows 10 but i have problems

I'm having troubles to enable this on windows 10
i have encypted the files and packet them into data.zip
also uploaded unpacked files but encrypt to C:\xampp\htdocs\windowsfiles in there i placed
xxx_gl, xxx_dx + dlls + modules, data, mods, ( also tried with unpacled files

i saw that this is the equivalent of chmod 777
Lua:
ua:
takeown /f C:\xampp\htdocs\windowsupdater\updater.php* /r
icacls C:\xampp\htdocs\windowsupdater\updater.php /grant Everyone:F /t

also
Code:
Code:
takeown /f C:\xampp\htdocs\windowsupdater* /r
icacls C:\xampp\htdocs\windowsupdater /grant Everyone:F /t

i recieved this

Code:
Code:
Microsoft Windows [Version 10.0.19045.3448]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>takeown /f C:\xampp\htdocs\windowsupdater\updater.php* /r

SUCCESS: The file (or folder): "C:\xampp\htdocs\windowsupdater\updater.php" now owned by user "DESKTOP-84KJ0MG\pasturryx".

C:\Windows\system32>icacls C:\xampp\htdocs\windowsupdater\updater.php /grant Everyone:F /t
Everyone: No mapping between account names and security IDs was done.
Successfully processed 0 files; Failed processing 1 files

C:\Windows\system32>
my init.lua
Code:
Code:
Services = {
website = "http://xxx.ddns.net", -- currently not used
updater = "http://xxxx.ddns.net/windowsupdater/updater.php",
updater = "",
stats = "",
crash = "",
feedback = "",
status = ""
}
and my updater.php
Code:
Code:
<?php
// CONFIG
$files_dir = "C:/windowsfiles";
$files_url = "http://xxxt.ddns.net/windowsfiles";
$files_and_dirs = array("init.lua", "data", "modules", "layouts");
$checksum_file = "checksums.txt";
$checksum_update_interval = 60; // seconds
$binaries = array(
"WIN32-WGL" => "ForgottenNot_gl.exe",
"WIN32-EGL" => "ForgottenNot_gl_dx.exe",
"WIN32-WGL-GCC" => "ForgottenNot_gl_gcc_gl.exe",
"WIN32-EGL-GCC" => "oForgottenNot_gl_gcc_dx.exe",
"X11-GLX" => xxx_gl_linux",
"X11-EGL" => "xxx_gl_linux",
"ANDROID-EGL" => "", // we can't update android binary
"ANDROID64-EGL" => "" // we can't update android binary
);

/also tried you updater like this
Code:
<?php
// CONFIG
//$files_dir = "C:\Users\******\Desktop\***********\UniServerZ\www\clientfiles";
//$files_url = "http://**********.com/updater/files";
$files_dir = "C:\xampp\htdocs\windowsfiles";
$files_url = "http://forgottennot.ddns.net/windowsfiles";
$files_and_dirs = array("init.lua", "data", "modules", "layouts");
$checksum_file = "checksums.txt";
$checksum_update_interval = 60; // seconds
$binaries = array(
    "WIN32-WGL" => "otclient_gl.exe",
    "WIN32-EGL" => "otclient_dx.exe",
    "WIN32-WGL-GCC" => "otclient_gcc_gl.exe",
    "WIN32-EGL-GCC" => "otclient_gcc_dx.exe",
    "X11-GLX" => "otclient_linux",
    "X11-EGL" => "otclient_linux",
    "ANDROID-EGL" => "", // we can't update android binary
    "ANDROID64-EGL" => "" // we can't update android binary
);
// CONFIG END

function sendError($error) {
    echo(json_encode(array("error" => $error)));
    die(); 
}

$data = json_decode(file_get_contents("php://input"));
//if(!$data) {
//    sendError("Invalid input data");
//}

$version = $data->version ?: 0; // APP_VERSION from init.lua
$build = $data->build ?: ""; // 2.4, 2.4.1, 2.5, etc
$os = $data->os ?: "unknown"; // android, windows, mac, linux, unknown
$platform = $data->platform ?: ""; // WIN32-WGL, X11-GLX, ANDROID-EGL, etc
$args = $data->args; // custom args when calling Updater.check()
$binary = $binaries[$platform] ?: "";

$cache = null;
$cache_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $checksum_file;
if (file_exists($cache_file) && (filemtime($cache_file) + $checksum_update_interval > time())) {
    $cache = json_decode(file_get_contents($cache_file), true);
}
if(!$cache) { // update cache
    $dir = realpath($files_dir);
    $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
    $cache = array();
    foreach ($rii as $file) {
        if (!$file->isFile())
            continue;
        $path = str_replace($dir, '', $file->getPathname());
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        $cache[$path] = hash_file("crc32b", $file->getPathname());
    }
    file_put_contents($cache_file . ".tmp", json_encode($cache));
    rename($cache_file . ".tmp", $cache_file);
}
$ret = array("url" => $files_url, "files" => array(), "keepFiles" => false);
foreach($cache as $file => $checksum) {
    $base = trim(explode("/", ltrim($file, "/"))[0]);
    if(in_array($base, $files_and_dirs)) {
        $ret["files"][$file] = $checksum;
    }
    if($base == $binary && !empty($binary)) {
        $ret["binary"] = array("file" => $file, "checksum" => $checksum);
    }
}

echo(json_encode($ret, JSON_PRETTY_PRINT));

?>

tried to change this
Code:
$files_dir = "C:\xampp\htdocs\windowsfiles";
to this:
Code:
$files_dir = "C:/xampp/htdocs/windowsfiles";
it don't want to work. can somebody help me?

also noticed there's an updater.php and another file caled adavanced_upater.php have tried both none of them have worked for me.
somebody have managed to make this work in windows? help pls
 
Back
Top