Can I turn Off computer using PHP script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • k2swap
    New Member
    • May 2010
    • 1

    #1

    Can I turn Off computer using PHP script

    Can I turn off a computer using a PHP script?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You can turn off the server computer, sure. Just use the exec function to execute the shutdown command for your OS. (The exact command varies between OSs).

    For example, for a Linux server, you could do:
    [code=php]exec("shutdown -P now");[/code]
    This, obviously, requires that PHP (or Apache, if PHP is run as an Apache module) is run by a user that is allowed to use that command. If not, you will not be able to do this.

    If you are trying to shut down the computer's of a client (website visitor) then no, you can not. It's just basic security.

    Comment

    Working...