function want($type) { $vp = VaultPress::init(); if ($type == 'plugins') { $this->dir = realpath($vp->resolve_content_dir() . 'plugins'); $this->type = 'p'; return true; } if ($type == 'themes') { $this->dir = realpath($vp->resolve_content_dir() . 'themes'); $this->type = 't'; return true; } if ($type == 'uploads') { $this->dir = realpath($vp->resolve_upload_path()); $this->type = 'u'; return true; } if ($type == 'content') { $this->dir = realpath($vp->resolve_content_dir()); $this->type = 'c'; return true; } if ($type == 'root') { $this->dir = realpath(ABSPATH); $this->type = 'r'; return true; } die('naughty naughty'); }
function jetpack_vaultpress_sync_options() { if (!class_exists('VaultPress')) { return; } $vaultpress = VaultPress::init(); Jetpack_Sync::sync_options(__FILE__, $vaultpress->auto_register_option, $vaultpress->option_name); }
function _scan_batch() { $paths = get_option('_vp_current_scan'); if (empty($paths) || $this->_scan_clean_up($paths)) { return false; } reset($paths); list($type, $current) = each($paths); if (!is_object($current) || empty($current->last_dir)) { return $this->_scan_clean_up($paths, $type); } $default_batch_limit = 400; if (!function_exists('set_time_limit') || !@set_time_limit(0)) { $default_batch_limit = 100; // avoid timeouts } $GLOBALS['vp_signatures'] = get_option('_vp_signatures'); if (empty($GLOBALS['vp_signatures'])) { return false; } $limit = get_option('_vp_batch_file_size', $default_batch_limit); $files = $current->get_files($limit); // No more files to scan. if (!$current->last_dir || count($files) < $limit) { unset($paths[$type]); } update_option('_vp_current_scan', $paths); $results = array(); foreach ($files as $file) { $verdict = vp_scan_file($file); if (!empty($verdict)) { $results[$file] = array('hash' => @md5_file($file), 'verdict' => $verdict); } } if (!empty($results)) { $vaultpress = VaultPress::init(); $vaultpress->add_ping('security', array('suspicious_v2' => $results)); } }
function should_backup_file($filepath) { $vp = VaultPress::init(); if (is_dir($filepath)) { $filepath = trailingslashit($filepath); } $regex_patterns = $vp->get_should_ignore_files(); foreach ($regex_patterns as $pattern) { $matches = array(); if (preg_match($pattern, $filepath, $matches)) { return false; } } return true; }
<?php if (is_plugin_active('vaultpress/vaultpress.php')) { if (VaultPress::init()->is_registered()) { $vp_link = 'https://dashboard.vaultpress.com'; $target = '_blank'; } else { $vp_link = admin_url('admin.php?page=vaultpress'); $target = '_self'; } } else { $vp_link = esc_url('https://wordpress.com/plans/' . Jetpack::build_raw_urls(get_home_url())); $target = '_blank'; } $modules = array('Appearance', 'Developers', 'Mobile', 'Other', 'Photos and Videos', 'Social', 'Site Stats', 'Writing'); ?> <script id="tmpl-category" type="text/html"> <?php foreach ($modules as $module) { $translated_module = Jetpack::translate_module_tag($module); $module_slug = strtolower(str_replace(array(' ', '.'), array('-', ''), $translated_module)); ?> <div class="cat category-<?php echo esc_attr($module_slug); ?> "><h3><?php echo esc_html($translated_module); ?> </h3><div class="clear"></div></div> <?php }
/** * Get VaultPress site data including, among other things, the date of the last backup if it was completed. * * @since 4.3.0 * * @return mixed|WP_Error VaultPress site data. Otherwise, a WP_Error instance with the corresponding error. */ public function get_vaultpress_data() { if (!class_exists('VaultPress')) { return new WP_Error('not_active', esc_html__('The requested Jetpack module is not active.', 'jetpack'), array('status' => 404)); } $vaultpress = new VaultPress(); if (!$vaultpress->is_registered()) { return rest_ensure_response(array('code' => 'not_registered', 'message' => esc_html__('You need to register for VaultPress.', 'jetpack'))); } $data = json_decode(base64_decode($vaultpress->contact_service('plugin_data'))); if (is_wp_error($data)) { return $data; } else { if (!$data->backups->last_backup) { return rest_ensure_response(array('code' => 'success', 'message' => esc_html__('VaultPress is active and will back up your site soon.', 'jetpack'), 'data' => $data)); } else { return rest_ensure_response(array('code' => 'success', 'message' => esc_html(sprintf(__('Your site was successfully backed-up %s ago.', 'jetpack'), human_time_diff($data->backups->last_backup, current_time('timestamp')))), 'data' => $data)); } } }
add_action('added_option', array($this, 'option_handler'), 1); $this->add_vp_required_filters(); } function add_vp_required_filters() { // Log ins if ($this->get_option('login_lockdown')) { add_filter('authenticate', array($this, 'authenticate'), 999); } // Report back to VaultPress add_action('shutdown', array($this, 'do_pings')); // VaultPress likes being first in line add_filter('pre_update_option_active_plugins', array($this, 'load_first')); } } $vaultpress = VaultPress::init(); if (isset($_GET['vaultpress']) && $_GET['vaultpress']) { if (!function_exists('wp_magic_quotes')) { // If already slashed, strip. if (get_magic_quotes_gpc()) { $_GET = stripslashes_deep($_GET); $_POST = stripslashes_deep($_POST); $_COOKIE = stripslashes_deep($_COOKIE); } // Escape with wpdb. $_GET = add_magic_quotes($_GET); $_POST = add_magic_quotes($_POST); $_COOKIE = add_magic_quotes($_COOKIE); $_SERVER = add_magic_quotes($_SERVER); // Force REQUEST to be GET + POST. If SERVER, COOKIE, or ENV are needed, use those superglobals directly. $_REQUEST = array_merge($_GET, $_POST);