| Server IP : 38.190.208.107 / Your IP : 216.73.217.2 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/test28.chuangfenglink.xyz/wp-content/plugins/fluent-smtp/includes/Core/ |
Upload File : |
<?php
namespace FluentMail\Includes\Core;
use FluentMail\Includes\Support\ForbiddenException;
trait CoreTrait
{
public function get($action, $handler, $isAdmin = true)
{
$action = $this->getAjaxAction($action, 'get', $isAdmin);
return add_action($action, $this->parseAjaxHandler($handler));
}
public function getPublic($action, $handler)
{
$this->get($action, $handler, false);
}
public function post($action, $handler, $isAdmin = true)
{
$action = $this->getAjaxAction($action, 'post', $isAdmin);
return add_action($action, function() use ($handler) {
try {
$slug = FLUENTMAIL;
if (check_ajax_referer($slug, 'nonce', false)) {
$method = $this->parseAjaxHandler($handler);
return $method();
}
throw new ForbiddenException('Forbidden!', 401);
} catch (ForbiddenException $e) {
return $this->docustomAction('handle_exception', $e);
}
});
}
public function postPublic($action, $handler)
{
$this->post($action, $handler, false);
}
public function getAjaxAction($action, $method, $isAdmin)
{
$context = $isAdmin ? 'wp_ajax_' : 'wp_ajax_nopriv_';
$action = $action == '/' ? $action : ltrim($action, '/');
return $context.$this->hook($method.'-'.$action);
}
public function hook($hook)
{
return FLUENTMAIL . '-' . $hook;
}
public function parseAjaxHandler($handler)
{
if (!$handler) return;
if (is_string($handler)) {
$handler = $this->controllerNamespace . '\\' . $handler;
} else if (is_array($handler)) {
list($class, $method) = $handler;
if (is_string($class)) {
$handler = $this->controllerNamespace . '\\' . $class . '::' . $method;
}
}
return function() use ($handler) {
return $this->call($handler);
};
}
public function addAction($action, $handler, $priority = 10, $numOfArgs = 1)
{
return add_action(
$action,
$this->parseHookHandler($handler),
$priority,
$numOfArgs
);
}
public function addCustomAction($action, $handler, $priority = 10, $numOfArgs = 1)
{
return $this->addAction($this->hook($action), $handler, $priority, $numOfArgs);
}
public function doAction()
{
return call_user_func_array('do_action', func_get_args());
}
public function doCustomAction()
{
$args = func_get_args();
$args[0] = $this->hook($args[0]);
return call_user_func_array('do_action', $args);
}
public function addFilter($action, $handler, $priority = 10, $numOfArgs = 1)
{
return add_filter(
$action,
$this->parseHookHandler($handler),
$priority,
$numOfArgs
);
}
public function addCustomFilter($action, $handler, $priority = 10, $numOfArgs = 1)
{
return $this->addFilter($this->hook($action), $handler, $priority, $numOfArgs);
}
public function applyFilters()
{
return call_user_func_array('apply_filters', func_get_args());
}
public function applyCustomFilters()
{
$args = func_get_args();
$args[0] = $this->hook($args[0]);
return call_user_func_array('apply_filters', $args);
}
public function parseHookHandler($handler)
{
if (is_string($handler)) {
list($class, $method) = preg_split('/::|@/', $handler);
if ($this->hasNamespace($handler)) {
$class = $this->make($class);
} else {
$class = $this->make($this->handlerNamespace . '\\' . $class);
}
return [$class, $method];
} else if (is_array($handler)) {
list($class, $method) = $handler;
if (is_string($class)) {
if ($this->hasNamespace($handler)) {
$class = $this->make($class);
} else {
$class = $this->make($this->handlerNamespace . '\\' . $class);
}
}
return [$class, $method];
}
return $handler;
}
public function hasNamespace($handler)
{
$parts = explode('\\', $handler);
return count($parts) > 1;
}
}