public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $profile = $arguments['profile'];
     if ('db' == $profile) {
         // db profile is always index 1.
         $profile = '1';
     } elseif ('full' == $profile) {
         // full profile is always index 2.
         $profile = '2';
     }
     if (is_numeric($profile)) {
         if (isset(pb_backupbuddy::$options['profiles'][$profile])) {
             $profileArray = pb_backupbuddy::$options['profiles'][$profile];
         } else {
             return array('api' => '0', 'status' => 'error', 'message' => 'Error #2332904: Invalid profile ID `' . htmlentities($profile) . '`. Profile with this number was not found. Try deactivating then reactivating the plugin. If this fails please reset the plugin Settings back to Defaults from the Settings page.');
         }
     } else {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #85489548955. Invalid profile ID not numeric: `' . htmlentities($profile) . '`.');
     }
     require_once pb_backupbuddy::plugin_path() . '/classes/backup.php';
     pb_backupbuddy::$classes['backup'] = new pb_backupbuddy_backup();
     // Set serial ahead of time so can be used by AJAX before backup procedure actually begins.
     $serial = pb_backupbuddy::random_string(10);
     $profileArray['backup_mode'] = '2';
     // Force modern mode when running under sync.
     // Run the backup!
     if (pb_backupbuddy::$classes['backup']->start_backup_process($profileArray, 'manual', array(), array(), 'it-sync', $serial, array()) !== true) {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #435832: Backup failed. See BackupBuddy log for details.');
     }
     return array('api' => '0', 'status' => 'ok', 'message' => 'Backup initiated successfully.');
 }
示例#2
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     include_once ABSPATH . WPINC . '/comment.php';
     $actions = array('add' => '', 'edit' => '', 'approve' => array($this, 'approve_comment'), 'unapprove' => array($this, 'unapprove_comment'), 'spam' => array($this, 'spam_comment'), 'unspam' => array($this, 'unspam_comment'), 'trash' => array($this, 'trash_comment'), 'restore' => array($this, 'restore_comment'), 'untrash' => array($this, 'restore_comment'), 'delete' => array($this, 'delete_comment'), 'emptyspam' => array($this, 'empty_spam'), 'emptytrash' => array($this, 'empty_trash'));
     foreach ($arguments as $action => $data) {
         if ('get-actions' == $action) {
             $this->response[$action] = array_keys($actions);
             continue;
         }
         if (!isset($actions[$action])) {
             $this->response[$action] = 'This action is not recognized.';
             continue;
         }
         if ('add' == $action) {
             $this->response[$action] = $this->add_comment($data);
         } else {
             if ('edit' == $action) {
                 $this->response[$action] = $this->edit_comments($data);
             } else {
                 if ('emptyspam' == $action) {
                     $function = $actions[$action];
                     if (!is_callable($actions[$action])) {
                         return new WP_Error("missing-function-{$function}", "Due to an unknown issue, the {$function} function is not available.");
                     }
                     $this->response[$action] = call_user_func($function);
                 } else {
                     $this->response[$action] = $this->run_function_on_ids($actions[$action], $data);
                 }
             }
         }
     }
     return $this->response;
 }
示例#3
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     include_once ABSPATH . WPINC . '/comment.php';
     $actions = array('add' => '', 'edit' => '', 'trash' => 'wp_trash_comment', 'untrash' => 'wp_untrash_comment', 'spam' => 'wp_spam_comment', 'unspam' => 'wp_unspam_comment', 'approve' => array($this, 'approve_comment'), 'unapprove' => array($this, 'unapprove_comment'), 'delete' => array($this, 'delete_comment'));
     foreach ($arguments as $action => $data) {
         if ('get-actions' == $action) {
             $this->response[$action] = array_keys($actions);
             continue;
         }
         if (!isset($actions[$action])) {
             $this->response[$action] = 'This action is not recognized.';
             continue;
         }
         if (!is_array($data)) {
             $this->response[$action] = new WP_Error('invalid-argument', 'This action requires an array.');
             continue;
         }
         if ('add' == $action) {
             $this->response[$action] = $this->add_comment($data);
         } else {
             if ('edit' == $action) {
                 $this->response[$action] = $this->edit_comments($data);
             } else {
                 $this->response[$action] = $this->run_function_on_ids($actions[$action], $data);
             }
         }
     }
     return $this->response;
 }
 public function run($arguments)
 {
     global $itsec_lockout;
     if (!isset($arguments['ip'])) {
         return new WP_Error('missing-argument-ip', __('The ip argument is missing.', 'better-wp-security'));
     }
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $ip = sanitize_text_field($arguments['ip']);
     if (empty($ip)) {
         return new WP_Error('empty-ip', __('An empty ip argument was submitted.', 'better-wp-security'));
     }
     $direction = isset($arguments['direction']) ? $arguments['direction'] : 'add';
     if ('add' === $direction) {
         $itsec_lockout->add_to_temp_whitelist($ip);
     } else {
         if ('remove' === $direction) {
             $itsec_lockout->remove_from_temp_whitelist($ip);
         } else {
             if ('clear' === $direction) {
                 $itsec_lockout->clear_temp_whitelist();
             } else {
                 return new WP_Error('invalid-argument-value-for-direction', __('The direction argument must be either "add", "clear", or "remove".', 'better-wp-security'));
             }
         }
     }
     return true;
 }
示例#5
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (!is_callable('get_comments')) {
         include_once ABSPATH . WPINC . '/wp-includes/comment.php';
     }
     if (!is_callable('get_comments')) {
         return new WP_Error('missing-function-get_comments', 'Due to an unknown issue, the wp_comments function is not available.');
     }
     $comments = get_comments($arguments['args']);
     if (is_array($comments)) {
         $this->response['comments'] = array();
         foreach ($comments as $index => $comment) {
             $this->response['comments'][$comment->comment_ID] = (array) $comment;
         }
         if ($arguments['include-parent-details']) {
             $this->add_parent_details();
         }
         if ($arguments['include-post-details']) {
             $this->add_post_details();
         }
         if ($arguments['include-user-details']) {
             $this->add_user_details();
         }
     } else {
         $this->response = $comments;
     }
     return $this->response;
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     pb_backupbuddy::$options['remote_destinations'][] = $arguments['settings'];
     pb_backupbuddy::save();
     return array('api' => '0', 'status' => 'ok', 'message' => 'Destination added.');
 }
示例#7
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (!is_callable(array($GLOBALS['ithemes-sync-api'], 'run'))) {
         return new WP_Error('missing-method-api-run', 'The Ithemes_Sync_API::run function is not callable. Unable to generate status details.');
     }
     $status_elements = Ithemes_Sync_Functions::get_status_elements($arguments);
     if (!empty($arguments['status_elements'])) {
         if (is_array($arguments['status_elements'])) {
             $show_status_elements = $arguments['status_elements'];
         } else {
             trigger_error('A non-array status_elements argument was supplied. The argument will be ignored.');
         }
         unset($arguments['status_elements']);
     }
     if (!isset($show_status_elements)) {
         $show_status_elements = Ithemes_Sync_Functions::get_default_status_elements();
     }
     foreach ($show_status_elements as $element) {
         if (isset($status_elements[$element])) {
             $var = $status_elements[$element];
             $element_arguments = $arguments;
             if (isset($arguments[$var])) {
                 $element_arguments = $arguments[$var];
             }
             $data = $GLOBALS['ithemes-sync-api']->run($status_elements[$element], $element_arguments);
         } else {
             $data = "This element is not recognized";
         }
         $status[$element] = $data;
     }
     return $status;
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     pb_backupbuddy::$options['remote_destinations'][] = $arguments['settings'];
     pb_backupbuddy::save();
     $highest_destination_index = end(array_keys(pb_backupbuddy::$options['remote_destinations']));
     return array('api' => '1', 'status' => 'ok', 'message' => 'Destination added.', 'destination_id' => $highest_destination_index);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $profiles = array();
     foreach (pb_backupbuddy::$options['profiles'] as $profile_id => $profile) {
         $profiles[$profile_id] = array('title' => strip_tags($profile['title']), 'type' => $profile['type'], 'id' => $profile_id);
     }
     return array('api' => '0', 'status' => 'ok', 'message' => 'Profiles listed successfully.', 'profiles' => $profiles);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (false === ($currentBackupStats = backupbuddy_api::getLatestBackupStats())) {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #238923: Stats for the latest backup not found. One may have not started yet or stats file is missing.');
     } else {
         return array('version' => '4', 'status' => 'ok', 'message' => 'Latest backup process details retrieved successfully.', 'latestBackupProcess' => $currentBackupStats, 'localTime' => time());
     }
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $schedules = array();
     foreach (pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule) {
         $schedules[$schedule_id] = array('title' => strip_tags($schedule['title']), 'profileID' => $schedule['profile'], 'interval' => $schedule['interval'], 'lastRun' => $schedule['last_run'], 'enabled' => $schedule['on_off'], 'id' => $schedule_id);
     }
     return array('api' => '0', 'status' => 'ok', 'message' => 'Scheduled listed successfully.', 'schedules' => $schedules);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $destinations = array();
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
         $destinations[$destination_id] = array('title' => strip_tags($destination['title']), 'type' => $destination['type'], 'id' => $destination_id);
     }
     return array('api' => '0', 'status' => 'ok', 'message' => 'Destinations listed successfully.', 'destinations' => $destinations);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (true !== backupbuddy_api::addSchedule($arguments['title'], $arguments['profile'], $arguments['interval'], $arguments['firstRun'], $arguments['destinations'], $arguments['deleteAfter'], $arguments['enabled'])) {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #378235: Creating schedule failed. A plugin may have blocked scheduling with WordPress. Details: ' . backupbuddy_api::$lastError);
     } else {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Schedule added successfully.', 'scheduleID' => (int) (pb_backupbuddy::$options['next_schedule_index'] - 1));
     }
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $result = backupbuddy_api::deleteSchedule($arguments['id'], $confirm = true);
     if (true !== $result) {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #32893: Failure deleting schedule.');
     } else {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Schedule deleted.');
     }
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $status = 'error';
     $schedules = backupbuddy_api::getSchedules();
     if (false !== $schedules) {
         $status = 'ok';
     }
     return array('api' => '0', 'status' => $status, 'message' => 'Schedules listed successfully.', 'schedules' => $schedules);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $results = backupbuddy_api::runBackup($arguments['profile'], 'iThemes Sync', $backupMode = '2');
     if (true !== $results) {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error running backup. Details: ' . $results);
     } else {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Backup initiated successfully.', 'serial' => $serial);
     }
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (isset(pb_backupbuddy::$options['remote_destinations'][$arguments['id']])) {
         return array('api' => '1', 'status' => 'ok', 'message' => 'Destination settings retrieved.', 'settings' => pb_backupbuddy::$options['remote_destinations'][$arguments['id']], 'destination_id' => $arguments['id']);
     } else {
         // Invalid destination ID.
         return array('api' => '1', 'status' => 'error', 'message' => 'Error #327783: Invalid destination ID.');
     }
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (!isset(pb_backupbuddy::$options['remote_destinations'][$arguments['id']])) {
         return array('api' => '1', 'status' => 'error', 'message' => 'Error #847383: Invalid destination ID. Not found.');
     }
     unset(pb_backupbuddy::$options['remote_destinations'][$arguments['id']]);
     pb_backupbuddy::save();
     return array('api' => '1', 'status' => 'ok', 'message' => 'Destination deleted.', 'destination_id' => $arguments['id']);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     if (true === ($results = pb_backupbuddy_destinations::test($settings))) {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Supported destinations retrieved.');
     } else {
         return array('api' => '0', 'status' => 'error', 'message' => $results);
     }
 }
示例#20
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (!isset($arguments['show_sync'])) {
         return new WP_Error('missing-show_sync-argument', 'The show_sync argument is missing. The new show_sync value should be sent in the show_sync argument.');
     }
     $options = $GLOBALS['ithemes-sync-settings']->get_options();
     $options['show_sync'] = $arguments['show_sync'];
     $GLOBALS['ithemes-sync-settings']->update_options($options);
     return array('success' => 1);
 }
示例#21
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $posts = get_posts($arguments);
     // Add some additional data
     foreach ($posts as &$post) {
         $post->permalink = get_permalink($post->ID);
         $post->author_display_name = get_the_author_meta('display_name', $post->post_author);
     }
     return $posts;
 }
示例#22
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once $GLOBALS['ithemes_sync_path'] . '/notice-handler.php';
     $normal = $GLOBALS['ithemes_sync_notice_handler']->get_notices($arguments);
     $urgent = $GLOBALS['ithemes_sync_notice_handler']->get_urgent_notices();
     if ($arguments['clear-urgent-notices']) {
         $GLOBALS['ithemes_sync_notice_handler']->clear_urgent_notices();
     }
     return compact('normal', 'urgent');
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $response = pb_backupbuddy_destinations::delete($arguments['id'], true);
     if (true === $response) {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Destination deleted.');
     } else {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #384783783: Failure deleting destination.');
     }
 }
 public function run($arguments = array())
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (true === backupbuddy_api::runLiveSnapshot()) {
         $status = 'ok';
         $message = 'Snapshot initiated. Scanning for changes first.';
     } else {
         $status = 'error';
         $message = 'Snapshot failed to initiate. A scan is currently in progress.';
     }
     return array('version' => '1', 'status' => $status, 'message' => $message);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     pb_backupbuddy::$options['remote_destinations'][] = $arguments['settings'];
     pb_backupbuddy::save();
     $newDestination = array();
     $newDestination['title'] = $arguments['settings']['title'];
     $newDestination['type'] = $arguments['settings']['type'];
     backupbuddy_core::addNotification('destination_created', 'Remote destination created', 'A new remote destination "' . $newDestination['title'] . '" has been created.', $newDestination);
     $highest_destination_index = end(array_keys(pb_backupbuddy::$options['remote_destinations']));
     return array('api' => '1', 'status' => 'ok', 'message' => 'Destination added.', 'destination_id' => $highest_destination_index);
 }
示例#26
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once ABSPATH . 'wp-admin/includes/user.php';
     $roles = get_editable_roles();
     if ($arguments['just-names']) {
         foreach ($roles as $index => $data) {
             $roles[$index] = $data['name'];
         }
     }
     return $roles;
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     $overview = backupbuddy_api0::getOverview();
     // If archive file is set but actual file does not exist then clear out value.
     if (isset($overview['lastBackupStats']['archiveFile']) && !file_exists($overview['lastBackupStats']['archiveFile'])) {
         $overview['lastBackupStats']['archiveFile'] = '';
     }
     return array('version' => '4', 'status' => 'ok', 'message' => 'Overview retrieved successfully.', 'overview' => $overview);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     if ('' == $arguments['id'] || !is_numeric($arguments['id'])) {
         return array('api' => '1', 'status' => 'error', 'message' => 'Missing destination ID setting or not numeric.');
     }
     if (!isset(pb_backupbuddy::$options['remote_destinations'][$arguments['id']])) {
         return array('api' => '1', 'status' => 'error', 'message' => 'Invalid destination ID. Not found.');
     }
     // Merge passed settings over current ones.
     pb_backupbuddy::$options['remote_destinations'][$arguments['id']] = array_merge(pb_backupbuddy::$options['remote_destinations'][$arguments['id']], $arguments['settings']);
     pb_backupbuddy::save();
     return array('api' => '1', 'status' => 'ok', 'message' => 'Destination updated.', 'destination_id' => $arguments['id']);
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     global $itsec_logger;
     $items = $itsec_logger->get_events('malware', array(), $arguments['count']);
     $response = array();
     foreach ($items as $item) {
         $item['log_data'] = maybe_unserialize($item['log_data']);
         if (!isset($item['log_data']['SCAN']['SITE'])) {
             // Don't return old scan data.
             continue;
         }
         $response[] = $item;
     }
     return $response;
 }
示例#30
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     $response = array();
     $actions = array('get-enabled-multisite' => 'get_enabled_themes', 'enable-multisite' => 'enable_themes', 'disable-multisite' => 'disable_themes', 'install' => 'install_themes', 'uninstall' => 'uninstall_themes', 'install-and-activate' => 'install_and_activate_theme', 'activate' => 'activate_theme');
     foreach ($arguments as $action => $data) {
         if (isset($actions[$action])) {
             $response[$action] = call_user_func(array($this, $actions[$action]), $data);
         } else {
             $response[$action] = 'This action is not recognized';
         }
     }
     if (isset($actions['get-actions'])) {
         $response['get-actions'] = array_keys($actions);
     }
     return $response;
 }