-1

I am trying to write a php program which can execute service fcserver status to find whether my chat room is running or not. If it is running then output should be

http://i40.tinypic.com/15ysobn.png

and if it's not running then the output should be

http://i44.tinypic.com/2mo5t3a.png

If it is not running then there should be an start button to start the chat room. and when somebody clicks on that button, my script executes service fcserver start command.

well, i can't execute commands like "service fcserver status" or "service fcserver start" as www-data user. I need a root permission. please help me!! what are the ways to get this little task done without compromising with server security?

Thank you!

Lemur
  • 2,659
  • 4
  • 26
  • 41
Shubham Nishad
  • 52
  • 1
  • 1
  • 7
  • RTLM: http://en.wikipedia.org/wiki/Sudo – Marc B Apr 26 '13 at 20:35
  • 2
    is this a 123flashchat by any chance? and why would u want an end user to start chat rooms for you? – ebolton Apr 26 '13 at 20:36
  • 1
    This has been asked many time. Search SO for: `php exec root` and you'll find plenty of info (and most of it will tell you that it's not a wise approach due to security concerns). – tptcat Apr 26 '13 at 20:37

1 Answers1

0

This is purely in response to the status portion of the question:

How frequently do you need to poll this? On demand? Or would regular polling work (i.e., a cron job)?

If a cron job works, you could have a root level cron job produce a status file in the web directory every 1-5 minutes. Then php is not executing the system command itself, but rather just reading a status file and parsing.

With this, you would at least be able to see up to the minute status info, without compromising any security.

As for executing a system command from a remote web interface, it would be highly discourage to do so.

Alec Bennett
  • 5,457
  • 2
  • 17
  • 18