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/tawkto-live-chat/upgrades/version.070.php
<?php

if ( ! class_exists( 'TawkToUpgradeBase' ) ) {
	require_once dirname( __FILE__ ) . '/base.php';
}

use Tawk\Helpers\PathHelper;
use Tawk\Helpers\Common as CommonHelper;

/**
 * Upgrade for release version 0.7.0
 */
class TawkToUpgradeVersion070 extends TawkToUpgradeBase {
	const VERSION = '0.7.0';

	/**
	 * Migration for url patterns with ending wildcards. (ex. https://www.example.com/path/to/somewhere/*)
	 *
	 * Adds the same url pattern without the ending wildcard (ex. https://www.example.com/path/to/somewhere)
	 * to adjust with the new pattern matching lib.
	 */
	public static function upgrade() {
		$visibility = get_option( TawkTo_Settings::TAWK_VISIBILITY_OPTIONS );

		$visibility['included_url_list'] = self::process_patterns( $visibility['included_url_list'] );
		$visibility['excluded_url_list'] = self::process_patterns( $visibility['excluded_url_list'] );

		update_option( TawkTo_Settings::TAWK_VISIBILITY_OPTIONS, $visibility );
	}

	/**
	 * Processes the patterns with ending wildcards and adds
	 * a copy of it without the wildcard to the list.
	 *
	 * @param string $pattern_list Comma separated pattern list.
	 *
	 * @return string Updated pattern list.
	 */
	protected static function process_patterns( $pattern_list ) {
		$splitted_pattern_list = array_map( 'trim', preg_split( '/,/', $pattern_list ) );
		$wildcard              = PathHelper::get_wildcard();

		$new_pattern_list = array();
		$added_patterns   = array();

		foreach ( $splitted_pattern_list as $url ) {
			if ( empty( $url ) ) {
				continue;
			}

			$new_pattern_list[] = $url;

			if ( false === CommonHelper::text_ends_with( $url, $wildcard ) ) {
				continue;
			}

			$new_pattern = rtrim( $url, '/' . $wildcard );
			if ( in_array( $new_pattern, $splitted_pattern_list, true ) ) {
				continue;
			}

			if ( true === isset( $added_patterns[ $new_pattern ] ) ) {
				continue;
			}

			$new_pattern_list[]             = $new_pattern;
			$added_patterns[ $new_pattern ] = true;
		}

		return join( ', ', $new_pattern_list );
	}
}