/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/destinations/rackspace/_manage.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
//pb_backupbuddy::$ui->title( 'Rackspace Cloudfiles' );
//echo '<h3>Viewing `' . $destination['title'] . '` (' . $destination['type'] . ')</h3>';
    
    // Rackspace information
    
$rs_username $destination['username'];
    
$rs_api_key $destination['api_key'];
    
$rs_container $destination['container'];
    
$rs_server $destination['server'];
    
/*
    if ( isset( $destination['server'] ) ) {
        $rs_server = $destination['server'];
    } else {
        $rs_server = 'https://auth.api.rackspacecloud.com';
    }
    $rs_path = ''; //$destination['path'];
    */
    
    
require_once( pb_backupbuddy::plugin_path() . '/destinations/rackspace/lib/rackspace/cloudfiles.php');
    
$auth = new CF_Authentication$rs_username$rs_api_keyNULL$rs_server );
    
$auth->authenticate();
    
    try {
    
$conn = new CF_Connection$auth );
    } catch (
Exception $e) {
        echo 
'Error #847834: Exception caught accessing Rackspace. If this persists try deleting (by selecting the configure destination button) & re-creating this destination. Details: `' $e->getMessage() . '`.';
        die();
    }
    
    
// Set container
    
$container = @$conn->get_container($rs_container);
    
    
// Delete Rackspace backups
    
if ( !empty( $_POST['delete_file'] ) ) {
        
pb_backupbuddy::verify_nonce();
        
        
$delete_count 0;
        if ( !empty( 
$_POST['files'] ) && is_array$_POST['files'] ) ) {    
            
// loop through and delete Rackspace files
            
foreach ( $_POST['files'] as $rsfile ) {
                
$delete_count++;
                
// Delete Rackspace file
                
$container->delete_object($rsfile);
            }
        }
        if ( 
$delete_count ) {
            
pb_backupbuddy::alertsprintf_n('Deleted %d file''Deleted %d files'$delete_count'it-l10n-backupbuddy' ), $delete_count) );
        }
        echo 
'<br>';
    }
    
    
// Copy Rackspace backup to the local backup files
    
if ( !empty( $_GET['cpy_file'] ) ) {
        
pb_backupbuddy::alert'The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.' );
        echo 
'<br>';
        
pb_backupbuddy::status'details',  'Scheduling Cron for creating Rackspace copy.' );
        
backupbuddy_core::schedule_single_eventtime(), pb_backupbuddy::cron_tag'process_rackspace_copy' ), array( $_GET['cpy_file'], $rs_username$rs_api_key$rs_container$rs_server ) );
        
spawn_crontime() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit.
        
update_option'_transient_doing_cron'); // Prevent cron-blocking for next item.
    
}
    
    
// List objects in container
    /*
    if ( $rs_path != '' ) {
        $results = $container->get_objects( 0, NULL, 'backup-', $rs_path );
    } else {
    */
        
$results $container->get_objects0NULL'backup-');
    
/* } */


$urlPrefix pb_backupbuddy::ajax_url'remoteClient' ) . '&destination_id=' htmlentitiespb_backupbuddy::_GET'destination_id' ) );
?>
<div style="max-width: 950px;">
    <form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php echo $urlPrefix?>">
        <div class="tablenav">
            <div class="alignleft actions">
                <input type="submit" name="delete_file" value="Delete from Rackspace" class="button-secondary delete" />
            </div>
        </div>
        <table class="widefat">
            <thead>
                <tr class="thead">
                    <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries" /></th>
                    <th>Backup File <img src="<?php echo pb_backupbuddy::plugin_url(); ?>/images/sort_down.png" style="vertical-align: 0px;" title="Sorted by filename" /></th>
                    <th>Last Modified</th>
                    <th>File Size</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tfoot>
                <tr class="thead">
                    <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries" /></th>
                    <th>Backup File <img src="<?php echo pb_backupbuddy::plugin_url(); ?>/images/sort_down.png" style="vertical-align: 0px;" title="Sorted by filename" /></th>
                    <th>Last Modified</th>
                    <th>File Size</th>
                    <th>Actions</th>
                </tr>
            </tfoot>
            <tbody>
                <?php
                
                
if ( empty( $results ) ) {
                    echo 
'<tr><td colspan="5" style="text-align: center;"><i>You have not created any Rackspace backups yet.</i></td></tr>';
                } else {
                    
$file_count 0;
                    foreach ( (array) 
$results as $backup ) {
                        
$file_count++;
                        
?>
                        <tr class="entry-row alternate">
                            <th scope="row" class="check-column"><input type="checkbox" name="files[]" class="entries" value="<?php echo $backup->name?>" /></th>
                            <td><?php echo $backup->name?></td>
                            <td style="white-space: nowrap;">
                                <?php
                                    
echo pb_backupbuddy::$format->datepb_backupbuddy::$format->localize_timestrtotime($backup->last_modified) ) );
                                    echo 
'<br /><span class="description">(' pb_backupbuddy::$format->time_agostrtotime($backup->last_modified) ) . ' ago)</span>';
                                
?>
                            </td>
                            <td style="white-space: nowrap;">
                                <?php echo pb_backupbuddy::$format->file_size$backup->content_length ); ?>
                            </td>
                            <td>
                                <?php echo '<a href="' $urlPrefix '&#38;cpy_file=' $backup->name '">Copy to local</a>'?>
                            </td>
                        </tr>
                        <?php
                    
}
                }
                
?>
            </tbody>
        </table>
        <div class="tablenav">
            <div class="alignleft actions">
                <input type="submit" name="delete_file" value="Delete from Rackspace" class="button-secondary delete" />
            </div>
        </div>
        
        <?php pb_backupbuddy::nonce(); ?>
    </form><br />
</div>