Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- check_login('3');
- $username = $_SESSION['username'];
- if($_GET['submit'] == NULL) {
- ?>
- <h2><a href="#">Dashboard</a> » <a href="#" class="active">Backup Files</a></h2>
- <div id="main">
- <h3>Existing Backups</h3>
- <table cellpadding="0" cellspacing="0">
- <tr>
- <?php
- $domains = mysql_query("SELECT DISTINCT domain FROM `cpanel` WHERE username = '$username'");
- $num = mysql_num_rows($domains);
- if ($num == 0) {
- echo "<tr>";
- echo "<td>You have no backups configured, click <a href=\"index.php?page=add\">here</a> to get started!</td>";
- echo "</tr>";
- }
- else {
- function is_txt($file) {
- // return preg_match('/.*\.tar.gz/', $file) > 0;
- return preg_match('/backup-[0-9]/', $file) > 0;
- }
- while($domain = mysql_fetch_array($domains)) {
- echo '<tr><td colspan=2><h3>'.$domain['domain'].'</h3></td></tr>';
- $query = mysql_query("SELECT * FROM `cpanel` WHERE username = '$username' AND domain='".$domain['domain']."'");
- $num = mysql_num_rows($query);
- while($row = mysql_fetch_array($query)) {
- // main display loop
- $ftp_server = $row['domain'];
- $ftp_user_name = $row['cpuser'];
- $ftp_user_pass = $row['cppass'];
- // set up basic connection
- $conn_id = ftp_connect($ftp_server);
- // login with username and password
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
- $list = ftp_nlist($conn_id, '.');
- $filtered = array_filter($list, is_txt);
- //$file = $_GET['file'];
- //print_r($filtered);
- foreach( $filtered as $name => $file){
- // get the size of $file
- $res = ftp_size($conn_id, $file)/1048576;
- $rou = round($res);
- echo "<tr>";
- echo "<td>".$file."</td>";
- 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>";
- echo "</tr>";
- }
- ftp_close($conn_id);
- }
- }
- }
- }
- elseif($_GET['submit'] != "yes" && $_GET['submit'] != NULL && $_GET['edit'] != NULL) {
- echo "You're on a page you shouldn't be. ";
- }
- ?>
- </tr>
- </table>
- <br>
- </div>
Add Comment
Please, Sign In to add comment