HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wptuneprotect/wp-content/plugins/insert-php/admin/ajax/check-license.php
<?php
	/**
	 * Ajax plugin check licensing
	 * @author Webcraftic <wordpress.webraftic@gmail.com>
	 * @copyright (c) 2017 Webraftic Ltd
	 * @version 1.0
	 */

	// Exit if accessed directly
	if( !defined('ABSPATH') ) {
		exit;
	}

	/**
	 * Обработчик ajax запросов для проверки, активации, деактивации лицензионного ключа
	 *
	 * @since 1.4.0
	 */
	function winp_check_license()
	{
		check_admin_referer('license');

		$action = WINP_Plugin::app()->request->post('license_action', false, true);
		$license_key = WINP_Plugin::app()->request->post('licensekey', null);

		if( empty($action) || !in_array($action, array('activate', 'deactivate', 'sync', 'unsubscribe')) ) {
			wp_send_json_error(array('error_message' => __('Licensing action not passed or this action is prohibited!', 'insert-php')));
			die();
		}

		$licensing = WINP_Plugin::app()->premium;

		$result = null;
		$success_message = '';

		switch( $action ) {
			case 'activate':
				if( empty($license_key) || strlen($license_key) > 32 ) {
					wp_send_json_error(array('error_message' => __('License key is empty or license key too long (license key is 32 characters long)', 'insert-php')));
				} else {
					$result = $licensing->activate($license_key);
					$success_message = __('Your license has been successfully activated', 'insert-php');
				}
				break;
			case 'deactivate':
				$result = $licensing->deactivate();
				$success_message = __('The license is deactivated', 'insert-php');
				break;
			case 'sync':
				$result = $licensing->sync();
				$success_message = __('The license has been updated', 'insert-php');
				break;
			case 'unsubscribe':
				$result = $licensing->cancel_paid_subscription();
				$success_message = __('Subscription success cancelled', 'insert-php');
				break;
		}

		if( is_wp_error($result) ) {

			/**
			 * Экшен выполняет, когда проверка лицензии вернула ошибку
			 * @param string $action
			 * @param string $license_key
			 * @since 1.4.0
			 */
			add_action('wbcr/inp/check_license_error', $action, $license_key);

			wp_send_json_error(array('error_message' => $result->get_error_message()));
			die();
		}

		/**
		 * Экшен выполняет, когда проверка лицензии успешно завершена
		 * @param string $action
		 * @param string $license_key
		 * @since 1.4.0
		 */
		add_action('wbcr/inp/check_license_success', $action, $license_key);

		wp_send_json_success(array('message' => $success_message));

		die();
	}

	add_action('wp_ajax_winp_check_license', 'winp_check_license');