Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

howto use old "lgsl_servers.txt" file? #238

Open
RonXTCdaBass opened this issue Dec 8, 2024 · 5 comments
Open

howto use old "lgsl_servers.txt" file? #238

RonXTCdaBass opened this issue Dec 8, 2024 · 5 comments

Comments

@RonXTCdaBass
Copy link

Hello and big THX for holding this lgsl project alive!

my question is

How to read an old lgsl_servers.txt file from same webhost because in this file is written the actual IP to use like a dyndns.

the feed php from the old "lgsl_standalone_v3.2" makes an error 500 at my webhost.

@tltneon
Copy link
Owner

tltneon commented Dec 27, 2024

Hi @RonXTCdaBass
You can try open http://urwebsite/lgsl_files/lgsl_export.php and copy data.
image

After it you can paste it into new LGSL instance using Advanced management
image

@RonXTCdaBass
Copy link
Author

RonXTCdaBass commented Dec 27, 2024

Thanks, but its not what i am searching...

i'll try to expose...

in my old version of lgsl are some lines:

file: lgsl_settings.php

unset($get_type);

  $lines = file("../../../dyn/lgsl_servers.txt");

  foreach ($lines as $line)
  {
    if (!trim($line)) { continue; } // SKIP BLANK LINES

    $part        = explode(":", $line);
    $server_ip   = trim($part[0]);  // TRIM REMOVES
    $server_port = trim($part[1]);  // ACCIDENTAL SPACES
    $server_type = trim($part[2]);  // AND NEWLINE CHARACTERS
    
    if ($server_ip == $get_ip && $server_port == $get_port)
    {
      $get_type = $server_type; // GETS THE SERVER TYPE FROM THE LGSL_SERVERS.TXT
    }
  }

and it works => not since update to php8.3.10
old_lgsl_works

it takes the server data from a file wich is automaticly updated from a small script for detecting the actual ip from my router at home, like a dyndns... i've added a few lines so the old lgsl worked with the txt file.

my file setip.php

if (isset($_GET["passwd"]) && isset($_GET["sip"]))
  {
    $passwd = $_GET["passwd"];
    $sip = $_GET["sip"];
 
    if ($passwd == $pwort)
    {
        // der Server muss Schreibrechte im akt. Verzeichnis besitzen
        $f = fopen("dyn/dyndns.txt", "w");
        fwrite($f, $sip);
        fclose($f); 
		
		$g = fopen("dyn/lgsl_servers.txt", "w");
        fwrite($g, $sip);
		fwrite($g, ':28960:wolfet:on');
        fclose($g); 
    }
  }

how can i add this way to the actual version, maybe to the "lgsl_feed.php" or "lgsl_protocol.php"
and for the menu like the add New "~ Test ( For PHP Developers )" ?

i think the right way can be a new part into the "lgsl_protocol.php" ?
like function lgsl_query_file ?

i hope my english was good enough to understand what i mean. ^^
(i'm not a developer... only a user who tries something until it works ;) ...)

@Rosenstein
Copy link
Contributor

Why not update LGSL to V6.2.1 or V7.0 and then change your setip.php script to update the "ip" field in lgsl SQL table?
That might be hard for you at first, but will be easier down the road when new versions of LGSL get released ( no PHP code patching on every update ).

@RonXTCdaBass
Copy link
Author

Thanks Rosenstein.

I think it's the only way with a target.

I've made a php upgrade at the weekend d and no lots of my scripts and snippets runs nevermore. I've looked at some scripts to (maybe) learn an see how it works.

But all this can wait until next year 😂

🎉✌️ I wich all here a great Silvester and a HAPPY NEW Year! 🍻🍻🍻🎉🎈

@RonXTCdaBass
Copy link
Author

hey there!

if somebody interested...
here my working updated "setip.php":

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$pwort = 'PASSWORD-ROUTER+WEB';

if (isset($_GET["passwd"]) && isset($_GET["sip"])) {
	$passwd = $_GET["passwd"];
	$sip = $_GET["sip"];
		if ($passwd == $pwort) {
		// Schreiben Sie die IP in die Textdatei - Write the IP into the text file
		$f = fopen("dyn/dyndns.txt", "w");
			if ($f === false) {
			echo "FEHLER: Datei konnte nicht geöffnet werden. - ERROR: File could not be opened. ";
			exit;
			}
				fwrite($f, $sip);
				fclose($f);
				// Verbindung zur Datenbank herstellen und IP-Adresse aktualisieren - Connect to the database and update the IP address
			$link = mysqli_connect("localhost", "USER", "SQL-PASSWORD", "DATABASE");
			if ($link === false) {
			die("FEHLER: Verbindung konnte nicht hergestellt werden. - ERROR: Connection could not be established. " . mysqli_connect_error());
			}
			$sql = "UPDATE lgsl SET ip='$sip' WHERE id=1"; //ID 1 because first server in my list is my homeserver
		if (mysqli_query($link, $sql)) {
		echo "Datensatz wurde erfolgreich aktualisiert. - Record was updated successfully. ";
		} else {
		echo "FEHLER: $sql konnte nicht ausgeführt werden. - ERROR: $sql could not be executed. " . mysqli_error($link);
		}
		mysqli_close($link);
		}
}
?>

now my router updates the .txt file and the sql entry :D

Thanks again @Rosenstein!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants