.htaccess
1 year ago
AbortQueueItem.php
1 year ago
AddToQueue.php
3 months ago
ClearAlerts.php
1 year ago
ClearCompletedQueueItems.php
1 year ago
CreateSupportUser.php
1 year ago
DeleteBackupJob.php
1 year ago
DeleteDestination.php
1 year ago
DeleteDownload.php
1 year ago
DeleteSchedule.php
1 year ago
DeleteSnapshot.php
1 year ago
DestinationSetExportConfig.php
1 year ago
DuplicateBackupJob.php
1 year ago
EditBackupNotes.php
1 year ago
EnableBackupJob.php
1 year ago
EnableDestination.php
1 year ago
ExecuteCron.php
1 year ago
FileManager.php
10 months ago
GetBackup.php
1 year ago
GetBackupJob.php
1 year ago
GetDashboard.php
1 year ago
GetDatabaseTables.php
1 year ago
GetDestination.php
1 year ago
GetLog.php
1 year ago
GetQRCode.php
1 year ago
GetQueueItem.php
1 year ago
GetSchedule.php
1 year ago
GetSettingsAutomation.php
1 year ago
GetSettingsGeneral.php
1 year ago
GetSettingsIntegrations.php
1 year ago
GetSettingsLogging.php
1 year ago
GetSettingsMaintenance.php
1 year ago
GetSettingsNotifications.php
1 year ago
GetSettingsPerformance.php
1 year ago
GetSettingsRestore.php
1 year ago
GetSettingsSecurity.php
1 year ago
GetSettingsUpdates.php
1 year ago
GetSystemInfo.php
11 months ago
ListAlerts.php
1 year ago
ListBackupJobs.php
1 year ago
ListBackups.php
1 year ago
ListDatabaseTables.php
1 year ago
ListDestinations.php
1 year ago
ListDownloads.php
1 year ago
ListQueueItems.php
4 months ago
ListSchedules.php
1 year ago
LockSnapshot.php
1 year ago
ManageBackupJob.php
1 year ago
ManageDestination.php
1 year ago
ManageSchedule.php
3 months ago
ManageSettingsAutomation.php
10 months ago
ManageSettingsGeneral.php
4 months ago
ManageSettingsIntegrations.php
1 year ago
ManageSettingsLogging.php
1 year ago
ManageSettingsMaintenance.php
1 year ago
ManageSettingsNotifications.php
1 year ago
ManageSettingsPerformance.php
1 year ago
ManageSettingsRestore.php
1 year ago
ManageSettingsSecurity.php
1 week ago
ManageSettingsUpdates.php
1 year ago
ManageShowcase.php
1 year ago
PanelPreload.php
1 year ago
SendTestEmail.php
1 year ago
StartOverQueueItem.php
1 year ago
ValidateDestination.php
1 year ago
ValidateMFA.php
1 year ago
index.html
1 year ago
web.config
1 year ago
PanelPreload.php
107 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Ajax\Calls; |
| 4 | |
| 5 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 6 | |
| 7 | use Exception; |
| 8 | use JetBackup\Ajax\aAjax; |
| 9 | use JetBackup\Config\System; |
| 10 | use JetBackup\Entities\Util; |
| 11 | use JetBackup\Exception\LicenseException; |
| 12 | use JetBackup\Factory; |
| 13 | use JetBackup\JetBackup; |
| 14 | use JetBackup\JetBackupLinux\JetBackupLinux; |
| 15 | use JetBackup\License\License; |
| 16 | use JetBackup\MFA\GoogleAuthenticator; |
| 17 | use JetBackup\Wordpress\Helper; |
| 18 | use JetBackup\Wordpress\UI; |
| 19 | use JetBackup\Wordpress\Wordpress; |
| 20 | use JetBackup\Showcase\Showcase; |
| 21 | |
| 22 | class PanelPreload extends aAjax { |
| 23 | |
| 24 | /** |
| 25 | * @return void |
| 26 | * @throws Exception |
| 27 | */ |
| 28 | public function execute(): void { |
| 29 | |
| 30 | $user = Wordpress::getCurrentUser(); |
| 31 | |
| 32 | $user_name = $user->data->user_nicename ?? $user->data->display_name ?? $user->data->user_login ?? 'User'; |
| 33 | $user_role = $user->roles[0] ?? 'Role'; |
| 34 | $user_profile = Wordpress::getAdminURL() . 'profile.php'; |
| 35 | |
| 36 | |
| 37 | $licenseStatus = License::STATUS_ACTIVE; |
| 38 | $licenseMessage = ''; |
| 39 | |
| 40 | try { |
| 41 | License::checkLocalKey(); |
| 42 | } catch(LicenseException $e) { |
| 43 | $licenseStatus = $e->getStatus(); |
| 44 | $licenseMessage = $e->getMessage(); |
| 45 | } |
| 46 | |
| 47 | $this->setResponseData([ |
| 48 | 'mfa' => [ |
| 49 | 'isEnabled' => Factory::getSettingsSecurity()->isMFAEnabled(), |
| 50 | 'isValid' => UI::validateMFA(), |
| 51 | 'isCompleted' => GoogleAuthenticator::isSetupCompleted(), |
| 52 | ], |
| 53 | 'info' => [ |
| 54 | 'development' => JetBackup::DEVELOPMENT, |
| 55 | 'errors' => [], |
| 56 | ], |
| 57 | 'account' => [ |
| 58 | 'name' => $user_name, |
| 59 | 'role' => $user_role, |
| 60 | 'profile' => $user_profile, |
| 61 | ], |
| 62 | 'language_ns' => self::_loadNS(JetBackup::PUBLIC_PATH . '/lang/en_US'), |
| 63 | 'language_cdn' => Factory::getSettingsGeneral()->isCommunityLanguages(), |
| 64 | 'license' => [ |
| 65 | 'status' => $licenseStatus, |
| 66 | 'message' => $licenseMessage, |
| 67 | ], |
| 68 | 'integration' => [ |
| 69 | 'installed' => JetBackupLinux::isInstalled(), |
| 70 | 'enabled' => Factory::getSettingsGeneral()->isJBIntegrationEnabled(), |
| 71 | ], |
| 72 | 'configuration' => [ |
| 73 | 'UI' => [ |
| 74 | 'site_url' => Wordpress::getSiteURL(), |
| 75 | 'admin_url' => Wordpress::getAdminURL(), |
| 76 | 'plugin_path' => UI::getPluginPath(), |
| 77 | 'timezones' => Util::generateTimeZoneList(), |
| 78 | ], |
| 79 | 'env' => [ |
| 80 | 'is_windows' => System::isWindowsOS(), |
| 81 | 'is_multisite' => Helper::isMultisite(), |
| 82 | 'multisite_main_site_id' => Helper::getMainSiteId(), |
| 83 | ], |
| 84 | 'showcase' => Showcase::getAll(), |
| 85 | ], |
| 86 | ]); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @param $directory |
| 91 | * |
| 92 | * @return array |
| 93 | */ |
| 94 | private static function _loadNS($directory): array { |
| 95 | if(!is_dir($directory)) return []; |
| 96 | |
| 97 | $output = []; |
| 98 | $dir = dir($directory); |
| 99 | while (false !== ($entry = $dir->read())) { |
| 100 | if(!preg_match("/^(.*)\.json$/", $entry, $matches)) continue; |
| 101 | $output[] = $matches[1]; |
| 102 | } |
| 103 | $dir->close(); |
| 104 | |
| 105 | return $output; |
| 106 | } |
| 107 | } |