| 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-pro/src/Views/ |
Upload File : |
<?php
namespace Duplicator\Views;
class UserUIOptions
{
const USER_UI_OPTION_META_KEY = 'duplicator_user_ui_option';
const VAL_PACKAGES_PER_PAGE = 'num_packages_list';
const VAL_CREATED_DATE_FORMAT = 'created_date_format';
const VAL_SHOW_COL_NOTE = 'show_note_column';
const VAL_SHOW_COL_SIZE = 'show_size_column';
const VAL_SHOW_COL_CREATED = 'show_created_column';
const VAL_SHOW_COL_AGE = 'show_age_column';
/** @var ?self */
private static $instance = null;
/** @var int */
private $userId = 0;
/** @var array<string,scalar> */
private $options = [
self::VAL_PACKAGES_PER_PAGE => 10,
self::VAL_CREATED_DATE_FORMAT => 1,
self::VAL_SHOW_COL_NOTE => false,
self::VAL_SHOW_COL_SIZE => true,
self::VAL_SHOW_COL_CREATED => true,
self::VAL_SHOW_COL_AGE => false,
];
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* CLass constructor
*/
protected function __construct()
{
$this->userId = get_current_user_id();
$this->load();
}
/**
* Get the value of an option
*
* @param string $option the option name
*
* @return scalar
*/
public function get($option)
{
if (!isset($this->options[$option])) {
return false;
}
return $this->options[$option];
}
/**
* Set the value of an option
*
* @param string $option the option name
* @param scalar $value the option value
*
* @return void
*/
public function set($option, $value)
{
if (!isset($this->options[$option])) {
// don't set unknown options
return;
}
$this->options[$option] = $value;
}
/**
* Load the option from meta user table
*
* @return void
*/
protected function load()
{
if ($this->userId == 0) {
return;
}
$options = get_user_meta($this->userId, self::USER_UI_OPTION_META_KEY, true);
if (is_array($options)) {
foreach (array_keys($this->options) as $option) {
$this->options[$option] = $options[$option];
}
}
$this->loadOldValues();
}
/**
* Load old values from meta user table
*
* @return void
*/
protected function loadOldValues()
{
$save = false;
//Inheriting the value of the old created format option to the screen option
$createdFormat = get_user_meta($this->userId, 'duplicator_pro_created_format', true);
if (is_numeric($createdFormat)) {
$save = true;
$this->options[self::VAL_CREATED_DATE_FORMAT] = $createdFormat;
delete_user_meta($this->userId, 'duplicator_pro_created_format');
}
$perPage = get_user_meta($this->userId, 'duplicator_pro_opts_per_page', true);
if (is_numeric($perPage)) {
$save = true;
$this->options[self::VAL_PACKAGES_PER_PAGE] = $perPage;
delete_user_meta($this->userId, 'duplicator_pro_opts_per_page');
}
if ($save) {
$this->save();
}
}
/**
* Save the option to meta user table
*
* @return void
*/
public function save()
{
if ($this->userId == 0) {
return;
}
update_user_meta($this->userId, self::USER_UI_OPTION_META_KEY, $this->options);
}
}