Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $cpuser="demo";
- $pass="test";
- $apipath = "/xml-api/passwd?user=$cpuser&pass=$newpass";
- $listpath = "/xml-api/listaccts";
- // $hash = your hash (not needed if using password authentication, if using uncomment user and pass vars)
- $hash = "edited;
- $user = "root";
- $pass = "edited";
- $server = "edited";
- # Make hash into one long string, in case it isn't already
- $hash = str_replace("\n","",$hash);
- # Open a socket for HTTPS
- $fp = fsockopen("ssl://" . $server, 2087, $errno, $errstr, 30);
- # Die on error initializing socket
- if ($errno == 0 && $fp == FALSE) {
- die("Socket Error: Could not initialize socket.");
- } elseif ($fp == FALSE) {
- die("Socket Error #" . $errno . ": " . $errstr);
- }
- # Assemble the header to send
- $header = "";
- $header .= "GET " . $listpath . " HTTP/1.0\r\n";
- $header .= "Host: " . $server . "\r\n";
- $header .= "Connection: Close\r\n";
- $header .= "Authorization: WHM " . $user . ":" . $hash . "\r\n";
- # Comment above line and uncomment below line to use password authentication in place of hash authentication
- //$header .= "Authorization: Basic " . base64_encode($user . ":" . $pass) . "\r\n";
- $header .= "\r\n";
- # Send the Header
- fputs($fp, $header);
- # Get the raw output from the server
- $rawResult = "";
- while (!feof($fp)) {
- $rawResult .= @fgets($fp, 128); // Suppress errors with @
- }
- # Close the socket
- fclose($fp);
- # Ignore headers
- $rawResultParts = explode("\r\n\r\n",$rawResult);
- $result = $rawResultParts[1];
- # Output XML
- echo $result;
Add Comment
Please, Sign In to add comment