Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* php script
- * first I login to my account to get the cookie
- * next I open link (together with login cookie) with command to boot vps and return the response code in json
- * fill out UsernameHere , PasswordHere and IdOfServiceHere
- */
- function getCookie($url){
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'); // spoof
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HEADER, true);
- $output = curl_exec($ch);
- curl_close($ch);
- $regex = '/Set-Cookie: (.+?); path=\/; HttpOnly/';
- preg_match($regex,$output,$match);
- if(count($match) == 0){
- return "";
- }
- else{
- return 'Cookie: '.$match[1];
- }
- }
- function curlWithCookie($url,$cookie){
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'); // spoof
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $headers = array();
- $headers[] = $cookie;
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $output = curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- function bootVPS(){
- $cookie=getCookie("https://bill.hostkey.com/dologin.php?username=UsernameHere&password=PasswordHere");
- if($cookie!=""){
- $booting=curlWithCookie('https://bill.hostkey.com/clientarea.php?action=productdetails&id=IdOfServiceHere&json=1&page=home&subaction=startVM',$cookie);
- }else{
- $booting="No cookie found";
- }
- return $booting;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement