Worqy Posted August 5, 2012 Share Posted August 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/ Share on other sites More sharing options...
Christian F. Posted August 6, 2012 Share Posted August 6, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367259 Share on other sites More sharing options...
Jessica Posted August 6, 2012 Share Posted August 6, 2012 If I understand you correctly, you would use ajax. Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367320 Share on other sites More sharing options...
Worqy Posted August 7, 2012 Author Share Posted August 7, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367563 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367569 Share on other sites More sharing options...
Worqy Posted August 8, 2012 Author Share Posted August 8, 2012 So I need to rewrite a part of the rcon class im using? Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367746 Share on other sites More sharing options...
scootstah Posted August 8, 2012 Share Posted August 8, 2012 Yes. If you don't have a persistent socket, it will just be closed when the script terminates. So, AJAX or not, you will still be re-opening the connection on every request. Quote Link to comment https://forums.phpfreaks.com/topic/266697-rcon-webpanel/#findComment-1367790 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.