Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../includes/updater
File: update.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// Exit if accessed directly
[2] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[3] Fix | Delete
exit;
[4] Fix | Delete
}
[5] Fix | Delete
[6] Fix | Delete
function ampforwp_get_licence_activate_update(){
[7] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_extension' ) ) {
[8] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[9] Fix | Delete
die;
[10] Fix | Delete
}
[11] Fix | Delete
// Exit if the user does not have proper permissions
[12] Fix | Delete
if(! current_user_can( 'manage_options' ) ) {
[13] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User not have authority','accelerated-mobile-pages')));
[14] Fix | Delete
die;
[15] Fix | Delete
}
[16] Fix | Delete
$selectedOption = get_option('redux_builder_amp',true);
[17] Fix | Delete
if($_SERVER['REQUEST_METHOD']=='POST'){
[18] Fix | Delete
if(!isset($_POST['update_check'])){
[19] Fix | Delete
$ampforwp_license_activate = sanitize_text_field($_POST['ampforwp_license_activate']);
[20] Fix | Delete
$license = sanitize_text_field($_POST['license']);
[21] Fix | Delete
$item_name = sanitize_text_field($_POST['item_name']);
[22] Fix | Delete
$store_url = sanitize_text_field($_POST['store_url']);
[23] Fix | Delete
$plugin_active_path = sanitize_text_field($_POST['plugin_active_path']);
[24] Fix | Delete
}else{
[25] Fix | Delete
$ampforwp_license_activate = sanitize_text_field($_POST['ampforwp_license_activate']);
[26] Fix | Delete
$license = $selectedOption['amp-license'][$ampforwp_license_activate]['license'];
[27] Fix | Delete
$item_name = $selectedOption['amp-license'][$ampforwp_license_activate]['item_name'];
[28] Fix | Delete
$store_url = $selectedOption['amp-license'][$ampforwp_license_activate]['store_url'];
[29] Fix | Delete
if($selectedOption['amp-license'][$ampforwp_license_activate]['item_name']=="" || $selectedOption['amp-license'][$ampforwp_license_activate]['item_name']==NULL){
[30] Fix | Delete
$item_name = $selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['item_name'];
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
$status = 400;
[34] Fix | Delete
if($license==""){
[35] Fix | Delete
$message = "Please Enter valid license key";
[36] Fix | Delete
}else{
[37] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['license'] = $license;
[38] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['item_name'] = $item_name;
[39] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['store_url'] = $store_url;
[40] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['plugin_active_path'] = $plugin_active_path;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
[44] Fix | Delete
if( isset($selectedOption['amp-license']) && "" != $selectedOption['amp-license']){
[45] Fix | Delete
// data to send in our API request
[46] Fix | Delete
$api_params = array(
[47] Fix | Delete
'edd_action' => 'activate_license',
[48] Fix | Delete
'license' => $license,
[49] Fix | Delete
'item_name' => urlencode( $item_name ), // the name of our product in EDD
[50] Fix | Delete
'url' => home_url()
[51] Fix | Delete
);
[52] Fix | Delete
[53] Fix | Delete
// Call the custom API.
[54] Fix | Delete
$response = wp_remote_post( $store_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
[55] Fix | Delete
$message = '';
[56] Fix | Delete
// make sure the response came back okay
[57] Fix | Delete
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
[58] Fix | Delete
[59] Fix | Delete
if ( is_wp_error( $response ) ) {
[60] Fix | Delete
$message = $response->get_error_message();
[61] Fix | Delete
} else {
[62] Fix | Delete
$message = esc_html__( 'An error occurred, please try again.', 'accelerated-mobile-pages' );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
} else {
[66] Fix | Delete
$response = wp_remote_retrieve_body( $response );
[67] Fix | Delete
$license_data = json_decode( $response );
[68] Fix | Delete
if ( false === $license_data->success ) {
[69] Fix | Delete
switch( $license_data->error ) {
[70] Fix | Delete
case 'expired' :
[71] Fix | Delete
$message = sprintf(
[72] Fix | Delete
esc_html__( 'Your license key expired on %s.', 'accelerated-mobile-pages' ),
[73] Fix | Delete
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
[74] Fix | Delete
);
[75] Fix | Delete
$message .= "<a href='".esc_url($store_url)."/order/?edd_license_key=".esc_html($license)."'>Renew Link</a>";
[76] Fix | Delete
break;
[77] Fix | Delete
[78] Fix | Delete
case 'revoked' :
[79] Fix | Delete
[80] Fix | Delete
$message = esc_html__( 'Your license key has been disabled.', 'accelerated-mobile-pages' );
[81] Fix | Delete
break;
[82] Fix | Delete
[83] Fix | Delete
case 'missing' :
[84] Fix | Delete
$message = esc_html__( 'Invalid license.', 'accelerated-mobile-pages' );
[85] Fix | Delete
break;
[86] Fix | Delete
[87] Fix | Delete
case 'invalid' :
[88] Fix | Delete
case 'site_inactive' :
[89] Fix | Delete
[90] Fix | Delete
$message = esc_html__( 'Your license is not active for this URL.', 'accelerated-mobile-pages' );
[91] Fix | Delete
break;
[92] Fix | Delete
[93] Fix | Delete
case 'item_name_mismatch' :
[94] Fix | Delete
[95] Fix | Delete
$message = sprintf(
[96] Fix | Delete
esc_html__( 'This appears to be an invalid license key for %s.', 'accelerated-mobile-pages' ),
[97] Fix | Delete
$item_name
[98] Fix | Delete
);
[99] Fix | Delete
break;
[100] Fix | Delete
[101] Fix | Delete
case 'no_activations_left':
[102] Fix | Delete
[103] Fix | Delete
$message = esc_html__( 'Your license key has reached its activation limit.', 'accelerated-mobile-pages' );
[104] Fix | Delete
break;
[105] Fix | Delete
[106] Fix | Delete
default :
[107] Fix | Delete
[108] Fix | Delete
$message = esc_html__( 'An error occurred, please try again.', 'accelerated-mobile-pages' );
[109] Fix | Delete
break;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
}//else Closed
[115] Fix | Delete
// Check if anything passed on a message constituting a failure
[116] Fix | Delete
$status = false;
[117] Fix | Delete
if ( ! empty( $message ) ) {
[118] Fix | Delete
if(isset($license_data) && is_object($license_data)){
[119] Fix | Delete
$status = $license_data->error;
[120] Fix | Delete
}else{
[121] Fix | Delete
$status = "An error occurred, Error type not found.";
[122] Fix | Delete
}
[123] Fix | Delete
}else{
[124] Fix | Delete
$status = $license_data->license;
[125] Fix | Delete
$limit = ampforwp_set_plugin_limit( true, $license_data, $ampforwp_license_activate);
[126] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['limit'] = $limit;
[127] Fix | Delete
//$selectedOption['amp-license'][$ampforwp_license_activate]['all_data'] = json_decode($response,true);
[128] Fix | Delete
$response_all_data = json_decode($response,true);
[129] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['success'] = $response_all_data['success'];
[130] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['license'] = $response_all_data['license'];
[131] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['item_name'] = $response_all_data['item_name'];
[132] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['expires'] = $response_all_data['expires'];
[133] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['customer_name'] = $response_all_data['customer_name'];
[134] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['all_data']['customer_email'] = $response_all_data['customer_email'];
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['status'] = $status;
[138] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_activate]['message'] = $message;
[139] Fix | Delete
[140] Fix | Delete
if($status=='valid'){
[141] Fix | Delete
update_option( 'redux_builder_amp', $selectedOption );
[142] Fix | Delete
$status = "200";
[143] Fix | Delete
$message = esc_html__("Plugin activated successfully",'accelerated-mobile-pages');
[144] Fix | Delete
}else{
[145] Fix | Delete
$status = "500";
[146] Fix | Delete
}
[147] Fix | Delete
}else{
[148] Fix | Delete
$status = "400";
[149] Fix | Delete
$message = esc_html__("License not found",'accelerated-mobile-pages');
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
echo wp_json_encode(array("status"=>$status,"message"=>$message,"other"=> $selectedOption['amp-license'][$ampforwp_license_activate]));
[153] Fix | Delete
die;
[154] Fix | Delete
}
[155] Fix | Delete
}
[156] Fix | Delete
add_action( 'wp_ajax_ampforwp_get_licence_activate_update', 'ampforwp_get_licence_activate_update' );
[157] Fix | Delete
[158] Fix | Delete
add_action( 'wp_ajax_ampforwp_set_license_transient', 'ampforwp_set_license_transient' );
[159] Fix | Delete
function ampforwp_set_license_transient(){
[160] Fix | Delete
$transient_load = 'ampforwp_addon_set_transient';
[161] Fix | Delete
$value_load = 'ampforwp_addon_set_transient_value';
[162] Fix | Delete
$expiration_load = 86400 ;
[163] Fix | Delete
set_transient( $transient_load, $value_load, $expiration_load );
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
[167] Fix | Delete
/***********************************************
[168] Fix | Delete
* Illustrates how to deactivate a license key.
[169] Fix | Delete
* This will decrease the site count
[170] Fix | Delete
***********************************************/
[171] Fix | Delete
[172] Fix | Delete
function ampforwp_deactivate_license() {
[173] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_extension' ) ) {
[174] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[175] Fix | Delete
die;
[176] Fix | Delete
}
[177] Fix | Delete
// Exit if the user does not have proper permissions
[178] Fix | Delete
if(! current_user_can( 'manage_options' ) ) {
[179] Fix | Delete
return ;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
// listen for our activate button to be clicked
[183] Fix | Delete
if( isset( $_POST['ampforwp_license_deactivate'] ) ) {
[184] Fix | Delete
[185] Fix | Delete
$ampforwp_license_deactivate = sanitize_text_field( wp_unslash($_POST['ampforwp_license_deactivate']));
[186] Fix | Delete
// retrieve the license from the database
[187] Fix | Delete
$selectedOption = get_option('redux_builder_amp',true);
[188] Fix | Delete
$license = '';//trim( get_option( 'amp_ads_license_key' ) );
[189] Fix | Delete
$pluginItemName = '';
[190] Fix | Delete
$pluginItemStoreUrl = '';
[191] Fix | Delete
if( isset($selectedOption['amp-license']) && "" != $selectedOption['amp-license']){
[192] Fix | Delete
$pluginsDetail = $selectedOption['amp-license'][$ampforwp_license_deactivate];
[193] Fix | Delete
$license = $pluginsDetail['license'];
[194] Fix | Delete
$pluginItemName = $pluginsDetail['item_name'];
[195] Fix | Delete
$pluginItemStoreUrl = $pluginsDetail['store_url'];
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
// data to send in our API request
[199] Fix | Delete
$api_params = array(
[200] Fix | Delete
'edd_action' => 'deactivate_license',
[201] Fix | Delete
'license' => $license,
[202] Fix | Delete
'item_name' => urlencode( $pluginItemName ), // the name of our product in EDD
[203] Fix | Delete
'url' => home_url()
[204] Fix | Delete
);
[205] Fix | Delete
[206] Fix | Delete
// Call the custom API.
[207] Fix | Delete
$response = wp_remote_post( $pluginItemStoreUrl, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
[208] Fix | Delete
[209] Fix | Delete
// make sure the response came back okay
[210] Fix | Delete
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
[211] Fix | Delete
[212] Fix | Delete
if ( is_wp_error( $response ) ) {
[213] Fix | Delete
$message = $response->get_error_message();
[214] Fix | Delete
} else {
[215] Fix | Delete
$message = esc_html__( 'An error occurred, please try again.', 'accelerated-mobile-pages' );
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
echo wp_json_encode(array('status'=>500,"message"=>$message,"test"=>$selectedOption['amp-license'][$ampforwp_license_deactivate], "dsc"=>$pluginItemStoreUrl));
[219] Fix | Delete
exit();
[220] Fix | Delete
}else{
[221] Fix | Delete
$message = esc_html__( 'Plugin deactivated successfully', 'accelerated-mobile-pages' );
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
// decode the license data
[225] Fix | Delete
$license_data = json_decode( wp_remote_retrieve_body( $response ) ,true);
[226] Fix | Delete
[227] Fix | Delete
// $license_data->license will be either "deactivated" or "failed"
[228] Fix | Delete
if(is_object($license_data) && $license_data->license == 'deactivated' ) {
[229] Fix | Delete
delete_option( 'amp_ads_license_status' );
[230] Fix | Delete
}
[231] Fix | Delete
if( isset($selectedOption['amp-license']) && "" != $selectedOption['amp-license']){
[232] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_deactivate]['status']= 'invalid';
[233] Fix | Delete
$selectedOption['amp-license'][$ampforwp_license_deactivate]['license']= '';
[234] Fix | Delete
update_option( 'redux_builder_amp', $selectedOption );
[235] Fix | Delete
}
[236] Fix | Delete
echo wp_json_encode(array('status'=>200,"message"=>$message));
[237] Fix | Delete
exit();
[238] Fix | Delete
}
[239] Fix | Delete
exit();
[240] Fix | Delete
}
[241] Fix | Delete
add_action( 'wp_ajax_ampforwp_deactivate_license', 'ampforwp_deactivate_license' );
[242] Fix | Delete
[243] Fix | Delete
/**
[244] Fix | Delete
* This is a means of catching errors from the activation method above and displaying it to the customer
[245] Fix | Delete
*/
[246] Fix | Delete
function ampforwp_admin_notices() {
[247] Fix | Delete
if ( isset( $_GET['sl_activation'] ) && ! empty( $_GET['message'] ) ) {
[248] Fix | Delete
[249] Fix | Delete
switch( $_GET['sl_activation'] ) {
[250] Fix | Delete
[251] Fix | Delete
case 'false':
[252] Fix | Delete
$message = urldecode( $_GET['message'] );
[253] Fix | Delete
?>
[254] Fix | Delete
<div class="error">
[255] Fix | Delete
<p><?php echo esc_html($message); ?></p>
[256] Fix | Delete
</div>
[257] Fix | Delete
<?php
[258] Fix | Delete
break;
[259] Fix | Delete
[260] Fix | Delete
case 'true':
[261] Fix | Delete
default:
[262] Fix | Delete
// Developers can put a custom success message here for when activation is successful if they way.
[263] Fix | Delete
break;
[264] Fix | Delete
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
function ampforwp_set_plugin_limit( $force=false, $license_data='', $data = '') {
[270] Fix | Delete
[271] Fix | Delete
global $wp_version;
[272] Fix | Delete
[273] Fix | Delete
$limit = isset($data['limit']) ? trim( $data['limit'] ) : false;
[274] Fix | Delete
// If limit is set
[275] Fix | Delete
if( ! $force && $limit !== false ) {
[276] Fix | Delete
return $limit;
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
// If we haven't passed in any license data, get it now
[280] Fix | Delete
// Avoid doubling up on HTTP requests
[281] Fix | Delete
if( empty( $license_data ) ) {
[282] Fix | Delete
[283] Fix | Delete
$license = trim( isset($data['license']) ? $data['license'] : "" );
[284] Fix | Delete
$store_url = isset($data['store_url']) ? $data['store_url'] : "" ;
[285] Fix | Delete
$item_name = isset($data['item_name']) ? $data['item_name'] : "" ;
[286] Fix | Delete
[287] Fix | Delete
$api_params = array(
[288] Fix | Delete
'edd_action' => 'check_license',
[289] Fix | Delete
'license' => esc_attr($license),
[290] Fix | Delete
'item_name' => urlencode( $item_name ),
[291] Fix | Delete
'url' => esc_url(home_url())
[292] Fix | Delete
);
[293] Fix | Delete
[294] Fix | Delete
// Call the custom API.
[295] Fix | Delete
$response = wp_remote_post( $store_url, array( 'timeout' => 15, 'body' => $api_params ) );
[296] Fix | Delete
[297] Fix | Delete
if ( is_wp_error( $response ) )
[298] Fix | Delete
return false;
[299] Fix | Delete
[300] Fix | Delete
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
[301] Fix | Delete
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
$limit = 0;
[305] Fix | Delete
[306] Fix | Delete
if( $license_data->license != 'valid' ) {
[307] Fix | Delete
// This license is not valid
[308] Fix | Delete
$limit = -1;
[309] Fix | Delete
} else if( isset( $license_data->license_limit ) ) {
[310] Fix | Delete
// Using the license_limit to define how many plugins can be tracked
[311] Fix | Delete
$limit = $license_data->license_limit;
[312] Fix | Delete
}
[313] Fix | Delete
return $limit;
[314] Fix | Delete
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
[318] Fix | Delete
function ampforwp_plgins_update_message_according_pluginOpt( $plugin_data, $r )
[319] Fix | Delete
{
[320] Fix | Delete
$selectedOption = get_option('redux_builder_amp',true);
[321] Fix | Delete
$license_key = '';//trim( get_option( 'amp_ads_license_key' ) );
[322] Fix | Delete
$pluginItemName = '';
[323] Fix | Delete
$pluginItemStoreUrl = '';
[324] Fix | Delete
$pluginstatus = '';
[325] Fix | Delete
if( isset($selectedOption['amp-license']) && "" != $selectedOption['amp-license']){
[326] Fix | Delete
$pluginsDetail = $selectedOption['amp-license']['amp-ads-google-adsense'];
[327] Fix | Delete
$license_key = $pluginsDetail['license'];
[328] Fix | Delete
$pluginItemName = $pluginsDetail['item_name'];
[329] Fix | Delete
$pluginItemStoreUrl = $pluginsDetail['store_url'];
[330] Fix | Delete
$pluginstatus = $pluginsDetail['status'];
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
if($license_key==""){
[334] Fix | Delete
echo "<a href='".self_admin_url("?page=amp_options&tab=29")."'>Please enter key</a>";
[335] Fix | Delete
}
[336] Fix | Delete
if($pluginstatus!="valid"){
[337] Fix | Delete
echo "<a href='".self_admin_url("?page=amp_options&tab=29")."'>Please enter a valid key</a>";
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
}
[341] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function