| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/./mahyarcake/public_html/wp-content/plugins/duplicator/src/Utils/CachesPurge/ |
Upload File : |
<?php
namespace Duplicator\Utils\CachesPurge;
use DUP_Log;
use Error;
use Exception;
class CacheItem
{
/**
* name of purge element (usualli plugin name)
*
* @var string
*/
protected $name = '';
/**
* check function, returns true if the element is to be purged
*
* @var callable|bool
*/
protected $checkCallback = null;
/**
* Purge cache callback
*
* @var callable
*/
protected $purgeCallback = null;
/**
* Message when cache is purged
*
* @var string
*/
protected $purgedMessage = '';
/**
* Construnctor
*
* @param string $name item name
* @param bool|callable $checkCallback check callback, return true if cache of current item have to removed
* @param callable $purgeCallback purge cache callback
*/
public function __construct($name, $checkCallback, $purgeCallback)
{
if (strlen($name) == 0) {
throw new Exception('name can\'t be empty');
}
$this->name = $name;
if (!is_bool($checkCallback) && !is_callable($checkCallback)) {
throw new Exception('checkCallback must be boolean or callable');
}
$this->checkCallback = $checkCallback;
/* purge callback may not exist if the referenced plugin is not initialized.
* That's why the check is performed only if you actually purge the plugin
*/
$this->purgeCallback = $purgeCallback;
$this->purgedMessage = sprintf(__('All caches on <b>%s</b> have been purged.', 'duplicator'), $this->name);
}
/**
* overwrite default purged message
*
* @param string $message message if item have benn purged
*
* @return void
*/
public function setPurgedMessage($message)
{
$this->purgedMessage = $message;
}
/**
* purge caches item
*
* @param string $message message if item have benn purged
*
* @return bool
*/
public function purge(&$message)
{
try {
if (
(is_bool($this->checkCallback) && $this->checkCallback) ||
call_user_func($this->checkCallback) == true
) {
DUP_Log::trace('Purge ' . $this->name);
if (!is_callable($this->purgeCallback)) {
throw new Exception('purgeCallback must be callable');
}
call_user_func($this->purgeCallback);
$message = $this->purgedMessage;
}
return true;
} catch (Exception $e) {
DUP_Log::trace('Error purge ' . $this->name . ' message:' . $e->getMessage());
$message = sprintf(__('Error on caches purge of <b>%s</b>.', 'duplicator'), $this->name);
return false;
} catch (Error $e) {
DUP_Log::trace('Error purge ' . $this->name . ' message:' . $e->getMessage());
$message = sprintf(__('Error on caches purge of <b>%s</b>.', 'duplicator'), $this->name);
return false;
}
}
}