/** * Process the requests sent by the form submissions originated in the infosys * page, all forms must have a nonce field that will be checked against the one * generated in the template render function. * * @param boolean $page_nonce True if the nonce is valid, False otherwise. * @return void */ function sucuriscan_infosys_form_submissions() { if (SucuriScanInterface::check_nonce()) { // Modify the scheduled tasks (run now, remove, re-schedule). $allowed_actions = '(runnow|hourly|twicedaily|daily|remove)'; if ($cronjob_action = SucuriScanRequest::post(':cronjob_action', $allowed_actions)) { $cronjobs = SucuriScanRequest::post(':cronjobs', '_array'); if (!empty($cronjobs)) { $total_tasks = count($cronjobs); // Force execution of the selected scheduled tasks. if ($cronjob_action == 'runnow') { SucuriScanInterface::info($total_tasks . ' tasks were scheduled to run in the next ten seconds.'); SucuriScanEvent::report_notice_event(sprintf('Force execution of scheduled tasks: (multiple entries): %s', @implode(',', $cronjobs))); foreach ($cronjobs as $task_name) { wp_schedule_single_event(time() + 10, $task_name); } } elseif ($cronjob_action == 'remove') { SucuriScanInterface::info($total_tasks . ' scheduled tasks were removed.'); SucuriScanEvent::report_notice_event(sprintf('Delete scheduled tasks: (multiple entries): %s', @implode(',', $cronjobs))); foreach ($cronjobs as $task_name) { wp_clear_scheduled_hook($task_name); } } elseif ($cronjob_action == 'hourly' || $cronjob_action == 'twicedaily' || $cronjob_action == 'daily') { SucuriScanInterface::info($total_tasks . ' tasks were re-scheduled to run <code>' . $cronjob_action . '</code>.'); SucuriScanEvent::report_notice_event(sprintf('Re-configure scheduled tasks %s: (multiple entries): %s', $cronjob_action, @implode(',', $cronjobs))); foreach ($cronjobs as $task_name) { wp_clear_scheduled_hook($task_name); $next_due = wp_next_scheduled($task_name); wp_schedule_event($next_due, $cronjob_action, $task_name); } } } else { SucuriScanInterface::error('No scheduled tasks were selected from the list.'); } } } }
public static function page() { $output = array(); $output['BlockedUsers.List'] = ''; $output['BlockedUsers.NoItemsVisibility'] = 'visible'; if (SucuriScanInterface::check_nonce()) { $unblockUsers = SucuriScanRequest::post(':unblock_user', '_array'); if (is_array($unblockUsers) && !empty($unblockUsers)) { self::unblock($unblockUsers); SucuriScanInterface::info('Selected user accounts were unblocked'); } } $cache = new SucuriScanCache('blockedusers', false); $blocked = $cache->getAll(); if (is_array($blocked) && !empty($blocked)) { $counter = 0; foreach ($blocked as $data) { $css_class = $counter % 2 === 0 ? '' : 'alternate'; $output['BlockedUsers.List'] .= SucuriScanTemplate::getSnippet('lastlogins-blockedusers', array('BlockedUsers.CssClass' => $css_class, 'BlockedUsers.Username' => $data->username, 'BlockedUsers.BlockedAt' => self::datetime($data->blocked_at), 'BlockedUsers.FirstAttempt' => self::datetime($data->first_attempt), 'BlockedUsers.LastAttempt' => self::datetime($data->last_attempt))); $counter++; } if ($counter > 0) { $output['BlockedUsers.NoItemsVisibility'] = 'hidden'; } } return SucuriScanTemplate::getSection('lastlogins-blockedusers', $output); }