/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/lib/updater/settings-page.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
<?php

/*
Code to render and manage the settings page for the updater system.
Written by Chris Jean for iThemes.com
Version 1.1.0

Version History
    1.0.0 - 2013-04-11 - Chris Jean
        Release ready
    1.0.1 - 2013-09-19 - Chris Jean
        Updated requires to not use dirname().
        Updated ithemes-updater-object to ithemes-updater-settings.
    1.1.0 - 2013-10-23 - Chris Jean
        Enhancement: Added the quick_releases setting.
        Misc: Removed the show_on_sites setting as it is no longer used.
*/


class Ithemes_Updater_Settings_Page {
    private 
$page_name 'ithemes-licensing';
    
    private 
$path_url '';
    private 
$self_url '';
    private 
$messages = array();
    private 
$message_strings = array();
    private 
$errors = array();
    private 
$soft_errors = array();
    
    
    public function 
__construct() {
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/functions.php' );
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/api.php' );
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/keys.php' );
        
        
        
$this->path_url Ithemes_Updater_Functions::get_url$GLOBALS['ithemes_updater_path'] );
        
        list( 
$this->self_url ) = explode'?'$_SERVER['REQUEST_URI'] );
        
$this->self_url .= '?page=' $this->page_name;
        
        
        
add_action'ithemes_updater_settings_page_index', array( $this'index' ) );
        
add_action'admin_print_styles', array( $this'add_styles' ) );
    }
    
    public function 
add_styles() {
        
wp_enqueue_style'ithemes-updater-settings-page-style'"{$this->path_url}/css/settings-page.css" );
    }
    
    public function 
index() {
        
$post_data Ithemes_Updater_Functions::get_post_data( array( 'it-updater-username''it-updater-password''packages''action' ), true );
        
        if ( empty( 
$post_data['packages'] ) )
            
$post_data['packages'] = array();
        
        
        
$action $post_data['action'];
        
        if ( 
'license_packages' == $action )
            
$this->license_packages$post_data );
        else if ( 
'unlicense_packages' == $action )
            
$this->unlicense_packages$post_data );
        else if ( 
'save_settings' == $action )
            
$this->save_settings();
        
        
$this->list_packages$action$post_data );
    }
    
    private function 
get_error_explanation$error$package '' ) {
        
$code $error->get_error_code();
        
$package_name Ithemes_Updater_Functions::get_package_name$package );
        
$message '';
        
        switch( 
$code ) {
            case 
'ITXAPI_Updater_Bad_Login':
                
$message __'Incorrect password. Please make sure that you are supplying your iThemes membership username and password details.''it-l10n-backupbuddy' );
                break;
            case 
'ITXAPI_Updater_Username_Unknown':
            case 
'ITXAPI_Updater_Username_Invalid':
                
$message __'Invalid username. Please make sure that you are supplying your iThemes membership username and password details.''it-l10n-backupbuddy' );
                break;
            case 
'ITXAPI_Product_Package_Unknown':
                
$message sprintf__'The licensing server reports that the %1$s (%2$s) product is unknown. Please contact support for assistance.''it-l10n-backupbuddy' ), $package_name$package );
                break;
            case 
'ITXAPI_Updater_Too_Many_Sites':
                
$message sprintf__'%1$s could not be licensed since the membership account is out of available licenses for this product. You can unlicense the product on other sites or upgrade your membership to one with a higher number of licenses in order to increase the amount of available licenses.''it-l10n-backupbuddy' ), $package_name );
                break;
            case 
'ITXAPI_License_Key_Generate_Failed':
                
$message sprintf__'%s could not be licensed due to an internal error. Please try to license %s again at a later time. If this problem continues, please contact iThemes support.''it-l10n-backupbuddy' ), $package_name );
                break;
        }
        
        if ( empty( 
$message ) ) {
            if ( ! empty( 
$package ) )
                
$message sprintf__'An unknown error relating to the %1$s product occurred. Please contact iThemes support. Error details: %2$s''it-l10n-backupbuddy' ), $package_name$error->get_error_message() . " ($code)" );
            else
                
$message sprintf__'An unknown error occurred. Please contact iThemes support. Error details: %s''it-l10n-backupbuddy' ), $error->get_error_message() . " ($code)" );
        }
        
        return 
$message;
    }
    
    private function 
save_settings() {
        
check_admin_referer'save_settings''ithemes_updater_nonce' );
        
        
        
$settings_defaults = array(
            
'quick_releases' => false,
        );
        
        
$settings = array();
        
        foreach ( 
$settings_defaults as $var => $val ) {
            if ( isset( 
$_POST[$var] ) )
                
$settings[$var] = $_POST[$var];
            else
                
$settings[$var] = $val;
        }
        
        if ( 
$settings['quick_releases'] )
            
$settings['quick_releases'] = true;
        
        
$GLOBALS['ithemes-updater-settings']->update_options$settings );
        
        
$GLOBALS['ithemes-updater-settings']->flush'settings saved' );
        
        
        
$this->messages[] = __'Settings saved''it-l10n-backupbuddy' );
    }
    
    private function 
license_packages$data ) {
        
check_admin_referer'license_packages''ithemes_updater_nonce' );
        
        if ( empty( 
$data['username'] ) && empty( $data['password'] ) )
            
$this->errors[] = __'You must supply an iThemes membership username and password in order to license products.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['username'] ) )
            
$this->errors[] = __'You must supply an iThemes membership username in order to license products.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['password'] ) )
            
$this->errors[] = __'You must supply an iThemes membership password in order to license products.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['packages'] ) )
            
$this->errors[] = __'You must select at least one product to license. Ensure that you select the products that you wish to license in the listing below.''it-l10n-backupbuddy' );
        
        if ( ! empty( 
$this->errors ) )
            return;
        
        
        
$response Ithemes_Updater_API::activate_package$data['username'], $data['password'], $data['packages'] );
        
        if ( 
is_wp_error$response ) ) {
            
$this->errors[] = $this->get_error_explanation$response );
            
            return;
        }
        
        if ( empty( 
$response['packages'] ) ) {
            
$this->errors[] = __'An unknown server error occurred. Please try to license your products again at another time.''it-l10n-backupbuddy' );
            return;
        }
        
        
        
uksort$response['packages'], 'strnatcasecmp' );
        
        
$success = array();
        
$warn = array();
        
$fail = array();
        
        foreach ( 
$response['packages'] as $package => $data ) {
            if ( 
preg_match'/ \|\|\| \d+$/'$package ) )
                continue;
            
            
$name Ithemes_Updater_Functions::get_package_name$package );
            
            if ( ! empty( 
$data['key'] ) )
                
$success[] = $name;
            else if ( ! empty( 
$data['status'] ) && ( 'expired' == $data['status'] ) )
                
$warn[$name] = __'Your product subscription has expired''it-l10n-backupbuddy' );
            else
                
$fail[$name] = $data['error']['message'];
        }
        
        
        if ( ! empty( 
$success ) )
            
$this->messages[] = wp_sprintf__'Successfully licensed %l.''it-l10n-backupbuddy' ), $success );
        
        if ( ! empty( 
$fail ) ) {
            foreach ( 
$fail as $name => $reason )
                
$this->errors[] = sprintf__'Unable to license %1$s. Reason: %2$s''it-l10n-backupbuddy' ), $name$reason );
        }
        
        if ( ! empty( 
$warn ) ) {
            foreach ( 
$warn as $name => $reason )
                
$this->soft_errors[] = sprintf__'Unable to license %1$s. Reason: %2$s''it-l10n-backupbuddy' ), $name$reason );
        }
    }
    
    private function 
unlicense_packages$data ) {
        
check_admin_referer'unlicense_packages''ithemes_updater_nonce' );
        
        if ( empty( 
$data['username'] ) && empty( $data['password'] ) )
            
$this->errors[] = __'You must supply an iThemes membership username and password in order to remove licenses.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['username'] ) )
            
$this->errors[] = __'You must supply an iThemes membership username in order to remove licenses.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['password'] ) )
            
$this->errors[] = __'You must supply an iThemes membership password in order to remove licenses.''it-l10n-backupbuddy' );
        else if ( empty( 
$data['packages'] ) )
            
$this->errors[] = __'You must select at least one license to remove. Ensure that you select the licenses that you wish to remove in the listing below.''it-l10n-backupbuddy' );
        
        if ( ! empty( 
$this->errors ) )
            return;
        
        
        
$response Ithemes_Updater_API::deactivate_package$data['username'], $data['password'], $data['packages'] );
        
        if ( 
is_wp_error$response ) ) {
            
$this->errors[] = $this->get_error_explanation$response );
            
            return;
        }
        
        if ( empty( 
$response['packages'] ) ) {
            
$this->errors[] = __'An unknown server error occurred. Please try to remove licenses from your products again at another time.''it-l10n-backupbuddy' );
            return;
        }
        
        
        
uksort$response['packages'], 'strnatcasecmp' );
        
        
$success = array();
        
$fail = array();
        
        foreach ( 
$response['packages'] as $package => $data ) {
            if ( 
preg_match'/ \|\|\| \d+$/'$package ) )
                continue;
            
            
$name Ithemes_Updater_Functions::get_package_name$package );
            
            if ( isset( 
$data['status'] ) && ( 'inactive' == $data['status'] ) )
                
$success[] = $name;
            else if ( isset( 
$data['error'] ) && isset( $data['error']['message'] ) )
                
$fail[$name] = $data['error']['message'];
            else
                
$fail[$name] = __'Unknown server error.''it-l10n-backupbuddy' );
        }
        
        
        if ( ! empty( 
$success ) )
            
$this->messages[] = wp_sprintf_n'Successfully removed license from %l.''Successfully removed licenses from %l.'count$success ), 'it-l10n-backupbuddy' ), $success );
        
        if ( ! empty( 
$fail ) ) {
            foreach ( 
$fail as $name => $reason )
                
$this->errors[] = sprintf__'Unable to remove license from %1$s. Reason: %2$s''it-l10n-backupbuddy' ), $name$reason );
        }
    }
    
    public function 
list_packages$action$post_data ) {
        require_once( 
$GLOBALS['ithemes_updater_path'] . '/packages.php' );
        
$details Ithemes_Updater_Packages::get_full_details();
        
$packages $details['packages'];
        
        
$licensed = array();
        
$unlicensed = array();
        
$unrecognized = array();
        
        foreach ( 
$packages as $path => $data ) {
            
$name Ithemes_Updater_Functions::get_package_name$data['package'] );
            
$data['path'] = $path;
            
            if ( 
'unlicensed' == $data['status'] )
                
$unlicensed[$name] = $data;
            else if ( 
in_array$data['status'], array( 'active''expired' ) ) )
                
$licensed[$name] = $data;
            else
                
$unrecognized[$name] = $data;
        }
        
        
        if ( ! empty( 
$this->messages ) ) {
            foreach ( 
$this->messages as $message )
                echo 
"<div class=\"updated fade\"><p><strong>$message</strong></p></div>\n";
        }
        
        if ( ! empty( 
$this->errors ) ) {
            foreach ( 
$this->errors as $error )
                echo 
"<div class=\"error\"><p><strong>$error</strong></p></div>\n";
        }
        
        if ( ! empty( 
$this->soft_errors ) ) {
            foreach ( 
$this->soft_errors as $error )
                echo 
"<div class=\"error\"><p><strong>$error</strong></p></div>\n";
        }
        
        
?>
    <div class="wrap">
        <?php screen_icon(); ?>
        <h2><?php _e'iThemes Licensing''it-l10n-backupbuddy' ); ?></h2>
        
        <?php $this->list_licensed_products$licensed$post_data$action ); ?>
        
        <?php $this->list_unlicensed_products$unlicensed$post_data$action ); ?>
        
        <?php $this->list_unrecognized_products$unrecognized ); ?>
        
        <?php $this->show_settings(); ?>
    </div>
<?php
        
    
}
    
    private function 
show_settings() {
        
$quick_releases $GLOBALS['ithemes-updater-settings']->get_option'quick_releases' );
        
?>
    <form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php echo $this->self_url?>">
        <?php wp_nonce_field'save_settings''ithemes_updater_nonce' ); ?>
        
        <div id="ithemes-updater-settings">
            <h3 class="subtitle"><?php _e'Settings''it-l10n-backupbuddy' ); ?></h3>
            
            <table class="form-table">
                <tbody>
                    <tr valign="top">
                        <th scope="row">
                            <label for="quick_releases"><?php _e'Quick Release Updates''it-l10n-backupbuddy' ); ?></label>
                        </th>
                        <td>
                            <?php $checked = ( $quick_releases ) ? ' checked="checked"' ''?>
                            
                            <label>
                                <input id="quick_releases" type="checkbox" name="quick_releases" value="1" <?php echo $checked?>/>
                                <?php _e'Enable quick release updates''it-l10n-backupbuddy' ); ?>
                            </label>
                            
                            <p class="description"><?php _e'Some products have quick releases that are created to solve specific issues that some users experience. In order to avoid causing users to have updates show up too frequently, automatic updates to these quick releases are disabled by default. Enabling this feature allows quick releases to be available to the automatic update system. Using this option is only recommended if support has requested that you enable it in order to receive a quick release. You should disable this option at a later time after confirming that the quick release solves the issue for you.''it-l10n-backupbuddy' ); ?></p>
                        </td>
                    </tr>
                </tbody>
            </table>
            
            <p class="submit">
                <input id="save_settings" class="button button-primary" type="submit" value="<?php _e'Save Settings''it-l10n-backupbuddy' ); ?>" />
                <input type="hidden" name="action" value="save_settings" />
            </p>
        </div>
    </form>
<?php
        
    
}
    
    
    private function 
list_licensed_products$products$post_data$action ) {
        if ( empty( 
$products ) )
            return;
        
        
uksort$products'strnatcasecmp' );
        
        
$time time();
        
        
$headings = array(
            
__'Product''it-l10n-backupbuddy' ),
            
__'Member''it-l10n-backupbuddy' ),
            
__'Expiration''it-l10n-backupbuddy' ),
            
__'Remaining Licenses''it-l10n-backupbuddy' ),
        );
        
        if ( ( 
'unlicense_packages' != $action ) || empty( $this->errors ) ) {
            
$post_data = array(
                
'username' => '',
                
'password' => '',
                
'packages' => array(),
            );
        }
        
?>
    <form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php echo $this->self_url?>" autocomplete="off">
        <?php wp_nonce_field'unlicense_packages''ithemes_updater_nonce' ); ?>
        
        <div class="ithemes-updater-products" id="ithemes-updater-licensed">
            <h3 class="subtitle"><?php _e'Licensed Products''it-l10n-backupbuddy' ); ?></h3>
            
            <table class="ithemes-updater-listing widefat">
                <thead>
                    <tr>
                        <th id="cb" class="manage-column column-cb check-column" scope="col">
                            <label class="screen-reader-text" for="cb-select-all-1"><?php _e'Select All' ); ?></label>
                            <label>
                                <input id="cb-select-all-1" type="checkbox" />
                            </label>
                        </th>
                        <th scope="col">
                            <label for="cb-select-all-1"><?php _e'Product''it-l10n-backupbuddy' ); ?></label>
                        </th>
                        <th scope="col"><?php _e'Member''it-l10n-backupbuddy' ); ?></th>
                        <th scope="col"><?php _e'Product Status''it-l10n-backupbuddy' ); ?></th>
                        <th scope="col"><?php _e'Expiration''it-l10n-backupbuddy' ); ?></th>
                        <th scope="col"><?php _e'Remaining Licenses''it-l10n-backupbuddy' ); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $count 0?>
                    <?php foreach ( $products as $name => $data ) : ?>
                        <?php
                            
if ( -== $data['total'] )
                                
$remaining __'unlimited''it-l10n-backupbuddy' );
                            else
                                
$remaining $data['total'] - $data['used'];
                            
//                            if ( 0 == $remaining )
//                                $remaining .= ' <a class="button-secondary upgrade">' . __( 'Upgrade', 'it-l10n-backupbuddy' ) . '</a>';
                            
                            
                            
$expiration $this->get_expiration_string$data['expiration'] );
                            
$expiration '<time datetime="' date'Y-m-d\TH:i:s\Z'$data['expiration'] ) . '">' $expiration '</time>';
                            
                            
                            
$time_left $data['expiration'] - $time;
                            
$class 'expiring';
                            
                            if ( 
$time_left > ( 86400 30 ) )
                                
$class 'active';
                            else if ( 
$time_left <= )
                                
$class 'expired';
                            
                            
                            if ( 
'expired' == $data['status'] ) {
                                
$class 'expired';
                                
$remaining '&nbsp;';
                            }
                            
                            
                            
$status ucfirst$class );
                            
                            
                            
$check_id "cb-select-{$data['package']}";
                            
                            
                            
$checked = ( in_array$data['package'], $post_data['packages'] ) ) ? ' checked' '';
                        
?>
                        <tr class="<?php echo $class?>">
                            <th class="check-column" scope="row">
                                <label class="screen-reader-text" for="<?php echo $check_id?>"><?php printf__'Select %s' ), $name ); ?></label>
                                <label for="<?php echo $check_id?>">
                                    <input id="<?php echo $check_id ?>" name="packages[]" value="<?php echo $data['package']; ?>" type="checkbox"<?php echo $checked?>>
                                </label>
                            </th>
                            <td>
                                <label for="<?php echo $check_id?>"><?php echo $name?></label>
                            </td>
                            <td><?php echo $data['user']; ?></td>
                            <td><?php echo $status?></td>
                            <td><?php echo $expiration?></td>
                            <td><?php echo $remaining?></td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="6">
                            <input type="text" name="it-updater-username" placeholder="iThemes Username" value="<?php echo esc_attr$post_data['username'] ); ?>" autocomplete="off" />
                            <input type="password" name="it-updater-password" placeholder="Password" value="<?php echo esc_attr$post_data['password'] ); ?>" />
                            <input class="button-primary" type="submit" name="submit" value="<?php _e'Remove Licenses''it-l10n-backupbuddy' ); ?>" />
                            <input type="hidden" name="action" value="unlicense_packages" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </form>
<?php
        
    
}
    
    private function 
list_unlicensed_products$products$post_data$action ) {
        if ( empty( 
$products ) )
            return;
        
        
uksort$products'strnatcasecmp' );
        
        if ( ( 
'license_packages' != $action ) || empty( $this->errors ) ) {
            
$post_data = array(
                
'username' => '',
                
'password' => '',
                
'packages' => array(),
            );
            
            foreach ( 
$products as $name => $data )
                
$post_data['packages'][] = $data['package'];
        }
        
?>
    <form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php echo $this->self_url?>" autocomplete="off">
        <?php wp_nonce_field'license_packages''ithemes_updater_nonce' ); ?>
        
        <div class="ithemes-updater-products" id="ithemes-updater-unlicensed">
            <h3 class="subtitle"><?php _e'Unlicensed Products''it-l10n-backupbuddy' ); ?></h3>
            
            <p><?php _e'The following products have not been licensed. Licensing a product gives you access to automatic updates from within WordPress.''it-l10n-backupbuddy' ); ?></p>
            <p><?php _e'To license products, select the products you wish to license, enter your iThemes membership username and password, and press the License Products button.''it-l10n-backupbuddy' ); ?></p>
            <p><?php printf__'Need help? <a href="%s">Click here for a quick video tutorial</a>.''it-l10n-backupbuddy' ), 'http://ithemes.com/2013/04/11/introducing-the-new-and-improved-ithemes-licensing-system/' ); ?></p>
            
            <table class="ithemes-updater-listing widefat">
                <thead>
                    <tr>
                        <th id="cb" class="manage-column column-cb check-column" scope="col">
                            <label class="screen-reader-text" for="cb-select-all-2"><?php _e'Select All' ); ?></label>
                            <label>
                                <input id="cb-select-all-2" type="checkbox"<?php if ( count$post_data['packages'] ) == count$products ) ) echo ' checked'?> />
                            </label>
                        </th>
                        <th scope="col">
                            <label for="cb-select-all-2"><?php _e'Product''it-l10n-backupbuddy' ); ?></label>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ( $products as $name => $data ) : ?>
                        <?php
                            $check_id 
"cb-select-{$data['package']}";
                            
                            
                            if ( 
'license_packages' == $action )
                                
$checked = ( in_array$data['package'], $post_data['packages'] ) ) ? ' checked' '';
                            else
                                
$checked ' checked';
                        
?>
                        <tr>
                            <th class="check-column" scope="row">
                                <label class="screen-reader-text" for="<?php echo $check_id?>"><?php printf__'Select %s' ), $name ); ?></label>
                                <label for="<?php echo $check_id?>">
                                    <input id="<?php echo $check_id?>" name="packages[]" value="<?php echo $data['package']; ?>" type="checkbox" <?php echo $checked?>>
                                </label>
                            </th>
                            <td>
                                <label for="<?php echo $check_id?>"><?php echo $name?></label>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">
                            <input type="text" name="it-updater-username" placeholder="iThemes Username" value="<?php echo esc_attr$post_data['username'] ); ?>" autocomplete="off" />
                            <input type="password" name="it-updater-password" placeholder="Password" value="<?php echo esc_attr$post_data['password'] ); ?>" />
                            <input class="button-primary" type="submit" name="submit" value="<?php _e'License Products''it-l10n-backupbuddy' ); ?>" />
                            <input type="hidden" name="action" value="license_packages" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </form>
<?php
        
    
}
    
    private function 
list_unrecognized_products$products ) {
        if ( empty( 
$products ) )
            return;
        
        
uksort$products'strnatcasecmp' );
        
?>
    <div class="ithemes-updater-products" id="ithemes-updater-unrecognized">
        <h3 class="subtitle"><?php _e'Unrecognized Products''it-l10n-backupbuddy' ); ?></h3>
        
        <p><?php _e'The following products were not recognized by the licensing system. This can be due to a bug in the product code, a temporary server issue, or because the product is no longer supported.''it-l10n-backupbuddy' ); ?></p>
        <p><?php printf__'Please check this page again at a later time to see if the problem resolves itself. If the product remains, please contact <a href="%s">iThemes support</a> and provide them with the details given below.''it-l10n-backupbuddy' ), 'http://ithemes.com/forum/' ); ?></p>
        
        <table class="ithemes-updater-listing widefat">
            <thead>
                <tr>
                    <th scope="col"><?php _e'Product''it-l10n-backupbuddy' ); ?></th>
                    <th scope="col"><?php _e'Type''it-l10n-backupbuddy' ); ?></th>
                    <th scope="col"><?php _e'Package''it-l10n-backupbuddy' ); ?></th>
                    <th scope="col"><?php _e'Version''it-l10n-backupbuddy' ); ?></th>
                    <th scope="col"><?php _e'Server Response''it-l10n-backupbuddy' ); ?></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ( $products as $name => $data ) : ?>
                    <?php
                        
if ( ( 'error' == $data['status'] ) && ( ! empty( $data['error']['message'] ) ) )
                            
$response "{$data['error']['message']} ({$data['error']['code']})";
                        else
                            
$response __'Unknown Error''it-l10n-backupbuddy' );
                    
?>
                    <tr>
                        <td><?php echo $name?></td>
                        <td><?php echo $data['type']; ?></td>
                        <td><?php echo $data['package']; ?></td>
                        <td><?php echo $data['installed']; ?></td>
                        <td><?php echo $response?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
<?php
        
    
}
    
    private function 
get_expiration_string$expiration_timestamp ) {
        
$time time();
        
        
$time_left $expiration_timestamp $time;
        
        
$expired false;
        
        if ( 
$time_left ) {
            
$expired true;
            
$time_left abs$time_left );
        }
        
        if ( 
$time_left > ( 86400 30 ) )
            
$expiration date'Y-m-d'$expiration_timestamp );
        else {
            if ( 
$time_left 86400 )
                
$expiration sprintf_n'%d day''%d days'intval$time_left 86400 ), 'it-l10n-backupbuddy' ), intval$time_left 86400 ) );
            else if ( 
$time_left 3600 )
                
$expiration sprintf_n'%d hour''%d hours'intval$time_left 3600 ), 'it-l10n-backupbuddy' ), intval$time_left 3600 ) );
            else if ( 
$time_left 60 )
                
$expiration sprintf_n'%d minute''%d minutes'intval$time_left 60 ), 'it-l10n-backupbuddy' ), intval$time_left 60 ) );
            else
                
$expiration sprintf_n'%d second''%d seconds'$time_left'it-l10n-backupbuddy' ), intval$time_left 60 ) );
            
            if ( 
$expired )
                
$expiration sprintf__'%s ago''it-l10n-backupbuddy' ), $expiration );
        }
        
        return 
$expiration;
    }
}


new 
Ithemes_Updater_Settings_Page();