function update_blog_file_rules($include_rs_rules = true)
 {
     global $blog_id;
     // avoid file collision by skipping if another flush was initiated < 5 seconds ago
     if ($last_regen = scoper_get_option('file_htaccess_date')) {
         if (intval($last_regen) > agp_time_gmt() - 5) {
             return;
         }
     }
     scoper_update_option('file_htaccess_date', agp_time_gmt());
     $include_rs_rules = $include_rs_rules && scoper_get_option('file_filtering');
     if (!ScoperRewrite::site_config_supports_rewrite()) {
         return;
     } elseif (!$include_rs_rules) {
         $rules = '';
     } else {
         $rules = ScoperRewrite::build_blog_file_rules();
     }
     require_once dirname(__FILE__) . '/uploads_rs.php';
     $uploads = scoper_get_upload_info();
     // If a filter has changed MU basedir, don't filter file attachments for this blog because we might not be able to regenerate the basedir for rule removal at RS deactivation
     if (!IS_MU_RS || strpos($uploads['basedir'], "/blogs.dir/{$blog_id}/files") || false !== strpos($uploads['basedir'], trailingslashit(WP_CONTENT_DIR) . 'uploads')) {
         $htaccess_path = trailingslashit($uploads['basedir']) . '.htaccess';
         ScoperRewrite::insert_with_markers($htaccess_path, 'Role Scoper', $rules);
     }
 }
Example #2
0
 function clear_all_file_rules()
 {
     global $wpdb, $blog_id;
     $blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
     $orig_blog_id = $blog_id;
     foreach ($blog_ids as $id) {
         switch_to_blog($id);
         require_once dirname(__FILE__) . '/uploads_rs.php';
         $uploads = scoper_get_upload_info();
         $htaccess_path = trailingslashit($uploads['basedir']) . '.htaccess';
         if (file_exists($htaccess_path)) {
             ScoperRewrite::insert_with_markers($htaccess_path, 'Role Scoper', '');
         }
     }
     switch_to_blog($orig_blog_id);
 }