/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/controllers/ajax/quickstart_form.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
<?php
if ( ! is_admin() ) { die( 'Access denied.' ); }

// Quick Start form saving.

/* quickstart_form()
*
* Saving Quickstart form.
*
*/


$errors = array();
$form pb_backupbuddy::_POST();
//print_r( $form );

if ( ( '' != $form['email'] ) && ( false !== stristr$form['email'], '@' ) ) ) {
    
pb_backupbuddy::$options['email_notify_error'] = strip_tags$form['email'] );
} else {
    
$errors[] = 'Invalid email address.';
}

if ( ( 
'' != $form['password'] ) && ( $form['password'] == $form['password_confirm'] ) ) {
    
pb_backupbuddy::$options['importbuddy_pass_hash'] = md5$form['password'] );
    
pb_backupbuddy::$options['importbuddy_pass_length'] = strlen$form['password'] );
} elseif ( 
'' == $form['password'] ) {
    
$errors[] = 'Please enter a password for restoring / migrating.';
} else {
    
$errors[] = 'Passwords do not match.';
}

if ( 
'' != $form['schedule'] ) {
    
$destination_id '';
    if ( 
'' != $form['destination_id'] ) { // Dest id explicitly set.
        
$destination_id $form['destination_id'];
    } else { 
// No explicit destination ID; deduce it.
        
if ( '' != $form['destination'] ) {
            foreach( 
pb_backupbuddy::$options['remote_destinations'] as $destination_index => $destination ) { // Loop through ending with the last created destination of this type.
                
if ( $destination['type'] == $form['destination'] ) {
                    
$destination_id $destination_index;
                }
            }
        }
    }
    
    function 
pb_backupbuddy_schedule_exist_by_title$title ) {
        foreach( 
pb_backupbuddy::$options['schedules'] as $schedule ) {
            if ( 
$schedule['title'] == $title ) {
                return 
true;
            }
        }
        return 
false;
    }
    
    
// STARTER
    
if ( 'starter' == $form['schedule'] ) {
        
        
$title 'Weekly Database (Quick Setup - Starter)';
        if ( 
false === pb_backupbuddy_schedule_exist_by_title$title ) ) {
            
$add_response backupbuddy_api::addSchedule(
                
$title,
                
$profile '1',
                
$interval 'weekly',
                
$first_run = ( time() + ( get_option'gmt_offset' ) * 3600 ) + 86400 ),
                
$remote_destinations = array( $destination_id )
            );
            if ( 
true !== $add_response ) { $errors[] = $add_response; }
        }
        
        
$title 'Monthly Full (Quick Setup - Starter)';
        if ( 
false === pb_backupbuddy_schedule_exist_by_title$title ) ) {
            
$add_response backupbuddy_api::addSchedule(
                
$title,
                
$profile '2',
                
$interval 'monthly',
                
$first_run = ( time() + ( get_option'gmt_offset' ) * 3600 ) + 86400 18000 ),
                
$remote_destinations = array( $destination_id )
            );
            if ( 
true !== $add_response ) { $errors[] = $add_response; }
        }
        
    }
    
    
// BLOGGER
    
if ( 'blogger' == $form['schedule'] ) {
        
        
$title 'Daily Database (Quick Setup - Blogger)';
        if ( 
false === pb_backupbuddy_schedule_exist_by_title$title ) ) {
            
$add_response backupbuddy_api::addSchedule(
                
$title,
                
$profile '1',
                
$interval 'daily',
                
$first_run = ( time() + ( get_option'gmt_offset' ) * 3600 ) + 86400 ),
                
$remote_destinations = array( $destination_id )
            );
            if ( 
true !== $add_response ) { $errors[] = $add_response; }
        }
        
        
$title 'Weekly Full (Quick Setup - Blogger)';
        if ( 
false === pb_backupbuddy_schedule_exist_by_title$title ) ) {
            
$add_response backupbuddy_api::addSchedule(
                
$title,
                
$profile '2',
                
$interval 'weekly',
                
$first_run = ( time() + ( get_option'gmt_offset' ) * 3600 ) + 86400 18000 ),
                
$remote_destinations = array( $destination_id )
            );
            if ( 
true !== $add_response ) { $errors[] = $add_response; }
        }
        
    }
    
    
// end set schedule.


if ( == count$errors ) ) {
    
pb_backupbuddy::save();
    die( 
'Success.' );
} else {
    die( 
implode"\n"$errors ) );
}