Ich stell jetzt einfach mal die (hässliche) PHP-Lösung von uns online, ich habe die etwas modifiziert, damit die Standalone lauffähig ist:
<?php
function callLiveConfigPhpOption($func, $data = "") {
$url = "https://liveconfig.host:8443";
$usr = "admin";
$pwd = "SOAP_PASSWORD_HERE";
try {
if($func == "GetLiveConfigUrl") return $url;
foreach($data as &$v)
$v = str_replace("##apiusr##", $usr, $v);
$wsdl_url = $url . "/liveconfig/soap?wsdl&l=" . urlencode($usr) . "&p=" . urlencode($pwd);
$client = new SoapClient(
$wsdl_url,
[
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL,
]
);
$ts = gmdate("Y-m-d") . "T" . gmdate("H:i:s") . ".000Z";
$token = base64_encode(hash_hmac("sha1", "LiveConfig" . $usr . $func . $ts, $pwd, true));
$data['auth'] = [
'login' => $usr,
'timestamp' => $ts,
'token' => $token,
];
return $client->$func($data);
} catch (SoapFault $soapFault) {
die($soapFault->faultstring != "SOAP-ERROR: Parsing WSDL: Couldn't bind to service" ? $soapFault->faultstring : "Falsche Zugangsdaten.");
}
}
function setLiveConfigPhpOption($subscription_name, Array $settings) {
$cookieStr = rand(10000000, 99999999) . rand(10000000, 99999999) . rand(10000000, 99999999);
$cookieFile = __DIR__ . "/.lcphpcookie" . $cookieStr;
$subscription = callLiveConfigPhpOption("HostingSubscriptionGet", ['subscriptionname' => $subscription_name]);
if(empty($subscription->customerid)) {
throw new Exception("Own hosting not supported.");
}
$customers = callLiveConfigPhpOption("CustomerGet", []);
$customer = null;
foreach($customers->customers->CustomerDetails as $c)
if($c->id == $subscription->customerid)
$customer = $c;
if($customer === null) {
throw new Exception("Customer not found.");
}
$cid = $customer->cid;
$token = callLiveConfigPhpOption("SessionCreate", ['login' => '##apiusr##'])->token;
$ch = curl_init(callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/login/sso?token=" . $token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$session_id = substr($url, -24);
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/hosting/php?id=" . $session_id);
$html = curl_exec($ch);
$pos = strpos($html, "var list = ");
if($pos === null){
throw new Exception("PHP default settings not found.");
}
$json = substr($html, $pos + 11);
$json = substr($json, 0, strpos($json, "];") + 1);
$json = str_replace(['id:', 'title:'], [''id':', ''title':'], $json);
$json = json_decode($json);
$php_oid = $json[0]->id;
if(empty($php_oid)){
throw new Exception("PHP default settings not found (2).");
}
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/hosting/php/query?id=" . $session_id . "&oid=" . $php_oid);
$res = curl_exec($ch);
$pos = strpos($res, "var data=");
if($pos === null){
throw new Exception("PHP default options not found.");
}
$json = substr($res, $pos + 9);
$json = substr($json, 0, strpos($json, "};") + 1);
$json = json_decode($json)->data;
$php_settings = [];
foreach($json as $v)
$php_settings[$v->cols[0]] = $v->id;
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/search");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'id' => $session_id,
's' => $cid,
'submit' => '',
]));
$html = curl_exec($ch);
$pos = strpos($html, "var r= ");
if($pos === null){
throw new Exception("Customer not found in search result.");
}
$json = substr($html, $pos + 7);
$json = substr($json, 0, strpos($json, "};") + 1);
$customers = json_decode($json)->data;
$final_cid = "";
foreach($customers as $c)
if($c->cols[0] == $cid)
$final_cid = $c->id;
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/admin/customers/details/subscriptions?id=$session_id&oid=$final_cid");
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_POST, false);
$html = curl_exec($ch);
$pos = strpos($html, "var list = ");
if($pos === null){
throw new Exception("Subscription not found in search result.");
}
$json = substr($html, $pos + 11);
$json = substr($json, 0, strpos($json, "];") + 1);
$json = str_replace(['id:', 'title:'], [''id':', ''title':'], $json);
$subscriptions = json_decode($json);
$final_oid = "";
foreach($subscriptions as $c)
if($c->title == $subscription_name)
$final_oid = $c->id;
if(empty($final_oid)){
throw new Exception("Subscription not found in customers subscriptions.");
}
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/admin/customers/details/subscriptions/edit/php");
foreach($settings as $setting_id => $value) {
if(!array_key_exists($setting_id, $php_settings)){
throw new Exception("PHP setting $setting_id not found.");
}
if(is_numeric($value)) {
$vint = $value;
$unit = 0;
} else {
$vint = substr($value, 0, -1);
$unit = 2;
}
$data = [
'diff' => '1',
'vint' => $vint,
'unit' => $unit,
'id' => $session_id,
'cid' => $final_oid,
'oid' => $final_cid,
'v' => $php_settings[$setting_id],
"a" => "1",
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_exec($ch);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_URL, callLiveConfigPhpOption("GetLiveConfigUrl") . "/liveconfig/logout?id=$session_id");
curl_exec($ch);
curl_close($ch);
unlink($cookieFile);
}
setLiveConfigPhpOption("lcphpcust", [
'max_execution_time' => '90',
'memory_limit' => '100M',
'upload_max_filesize' => '100M',
'post_max_size' => '101M',
]);
Alles anzeigen
Als Werte werden nur Integer akzeptiert, oder mit einem "M" dahinter auch Angaben in MB. Andere Einheiten werden derzeit nicht unterstützt, da wir diese schlicht nicht brauchen.
Es können nur Kundenabonnements bearbeitet werden, keine "Mein Hosting"-Abonnements.