This repository has been archived by the owner on May 23, 2023. It is now read-only.
forked from BoldGrid/w3-total-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cdn_LimeLight_Popup.php
75 lines (56 loc) · 1.71 KB
/
Cdn_LimeLight_Popup.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
<?php
namespace W3TC;
class Cdnfsd_LimeLight_Popup {
static public function w3tc_ajax() {
$o = new Cdnfsd_LimeLight_Popup();
add_action( 'w3tc_ajax_cdn_limelight_intro',
array( $o, 'w3tc_ajax_cdn_limelight_intro' ) );
add_action( 'w3tc_ajax_cdn_limelight_save',
array( $o, 'w3tc_ajax_cdn_limelight_save' ) );
}
public function w3tc_ajax_cdn_limelight_intro() {
$this->render_intro( array() );
}
private function render_intro( $details ) {
$config = Dispatcher::config();
$domain = '';
$domains = $config->get_array('cdn.limelight.host.domains');
if ( count( $domains ) > 0 ) {
$domain = $domains[0];
}
include W3TC_DIR . '/Cdn_LimeLight_Popup_View_Intro.php';
exit();
}
public function w3tc_ajax_cdn_limelight_save() {
$short_name = $_REQUEST['short_name'];
$username = $_REQUEST['username'];
$api_key = $_REQUEST['api_key'];
$domain = $_REQUEST['domain'];
try {
$api = new Cdnfsd_LimeLight_Api( $short_name, $username, $api_key );
$url = ( Util_Environment::is_https() ? 'https://' : 'http://' ) . $domain . '/test';
$items = array(
array(
'pattern' => $url,
'exact' => true,
'evict' => false,
'incqs' => false
)
);
$api->purge( $items );
} catch ( \Exception $ex ) {
$this->render_intro( array(
'error_message' => 'Failed to make test purge request: ' . $ex->getMessage()
) );
exit();
}
$c = Dispatcher::config();
$c->set( 'cdn.limelight.short_name', $short_name );
$c->set( 'cdn.limelight.username', $username );
$c->set( 'cdn.limelight.api_key', $api_key );
$c->set( 'cdn.limelight.host.domains', array( $domain ) );
$c->save();
include W3TC_DIR . '/Cdn_LimeLight_Popup_View_Success.php';
exit();
}
}