'POST', CURLOPT_POSTFIELDS => 'username='.$_POST['username'].'&password='.$_POST['password'], CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded') ); $r = curl_call($_SESSION['ProxmoxApiURL'].'access/ticket', $curlOptions); if(empty($r['error']) && !empty($r['response'])){ $data = @json_decode($r['response'], true); if($data !== false){ $_SESSION['ticket'] = $data['data']['ticket']; $_SESSION['token'] = $data['data']['CSRFPreventionToken']; } } } // LOGON FORM if(empty($_SESSION['ticket']) || empty($_SESSION['ProxmoxApiURL']) || isset($_GET['logon'])){ echo '
'; } else { // SHOW MENU echo ''; print_r($data); echo ''; } } else { echo $r['header']; } } } } function curl_call($url, $options = null){ $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:75.0) Gecko/20100101 Firefox/75.0'); curl_setopt($curl, CURLOPT_NOBODY, false); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_HEADER_OUT, true); if(is_array($options)){ foreach($options AS $k=>$v){ curl_setopt($curl, $k, $v); } } $response = curl_exec($curl); $error = curl_error($curl); $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $responseBody = substr($response, $header_size); return array('error'=>$error, 'header'=>$header, 'response'=>$responseBody); } ?>