/**
 * @package Admin
 */
if (!defined('WPSEO_VERSION')) {
    header('Status: 403 Forbidden');
    header('HTTP/1.1 403 Forbidden');
    exit;
}
global $wpseo_admin_pages;
$options = get_site_option('wpseo_ms');
if (isset($_POST['wpseo_submit'])) {
    check_admin_referer('wpseo-network-settings');
    foreach (array('access', 'defaultblog') as $opt) {
        $options[$opt] = $_POST['wpseo_ms'][$opt];
    }
    WPSEO_Options::update_site_option('wpseo_ms', $options);
    add_settings_error('wpseo_ms', 'settings_updated', __('Settings Updated.', 'wordpress-seo'), 'updated');
}
if (isset($_POST['wpseo_restore_blog'])) {
    check_admin_referer('wpseo-network-restore');
    if (isset($_POST['wpseo_ms']['restoreblog']) && is_numeric($_POST['wpseo_ms']['restoreblog'])) {
        $restoreblog = (int) WPSEO_Option::validate_int($_POST['wpseo_ms']['restoreblog']);
        $blog = get_blog_details($restoreblog);
        if ($blog) {
            WPSEO_Options::reset_ms_blog($restoreblog);
            add_settings_error('wpseo_ms', 'settings_updated', sprintf(__('%s restored to default SEO settings.', 'wordpress-seo'), esc_html($blog->blogname)), 'updated');
        } else {
            add_settings_error('wpseo_ms', 'settings_updated', sprintf(__('Blog %s not found.', 'wordpress-seo'), esc_html($restoreblog)), 'error');
        }
        unset($restoreblog);
    }