C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\imagify\inc\classes\class-imagify-user.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
<?php
defined
'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
 * Imagify User class.
 *
 * @since 1.0
 */
class Imagify_User {
    
/**
     * The Imagify user ID.
     *
     * @since 1.0
     *
     * @var    string
     * @access public
     */
    
public $id;

    
/**
     * The user email.
     *
     * @since 1.0
     *
     * @var    string
     * @access public
     */
    
public $email;

    
/**
     * The plan ID.
     *
     * @since 1.0
     *
     * @var    int
     * @access public
     */
    
public $plan_id;

    
/**
     * The plan label.
     *
     * @since 1.2
     *
     * @var    string
     * @access public
     */
    
public $plan_label;

    
/**
     * The total quota.
     *
     * @since 1.0
     *
     * @var    int
     * @access public
     */
    
public $quota;

    
/**
     * The total extra quota (Imagify Pack).
     *
     * @since 1.0
     *
     * @var    int
     * @access public
     */
    
public $extra_quota;

    
/**
     * The extra quota consumed.
     *
     * @since 1.0
     *
     * @var    int
     * @access public
     */
    
public $extra_quota_consumed;

    
/**
     * The current month consumed quota.
     *
     * @since 1.0
     *
     * @var    int
     * @access public
     */
    
public $consumed_current_month_quota;

    
/**
     * The next month date to credit the account.
     *
     * @since 1.1.1
     *
     * @var    date
     * @access public
     */
    
public $next_date_update;

    
/**
     * If the account is activate or not.
     *
     * @since 1.0.1
     *
     * @var    bool
     * @access public
     */
    
public $is_active;

    
/**
     * Store a \WP_Error object if the request to fetch the user data failed.
     * False overwise.
     *
     * @var    bool|\WP_Error
     * @since  1.9.9
     * @access private
     * @author Grégory Viguier
     */
    
private $error;

    
/**
     * The constructor.
     *
     * @since 1.0
     *
     * @return void
     */
    
public function __construct() {
        
$user get_imagify_user();

        if ( 
is_wp_error$user ) ) {
            
$this->error $user;
            return;
        }

        
$this->id                           $user->id;
        
$this->email                        $user->email;
        
$this->plan_id                      = (int) $user->plan_id;
        
$this->plan_label                   ucfirst$user->plan_label );
        
$this->quota                        $user->quota;
        
$this->extra_quota                  $user->extra_quota;
        
$this->extra_quota_consumed         $user->extra_quota_consumed;
        
$this->consumed_current_month_quota $user->consumed_current_month_quota;
        
$this->next_date_update             $user->next_date_update;
        
$this->is_active                    $user->is_active;
        
$this->error                        false;
    }

    
/**
     * Get the possible error returned when fetching user data.
     *
     * @since  1.9.9
     * @access public
     * @author Grégory Viguier
     *
     * @return bool|\WP_Error A \WP_Error object if the request to fetch the user data failed. False overwise.
     */
    
public function get_error() {
        return 
$this->error;
    }

    
/**
     * Percentage of consumed quota, including extra quota.
     *
     * @since 1.0
     *
     * @access public
     * @return float|int
     */
    
public function get_percent_consumed_quota() {
        static 
$done false;

        if ( 
$this->get_error() ) {
            return 
0;
        }

        
$quota          $this->quota;
        
$consumed_quota $this->consumed_current_month_quota;

        if ( 
imagify_round_half_five$this->extra_quota_consumed ) < $this->extra_quota ) {
            
$quota          += $this->extra_quota;
            
$consumed_quota += $this->extra_quota_consumed;
        }

        if ( ! 
$quota || ! $consumed_quota ) {
            
$percent 0;
        } else {
            
$percent 100 $consumed_quota $quota;
            
$percent round$percent);
            
$percent minmax0$percent ), 100 );
        }

        if ( 
$done ) {
            return 
$percent;
        }

        
$previous_percent Imagify_Data::get_instance()->get'previous_quota_percent' );

        
// Percent is not 100% anymore.
        
if ( 100.0 === (float) $previous_percent && $percent 100 ) {
            
/**
             * Triggered when the consumed quota percent decreases below 100%.
             *
             * @since  1.7
             * @author Grégory Viguier
             *
             * @param float|int $percent The current percentage of consumed quota.
             */
            
do_action'imagify_not_over_quota_anymore'$percent );
        }

        
// Percent is not >= 80% anymore.
        
if ( (float) $previous_percent >= 80.0 && $percent 80 ) {
            
/**
             * Triggered when the consumed quota percent decreases below 80%.
             *
             * @since  1.7
             * @author Grégory Viguier
             *
             * @param float|int $percent          The current percentage of consumed quota.
             * @param float|int $previous_percent The previous percentage of consumed quota.
             */
            
do_action'imagify_not_almost_over_quota_anymore'$percent$previous_percent );
        }

        if ( (float) 
$previous_percent !== (float) $percent ) {
            
Imagify_Data::get_instance()->set'previous_quota_percent'$percent );
        }

        
$done true;

        return 
$percent;
    }

    
/**
     * Count percent of unconsumed quota.
     *
     * @since 1.0
     *
     * @access public
     * @return float|int
     */
    
public function get_percent_unconsumed_quota() {
        return 
100 $this->get_percent_consumed_quota();
    }

    
/**
     * Check if the user has a free account.
     *
     * @since 1.1.1
     *
     * @access public
     * @return bool
     */
    
public function is_free() {
        return 
=== $this->plan_id;
    }

    
/**
     * Check if the user has consumed all his/her quota.
     *
     * @since 1.1.1
     * @since 1.9.9 Return false if the request to fetch the user data failed.
     *
     * @access public
     * @return bool
     */
    
public function is_over_quota() {
        if ( 
$this->get_error() ) {
            return 
false;
        }

        if ( 
$this->is_free() && 100.0 === (float) $this->get_percent_consumed_quota() ) {
            return 
true;
        }

        return 
false;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586