Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. // ********* Configuration *********
  5.  
  6. // Info required for cPanel access
  7. $cpuser = "user"; // Username used to login to CPanel
  8. $cppass = "password"; // Password used to login to CPanel
  9. $domain = "cpanel.mydomain.com"; // Domain name where CPanel is run
  10. $skin = "paper_lantern"; // Set to cPanel skin you use (script won't work if it doesn't match)
  11.  
  12. // Info required for FTP host
  13. $ftpuser = "ftpuser"; // Username for FTP account
  14. $ftppass = "ftppassword"; // Password for FTP account
  15. $ftphost = "ftphost"; // Full hostname or IP address for FTP host
  16. $ftpmode = "passiveftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)
  17. $ftpport = "21"; // FTP port, usually 21
  18. $ftpdir = "/ftp/directory"; // Path to folder where backups should be stored off of FTP root. Folder must exist.
  19.  
  20. // Notification information
  21. $notifyemail = "email"; // Email address to send results
  22.  
  23. // Secure or non-secure mode
  24. $secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
  25.  
  26. // Set to 1 to have web page result appear in your cron log
  27. $debug = 1;
  28.  
  29. // *********** Don't Touch!! *********
  30.  
  31. if ($secure) {
  32. $url = "ssl://".$domain;
  33. $port = 2083;
  34. } else {
  35. $url = $domain;
  36. $port = 2082;
  37. }
  38.  
  39. $socket = fsockopen($url,$port);
  40. if (!$socket) { echo "Failed to open socket connection... Bailing out!n"; exit; }
  41.  
  42. // Encode authentication string
  43. $authstr = $cpuser.":".$cppass;
  44. $pass = base64_encode($authstr);
  45.  
  46. $params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
  47.  
  48. // Make POST to cPanel
  49. fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0rn");
  50. fputs($socket,"Host: $domainrn");
  51. fputs($socket,"Authorization: Basic $passrn");
  52. fputs($socket,"Connection: Closern");
  53. fputs($socket,"rn");
  54.  
  55. // Grab response even if we don't do anything with it.
  56. while (!feof($socket)) {
  57. $response = fgets($socket,4096);
  58. if ($debug) echo $response;
  59. }
  60.  
  61. fclose($socket);
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement