private function saveWorkerConfiguration(array $data) { if (empty($data['setting'])) { return; } if (!empty($data['setting']['dataown'])) { $oldSettings = (array) $this->context->optionGet('wrksettings'); $this->context->optionSet('wrksettings', array_merge($oldSettings, array('dataown' => $data['setting']['dataown']))); } $configurationService = new MWP_Configuration_Service(); $configuration = new MWP_Configuration_Conf($data['setting']); $configurationService->saveConfiguration($configuration); }
/** * Save to database configuration instance * * @param MWP_Configuration_Conf $configuration */ public function saveConfiguration(MWP_Configuration_Conf $configuration) { self::$configuration = $configuration; $data = $configuration->toArray(); if (array_key_exists("master_cron_url", $data) && !empty($data['master_cron_url'])) { /** @handled function fix */ update_option("mwp_worker_configuration", $data); } }
function mwp_datasend_trigger($stats) { $configurationService = new MWP_Configuration_Service(); $configuration = $configurationService->getConfiguration(); $cachedData = get_transient("mwp_cache_notifications"); $cacheTime = (int) get_transient("mwp_cache_notifications_time"); $returnValue = false; if (false == $cachedData || empty($configuration)) { $returnValue = true; } /** * Cache lifetime check */ if (!$returnValue) { $now = time(); if ($now - $configuration->getNotiCacheLifeTime() >= $cacheTime) { $returnValue = true; } } /** * Themes difference check section * First check if array differ in size. If same size,then check values difference */ if (!$returnValue && empty($stats['upgradable_themes']) != empty($cachedData['upgradable_themes'])) { $returnValue = true; } if (!$returnValue && !empty($stats['upgradable_themes'])) { $themesArr = mwp_std_to_array($stats['upgradable_themes']); $cachedThemesArr = mwp_std_to_array($cachedData['upgradable_themes']); if ($themesArr != $cachedThemesArr) { $returnValue = true; } } /** * Plugins difference check section * First check if array differ in size. If same size,then check values difference */ if (!$returnValue && empty($stats['upgradable_plugins']) != empty($cachedData['upgradable_plugins'])) { $returnValue = true; } if (!$returnValue && !empty($stats['upgradable_plugins'])) { //we have hear stdclass $pluginsArr = mwp_std_to_array($stats['upgradable_plugins']); $cachedPluginsArr = mwp_std_to_array($cachedData['upgradable_plugins']); if ($pluginsArr != $cachedPluginsArr) { $returnValue = true; } } /** * Premium difference check section * First check if array differ in size. If same size,then check values difference */ if (!$returnValue && empty($stats['premium_updates']) != empty($cachedData['premium_updates'])) { $returnValue = true; } if (!$returnValue && !empty($stats['premium_updates'])) { $premiumArr = mwp_std_to_array($stats['premium_updates']); $cachedPremiumArr = mwp_std_to_array($cachedData['premium_updates']); if ($premiumArr != $cachedPremiumArr) { $returnValue = true; } } /** * Comments * Check if we have configs first, then check trasholds */ if (!$returnValue && (int) $stats['num_spam_comments'] >= $configuration->getNotiTresholdSpamComments() && $stats['num_spam_comments'] != (int) $cachedData['num_spam_comments']) { $returnValue = true; } if (!$returnValue && (int) $stats['num_spam_comments'] < (int) $cachedData['num_spam_comments']) { $returnValue = true; } if (!$returnValue && !empty($stats['comments'])) { if (!empty($stats['comments']['pending']) && count($stats['comments']['pending']) >= $configuration->getNotiTresholdPendingComments()) { $pendingArr = mwp_std_to_array($stats['comments']['pending']); $cachedPendingArr = mwp_std_to_array($cachedData['comments']['pending']); if ($pendingArr != $cachedPendingArr) { $returnValue = true; } } if (!empty($stats['comments']['approved']) && count($stats['comments']['approved']) >= $configuration->getNotiTresholdApprovedComments()) { $approvedArr = mwp_std_to_array($stats['comments']['approved']); $cachedApprovedArr = mwp_std_to_array($cachedData['comments']['approved']); if ($approvedArr != $cachedApprovedArr) { $returnValue = true; } } } /** * Drafts, posts */ if (!$returnValue && !empty($stats['drafts']) && count($stats['drafts']) >= $configuration->getNotiTresholdDrafts()) { if (count($stats['drafts']) > $configuration->getNotiTresholdDrafts() && empty($cachedData['drafts'])) { $returnValue = true; } else { $draftsArr = mwp_std_to_array($stats['drafts']); $cachedDraftsArr = mwp_std_to_array($cachedData['drafts']); if ($draftsArr != $cachedDraftsArr) { $returnValue = true; } } } if (!$returnValue && !empty($stats['posts']) && count($stats['posts']) >= $configuration->getNotiTresholdPosts()) { if (count($stats['posts']) > $configuration->getNotiTresholdPosts() && empty($cachedData['posts'])) { $returnValue = true; } else { $postsArr = mwp_std_to_array($stats['posts']); $cachedPostsArr = mwp_std_to_array($cachedData['posts']); if ($postsArr != $cachedPostsArr) { $returnValue = true; } } } /** * Core updates & backups */ if (!$returnValue && empty($stats['core_updates']) != empty($cachedData['core_updates'])) { $returnValue = true; } if (!$returnValue && !empty($stats['core_updates'])) { $coreArr = mwp_std_to_array($stats['core_updates']); $cachedCoreArr = mwp_std_to_array($cachedData['core_updates']); if ($coreArr != $cachedCoreArr) { $returnValue = true; } } if (!$returnValue && empty($stats['mwp_backups']) != empty($cachedData['mwp_backups'])) { $returnValue = true; } if (!$returnValue && !empty($stats['mwp_backups'])) { $backupArr = mwp_std_to_array($stats['mwp_backups']); $cachedBackupArr = mwp_std_to_array($cachedData['mwp_backups']); if ($backupArr != $cachedBackupArr) { $returnValue = true; } } return $returnValue; }
/** * Add notice to admin dashboard for security reasons */ public function admin_notice() { $configurationService = new MWP_Configuration_Service(); $configuration = $configurationService->getConfiguration(); $notice = $configuration->getNotice(); echo $notice; }