/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/lib/updater/updates.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
<?php

/*
Provides a simple interface for connecting iThemes' packages with the updater API.
Written by Chris Jean for iThemes.com
Version 1.3.0

Version History
    1.0.0 - 2013-04-11 - Chris Jean
        Release ready
    1.0.1 - 2013-09-19 - Chris Jean
        Changed the logic in process_server_response to skip updatable packages that have the 'upgrade' data set to a true value.
        Updated requires to not use dirname().
        Updated ithemes-updater-object to ithemes-updater-settings.
    1.1.0 - 2013-10-02 - Chris Jean
        Updated 'url' data for themes to point to the plugin-install.php file in order to show changelog notes as plugins have.
    1.2.0 - 2013-10-04 - Chris Jean
        Added logic to handle skipped updates when force_minor_version_update is set.
    1.2.1 - 2013-10-04 - Chris Jean
        Added a fix to prevent the code from executing if it is loaded by an older updater version. This can happen when updating a theme or plugin.
    1.3.0 - 2013-10-23 - Chris Jean
        Enhancement: Added support for quick_releases setting to force an update to a quick release.
*/


class Ithemes_Updater_Updates {
    public static function 
run_update() {
        
// Prevent the code from running if the code was loaded by an older updater version.
        
if ( ! isset( $GLOBALS['ithemes_updater_path'] ) )
            return;
        
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/api.php' );
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/packages.php' );
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/keys.php' );
        
        
        
$keys Ithemes_Updater_Keys::get();
        
$legacy_keys Ithemes_Updater_Keys::get_legacy();
        
        if ( empty( 
$keys ) && empty( $legacy_keys ) )
            return;
        
        
        
Ithemes_Updater_API::get_package_details();
    }
    
    public static function 
process_server_response$response ) {
        if ( empty( 
$response['packages'] ) )
            return;
        
        
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/keys.php' );
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/packages.php' );
        
        
        
$keys = array();
        
        foreach ( 
$response['packages'] as $package => $data ) {
            if ( isset( 
$data['key'] ) )
                
$keys[$package] = $data['key'];
            else if ( isset( 
$data['status'] ) && ( 'inactive' == $data['status'] ) )
                
$keys[$package] = '';
        }
        
        
Ithemes_Updater_Keys::set$keys );
        
        
        
$details Ithemes_Updater_Packages::get_full_details$response );
        
        
$updates = array(
            
'update_themes'  => array(),
            
'update_plugins' => array(),
            
'expiration'     => $details['expiration'],
            
'timestamp'      => time(),
        );
        
        
        if ( isset( 
$response['min_poll_time'] ) )
            
$updates['server-cache'] = $response['min_poll_time'];
        
        if ( ! isset( 
$updates['server-cache'] ) || ( $updates['server-cache'] < 30 ) )
            
$updates['server-cache'] = 30;
        
        
$use_ssl $GLOBALS['ithemes-updater-settings']->get_option'use_ssl' );
        
        
        foreach ( 
$details['packages'] as $path => $data ) {
            if ( empty( 
$data['package-url'] ) || version_compare$data['installed'], $data['available'], '>=' ) )
                continue;
            
            
            
$force_minor_version_update $GLOBALS['ithemes-updater-settings']->get_option'force_minor_version_update' );
            
$quick_releases $GLOBALS['ithemes-updater-settings']->get_option'quick_releases' );
            
            if ( ( isset( 
$data['upgrade'] ) && ! $data['upgrade'] ) && ! $force_minor_version_update && ! $quick_releases )
                continue;
            
            if ( ! 
$use_ssl )
                
$data['package-url'] = preg_replace'/^https/''http'$data['package-url'] );
            
            if ( 
'plugin' == $data['type'] ) {
                
$update = array(
                    
'id'          => 0,
                    
'slug'        => dirname$path ),
                    
'new_version' => $data['available'],
                    
'url'         => $data['info-url'],
                    
'package'     => $data['package-url'],
                );
                
$update = (object) $update;
            }
            else {
                
$update = array(
                    
'new_version' => $data['available'],
                    
'url'         => self_admin_url('plugin-install.php?tab=plugin-information&plugin=' dirname$path ) . '&section=changelog&TB_iframe=true&width=600&height=800'),
                    
'package'     => $data['package-url'],
                );
                
                
$path dirname$path );
            }
            
            
$updates["update_{$data['type']}s"][$path] = $update;
        }
        
        
        
$GLOBALS['ithemes-updater-settings']->update_options$updates );
    }
}