<?php
/**
* AbyssWS Host Control Functions
* Created by: Joshua H. (TRUSTAbyss)
*
* These functions allow you to stop or start a host.
* Usage: abyss_stop_host(url, port, user, pass, hostID)
* and abyss_start_host(...) to start a host.
*
* Note: Use these functions on the command line.
*/
function stop_abyss_host($url, $port, $user, $pass, $host_id)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "/hosts/host@$host_id/stop=Stop");
return curl_exec($ch);
}
function start_abyss_host($url, $port, $user, $pass, $host_id)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "/hosts/host@$host_id/start=Start");
return curl_exec($ch);
}
// You may change the below settings to match your Abyss Web Server
// console settings. The abyss_stop_host() function stops the host,
// and the abyss_start_host() starts the host.
// Console Address
$url = "http://127.0.0.1";
// Console Port (Default: 9999)
$port = 9999;
// Console Login: Username
$user = "USERNAME";
// Console Login: Password
$pass = "PASSWORD";
// Virtual Host to stop (Host ID)
$host_id = 0;
stop_abyss_host($url, $port, $user, $pass, $host_id);
?>