wpf_post.php
1.41 KB
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
<?php
if(!isset($_REQUEST['contactId']))
return;
set_time_limit(0);
error_reporting(1);
$full_path = getcwd();
$ar = explode("wp-", $full_path);
$wp_root_path = $ar[0];
include_once($wp_root_path . DIRECTORY_SEPARATOR . "wp-config.php");
//include_once($wp_root_path . DIRECTORY_SEPARATOR . "wp-load.php");
include_once($wp_root_path . "wp-includes" . DIRECTORY_SEPARATOR . "wp-db.php");
wp_fusion_process_post();
function wp_fusion_process_post() {
if(!isset($_REQUEST['action']) || $_REQUEST['action'] == 'update') {
$result = wp_remote_post(
admin_url( 'admin-ajax.php' ),
array(
'body' => array(
'action' => 'wpf_update_user',
'contact_id' => $_REQUEST['contactId']
)
)
);
} elseif ($_REQUEST['action'] == 'add') {
$wpf_options = get_option('wpf_options');
// If access key doesn't match
if(!isset($_REQUEST['access_key']) || $_REQUEST['access_key'] != $wpf_options['access_key']){
echo "Access Key Invalid";
return;
}
if(isset($_REQUEST['send_notification']) && $_REQUEST['send_notification'] == 'true') {
$send_notification = true;
} else {
$send_notification = false;
}
$result = wp_remote_post(
admin_url( 'admin-ajax.php' ),
array(
'body' => array(
'action' => 'wpf_add_user',
'contact_id' => $_REQUEST['contactId'],
'send_notification' => $send_notification,
'role' => $_REQUEST['role']
)
)
);
}
}