Guest User

Untitled

a guest
Jan 4th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php
  2.  
  3. check_login('3');
  4.  
  5. $username = $_SESSION['username'];
  6.  
  7. if($_GET['submit'] == NULL) {
  8.  
  9. ?>
  10.  
  11. <h2><a href="#">Dashboard</a> &raquo; <a href="#" class="active">Backup Files</a></h2>
  12.  
  13. <div id="main">
  14. <h3>Existing Backups</h3>
  15. <table cellpadding="0" cellspacing="0">
  16. <tr>
  17.  
  18. <?php
  19. $domains = mysql_query("SELECT DISTINCT domain FROM `cpanel` WHERE username = '$username'");
  20. $num = mysql_num_rows($domains);
  21.  
  22. if ($num == 0) {
  23. echo "<tr>";
  24. echo "<td>You have no backups configured, click <a href=\"index.php?page=add\">here</a> to get started!</td>";
  25. echo "</tr>";
  26. }
  27. else {
  28.  
  29. function is_txt($file) {
  30. // return preg_match('/.*\.tar.gz/', $file) > 0;
  31. return preg_match('/backup-[0-9]/', $file) > 0;
  32. }
  33.  
  34. while($domain = mysql_fetch_array($domains)) {
  35. echo '<tr><td colspan=2><h3>'.$domain['domain'].'</h3></td></tr>';
  36.  
  37. $query = mysql_query("SELECT * FROM `cpanel` WHERE username = '$username' AND domain='".$domain['domain']."'");
  38. $num = mysql_num_rows($query);
  39.  
  40.  
  41. while($row = mysql_fetch_array($query)) {
  42.  
  43. // main display loop
  44.  
  45. $ftp_server = $row['domain'];
  46. $ftp_user_name = $row['cpuser'];
  47. $ftp_user_pass = $row['cppass'];
  48.  
  49. // set up basic connection
  50. $conn_id = ftp_connect($ftp_server);
  51.  
  52. // login with username and password
  53. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  54.  
  55. $list = ftp_nlist($conn_id, '.');
  56.  
  57.  
  58. $filtered = array_filter($list, is_txt);
  59.  
  60. //$file = $_GET['file'];
  61. //print_r($filtered);
  62. foreach( $filtered as $name => $file){
  63. // get the size of $file
  64. $res = ftp_size($conn_id, $file)/1048576;
  65. $rou = round($res);
  66.  
  67. echo "<tr>";
  68. echo "<td>".$file."</td>";
  69. echo "<td class=\"action\"><a href=\"#\" class=\"view\">";if ($res != -1) { echo "$rou MB";} else { echo "Error";} echo "</a><a href=\"index.php?page=ftpdel&file=".$file."&domain=".$domain['domain']."\" class=\"delete\">Delete</a></td>";
  70. echo "</tr>";
  71.  
  72. }
  73. ftp_close($conn_id);
  74. }
  75.  
  76. }
  77.  
  78. }
  79. }
  80.  
  81.  
  82.  
  83. elseif($_GET['submit'] != "yes" && $_GET['submit'] != NULL && $_GET['edit'] != NULL) {
  84.  
  85. echo "You're on a page you shouldn't be. ";
  86.  
  87. }
  88.  
  89.  
  90. ?>
  91.  
  92. </tr>
  93. </table>
  94. <br>
  95. </div>
Add Comment
Please, Sign In to add comment