| 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/Controllers/ |
Upload File : |
<?php
/**
* Schedule page controller
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
namespace Duplicator\Controllers;
use DUP_PRO_Schedule_Entity;
use Duplicator\Addons\ProBase\License\License;
use Duplicator\Addons\ProBase\License\LicenseNotices;
use Duplicator\Core\CapMng;
use Duplicator\Core\Controllers\ControllersManager;
use Duplicator\Core\Controllers\AbstractMenuPageController;
use Duplicator\Core\Controllers\PageAction;
use Duplicator\Core\Upgrade\UpgradePlugin;
use Duplicator\Core\Views\TplMng;
use Duplicator\Libs\Snap\SnapUtil;
class SchedulePageController extends AbstractMenuPageController
{
const INNER_PAGE_LIST = 'schedules';
const INNER_PAGE_EDIT = 'edit';
/*
* action types
*/
const ACTION_EDIT_SAVE = 'save';
const ACTION_EDIT_COPY = 'copy-schedule';
/**
* Class constructor
*/
protected function __construct()
{
$this->parentSlug = ControllersManager::MAIN_MENU_SLUG;
$this->pageSlug = ControllersManager::SCHEDULES_SUBMENU_SLUG;
$this->pageTitle = __('Schedule Backups', 'duplicator-pro');
$this->menuLabel = __('Schedule Backups', 'duplicator-pro');
$this->capatibility = CapMng::CAP_SCHEDULE;
$this->menuPos = 30;
add_filter('duplicator_page_actions_' . $this->pageSlug, array($this, 'pageActions'));
add_filter('duplicator_page_template_data_' . $this->pageSlug, array($this, 'updatePackagePageTitle'));
add_action('duplicator_render_page_content_' . $this->pageSlug, array($this, 'renderContent'), 10, 2);
}
/**
* Return actions for current page
*
* @param PageAction[] $actions actions lists
*
* @return PageAction[]
*/
public function pageActions($actions)
{
$actions[] = new PageAction(
self::ACTION_EDIT_SAVE,
[
$this,
'saveSchedule',
],
[$this->pageSlug],
self::INNER_PAGE_EDIT
);
$actions[] = new PageAction(
self::ACTION_EDIT_COPY,
[
$this,
'copySchedule',
],
[$this->pageSlug],
self::INNER_PAGE_EDIT
);
return $actions;
}
/**
* Set Backup page title
*
* @param array<string, mixed> $tplData template global data
*
* @return array<string, mixed>
*/
public function updatePackagePageTitle($tplData)
{
switch ($this->getCurrentInnerPage()) {
case self::INNER_PAGE_EDIT:
break;
case self::INNER_PAGE_LIST:
default:
$tplData['pageTitle'] = __('Schedule Backup', 'duplicator-pro');
$tplData['templateSecondaryPart'] = 'admin_pages/schedules/schedule_create_button';
break;
}
return $tplData;
}
/**
* Save schedule
*
* @return array<string, mixed>
*/
public function saveSchedule()
{
$result = [
'saveSuccess' => false,
'actionScheduleId' => SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'schedule_id', -1),
];
$schedule_id = $result['actionScheduleId'];
if ($schedule_id == -1) {
$schedule = new DUP_PRO_Schedule_Entity();
} else {
$schedule = DUP_PRO_Schedule_Entity::getById($schedule_id);
}
if ($schedule == false) {
$result['errorMessage'] = __('Schedule not found', 'duplicator-pro');
return $result;
}
$schedule->setFromInput(SnapUtil::INPUT_REQUEST);
if ($schedule->save() == false) {
$result['errorMessage'] = __('Is not possible to update the schedule settings', 'duplicator-pro');
} else {
$result['saveSuccess'] = true;
$result['successMessage'] = __('Schedule saved', 'duplicator-pro');
}
$result['actionScheduleId'] = $schedule->getId();
return $result;
}
/**
* Save schedule
*
* @return array<string, mixed>
*/
public function copySchedule()
{
$result = [
'saveSuccess' => false,
'actionScheduleId' => SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'schedule_id', -1),
];
$schedule_id = $result['actionScheduleId'];
$source_id = SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'duppro-source-schedule-id', -1);
if ($source_id == -1 || !DUP_PRO_Schedule_Entity::exists($source_id)) {
$result['errorMessage'] = __('Schedule to copy not found', 'duplicator-pro');
return $result;
}
if ($schedule_id == -1) {
$schedule = new DUP_PRO_Schedule_Entity();
} else {
$schedule = DUP_PRO_Schedule_Entity::getById($schedule_id);
}
if ($schedule == false) {
$result['errorMessage'] = __('Schedule not found', 'duplicator-pro');
return $result;
}
$schedule->copy_from_source_id($source_id);
if ($schedule->save() == false) {
$result['errorMessage'] = __('Is not possible to update the schedule settings', 'duplicator-pro');
} else {
$result['saveSuccess'] = true;
$result['successMessage'] = __('Schedule copied.', 'duplicator-pro');
}
$result['actionScheduleId'] = $schedule->getId();
return $result;
}
/**
* Render page content
*
* @param string[] $currentLevelSlugs current menu slugs
* @param string $innerPage current inner page, empty if not set
*
* @return void
*/
public function renderContent($currentLevelSlugs, $innerPage)
{
switch ($this->getCurrentInnerPage()) {
case self::INNER_PAGE_EDIT:
$scheduleId = TplMng::getInstance()->getGlobalValue(
'actionScheduleId',
SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'schedule_id', -1)
);
if ($scheduleId == -1) {
$schedule = new DUP_PRO_Schedule_Entity();
} else {
$schedule = DUP_PRO_Schedule_Entity::getById($scheduleId);
}
TplMng::getInstance()->render(
'admin_pages/schedules/schedule_edit',
[
'schedule' => $schedule,
'blur' => !License::can(License::CAPABILITY_SCHEDULE),
]
);
break;
case self::INNER_PAGE_LIST:
default:
TplMng::getInstance()->render(
'admin_pages/schedules/schedule_list',
[
'blur' => !License::can(License::CAPABILITY_SCHEDULE),
]
);
break;
}
}
/**
* Get schedule edit URL
*
* @return string
*/
public function getEditBaseUrl()
{
return ControllersManager::getMenuLink(
ControllersManager::SCHEDULES_SUBMENU_SLUG,
null,
null,
[ControllersManager::QUERY_STRING_INNER_PAGE => 'edit']
);
}
/**
* Get schedule edit URL
*
* @param int $scheduleId schedule id, if -1 then new schedule will be created
*
* @return string
*/
public function getEditUrl($scheduleId = -1)
{
return ControllersManager::getMenuLink(
ControllersManager::SCHEDULES_SUBMENU_SLUG,
null,
null,
[
ControllersManager::QUERY_STRING_INNER_PAGE => 'edit',
'schedule_id' => $scheduleId,
]
);
}
/**
* Get schedule copy action URL
*
* @param int $scheduleId schedule id, if -1 then new schedule will be created
* @param int $sourceId source schedule id, if -1 then source if ins't add on URL
*
* @return string
*/
public function getCopyActionUrl($scheduleId = -1, $sourceId = -1)
{
$action = $this->getActionByKey(self::ACTION_EDIT_COPY);
$extraArgs = [
ControllersManager::QUERY_STRING_INNER_PAGE => 'edit',
'action' => $action->getKey(),
'_wpnonce' => $action->getNonce(),
'schedule_id' => $scheduleId,
];
if ($sourceId > -1) {
$extraArgs['duppro-source-schedule-id'] = $sourceId;
}
return ControllersManager::getMenuLink(
ControllersManager::SCHEDULES_SUBMENU_SLUG,
null,
null,
$extraArgs
);
}
}