/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/controllers/pages/scheduling.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php
//print_r( backupbuddy_api::getOverview() );


//pb_backupbuddy::load_script( 'jquery-ui-core', true ); // WP core script.
pb_backupbuddy::load_script'jquery-ui-datepicker'true ); // WP core script.
pb_backupbuddy::load_script'jquery-ui-slider'true ); // WP core script.
pb_backupbuddy::load_script'timepicker.js' );

pb_backupbuddy::load_style'admin.css'false ); // Plugin-specific file.
pb_backupbuddy::load_style'jquery_smoothness.css'false ); // Plugin-specific file.
?>


<script type="text/javascript">
jQuery(document).ready(function(){
    
    // WP 3.2.1 does not like the datepicker and breaks other JS so we omit it if it failed to load properly.
    if (jQuery.isFunction(jQuery.fn.datepicker)) {
        jQuery( '#pb_backupbuddy_first_run' ).datetimepicker({
            ampm: true
        });
    }
    
});
</script>

<?php

backupbuddy_core
::versions_confirm();
$date_format_example 'mm/dd/yyyy hh:mm [am/pm]'// Example date format for displaying to user.


// HANDLE SCHEDULE DELETION.
if ( pb_backupbuddy::_POST'bulk_action' ) == 'delete_schedule' ) {
    
pb_backupbuddy::verify_noncepb_backupbuddy::_POST'_wpnonce' ) ); // Security check to prevent unauthorized deletions by posting from a remote place.
    
    
$deleted_schedules = array();
    foreach( 
pb_backupbuddy::_POST'items' ) as $id ) {
        
$deleted_schedules[] = htmlentitiespb_backupbuddy::$options['schedules'][$id]['title'] );
        
        
backupbuddy_api::deleteSchedule$id$confirm true );
        
    } 
// end foreach.
    
    
pb_backupbuddy::alert__'Deleted schedule(s):''it-l10n-backupbuddy' ) . ' ' implode', '$deleted_schedules ) );
// End if deleting backup(s).



// Run schedule manually now.
if ( pb_backupbuddy::_GET'run' ) != '' ) {
    
pb_backupbuddy::alert'Manually running scheduled backup "' pb_backupbuddy::$options['schedules'][pb_backupbuddy::_GET'run' )]['title'] . '" in the background.' '<br>' .
        
__'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.''it-l10n-backupbuddy' ) );
    
do_action_ref_array'pb_backupbuddy-cron_scheduled_backup', array( (int)pb_backupbuddy::_GET'run' ) ) );
}


// Edit existing schedule.
if ( pb_backupbuddy::_GET'edit' ) != '' ) {
    
$mode 'edit';
    
$data['mode_title'] = __('Save Schedule''it-l10n-backupbuddy' );
    
$savepoint 'schedules#' pb_backupbuddy::_GET'edit' );
    
    
$next_run wp_next_scheduled'pb_backupbuddy-cron_scheduled_backup', array( (int)pb_backupbuddy::_GET'edit' ) ) );
    
    
$first_run_value date('m/d/Y h:i a'$next_run + ( get_option'gmt_offset' ) * 3600 ) ); // pb_backupbuddy::$options['schedules'][pb_backupbuddy::_GET( 'edit' )]['first_run']
    
    
$remote_destinations explode'|'pb_backupbuddy::$options['schedules'][pb_backupbuddy::_GET'edit' )]['remote_destinations'] );
    
$remote_destinations_html '';
    foreach( 
$remote_destinations as $destination ) {
        if ( isset( 
$destination ) && ( $destination != '' ) ) {
            
$remote_destinations_html .= '<li id="pb_remotedestination_' $destination '">';
            
$remote_destinations_html .= pb_backupbuddy::$options['remote_destinations'][$destination]['title'];
            
$remote_destinations_html .= ' (' backupbuddy_core::pretty_destination_typepb_backupbuddy::$options['remote_destinations'][$destination]['type'] ) . ') ';
            
$remote_destinations_html .= '<img class="pb_remotedestionation_delete" src="' pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px; cursor: pointer;" title="' __'Remove remote destination from this schedule.''it-l10n-backupbuddy' ) . '" />';
            
$remote_destinations_html .= '</li>';
        }
    }
    
$remote_destinations '<ul id="pb_backupbuddy_remotedestinations_list">' $remote_destinations_html '</ul>';
} else {
    
$mode 'add';
    
$data['mode_title'] = __('Add New Schedule''it-l10n-backupbuddy' );
    
$savepoint false;
    
    
$first_run_value date('m/d/Y h:i a'time() + ( ( get_option'gmt_offset' ) * 3600 ) + 86400 ) );
    
$remote_destinations '<ul id="pb_backupbuddy_remotedestinations_list"></ul>';
}




$schedule_form = new pb_backupbuddy_settings'scheduling'$savepoint'edit=' pb_backupbuddy::_GET'edit' ), 250 );

$schedule_form->add_setting( array(
    
'type'        =>        'text',
    
'name'        =>        'title',
    
'title'        =>        'Schedule name',
    
'tip'        =>        __('This is a name for your reference only.''it-l10n-backupbuddy' ),
    
'rules'        =>        'required',
) );

$profile_list = array();
foreach( 
pb_backupbuddy::$options['profiles'] as $profile_id => $profile ) {
    if ( 
$profile_id == ) { continue; } // default profile.
    
if ( $profile['type'] == 'full' ) {
        
$pretty_type 'Full';
    } elseif ( 
$profile['type'] == 'db' ) {
        
$pretty_type 'Database Only';
        } elseif ( 
$profile['type'] == 'files' ) {
        
$pretty_type 'Files Only';
    } else {
        
$pretty_type 'Unknown';
    }
    
$profile_list$profile_id ] = htmlentities$profile['title'] ) . ' (' $pretty_type ')';
}
$schedule_form->add_setting( array(
    
'type'        =>        'select',
    
'name'        =>        'profile',
    
'title'        =>        'Backup profile',
    
'options'    =>        $profile_list,
    
'tip'        =>        __'Full backups contain all files (except exclusions) and your database. Database only backups consist of an export of your mysql database; no WordPress files or media. Database backups are typically much smaller and faster to perform and are typically the most quickly changing part of a site.''it-l10n-backupbuddy' ),
    
'rules'        =>        'required',
) );

if ( 
pb_backupbuddy::_GET'edit' ) != '' ) {
    
$defaultInterval null;
} else {
    
$defaultInterval 'daily';
}
$schedule_form->add_setting( array(
    
'type'        =>        'select',
    
'name'        =>        'interval',
    
'title'        =>        'Backup interval',
    
'options'    =>        array(
                            
'yearly'        =>        'Yearly',
                            
'monthly'        =>        'Monthly',
                            
'twicemonthly'    =>        'Twice Monthly',
                            
'weekly'        =>        'Weekly',
                            
'twiceweekly'    =>        'Twice Weekly',
                            
'everyotherday'    =>        'Every Other Day',
                            
'daily'            =>        'Daily',
                            
'twicedaily'    =>        'Twice Daily',
                            
'hourly'        =>        'Hourly',
                        ),
    
'default'    =>        $defaultInterval,
    
'tip'        =>         __'Time period between backups.''it-l10n-backupbuddy' ),
    
'rules'        =>        'required',
    
'after'        =>        '&nbsp;&nbsp;&nbsp;<span class="pb_label">Tip</span> Unsure how often to schedule? Try starting with daily database-only and weekly full backups.',
) );
$schedule_form->add_setting( array(
    
'type'        =>        'text',
    
'name'        =>        'first_run',
    
'title'        =>        'Date/time of next run',
    
'tip'        =>        __'IMPORTANT: For scheduled events to occur someone (or you) must visit this site on or after the scheduled time. If no one visits your site for a long period of time some backup events may not be triggered.''it-l10n-backupbuddy' ),
    
'rules'        =>        'required',
    
'default'    =>        $first_run_value,
    
'after'        =>        ' ' __('Currently''it-l10n-backupbuddy' ) . ' <code>' date'm/d/Y h:i a ' get_option'gmt_offset' ), time() + ( get_option'gmt_offset' ) * 3600 ) ) . ' UTC</code> ' __('based on''it-l10n-backupbuddy' ) . ' <a href="' admin_url'options-general.php' ) . '">' __'WordPress settings''it-l10n-backupbuddy' ) . '</a>.',
) );
$schedule_form->add_setting( array(
    
'type'        =>        'text',
    
'name'        =>        'remote_destinations',
    
'title'        =>        'Remote backup destination(s)',
    
'rules'        =>        '',
    
'css'        =>        'display: none;',
    
'after'        =>        $remote_destinations '<a href="' pb_backupbuddy::ajax_url'destination_picker' ) . '&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox button secondary-button" style="margin-top: 3px;" title="' __'Select a Destination''it-l10n-backupbuddy' ) . '">' __('+ Add Remote Destination''it-l10n-backupbuddy' ) . '</a>',
) );
$schedule_form->add_setting( array(
    
'type'        =>        'checkbox',
    
'name'        =>        'delete_after',
    
'title'        =>        '&nbsp;',
    
'after'        =>        ' '__'Delete local backup file after remote send success''it-l10n-backupbuddy' ),
    
'options'    =>        array( 'checked' => '1''unchecked' => '0' ),
    
'rules'        =>        '',
) );
$schedule_form->add_setting( array(
    
'type'        =>        'checkbox',
    
'name'        =>        'on_off',
    
'title'        =>        'Schedule enabled?',
    
'options'    =>        array( 'checked' => '1''unchecked' => '0' ),
    
'default'    =>        '1',
    
'tip'        =>        __'[Default: enabled] When disabled this schedule will be effectively turned off. This scheduled backup will not occur when disabled / off. You can re-enable schedules by editing them.''it-l10n-backupbuddy' ),
    
'after'        =>        ' ' __'Enable schedule to run''it-l10n-backupbuddy' ),
) );



// PROCESS ADDING SCHEDULE.
$submitted_schedule $schedule_form->process(); // Handles processing the submitted form (if applicable).

if ( ( $submitted_schedule != '' ) && ( count $submitted_schedule['errors'] ) == ) ) {
    
    
// ADD SCHEDULE.
    
if ( pb_backupbuddy::_GET'edit' ) == '' ) { // ADD SCHEDULE.
        
$error false;
        
        
// Don't allow 'delete file after send to destination' if no destination picked.
        
if ( ( $submitted_schedule['data']['delete_after'] == '1' ) && ( '' == trim$submitted_schedule['data']['remote_destinations'] ) ) ) {
            
pb_backupbuddy::alert'Error: You have selected to delete backups after sending but did not specify any remote destinations. Click "Add Remote Destination" to select a destination.'true );
            
$error true;
        }
        
        if ( ( 
$submitted_schedule['data']['first_run'] == ) || ( $submitted_schedule['data']['first_run'] == 18000 ) ) {
            
pb_backupbuddy::alertsprintf(__('Invalid time format. Please use the specified format / example %s''it-l10n-backupbuddy' ) , $date_format_example) );
            
$error true;
        }
        
        
$remote_destinations trim$submitted_schedule['data']['remote_destinations'], '|' );
        
$remote_destinations explode'|'$remote_destinations );
        if ( 
'1' == $submitted_schedule['data']['delete_after'] ) {
            
$delete_after true;
        } else {
            
$delete_after false;
        }
        
        if ( 
'1' == $submitted_schedule['data']['on_off'] ) {
            
$enabled true;
        } else {
            
$enabled false;
        }
        
        if ( 
$error === false ) {
            
            
$add_response backupbuddy_api::addSchedule(
                
$title $submitted_schedule['data']['title'],
                
$profile $submitted_schedule['data']['profile'],
                
$interval $submitted_schedule['data']['interval'],
                
$first_run pb_backupbuddy::$format->unlocalize_timestrtotime$submitted_schedule['data']['first_run'] ) ),
                
$remote_destinations,
                
$delete_after,
                
$enabled
            
);
                
            if ( 
true !== $add_response ) {
                
pb_backupbuddy::alert'Error scheduling: ' $add_response );
            } else { 
// Success
                
pb_backupbuddy::save();
                
$schedule_form->clear_values();
                
pb_backupbuddy::alert'Added new schedule `' htmlentities$submitted_schedule['data']['title'] ) . '`.' );
            }
        }
    } else { 
// EDIT SCHEDULE. Form handles saving; just need to update timestamp.
        
$first_run pb_backupbuddy::$format->unlocalize_timestrtotime$submitted_schedule['data']['first_run'] ) );
        if ( ( 
$first_run == ) || ( $first_run == 18000 ) ) {
            
pb_backupbuddy::alertsprintf(__('Invalid time format. Please use the specified format / example %s''it-l10n-backupbuddy' ) , $date_format_example) );
            
$error true;
        }
        
        
pb_backupbuddy::$options['schedules'][pb_backupbuddy::_GET'edit' )]['first_run'] = $first_run;
        
//echo 'first: ' . $first_run;
        
        
$next_scheduled_time wp_next_scheduled'pb_backupbuddy-cron_scheduled_backup', array( (int)$_GET['edit'] ) );
        
$result backupbuddy_core::unschedule_event$next_scheduled_time'pb_backupbuddy-cron_scheduled_backup', array( (int)$_GET['edit'] ) ); // Remove old schedule. pb_backupbuddy::$options['schedules'][$_GET['edit']]['first_run']
        
if ( $result === FALSE ) {
            
pb_backupbuddy::alert'Error #589689. Unable to unschedule scheduled cron job with WordPress. Please see your BackupBuddy error log for details.' );
        }
        
$result backupbuddy_core::schedule_event$first_run$submitted_schedule['data']['interval'], 'pb_backupbuddy-cron_scheduled_backup', array( (int)$_GET['edit'] ) ); // Add new schedule.
        
if ( $result === FALSE ) {
            
pb_backupbuddy::alert'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439. Check your BackupBuddy error log for details.'true );
        }
        
pb_backupbuddy::save();
        
pb_backupbuddy::alert'Edited schedule `' htmlentities$submitted_schedule['data']['title'] ) . '`.' );
    }
    
} elseif ( 
count $submitted_schedule['errors'] ) > ) {
    foreach( 
$submitted_schedule['errors'] as $error ) {
        
pb_backupbuddy::alert$error );
    }
}
$data['schedule_form'] = $schedule_form;









$schedules = array();
foreach ( 
pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule ) {
    
    
$profile pb_backupbuddy::$options['profiles'][ (int)$schedule['profile'] ];
    
    
$title $schedule['title'];
    if ( 
$profile['type'] == 'full' ) {
        
$type 'Full';
    } elseif ( 
$profile['type'] == 'files' ) {
        
$type 'Files only';
    } elseif ( 
$profile['type'] == 'db' ) {
        
$type 'Database only';
    } else {
        
$type 'Unknown (' $schedule['type'] . ')';
    }
    
$type $profile['title'] . ' (' $type ')';
    
$interval $schedule['interval'];
    
    if ( isset( 
$schedule['on_off'] ) && ( $schedule['on_off'] == '0' ) ) {
        
$on_off '<font color=red>Disabled</font>';
    } else {
        
$on_off 'Enabled';
    }
    
    
$destinations explode'|'$schedule['remote_destinations'] );
    
$destination_array = array();
    foreach( 
$destinations as &$destination ) {
        if ( isset( 
$destination ) && ( $destination != '' ) ) {
            
$destination_array[] = pb_backupbuddy::$options['remote_destinations'][$destination]['title'] . ' (' backupbuddy_core::pretty_destination_typepb_backupbuddy::$options['remote_destinations'][$destination]['type'] ) . ')';
        }
    }
    
    
$destinations implode', '$destination_array );
    
    if ( 
count$destination_array ) > ) {
        if ( 
$schedule['delete_after'] == '1' ) {
            
$destinations .= '<br>' '<span class="description">Delete local backup file after send</span>';
        } else {
            
$destinations .= '<br>' '<span class="description">Do not delete local backup file after send</span>';
        }
    } else {
        
$destinations '<span class="description">None</span>';
    }
    
    
// Determine first run.
    
$first_run pb_backupbuddy::$format->datepb_backupbuddy::$format->localize_time$schedule['first_run'] ) );
    
    
// Determine last run.
    
if ( isset( $schedule['last_run'] ) ) { // backward compatibility before last run tracking added. Pre v2.2.11. Eventually remove this.
        
if ( $schedule['last_run'] == ) {
            
$last_run '<i>' __'Never''it-l10n-backupbuddy' ) . '</i>';
        } else {
            
$last_run pb_backupbuddy::$format->datepb_backupbuddy::$format->localize_time$schedule['last_run'] ) );
        }
    } else { 
// backward compatibility for before last run tracking was added.
        
$last_run '<i> ' __'Unknown''it-l10n-backupbuddy' ) . '</i>';
    }
    
    
// Determine next run.
    
$next_run wp_next_scheduled'pb_backupbuddy-cron_scheduled_backup', array( (int)$schedule_id ) );
    if ( 
false === $next_run ) {
        
$next_run '<font color=red>Error: Cron event not found</font>';
        
pb_backupbuddy::alert'Error #874784. WordPress scheduled cron event not found. See "Next Run" time in the schedules list below for problem schedule. This may be caused by a conflicting plugin deleting the schedule or manual deletion. Try editing or deleting and re-creating the schedule.'true );
    } else {
        
$next_run pb_backupbuddy::$format->datepb_backupbuddy::$format->localize_time$next_run ) );
    }
    
    
$run_time 'First run: ' $first_run '<br>' .
        
'Last run: ' $last_run '<br>' .
        
'Next run: ' $next_run;
    
    
$schedules[$schedule_id] = array(
        
$title,
        
$type,
        
$interval,
        
$destinations,
        
$run_time,
        
$on_off,
    );
    
// End foreach.
$data['schedules'] = $schedules;



// Load view.
pb_backupbuddy::load_view'scheduling'$data );


?>