Skip to content

Commit ac1c76e

Browse files
committed
Fix. AdminActions. Checking permissions for Actions
1 parent 535adb9 commit ac1c76e

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

inc/cleantalk-admin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,10 @@ function apbct_action_adjust_change()
15511551
{
15521552
AJAXService::checkAdminNonce();
15531553

1554+
if(!current_user_can('activate_plugins')) {
1555+
wp_send_json_error('Permission denied');
1556+
}
1557+
15541558
if (in_array(Post::get('adjust'), array_keys(AdjustToEnvironmentHandler::SET_OF_ADJUST))) {
15551559
try {
15561560
$adjust = Post::getString('adjust');
@@ -1570,6 +1574,10 @@ function apbct_action_adjust_reverse()
15701574
{
15711575
AJAXService::checkAdminNonce();
15721576

1577+
if (!current_user_can('activate_plugins')) {
1578+
wp_send_json_error('Permission denied');
1579+
}
1580+
15731581
if (in_array(Post::getString('adjust'), array_keys(AdjustToEnvironmentHandler::SET_OF_ADJUST))) {
15741582
$adjust = Post::getString('adjust');
15751583
try {
@@ -1586,6 +1594,10 @@ function apbct_action_adjust_reverse()
15861594

15871595
function apbct_action__create_support_user()
15881596
{
1597+
if (!current_user_can('activate_plugins')) {
1598+
wp_send_json_error('Permission denied');
1599+
}
1600+
15891601
$support_user = new SupportUser();
15901602
$result = $support_user->ajaxProcess();
15911603
wp_send_json($result);

inc/cleantalk-settings.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,15 @@ function apbct_settings__sync($direct_call = false)
25922592

25932593
global $apbct;
25942594

2595+
if (!current_user_can('activate_plugins')) {
2596+
$out = array(
2597+
'success' => false,
2598+
'reload' => false,
2599+
'message' => __('You do not have sufficient permissions to access this page.', 'cleantalk-spam-protect'),
2600+
);
2601+
die(json_encode($out));
2602+
}
2603+
25952604
//Clearing all errors
25962605
$apbct->errorDeleteAll(true);
25972606

@@ -2720,6 +2729,15 @@ function apbct_settings__get_key_auto($direct_call = false)
27202729

27212730
global $apbct;
27222731

2732+
if(!current_user_can('activate_plugins')) {
2733+
$out = array(
2734+
'success' => false,
2735+
'message' => __('You do not have sufficient permissions to access this page.', 'cleantalk-spam-protect'),
2736+
2737+
);
2738+
die(json_encode($out));
2739+
}
2740+
27232741
$website = parse_url(get_option('home'), PHP_URL_HOST) . parse_url(get_option('home'), PHP_URL_PATH);
27242742
$platform = 'wordpress';
27252743
$user_ip = Helper::ipGet('real', false);
@@ -2983,6 +3001,14 @@ function apbct_settings__get__long_description()
29833001
global $apbct;
29843002
AJAXService::checkAdminNonce();
29853003

3004+
if(!current_user_can('activate_plugins')) {
3005+
$out = array(
3006+
'success' => false,
3007+
'message' => __('You do not have sufficient permissions to access this page.', 'cleantalk-spam-protect'),
3008+
);
3009+
die(json_encode($out));
3010+
}
3011+
29863012
$setting_id = TT::toString(Post::get('setting_id', null, 'word'));
29873013

29883014
$link_exclusion_by_form_signs = LinkConstructor::buildCleanTalkLink(
@@ -3150,6 +3176,15 @@ function apbct_settings__check_renew_banner()
31503176

31513177
AJAXService::checkAdminNonce();
31523178

3179+
if(!current_user_can('activate_plugins')) {
3180+
$out = array(
3181+
'success' => false,
3182+
'close_renew_banner' => false,
3183+
'message' => __('You do not have sufficient permissions to access this page.', 'cleantalk-spam-protect'),
3184+
);
3185+
die(json_encode($out));
3186+
}
3187+
31533188
die(
31543189
json_encode(
31553190
array('close_renew_banner' => ($apbct->data['notice_trial'] == 0 && $apbct->data['notice_renew'] == 0) ? true : false)

js/src/cleantalk-admin-settings-page.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,13 +724,15 @@ function apbctSettingsShowDescription(label, settingId) {
724724
{
725725
spinner: obj.children('img'),
726726
callback: function(result, data, params, obj) {
727-
obj.empty()
728-
.append('<div class=\'apbct_long_desc__angle\'></div>')
729-
.append('<i class=\'apbct_long_desc__cancel apbct-icon-cancel\'></i>')
730-
.append('<h3 class=\'apbct_long_desc__title\'>'+result.title+'</h3>')
731-
.append('<p>'+result.desc+'</p>');
732-
733-
jQuery(document).on('click', removeDescFunc);
727+
if (result && result.title && result.desc) {
728+
obj.empty()
729+
.append('<div class=\'apbct_long_desc__angle\'></div>')
730+
.append('<i class=\'apbct_long_desc__cancel apbct-icon-cancel\'></i>')
731+
.append('<h3 class=\'apbct_long_desc__title\'>'+result.title+'</h3>')
732+
.append('<p>'+result.desc+'</p>');
733+
734+
jQuery(document).on('click', removeDescFunc);
735+
}
734736
},
735737
},
736738
obj,

0 commit comments

Comments
 (0)