| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.huomanshiye.com/wp-content/themes/blocksy/admin/helpers/ |
Upload File : |
<?php
/**
* Sanitization helpers for admin inputs.
*
* @copyright 2019-present Creative Themes
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @package Blocksy
*/
if (! function_exists('blocksy_is_value_suspicious')) {
/**
* Check if a string value contains suspicious patterns.
*
* @param string $value The value to check.
* @return bool True if suspicious, false otherwise.
*/
function blocksy_is_value_suspicious($value) {
if (! is_string($value)) {
return false;
}
$value = trim($value);
// Characters that could enable XSS or CSS injection
$dangerous = ['<', '>'];
foreach ($dangerous as $char) {
if (strpos($value, $char) !== false) {
return true;
}
}
return false;
}
}
if (! function_exists('blocksy_sanitize_value_recursive')) {
/**
* Recursively sanitize all string values in an array.
*
* @param mixed $value The value to sanitize.
* @return mixed Sanitized value.
*/
function blocksy_sanitize_value_recursive($value) {
if (is_string($value)) {
if (blocksy_is_value_suspicious($value)) {
return '';
}
return $value;
}
if (is_array($value)) {
foreach ($value as $key => $item) {
$value[$key] = blocksy_sanitize_value_recursive($item);
}
}
return $value;
}
}
if (! function_exists('blocksy_sanitize_post_meta_options')) {
/**
* Sanitize post meta options by recursively checking all string values.
*
* Any string containing suspicious characters (< >) will be replaced
* with an empty string to prevent XSS attacks.
*
* Keys listed in the 'blocksy:post-meta:unfiltered-keys' filter are
* skipped when the current user has the 'unfiltered_html' capability.
*
* @param mixed $value The meta options to sanitize.
* @return mixed Sanitized meta options.
*/
function blocksy_sanitize_post_meta_options($value) {
$unfiltered_keys = [];
if (current_user_can('unfiltered_html')) {
$unfiltered_keys = apply_filters(
'blocksy:post-meta:unfiltered-keys',
[]
);
}
if (is_array($value) && ! empty($unfiltered_keys)) {
$preserved = [];
foreach ($unfiltered_keys as $key) {
if (array_key_exists($key, $value)) {
$preserved[$key] = $value[$key];
}
}
$value = blocksy_sanitize_value_recursive($value);
foreach ($preserved as $key => $val) {
$value[$key] = $val;
}
return $value;
}
return blocksy_sanitize_value_recursive($value);
}
}