-
Notifications
You must be signed in to change notification settings - Fork 0
/
novnc-proxmox.php
34 lines (27 loc) · 1.12 KB
/
novnc-proxmox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, '{{url_endpoint}}/api2/json/access/ticket');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=user@realm&password=xxx");
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}else {
$convertresult = json_decode($result, TRUE);
$CSRFPreventionToken= $convertresult['data']['CSRFPreventionToken'];
$PVEAuthCookie= $convertresult['data']['ticket'];
}
curl_close($ch);
//echo $CSRFPreventionToken;
//echo $PVEAuthCookie;
header("CSRFPreventionToken: $CSRFPreventionToken");
setcookie("PVEAuthCookie", $PVEAuthCookie, time()+7200 , "/", ".arch.my.id");
echo "<a href='https://{{url_endpoint}}/?console=kvm&novnc=1&vmid=XXX&vmname=XXX&node=XXX'>" . _("Open console") . "</a>";
?>