Advertisement
Guest User

Untitled

a guest
May 10th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.20 KB | None | 0 0
  1. <?php
  2.  
  3. // PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
  4. // This script contains passwords.  KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/)
  5.  
  6. // ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********
  7.  
  8. // Info required for cPanel access
  9. $cpuser = "*CPANEL USER NAME HERE*"; // Username used to login to CPanel
  10. $cppass = "*CPANEL PASSWORD HERE*"; // Password used to login to CPanel
  11. $domain = "*CPANEL HOSTNAME HERE*"; // Domain name where CPanel is run
  12. $skin = "x3"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme
  13.  
  14. // Info required for FTP host
  15. $ftpuser = "*FTP USER NAME HERE*"; // Username for FTP account
  16. $ftppass = "*FTP PASSWORD HERE*"; // Password for FTP account
  17. $ftphost = "**HOST*:*PORT*"; // Full hostname or IP address for FTP host
  18. $ftpmode = "passiveftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)
  19.  
  20. // Notification information
  21. $notifyemail = "*YOUR EMAIL HERE*"; // 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 = 0;
  28.  
  29. // *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
  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&submit=Generate Backup";
  47.  
  48. // Make POST to cPanel
  49. fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
  50. fputs($socket,"Host: $domain\r\n");
  51. fputs($socket,"Authorization: Basic $pass\r\n");
  52. fputs($socket,"Connection: Close\r\n");
  53. fputs($socket,"\r\n");
  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