Guest User

Untitled

a guest
Jul 9th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. $cpuser="demo";
  4. $pass="test";
  5. $apipath = "/xml-api/passwd?user=$cpuser&pass=$newpass";
  6.  
  7. $listpath = "/xml-api/listaccts";
  8.  
  9. // $hash = your hash (not needed if using password authentication, if using uncomment user and pass vars)
  10. $hash = "edited;
  11. $user = "root";
  12. $pass = "edited";
  13. $server = "edited";
  14.  
  15.  
  16. # Make hash into one long string, in case it isn't already
  17. $hash = str_replace("\n","",$hash);
  18.  
  19. # Open a socket for HTTPS
  20. $fp = fsockopen("ssl://" . $server, 2087, $errno, $errstr, 30);
  21.  
  22. # Die on error initializing socket
  23. if ($errno == 0 && $fp == FALSE) {
  24. die("Socket Error: Could not initialize socket.");
  25. } elseif ($fp == FALSE) {
  26. die("Socket Error #" . $errno . ": " . $errstr);
  27. }
  28.  
  29. # Assemble the header to send
  30. $header = "";
  31. $header .= "GET " . $listpath . " HTTP/1.0\r\n";
  32. $header .= "Host: " . $server . "\r\n";
  33. $header .= "Connection: Close\r\n";
  34. $header .= "Authorization: WHM " . $user . ":" . $hash . "\r\n";
  35. # Comment above line and uncomment below line to use password authentication in place of hash authentication
  36. //$header .= "Authorization: Basic " . base64_encode($user . ":" . $pass) . "\r\n";
  37. $header .= "\r\n";
  38.  
  39. # Send the Header
  40. fputs($fp, $header);
  41.  
  42. # Get the raw output from the server
  43. $rawResult = "";
  44. while (!feof($fp)) {
  45. $rawResult .= @fgets($fp, 128); // Suppress errors with @
  46. }
  47.  
  48.  
  49. # Close the socket
  50. fclose($fp);
  51.  
  52. # Ignore headers
  53. $rawResultParts = explode("\r\n\r\n",$rawResult);
  54. $result = $rawResultParts[1];
  55.  
  56. # Output XML
  57. echo $result;
Add Comment
Please, Sign In to add comment