public function execute(array $params = array(), MWP_Worker_Request $request) { $files = $params['files']; $rootPath = ABSPATH; $filesystem = new Symfony_Filesystem_Filesystem(); try { foreach ($files as $file) { $realpath = $rootPath . $file['pathname']; if ($file['dir'] === true) { $filesystem->mkdir($realpath); } else { // Files contents are sent as base64 encoded strings // mod_security scans request payload for PHP code and blocks the request // base64 is just a workaround which passes the mod_security check $filesystem->dumpFile($realpath, base64_decode($file['contents']), 0644); } } } catch (Symfony_Filesystem_Exception_IOException $e) { throw new MWP_Worker_Exception(MWP_Worker_Exception::IO_EXCEPTION, $e->getMessage()); } return array(); }
public function pre_init_stats($params) { include_once ABSPATH . 'wp-includes/update.php'; include_once ABSPATH . 'wp-admin/includes/update.php'; $stats = $this->mmb_parse_action_params('pre_init_stats', $params, $this); extract($params); if ($params['refresh'] == 'transient') { global $wp_current_filter; $wp_current_filter[] = 'load-update-core.php'; if (function_exists('wp_clean_update_cache')) { wp_clean_update_cache(); } wp_version_check(); wp_update_themes(); // THIS IS INTENTIONAL, please do not delete one of the calls to wp_update_plugins(), it is required for // some custom plugins (read premium) to work with ManageWP :) // the second call is not going to trigger the remote post invoked from the wp_update_plugins call wp_update_plugins(); array_pop($wp_current_filter); do_action('load-plugins.php'); } /** @var $wpdb wpdb */ global $wpdb, $wp_version, $mmb_plugin_dir; $stats['worker_version'] = $GLOBALS['MMB_WORKER_VERSION']; $stats['worker_revision'] = $GLOBALS['MMB_WORKER_REVISION']; $stats['wordpress_version'] = $wp_version; $stats['wordpress_locale_pckg'] = get_locale(); $stats['php_version'] = phpversion(); $stats['mysql_version'] = $wpdb->db_version(); $stats['server_functionality'] = $this->get_backup_instance()->getServerInformationForStats(); $stats['wp_multisite'] = $this->mmb_multisite; $stats['network_install'] = $this->network_admin_install; $stats['cookies'] = $this->get_stat_cookies(); $stats['admin_usernames'] = $this->getUserList(); $stats['site_title'] = get_bloginfo('name'); $stats['site_tagline'] = get_bloginfo('description'); $stats['blog_public'] = get_option('blog_public'); $stats['timezone'] = get_option('timezone_string'); $stats['timezone_offset'] = get_option('gmt_offset'); $stats['server_ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : null; $stats['hostname'] = php_uname('n'); $stats['db_name'] = $this->get_active_db(); $stats['db_prefix'] = $wpdb->prefix; $stats['content_path'] = WP_CONTENT_DIR; $stats['worker_path'] = $mmb_plugin_dir; $stats['site_home'] = get_option('home'); $fs = new Symfony_Filesystem_Filesystem(); if (defined('WP_CONTENT_DIR')) { $stats['content_relative_path'] = $fs->makePathRelative(WP_CONTENT_DIR, ABSPATH); } if (defined('WP_PLUGIN_DIR')) { $stats['plugin_relative_path'] = $fs->makePathRelative(WP_PLUGIN_DIR, ABSPATH); } if (defined('WPMU_PLUGIN_DIR')) { $stats['mu_plugin_relative_path'] = $fs->makePathRelative(WPMU_PLUGIN_DIR, ABSPATH); } if (defined('UPLOADS')) { // Uploads is already relative $stats['uploads_relative_path'] = UPLOADS; } if (!function_exists('get_filesystem_method')) { include_once ABSPATH . 'wp-admin/includes/file.php'; } $stats['fs_method'] = get_filesystem_method(); $mmode = get_option('mwp_maintenace_mode'); if (!empty($mmode) && isset($mmode['active']) && $mmode['active'] == true) { $stats['maintenance'] = true; } $stats['writable'] = $this->is_server_writable(); return $stats; }
/** * @param string $realPath * @param string $rootPath * * @return string */ private function getRelativePath($realPath, $rootPath) { $path = $this->fileSystem->makePathRelative($realPath, $rootPath); return rtrim($path, '/\\'); }