1. <?php
  2. /**
  3.  * AbyssWS Host Control Functions
  4.  * Created by: Joshua H. (TRUSTAbyss)
  5.  *
  6.  * These functions allow you to stop or start a host.
  7.  * Usage: abyss_stop_host(url, port, user, pass, hostID)
  8.  * and abyss_start_host(...) to start a host.
  9.  *
  10.  * Note: Use these functions on the command line.
  11.  */
  12.  
  13. function stop_abyss_host($url, $port, $user, $pass, $host_id)
  14. {
  15. $ch = curl_init();
  16.  
  17. curl_setopt($ch, CURLOPT_URL, $url);
  18. curl_setopt($ch, CURLOPT_PORT, $port);
  19. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  20. curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
  21. curl_setopt($ch, CURLOPT_POST, 1);
  22. curl_setopt($ch, CURLOPT_NOBODY, 1);
  23. curl_setopt($ch, CURLOPT_POSTFIELDS, "/hosts/host@$host_id/stop=Stop");
  24.  
  25. return curl_exec($ch);
  26. }
  27.  
  28. function start_abyss_host($url, $port, $user, $pass, $host_id)
  29. {
  30. $ch = curl_init();
  31.  
  32. curl_setopt($ch, CURLOPT_URL, $url);
  33. curl_setopt($ch, CURLOPT_PORT, $port);
  34. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  35. curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
  36. curl_setopt($ch, CURLOPT_POST, 1);
  37. curl_setopt($ch, CURLOPT_NOBODY, 1);
  38. curl_setopt($ch, CURLOPT_POSTFIELDS, "/hosts/host@$host_id/start=Start");
  39.  
  40. return curl_exec($ch);
  41. }
  42.  
  43. // You may change the below settings to match your Abyss Web Server
  44. // console settings. The abyss_stop_host() function stops the host,
  45. // and the abyss_start_host() starts the host.
  46.  
  47. // Console Address
  48. $url = "http://127.0.0.1";
  49.  
  50. // Console Port (Default: 9999)
  51. $port = 9999;
  52.  
  53. // Console Login: Username
  54. $user = "USERNAME";
  55.  
  56. // Console Login: Password
  57. $pass = "PASSWORD";
  58.  
  59. // Virtual Host to stop (Host ID)
  60. $host_id = 0;
  61.  
  62. stop_abyss_host($url, $port, $user, $pass, $host_id);
  63. ?>