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

[Linux/Debian-like] TheForgottenServer WWW Control

elf

Sing, sing blue silver
Senator
Joined
Dec 11, 2007
Messages
3,666
Solutions
1
Reaction score
125
Location
Warsaw, Poland
GitHub
tayandenga
Twitch
tayandenga
Basing on this: http://otland.net/f118/panel-ots-start-restart-stop-25400/

I've created an option-configurable WWW control panel for TheForgottenServer 0.3 at Debian (including forks as Ubuntu).
To run it properly you need to enable in your PHP configuration function called "shell_exec" and have installed commands "sudo" and "screen".
Here it goes...

Login to your server and switch to root user (directly via su, or sudo su)
Now follow the bolded commands:

pico /etc/init.d/theforgottenserver and paste this:
Code:
#!/bin/sh
#
# Startup and signals management script for TheForgottenServer
#

case "$1" in
  start)
        echo -n "Starting theforgottenserver: "
        cd $2 && screen -AdmS ./theforgottenserver
        echo "done."
        ;;
  stop)
        echo -n "Shutting down theforgottenserver: "
        killall -TERM theforgottenserver
        echo "done."
        ;;
  kill)
        echo -n "Killing theforgottenserver: "
        killall -KILL theforgottenserver
        echo "done."
        ;;
  quit)
        echo -n "Quitting theforgottenserver: "
        killall -QUIT theforgottenserver
        echo "done."
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  reload)
        echo -n "Reloading theforgottenserver: "
        killall -CONT theforgottenserver
        echo "done."
        ;;
  save)
        echo -n "Saving theforgottenserver data: "
        killall -HUP theforgottenserver
        echo "done."
        ;;
  clean)
        echo -n "Cleaning theforgottenserver map: "
        killall -TRAP theforgottenserver
        echo "done."
        ;;
  refresh)
        echo -n "Refreshing theforgottenserver map: "
        killall -CHLD theforgottenserver
        echo "done."
        ;;
  close)
        echo -n "Setting theforgottenserver gamestate to closed: "
        killall -USR1 theforgottenserver
        echo "done."
        ;;
  open)
        echo -n "Setting theforgottenserver gamestate to normal: "
        killall -USR2 theforgottenserver
        echo "done."
        ;;
  *)
        echo "Usage: $0 {start path|stop|kill|quit|restart|reload|save|clean|refresh|close|open}"
        exit 1
esac

exit 0
Press F2 and save the file.

visudo and add at end:
Code:
www-data ALL= NOPASSWD: ALL
Press F2 and save the file.

Switch to your www directory (cd /var/www?) and create a directory called "control" (mkdir control).
pico index.php and paste:
PHP:
<?php
$path = "/home/tfs";
$options = array("start" => true, "stop" => true, "kill" => true, "quit" => false, "restart" => true, "reload" => true, "save" => true, "clean" => true, "refresh" => false, "close" => true, "open" => true);

echo "<html>
	<head>
		<meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\">
		<title>TheForgottenServer WWW Control</title>
	</head>
	<body style=\"color: rgb(0, 0, 0); background-color: rgb(204, 204, 255);\" alink=\"#000099\" link=\"#000099\" vlink=\"#990099\">\n";
if(isset($_GET['do']) && in_array($_GET['do'], $options) && $options[$_GET['do']])
{
	$output = shell_exec("/usr/bin/sudo /etc/init.d/theforgottenserver ".$_GET['do'].($_GET['do'] == "start" ? " ".$path : ""));
	echo nl2br($output)."\n<br />\n<a href=\"".$_SERVER['HTTP_REFERER']."\">&raquo Back</a>\n";
}
else
{
	echo "\t\tAvailable options:<br />\n";
	foreach($options as $option => $enabled)
	{
		if($enabled)
			echo "\t\t<br />\n\t\t&raquo; <a href=\"".$_SERVER['PHP_SELF']."?do=".$option."\">".ucfirst($option)."</a>\n";
	}
}
	echo "\t</body>
</html>";
?>
Replace path in the $path to path, where you have theforgottenserver executable.
Press F2 and save the file.

Now you have to add there a password protection...
pico .htaccess and paste:
Code:
AuthUserFile [u]/var/www/control/[/u].htpasswd
AuthGroupFile /dev/null
AuthName "TheForgottenServer WWW Control Panel"
AuthType Basic

<limit GET POST>
require valid-user
</limit>
(Replace the underlined text with your path)
Press F2 and save the file.

Yet to generate the .htpasswd file...
htpasswd -cm .htpasswd user
(Replace the underlined text with your user)
and type your password (it won't be displayed, gonna be saved as MD5 hash in the .htpasswd).
If you want to add new users type: htpasswd -m .htpasswd user (wihout 'c' parameter).

At the end, you have to allow the theforgottenserver executable execution rights, so changed to directory where you have your server and: chmod +x theforgottenserver

You may perform some action now- enter the panel via http://link/control, type user & password and try it out.
 
Last edited:
Empty my post isn't useless.. I would love it if people would say that in my threads.. Only motivates the creator.

Elf it rox^^ Now make it possible for winblows?;d
 
Empty my post isn't useless.. I would love it if people would say that in my threads.. Only motivates the creator.

Elf it rox^^ Now make it possible for winblows?;d
lool i saw it 3 posts and then kab00m deleteds anyway good work elf i will post if i have any problem...
 
Windows doesn't handle signals, sorry, ask B. Gates.

isnt it possible like we do with the tibiaclient "Gamemaster" option.

like:

tfs.exe -reload talkactions.

or didnt u have a remote control what can do that and then that by the remote control.
 
isnt it possible like we do with the tibiaclient "Gamemaster" option.

like:

tfs.exe -reload talkactions.

or didnt u have a remote control what can do that and then that by the remote control.

1. No.
2. Yes, there is, but as first you need to compile TFS with admin protocol handling (-D__REMOTE_CONTROL__) and then, have a compiled and well-working OTAdmin.
 
1. No.
2. Yes, there is, but as first you need to compile TFS with admin protocol handling (-D__REMOTE_CONTROL__) and then, have a compiled and well-working OTAdmin.

2 = g0g00g please:D:p

0pr0 master's master's master's master?
 
Code:
www-data ALL= NOPASSWD: ALL

pretty insecure. ;p

@up
why i can't edit?
i didn't saw the htpasswd things. ;p
 
Last edited by a moderator:
there should probably be
Code:
echo "\t\t<br />\n\t\t&raquo; <a href=\"".$_SERVER['PHP_SELF']."?do=".$option."\">".ucfirst($option)."</a>\n";
instead of

Code:
echo "\t\t<br />\n\t\t&raquo; <a href=\"".$_SERVER['PHP_SELF']."\">".ucfirst($option)."</a>\n";
in the index.php file

Ok so I have tested it and it's fully working for me, but i had to chmod the file in init.d, until that it wasn't working. So just do this

Code:
chmod 755 /etc/init.d/theforgottenserver
Sorry for that second post, but there wasn't any option to edit the last one.
 
Last edited by a moderator:
there should probably be
Code:
echo "\t\t<br />\n\t\t&raquo; <a href=\"".$_SERVER['PHP_SELF']."?do=".$option."\">".ucfirst($option)."</a>\n";
instead of

Code:
echo "\t\t<br />\n\t\t&raquo; <a href=\"".$_SERVER['PHP_SELF']."\">".ucfirst($option)."</a>\n";
in the index.php file

Ok so I have tested it and it's fully working for me, but i had to chmod the file in init.d, until that it wasn't working. So just do this

Code:
chmod 755 /etc/init.d/theforgottenserver
Sorry for that second post, but there wasn't any option to edit the last one.
Thanks for testing! I'll fix up my first post now :)
 
pretty usefull the killall parameters. thanks :)
 
also imho this is much insecure.
Code:
www-data ALL= NOPASSWD: ALL
If I'm hosting more websites than the otserv, all can call shell commands from php. ^^ It's better to give root access only for specific virtualhost, but I don't know how to do it yet.
 
Back
Top