( search forums )
begining of a php admin tool. help
Soldat Forums - Soldat Talk - Developers Corner
EvO
March 26, 2005, 10:45 pm
im making this because i host servers for people and i can let them control their server from the web browser.

<?php
//Variables
$password = "ok?";
$port = "23073";
//End Variables
//Connect And Authorize
$serv = fsockopen("localhost",$port,$error['number'],$error['string'],30);
if (!$serv)
{
echo($error['string']);
} else {
fwrite($serv,$password);
$rec = fgets($serv,256);
if (!eregi("Connection",$rec)) {
echo("Invalid Password");
echo($rec);
exit(0);
}

}
//End Initial Connection
echo("<HTML>");
echo("<HEAD><TITLE>SoldatAdmin</TITLE></HEAD><BODY>");
//Command Handler..
$cmd = $_GET['cmd'];
if (!$cmd) {
echo("<a href='index.php?cmd=users'>Users Online</a><br>");
echo("<a href='index.php?cmd=shutdown'>Shut Down Server</a><br>");
echo("<a href='index.php?cmd=start'>Start Server</a><br>");
}else{
switch($cmd) {
case users:show_users($serv);
}
}

//User Functions
function show_users($serv) {
echo("<select name=users>");
fwrite($serv,"REFRESH");
$data = fgets($serv,1028);
echo ($data);
echo("</select>");
}

?>

I send the refesh command but im not getting anything back?

Denacke
March 27, 2005, 12:13 am
Although I cannot help you with your problem, I am also intrested in making webtool for adminning my soldat server.

I hope there are some people with expirience here that could help us out :)

EvO
March 27, 2005, 12:47 am
<?php
//Variables
$set['home'] = "/home/nickhos/RSS/";
$set['ini'] = $set['home']."soldat.ini";
$set['maps'] = $set['home']."mapslist.txt";
$set['maxp'] = "8";
$set['port'] = "23073";
$set['pass'] = "password";
//End Variables

echo("<HTML>");
echo("<HEAD><TITLE>SoldatAdmin</TITLE></HEAD><BODY>");
//Command Handler..
$cmd = $_GET['cmd'];
if (!$cmd) {
echo("<a href='index.php?cmd=users'>Users Online</a><br>");
echo("<a href='index.php?cmd=shutdown'>Shut Down Server</a><br>");
echo("<a href='index.php?cmd=start'>Start Server</a><br>");
}else{
switch($cmd) {
case users:show_users($set['port'],$set['pass']);
case start:startup($set['port'],$set['maxp'],$set['ini'],$set['maps']);
}
}

//User Functions
function show_users($port,$pass) {
echo("<select name=users>");
//Connect And Authorize
$serv = fsockopen("localhost",$port,$error['number'],$error['string'],30);
if (!$serv)
{
echo($error['string']);
} else {
fwrite($serv,$pass);
$rec = fgets($serv,256);
if (!eregi("Connection",$rec)) {
echo("Invalid Password");
echo($rec);
exit(0);
}

}
//Get user list
fwrite($serv,"REFRESH");
$data = fgets($serv,1028);
echo ($data);
echo("</select>");
}
function shutdown() {

}
function startup() {
system("nohup ./home/nickhos/RSS/soldatserver ");
}


?>

Deleted User
March 27, 2005, 12:48 am
change
"fwrite($serv,"REFRESH");"

to

"fwrite($serv,"REFRESH\n");"


problem solved.

EDIT: Oh, and everything you send to the server must end with \n (newline)

EvO
March 27, 2005, 1:28 am
Ah Thanks mate :)

EvO
March 27, 2005, 1:32 am
Still doesnt work for some reason.

D3c0d3
March 27, 2005, 1:40 am
Im making a soldat web administration too in PHP, i can do REFRESH command try with REFRESH\n\r but the data incoming enrypted. That is my problem.

(Sorry for my bad english)

rusty
March 27, 2005, 1:45 am
quote:Originally posted by D3c0d3Im making a soldat web administration too in PHP, i can do REFRESH command try with REFRESH\n\r but the data incoming enrypted. That is my problem.

(Sorry for my bad english)


Take a look here:

[URL]

Deleted User
March 27, 2005, 6:19 am
try this instead

"fwrite($serv,"REFRESH\r\n");"

If that doesnt work, ur PHP server is mongulated.

FliesLikeABrick
March 27, 2005, 6:13 pm
if it is a linux server then just \n should be enough. on a windows server \r has to come before \n