• 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!

Auto Global IP in config.lua

Holix

retard
Joined
Jun 3, 2007
Messages
93
Reaction score
13
I dont know if this is right place to post so if this is wrong please move it to right place.
Thanks.

This is utility i made for myself. It puts right IP in config.lua if u got dynamic ip.
It check for right ip from 'http://www.whatismyip.com/automation/n09230945.asp'.
You need PHP support to do it (if you are using xampp its ok)

So lets begin.
First open your servers directory.
Make 'fix.php'. Put this inside:
Code:
<?php
$file = "config.lua";
$ip=file_get_contents("http://ip1.dynupdate.no-ip.com/");
$ir = 'ip = "'.$ip.'"';
$handle = fopen($file, 'r');
$contents = fread($handle, filesize($file));
fclose($handle);
$handle = fopen($file, 'w');
$test = preg_replace('/ip \= \"(.*?)\"/', $ir, $contents);
fwrite($handle, $test);
fclose($handle);
?>
-
Make 'start.bat'. Put this inside:
Code:
cls
@echo off
echo Putting right IP in config.
C:/xampp/php/php.exe fix.php
YurOTS.exe
To edit path where php.exe is, change this C:/xampp/php/php.exe. For example your xampp directory is in D: so it would be D:/xampp/php/php.exe
To edit name of servers file edit this YurOTS.exe.

That would be it. I made this for 7.6 version and could work for higher versions.
If you got server restarter, simply instead of YurOTS.exe put Restarter.bat or how it is called.

;)

-- Credits: Holix (me)
 
Last edited:
More clean version what works with Unix systems.
Only u must have installed PHP and it binary must be installed in /usr/bin/php if it isn't put your own path.
Code:
#!/usr/bin/php
<?php
$file = "config.lua";
$ip=file_get_contents("http://www.whatismyip.com/automation/n09230945.asp");

$handle = fopen($file, 'r');
$contents = fread($handle, filesize($file));
fclose($handle);
$handle = fopen($file, 'w');
$test = preg_replace('/(\d+).(\d+).(\d+).(\d+)/', $ip, $contents);
fwrite($handle, $test);
fclose($handle);
?>
 
Azi, lol. No, from _SERVER['REMOTE_ADDR'] you can get client IP no server, also if you run APP with command line this var will not exist.
 
Made some changes:
- If it misses to update ip, ip will be "" and it will never update it again.
- Changed ip source.

Look on first post for update :)
 
More clean version what works with Unix systems.
Only u must have installed PHP and it binary must be installed in /usr/bin/php if it isn't put your own path.
Code:
#!/usr/bin/php
<?php
$file = "config.lua";
$ip=file_get_contents("http://www.whatismyip.com/automation/n09230945.asp");

$handle = fopen($file, 'r');
$contents = fread($handle, filesize($file));
fclose($handle);
$handle = fopen($file, 'w');
$test = preg_replace('/(\d+).(\d+).(\d+).(\d+)/', $ip, $contents);
fwrite($handle, $test);
fclose($handle);
?>

It's code very good
 
if i lost my connection my ip change, correct?
my server continue ON but players dont have connection.
this script works for my problem?

thanks and sorry for my bad english ;s
 
Back
Top