-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhandler.php
128 lines (120 loc) · 3.57 KB
/
handler.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
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVCallbackHandler')) :
class BVCallbackHandler {
public $db;
public $settings;
public $siteinfo;
public $request;
public $account;
public $response;
public $bvinfo;
public function __construct($db, $settings, $siteinfo, $request, $account, $response) {
$this->db = $db;
$this->settings = $settings;
$this->siteinfo = $siteinfo;
$this->request = $request;
$this->account = $account;
$this->response = $response;
$this->bvinfo = new ALInfo($this->settings);
}
public function bvAdmExecuteWithoutUser() {
$this->execute(array("bvadmwithoutuser" => true));
}
public function bvAdmExecuteWithUser() {
$this->execute(array("bvadmwithuser" => true));
}
public function execute($resp = array()) {
$params = $this->request->params;
if (array_key_exists('disable_global_cache', $params)) {
$GLOBALS['_wp_using_ext_object_cache'] = false;
}
$this->routeRequest();
$resp = array(
"request_info" => $this->request->info(),
"site_info" => $this->siteinfo->info(),
"account_info" => $this->account->info(),
"bvinfo" => $this->bvinfo->info(),
"api_pubkey" => substr(ALAccount::getApiPublicKey($this->settings), 0, 8)
);
$this->response->terminate($resp);
}
public function routeRequest() {
switch ($this->request->wing) {
case 'manage':
require_once dirname( __FILE__ ) . '/wings/manage.php';
$module = new BVManageCallback($this);
break;
case 'fs':
require_once dirname( __FILE__ ) . '/wings/fs.php';
$module = new BVFSCallback($this);
break;
case 'db':
require_once dirname( __FILE__ ) . '/wings/db.php';
$module = new BVDBCallback($this);
break;
case 'info':
require_once dirname( __FILE__ ) . '/wings/info.php';
$module = new BVInfoCallback($this);
break;
case 'dynsync':
require_once dirname( __FILE__ ) . '/wings/dynsync.php';
$module = new BVDynSyncCallback($this);
break;
case 'ipstr':
require_once dirname( __FILE__ ) . '/wings/ipstore.php';
$module = new BVIPStoreCallback($this);
break;
case 'wtch':
require_once dirname( __FILE__ ) . '/wings/watch.php';
$module = new BVWatchCallback($this);
break;
case 'brand':
require_once dirname( __FILE__ ) . '/wings/brand.php';
$module = new BVBrandCallback($this);
break;
case 'pt':
require_once dirname( __FILE__ ) . '/wings/protect.php';
$module = new BVProtectCallback($this);
break;
case 'act':
require_once dirname( __FILE__ ) . '/wings/account.php';
$module = new BVAccountCallback($this);
break;
case 'fswrt':
require_once dirname( __FILE__ ) . '/wings/fs_write.php';
$module = new BVFSWriteCallback();
break;
case 'actlg':
require_once dirname( __FILE__ ) . '/wings/actlog.php';
$module = new BVActLogCallback($this);
break;
case 'speed':
require_once dirname( __FILE__ ) . '/wings/speed.php';
$module = new BVSpeedCallback($this);
break;
case 'scrty':
require_once dirname( __FILE__ ) . '/wings/security.php';
$module = new BVSecurityCallback($this);
break;
default:
require_once dirname( __FILE__ ) . '/wings/misc.php';
$module = new BVMiscCallback($this);
break;
}
$resp = $module->process($this->request);
if ($resp === false) {
$resp = array(
"statusmsg" => "Bad Command",
"status" => false);
}
$resp = array(
$this->request->wing => array(
$this->request->method => $resp
)
);
$this->response->addStatus("callbackresponse", $resp);
return 1;
}
}
endif;