HEX
Server: nginx/1.18.0
System: Linux iZj6c1ieg2jrpk1z5tzi19Z 6.3.9-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 21 22:18:40 EDT 2023 x86_64
User: www (1001)
PHP: 8.2.4
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/wp-social/inc/admin-rest-api.php
<?php

defined('ABSPATH') || exit;

/**
 * Function Name : xs_return_call_back_login_function();
 * Function Details : WP Rest API.
 *
 * @params : void
 *
 * @return : array()
 *
 * @since : 1.0
 */
if(!function_exists('xs_return_call_back_login_function')) {

	function xs_return_call_back_login_function(WP_REST_Request $request) {

		$param = $request['data'];
		$code = $request['code'];
		if(is_null($param)) {
			$typeSocial = '';
		}

		$typeSocial  = $param;
		$socialType  = '';
		$callBackUrl = '';

		require_once(WSLU_LOGIN_PLUGIN . '/inc/admin-create-user.php');
		die();
	}
}

/**
 * wp rest api add action
 */
add_action('rest_api_init', function() {

	//https://dev.finesttheme.com/social/wp-json/wslu-social-login/type/google
	register_rest_route('wslu-social-login', '/type/(?P<data>\w+)/',
		array(
			'methods'  => 'GET',
			'callback' => 'xs_return_call_back_login_function',
			'permission_callback' => '__return_true',
		)
	);


	register_rest_route('wslu/v1', '/check_cache/(?P<type>\w+)/',
		array(
			'methods'  => 'POST',
			'callback' => 'post_check_counter_cache',
			'permission_callback' => '__return_true',
		)
	);

	register_rest_route('wslu/v1', '/save_cache/(?P<type>\w+)/',
		array(
			'methods'  => 'POST',
			'callback' => 'post_save_instagram_counter_cache',
			'permission_callback' => '__return_true',
		)
	);
});


function post_save_instagram_counter_cache(WP_REST_Request $request) {

	$data = $request->get_params();

	$ins = new \WP_Social\Lib\Counter\Instagram_Counter();

	$ins->cache_instagram_return($data['content']['count'], \WP_Social\App\Settings::get_counter_cache_time());

	return array(
		'success' => true,
		'msg'     => 'successfully fetched and cached',
		//'result' => $data,
	);
}


function post_check_counter_cache(WP_REST_Request $request) {

	$data = $request->get_params();

	if($data['type'] == 'instagram') {

		$ins = new \WP_Social\Lib\Counter\Instagram_Counter();

		$ins->load();

		if($ins->cache_expired) {

			return array(
				'msg'     => 'Successfull',
				'expired' => true,
				'unm'     => $ins->user_id,
				'success' => true,
			);
		}


		return array(
			'msg'     => 'Successfull',
			'expired' => false,
			'success' => true,
		);
	}

	return array(
		'msg'     => 'error',
		'success' => false,
	);
}