Guest User

Untitled

a guest
Jun 10th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php
  2.  
  3. // Server credentials
  4. $vst_hostname = 'server.vestacp.com';
  5. $vst_username = 'admin';
  6. $vst_password = 'p4ssw0rd';
  7. $vst_returncode = 'yes';
  8. $vst_command = 'v-add-user';
  9.  
  10. // New Account
  11. $username = 'demo';
  12. $password = 'd3m0p4ssw0rd';
  13. $email = 'demo@gmail.com';
  14. $package = 'default';
  15. $fist_name = 'Rust';
  16. $last_name = 'Cohle';
  17.  
  18. // Prepare POST query
  19. $postvars = array(
  20. 'user' => $vst_username,
  21. 'password' => $vst_password,
  22. 'returncode' => $vst_returncode,
  23. 'cmd' => $vst_command,
  24. 'arg1' => $username,
  25. 'arg2' => $password,
  26. 'arg3' => $email,
  27. 'arg4' => $package,
  28. 'arg5' => $fist_name,
  29. 'arg6' => $last_name
  30. );
  31. $postdata = http_build_query($postvars);
  32.  
  33. // Send POST query via cURL
  34. $postdata = http_build_query($postvars);
  35. $curl = curl_init();
  36. curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
  37. curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
  38. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  39. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  40. curl_setopt($curl, CURLOPT_POST, true);
  41. curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  42. $answer = curl_exec($curl);
  43.  
  44. // Check result
  45. if($answer == 0) {
  46. echo "User account has been successfuly created\n";
  47. } else {
  48. echo "Query returned error code: " .$answer. "\n";
  49. }
  50. ?>
Add Comment
Please, Sign In to add comment