Ejemplo n.º 1
0
  public static function create_directories() {
    
    MPU::incl("view/mpv.php");

    global $wf;
    global $blog_id;
    
    $main_exists = true;
    $global_exists = true;
		$try_content = true;
		

    self::$is_masterplan = ( isset($_GET["page"] ) && $_GET["page"] == "masterpress" );
    
    
    if (!file_exists(MASTERPRESS_CONTENT_DIR)) {
      
			if ($try_content) {

	      // if the base uploads directory doesn't exist, try to create it
	      if (!wp_mkdir_p(MASTERPRESS_CONTENT_DIR)) {
	        $main_exists = FALSE;
			
					// check that the base blogs.dir actually exists!
					$bd_base_dir = WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir";
				
	        if (is_multisite()) {
	  				MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s for this site does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content/blogs.dir/'.$blog_id.'/</span>', self::dir_cmd(WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir".WOOF_DIR_SEP.$blog_id.WOOF_DIR_SEP), '"'.MPU::current_url().'"')); 
	        } else {
	          MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 
	        }
      
	        update_site_option("mp_dir_problem", true);
        
	      } else {
        
	        chmod(MASTERPRESS_CONTENT_DIR, 0755);
        
	      }

			}
		
    }
    
    
    if (!file_exists(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
      // if the global content directory doesn't exist, try to create it
      if (MASTERPRESS_GLOBAL_CONTENT_DIR != MASTERPRESS_CONTENT_DIR) {
        
        if (!wp_mkdir_p(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
          $global_exists = FALSE;
          MPV::warn(sprintf(__('<strong>Note: the MasterPress shared content folder %s for your multi-site network does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 

          update_site_option("mp_dir_problem", true);
        
        } else {
        
          chmod(MASTERPRESS_GLOBAL_CONTENT_DIR, 0755);

        }
        
      } 
      
    } 

    $warning_777 = __('Please change the permissions of your <span class="tt">wp-content</span> directory to <span class="tt">755</span>. <br />');

    $stop_trying_global = false;
    $stop_trying = false;

    
    if ($main_exists && $global_exists) {
      
      $stop_trying = false;
      $stop_trying_global = false;
      
      // test if the standard sub-directories exist
      
      $not_writable_warning = sprintf(__('<strong>Note: the MasterPress folder %s does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'.</span>', self::chmod_cmd(MASTERPRESS_CONTENT_DIR), '"'.MPU::current_url().'"');
      
      if (is_multisite()) {
        $not_writable_global_warning = sprintf(__('<strong>Note: the MasterPress shared folder %s for your multi-site network does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', self::chmod_cmd(MASTERPRESS_GLOBAL_CONTENT_DIR), '"'.MPU::current_url().'"');
      } else {
        $not_writable_global_warning = $not_writable_warning;
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
            $stop_trying = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          } 
        }
        
      }      
      
      if (!is_multisite() && $stop_trying) {
        // global and site are the same path
        $stop_trying_global = true;
      }
      

      if (!$stop_trying_global) {
            
        if (!file_exists(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
            $stop_trying_global = true;
            MPV::warn($not_writable_global_warning); 
          
          }
        } 
      
      }
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_global_warning); 
          }
        }
        
      }
      
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_TMP_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_TMP_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }


      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }
  
      
      if (!$stop_trying) {

        // check the writable status of MasterPress directories

        $not_writables = self::check_writable( array(
          MASTERPRESS_CONTENT_MENU_ICONS_DIR, 
          MASTERPRESS_CONTENT_IMAGE_CACHE_DIR, 
          MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_FILE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_MPFT_CACHE_DIR, 
          MASTERPRESS_TMP_DIR, 
          MASTERPRESS_CONTENT_MASTERPLANS_DIR, 
          MASTERPRESS_EXTENSIONS_DIR, 
          MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR, 
          MASTERPRESS_EXTENSIONS_ICONS_DIR, 
          MASTERPRESS_CONTENT_UPLOADS_DIR
        ));
        
        if (count($not_writables)) {
          $content_paths = WOOF_HTML::open("p");
          $chmods = WOOF_HTML::open("code");
          
          foreach ($not_writables as $nw) {
            $content_paths .= WOOF_HTML::tag("span", "class=tt", $nw["content_path"]."<br />");
            $chmods .= $nw["chmod"];
          }

          $content_paths .= WOOF_HTML::close("p");
          $chmods .= WOOF_HTML::close("code");

          MPV::warn(sprintf(__('<p><strong>Note:</strong> these MasterPress folders in <span class="tt">wp-content</span> are not writable which will cause problems using WordPress:%s<br /></p><p>Using your FTP client, server admin panel, or operating system (for local installations), please give these folders permission 777.<br /><br />Alternatively, use the following commands if you have shell or terminal access:<br />%s', MASTERPRESS_DOMAIN), $content_paths, $chmods)); 

        } 
      

        
      }
      
      
    }

		


    
    
  }
Ejemplo n.º 2
0
  MPU::incl("api/meow/meow-data-provider.php");
  MPU::incl("api/meow/meow-field-set-collection.php");
  MPU::incl("api/meow/meow-virtual-field-set-collection.php");
  MPU::incl("api/meow/meow-field-set.php");
  MPU::incl("api/meow/meow-field-set-creator.php");
  MPU::incl("api/meow/meow-field.php");
  MPU::incl("api/meow/meow-field-creator.php");
  MPU::incl("api/meow/meow-post.php");
  MPU::incl("api/meow/meow-attachment.php");
  MPU::incl("api/meow/meow-post-type.php");
  MPU::incl("api/meow/meow-site.php");
  MPU::incl("api/meow/meow-taxonomy.php");
  MPU::incl("api/meow/meow-user.php");
  MPU::incl("api/meow/meow-term.php");
  MPU::incl("api/meow/meow-rest-api.php");

}

/* 
  MEOW: The top-level object for the new MasterPress Object-Oriented API
  This is accessed through the new global variable $mp (masterpress framework)
*/


class MEOW extends WOOF {

  // re-define directories that point to WOOF-specific directories
  public $content_dir = MASTERPRESS_CONTENT_DIR; 
  public $content_url = MASTERPRESS_CONTENT_URL;