Jump to content

Recommended Posts

Hi.

 

I'm not sure if this can be solved with php, but I'll give it a shot.

So I'm making a RCON webpanel, based on this code: http://fremnet.net/article/199/source-rcon-class .

Now, the design of my site is going to be "console" like, a big textarea and a text field where you write the commands.

My problem is that I wan't to run this piece of code:

$r->rconCommand([i]TEXTFIELD DATA[/i])

whenever I press a button. But php is server-sided and what I wan't to do is kind of client-sided.

Link to comment
https://forums.phpfreaks.com/topic/266697-rcon-webpanel/
Share on other sites

Then you either have to use PHP-CLI, or a different language. If you don't want to ship a full web server with your web panel, that is.

There are some PHP "compilers" as well, but the last time I looked at one they were only available for PHP4. Couple of years ago now though, so there could have been some improvement on that front. A search should be able to tell you.

Link to comment
https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367259
Share on other sites

Ok. So for you guys to even better understand what I wan't to do, I'll paste the files:

<?php
Session_start();
include "config.php";
include_once("rcon.class.php");
echo "Console" . "<br />";
$r = new rcon("$serverip","$rcon_port","$rcon_password"); 

if($r->Auth())
{
$r->rconCommand("say Logged in");
}

function rcon_list()
{
echo $r->rconCommand("list");
}

function rcon_save()
{
$r->rconCommand("save");
echo $->rconCommand("say Saved");
}

?>
<html>
<head>
</head>
<body>
<button type="button">List</button><br />
<button type="button">Save</button><br />
</body>
</html>

 

Now by pressing the "list" button I wan't to run the function list, same with save.

But I need to do this without reloading the page since it takes quite long to connect and login to the server.

 

And ajax, could you give me an example how it would work in this case?

Link to comment
https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367563
Share on other sites

AJAX is seamless to the client, but it is still an additional request to the server - meaning you would still need to connect to the remote server again for each request.

 

So, what you need is a persistent connection that doesn't close when the script is finished. Check out pfsockopen.

Link to comment
https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367569
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.