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/gwolle-gb/functions/gb-stop-forum-spam.php
<?php
/**
 * Stop Forum Spam Function
 * https://www.stopforumspam.com
 * Copied and edited from seriously-simple-spam-blocker
 */


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



/*
 * Check the $entry against Stop Forum Spam service
 *
 * @param object $entry instance of gb_entry class
 * @return bool true or false
 *
 * @since 2.3.0
 */
function gwolle_gb_stop_forum_spam( $entry ) {
	$args = array();
	$args['ip']         = gwolle_gb_get_user_ip();
	$args['email']      = rawurlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_email() ));
	$args['username']   = rawurlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_name() ));
	$args['f']          = 'json';
	$args['confidence'] = true;
	$args = array_filter( $args );

	$url   = 'https://api.stopforumspam.com/api?';
	$query = $url . http_build_query( $args );
	$key   = md5( $query );

	$transient = get_transient( 'gwolle_gb_sfs_' . $key );
	if ( false === $transient ) {
		$result = wp_remote_get( $query );
		if ( ! is_wp_error( $result ) ) {

			if ( strlen( $result['body'] ) < 10 || ! (int) $result['response']['code'] === 200 ) {
				return false;
			}

			if ( $data = json_decode( $result['body'] ) ) {
				// It is json. Continue.
				if ( (int) $data->success !== 1 ) {
					return false;
				}

				if ( isset( $data->ip ) || isset( $data->email ) || isset( $data->username ) ) {

					$blocked = false;

					if ( isset( $data->ip->confidence ) && $data->ip->confidence > 75 ) {
						$blocked = 'ip';
					}
					if ( isset( $data->username->confidence ) && $data->username->confidence > 80 ) {
						$blocked = 'username';
					}
					if ( isset( $data->email->confidence ) && $data->email->confidence > 75 ) {
						$blocked = 'email';
					}

					if ( $blocked ) {
						set_transient( 'gwolle_gb_sfs_' . $key, 'true', DAY_IN_SECONDS );
						return true;
					} else {
						set_transient( 'gwolle_gb_sfs_' . $key, 'false', DAY_IN_SECONDS );
						return false;
					}
				}
			}
		}
	} else {
		if ( 'true' === $transient ) {
			return true;
		} else {
			return false;
		}
	}
	return false;
}