Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. <?php
  2. check_login('3');
  3. $id=$_REQUEST['id'];
  4. ?>
  5.  
  6. <h2><a href="index.php">Dashboard</a> &raquo; <a href="#" class="active">Reinstall</a></h2>
  7.  
  8. <div id="main">
  9.  
  10. <table cellpadding="0" cellspacing="0">
  11. <tr>
  12.  
  13. <?php
  14. $array = mysql_query("SELECT * FROM cpanel WHERE id = $id AND username = '".$_SESSION['username']."'") or die(mysql_error());
  15. $rows = mysql_fetch_array($array);
  16.  
  17. $people = array($rows['username']);
  18.  
  19. if (in_array($_SESSION['username'],$people, TRUE))
  20. {
  21.  
  22. $select = "SELECT * FROM cpanel WHERE id = $id";
  23. $results = mysql_query($select);
  24. $num_rows = mysql_num_rows($results);
  25.  
  26. while ($row = mysql_fetch_array($results)){
  27.  
  28. // Info required for cPanel access
  29. $cpuser = $row['cpuser']; // Username used to login to CPanel
  30. $cppass = $row['cppass']; // Password used to login to CPanel
  31. $domain = $row['domain']; // Domain name where CPanel is run
  32. $skin = $row['skin']; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme
  33.  
  34. // Info required for FTP host
  35. $ftpuser = $row['ftpuser']; // Username for FTP account
  36. $ftppass = $row['ftppass']; // Password for FTP account
  37. $ftphost = $row['ftphost']; // Full hostname or IP address for FTP host
  38. $ftpmode = $row['ftpmode']; // FTP mode ("ftp" for active, "passiveftp" for passive)
  39. $ftpport = $row['ftpport']; // FTP port
  40. $ftpdir = $row['ftpdir']; // FTP directory
  41.  
  42. // Notification information
  43. $notifyemail = $row['email']; // Email address to send results
  44.  
  45. // Secure or non-secure mode
  46. $secure = $row['secure']; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
  47.  
  48. // Set to 1 to have web page result appear in your cron log
  49. $debug = 1;
  50.  
  51. // *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
  52.  
  53.  
  54. if ($secure) {
  55. $url = "ssl://".$domain;
  56. $port = 2083;
  57. } else {
  58. $url = $domain;
  59. $port = 2082;
  60. }
  61.  
  62. $socket = fsockopen($url,$port);
  63. if (!$socket) {
  64. echo "Failed to open socket connection... Bailing out!\n";
  65. $to = $notifyemail;
  66. $subject = "Backup Failed!";
  67. $message = "Hello! This is a email reminder to let you know that the backup for your cPanel account failed to connect for ".$domain."... Please double check all of your connection settings!";
  68. $from = "failed@freeautobackup.com";
  69. $headers = "From:" . $from;
  70. mail($to,$subject,$message,$headers);
  71. echo "Notifying user!";
  72. exit;
  73. }
  74.  
  75. // Encode authentication string
  76. $authstr = $cpuser.":".$cppass;
  77. $pass = base64_encode($authstr);
  78.  
  79. //local with mail
  80. $m = "email=$notifyemail&submit=Generate Backup";
  81. //remote with mail
  82. $fm = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
  83. //remote with no mail
  84. $fnm = "dest=$ftpmode&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
  85.  
  86. $result = $nm;
  87.  
  88. if ($result == $nm) {
  89. $params = $nm;
  90. }
  91. elseif ($result == $m) {
  92. $params = $m;
  93. }
  94. elseif ($result == $fm) {
  95. $params = $fm;
  96. }
  97. elseif ($result == $fnm) {
  98. $params = $fnm;
  99. }
  100.  
  101. // Make POST to cPanel
  102. fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
  103. fputs($socket,"Host: $domain\r\n");
  104. fputs($socket,"Authorization: Basic $pass\r\n");
  105. fputs($socket,"Connection: Close\r\n");
  106. fputs($socket,"\r\n");
  107.  
  108. // Grab response even if we don't do anything with it.
  109. while (!feof($socket)) {
  110. $response = fgets($socket,4096);
  111. if ($debug) echo $response;
  112. }
  113.  
  114. if(preg_match("/401 access denied/i", $socket)){ echo "hi"; }
  115.  
  116. fclose($socket);
  117.  
  118.  
  119.  
  120. echo "Starting backup for user ".$cpuser." at ".$domain."";
  121. echo "<br>";
  122.  
  123.  
  124. }
  125. }
  126. else
  127. {
  128. echo "This isn't yours...<br />";
  129. }
  130.  
  131. ?>
  132. </tr>
  133. </table>
  134. <br>
  135. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement