Advertisement
TurnKey_MSP

local_backup.php

May 15th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #!/usr/bin/env php
  2.  
  3. <?php
  4. $cpaneluser = 'cPanel user';
  5. $cpaneluserpass = 'cPanel pass';
  6. $theme = 'paper_lantern';
  7. $ftp = false;
  8. $ftpserver = 'localhost';
  9. $ftpusername = 'cPanel user';
  10. $ftppassword = 'cPanel pass';
  11. $ftpport = 'port of protocol using';
  12. $ftpdirectory = '/must/exist/or/will/fail';
  13.  
  14.  
  15. // Do not edit below this line
  16. $domain = 'localhost';
  17. $secure = true;
  18. $auth = base64_encode($cpaneluser . ":" . $cpaneluserpass);
  19. if ($secure) {
  20. $url = "ssl://" . $domain;
  21. $port = 2083;
  22. } else {
  23. $url = $domain;
  24. $port = 2082;
  25. }
  26. $socket = fsockopen('localhost', 2082);
  27. if (!$socket) {
  28. exit("Failed to open socket connection.");
  29. }
  30. if ($ftp) {
  31. $params =
  32. "dest=scp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate
  33. Backup";
  34. } else {
  35. $params = "submit=Generate Backup";
  36. }
  37. fputs($socket, "POST /frontend/" . $theme . "/backup/dofullbackup.html?"
  38. . $params . " HTTP/1.0\r\n");
  39. fputs($socket, "Host: $domain\r\n");
  40. fputs($socket, "Authorization: Basic $auth\r\n");
  41. fputs($socket, "Connection: Close\r\n");
  42. fputs($socket, "\r\n");
  43. while (!feof($socket)) {
  44. $response = fgets($socket, 4096);
  45. // echo $response; //uncomment this line for debugging
  46. }
  47. fclose($socket);
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement