With the SCP webservice you can programmatically make changes within the Server Control Panel (SCP) via SOAP.
loginName
always corresponds to your SCP user, the password
differs from the usual access data and has to be set explicitly in the SCP. Furthermore, activating the web service at the same location in the SCP options is necessary.
WSDL: https://www.servercontrolpanel.de/WSEndUser?wsdl
Parameter:
loginName = Login name
password = Password
Return:
Strings []
Parameter:
loginName : Login name
password : Password
vserverName : String
Return:
WebServiceSimpleResult
Parameter:
loginName : Login name
password : Password
vserverName : String
Return:
WebServiceSimpleResult
Parameter:
loginName : Login name
password : Password
vserverName : String
Return:
String [online|offline]
Parameter:
loginName : Login name
password : Password
vserverName : String
Return:
String[]
Parameter:
loginName : Login name
password : Password
routedIP : String
routedMask : String
destinationVserverName : String
destinationInterfaceMAC : String
Changes the routing of a Failover IP to another server.
When using a MAC of 00:00:00:00:00:00
the IP is deleted from the routing table and has to be assigned before using it again. When performing a deletion request, the destinationVserverName
of the server to which the IP address is currently routed has to be used.
Parameter:
loginName : Login name
password : Password
vserverName : String
Return:
TOKEN
With the TOKEN
, CSV data with statistics can be loaded via the following URL. The uppercase parameters have to be replaced:
https://www.servercontrolpanel.de/SCP/StatsViewer?type=TYPE&TimeRange=TIMERANGE&token=TOKEN
TOKEN = return of getVServerStatToken
TYPE = Statistics type: cpu, iops, pps, traffic
TIMERANGE = How many hours (see SCP): 6, 24, 168, 744
success : boolean
message : String
If the request was successful, success
is true. If success
is false, an error message will be provided in message
.
id : String (Interne ID)
direction : String (INPUT | OUTPUT)
proto : String (any|tcp|udp|icmp)
target : String (ACCEPT|REJECT|DROP)
srcIP : String (IPv4 oder IPv6 IP)
srcPort : String (1-65535)
destIP : String (IPv4 oder IPv6 IP)
destPort : String (1-65535)
match : String (STATE|ICMP|LIMIT)
matchValue : String ([NEW,ESTABLISGED,RELEATED]|ICMP Code|Limit value)
srcPortRange : String (Wenn gesetzt, dann muss der Wert größer sein als srcPort)
destPortRange : String (Wenn gesetzt, dann muss der Wert größer sein als destPort)
sort : String
valid : String (Regel ist gültig)
Required parameters when adding:
direction
, target
, srcIP
or destIP
Invalid parameters when adding:
valid
, id
<?php
ini_set('default_socket_timeout',360);
class VcpWebServiceEndUser {
private $wsdl_url = 'https://www.servercontrolpanel.de/WSEndUser?wsdl';
private $soap_client;
private $loginname;
private $password;
public function getArrayFrom2DWebServiceStringArray($webServiceResultArray) {
$phpArray = array();
foreach ($webServiceResultArray->return as $globalArray) {
$phpArray[$globalArray->item[0]] = $globalArray->item[1];
}
return $phpArray;
}
function __construct($loginname, $password) {
$this->loginname = $loginname;
$this->password = $password;
$this->soap_client = new SOAPClient($this->wsdl_url, array('cache_wsdl' => 0));
// TODO error if no connection to soap server ...
}
/**
*
* @param String $vserverName needed
* @return String if action deleteVServer successfully started return actionId else return errorMessage
*/
public function getVServers() {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
);
$getVServerResult = $this->soap_client->getVServers($params);
return $getVServerResult->return;
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String
*/
public function getVServerState($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$startVServerResult = $this->soap_client->getVServerState($params);
return $startVServerResult->return;
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String
*/
public function getVServerLoad($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$startVServerResult = $this->soap_client->getVServerLoad($params);
return $startVServerResult->return;
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String
*/
public function getVServerUptime($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$startVServerResult = $this->soap_client->getVServerUptime($params);
return $startVServerResult->return;
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String[]
*/
public function getVServerIPs($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$startVServerResult = $this->soap_client->getVServerIPs($params);
return $startVServerResult->return;
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String if action deleteVServer successfully started return actionId else return errorMessage
*/
public function startVServer($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$startVServerResult = $this->soap_client->startVServer($params);
if ($startVServerResult->return->success) {
return $startVServerResult->return->exceptionMessage;
} else {
if ($startVServerResult->return->exceptionMessage != NULL) {
return $startVServerResult->return->exceptionMessage;
} else {
return "undefined error";
}
}
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String if action deleteVServer successfully started return actionId else return errorMessage
*/
public function stopVServer($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
$stopVServerResult = $this->soap_client->stopVServer($params);
if ($stopVServerResult->return->success) {
return $stopVServerResult->return->exceptionMessage;
} else {
if ($stopVServerResult->return->exceptionMessage != NULL) {
return $stopVServerResult->return->exceptionMessage;
} else {
return "undefined error";
}
}
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String if action deleteVServer successfully started return actionId else return errorMessage
*/
public function getFirewall($vserverName) {
try {
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName
);
return$this->soap_client->getFirewall($params);
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
/**
*
* @param String $vserverName needed
* @return String if action deleteVServer successfully started return actionId else return errorMessage
*/
public function addFirewallRule($vserverName, $direction, $proto, $srcip, $srcport, $srcportrange, $destip, $destport, $destportrange, $match, $matchvalue, $target) {
try {
$rule_params = array(
'direction' => $direction, // string needed
'proto' => $proto, // string needed
'srcIP' => $srcip,
'srcPort' => $srcport,
'destIP' => $destip,
'destPort' => $destport,
'match' => $match,
'matchValue' => $matchvalue,
'srcPortRange' => $srcportrange,
'destPortRange' => $destportrange,
'target' => $target,
'valid' => false,
'id' => 0,
);
$params = array(
'loginName' => $this->loginname,
'password' => $this->password,
'vserverName' => $vserverName,
'rule' => array($rule_params),
);
return $this->soap_client->addFirewallRule($params);
} catch (Exception $e) {
return "Exception occured: " . $e->getMessage();
}
}
}
?>
$vcpWebServiceEndUser = new VcpWebServiceEndUser("<VCPLOGINNAME>", "<VCPLOGINPASSWORD>");
var_dump($vcpWebServiceEndUser->getVServers());