| 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/././www/wp-content/plugins/duplicator-pro/src/Package/ |
Upload File : |
<?php
namespace Duplicator\Package;
use DUP_PRO_Package_Template_Entity;
use DUP_PRO_Schedule_Entity;
class NameFormat
{
const FORMATS = [
'year',
'month',
'day',
'hour',
'minute',
'second',
'domain',
'sitetitle',
'templatename',
'schedulename',
];
const FILTER_CHARS = [
'.',
'%',
':',
'-',
' ',
];
const DEFAULT_FORMAT = '%year%%month%%day%_%sitetitle%';
/** @var string */
private $format = self::DEFAULT_FORMAT;
/** @var int */
private $scheduleId = 0;
/** @var int */
private $templateId = 0;
/** @var int timestapm */
private $timestamp = 0;
/**
* Class constructor
*
* @param string $format The format
*/
public function __construct($format = '')
{
$this->setFormat($format);
$this->timestamp = time();
}
/**
* Set the format
*
* @param string $format The format
*
* @return void
*/
public function setFormat($format)
{
$this->format = (strlen($format) == 0 ? self::DEFAULT_FORMAT : (string) $format);
}
/**
* Set the schedule id
*
* @param int $scheduleId The schedule id
*
* @return void
*/
public function setScheduleId($scheduleId)
{
$this->scheduleId = (int) $scheduleId;
}
/**
* Set the template id
*
* @param int $templateId The template id
*
* @return void
*/
public function setTemplateId($templateId)
{
$this->templateId = (int) $templateId;
}
/**
* Set the timestamp
*
* @param int $timestamp The timestamp
*
* @return void
*/
public function setTimestamp($timestamp)
{
if ($timestamp == 0) {
$timestamp = time();
}
$this->timestamp = (int) $timestamp;
}
/**
* Get the name from format
*
* @return string
*/
public function getName()
{
$parsed = $this->format;
if (strpos($parsed, '%year%') !== false) {
$parsed = str_replace('%year%', gmdate('Y', $this->timestamp), $parsed);
}
if (strpos($parsed, '%month%') !== false) {
$parsed = str_replace('%month%', gmdate('m', $this->timestamp), $parsed);
}
if (strpos($parsed, '%day%') !== false) {
$parsed = str_replace('%day%', gmdate('d', $this->timestamp), $parsed);
}
if (strpos($parsed, '%hour%') !== false) {
$parsed = str_replace('%hour%', gmdate('H', $this->timestamp), $parsed);
}
if (strpos($parsed, '%minute%') !== false) {
$parsed = str_replace('%minute%', gmdate('i', $this->timestamp), $parsed);
}
if (strpos($parsed, '%second%') !== false) {
$parsed = str_replace('%second%', gmdate('s', $this->timestamp), $parsed);
}
if (strpos($parsed, '%domain%') !== false) {
$siteUrl = get_site_url();
$parsed = str_replace('%domain%', parse_url($siteUrl, PHP_URL_HOST), $parsed);
}
if (strpos($parsed, '%sitetitle%') !== false) {
$title = sanitize_title(get_bloginfo('name'));
$title = substr(sanitize_file_name($title), 0, 40);
$parsed = str_replace('%sitetitle%', $title, $parsed);
}
if (strpos($parsed, '%templatename%') !== false) {
$templateName = '';
if ($this->templateId > 0) {
$template = DUP_PRO_Package_Template_Entity::getById($this->templateId);
if ($template !== false) {
$templateName = $template->name;
}
}
$parsed = str_replace('%templatename%', $templateName, $parsed);
}
if (strpos($parsed, '%schedulename%') !== false) {
$scheduleName = '';
if ($this->scheduleId > 0) {
$schedule = DUP_PRO_Schedule_Entity::getById($this->scheduleId);
if ($schedule !== false) {
$scheduleName = $schedule->name;
}
}
$parsed = str_replace('%schedulename%', $scheduleName, $parsed);
}
$parsed = str_replace(self::FILTER_CHARS, '', $parsed);
return sanitize_file_name($parsed);
}
/**
* Get tags description
*
* @return array<string, string>
*/
public static function getTagsDescriptions()
{
return [
'year' => __('Current Year', 'duplicator-pro'),
'month' => __('Current Month', 'duplicator-pro'),
'day' => __('Current Day', 'duplicator-pro'),
'hour' => __('Current Hour', 'duplicator-pro'),
'minute' => __('Current Minute', 'duplicator-pro'),
'second' => __('Current Second', 'duplicator-pro'),
'domain' => __('Current Domain', 'duplicator-pro'),
'sitetitle' => __('Current Site Title', 'duplicator-pro'),
'templatename' => __('Current Template Name', 'duplicator-pro'),
'schedulename' => __('Current Schedule Name', 'duplicator-pro'),
];
}
}