Plugin Directory

Changeset 594166


Ignore:
Timestamp:
09/03/2012 08:24:14 PM (14 years ago)
Author:
ti2m
Message:

Directory create changes and writable checks

Location:
edge-suite/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • edge-suite/trunk/admin/manage.php

    r587841 r594166  
    5757    }
    5858
     59    // Init file system
     60    WP_Filesystem();
    5961
    60     //Here we check that $ok was not set to 0 by an error
    6162    $tmp_file = EDGE_SUITE_PUBLIC_DIR . '/tmp/' . $_FILES['edge_suite_composition_upload']['name'];
    6263    if (!is_dir(EDGE_SUITE_PUBLIC_DIR . '/tmp')) {
    63       mkdir(EDGE_SUITE_PUBLIC_DIR . '/tmp');
     64      if(!mkdir_recursive(EDGE_SUITE_PUBLIC_DIR . '/tmp')){
     65        throw new Exception("Edge suite tmp could not be created.<br />");
     66      }
     67    }
     68    if(!dir_is_writable(EDGE_SUITE_PUBLIC_DIR . '/tmp')){
     69      throw new Exception("Edge suite tmp is not writable.<br />");
    6470    }
    6571
    6672    if (move_uploaded_file($_FILES['edge_suite_composition_upload']['tmp_name'], $tmp_file)) {
    67       WP_Filesystem();
     73
    6874      edge_suite_comp_create($tmp_file, TRUE);
    6975      echo '<div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade">';
  • edge-suite/trunk/edge-suite.php

    r587841 r594166  
    114114
    115115  //Check if dir is writable and create directory structure.
    116   if (!wp_mkdir_p(EDGE_SUITE_COMP_PROJECT_DIR)) {
     116  if (!mkdir_recursive(EDGE_SUITE_COMP_PROJECT_DIR)) {
    117117    $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), EDGE_SUITE_COMP_PROJECT_DIR_REL);
    118118    return array('error' => $message);
  • edge-suite/trunk/includes/edge-suite-comp-builder.inc

    r587841 r594166  
    103103   */
    104104  public function __construct($base_dir, $project_dir) {
    105 //    global $user;
    106105    $this->edgeDir = $base_dir;
    107106    $this->edgeProjectDir = $project_dir;
     
    111110
    112111    if (!is_dir($base_dir . '/edge_tmp')) {
    113       mkdir($base_dir . '/edge_tmp');
     112      if(!mkdir_recursive($base_dir . '/edge_tmp')){
     113        throw new Exception ("Can't create edge_tmp directory.");
     114      };
    114115    }
    115116
    116117    if (!is_dir($this->tmpDirBase)) {
    117       mkdir($this->tmpDirBase);
     118      if(!mkdir_recursive($this->tmpDirBase)){
     119        throw new Exception ("Can't create project tmp directory.");
     120      }
    118121    }
    119122
    120123    if (!is_dir($this->edgeProjectDir)) {
    121       mkdir($this->edgeProjectDir);
    122     }
    123 
     124      if(!mkdir_recursive($this->edgeProjectDir)){
     125        throw new Exception ("Can't project directory.");
     126      }
     127    }
     128
     129    if(!dir_is_writable($base_dir . '/edge_tmp')){
     130      throw new Exception("edge_tmp is not writable.<br />");
     131    }
     132
     133    if(!dir_is_writable($this->tmpDirBase)){
     134      throw new Exception("Project tmp directory is not writable.<br />");
     135    }
     136
     137    if(!dir_is_writable($this->edgeProjectDir)){
     138      throw new Exception("Specific project directory is not writable.<br />");
     139    }
    124140
    125141    $this->dimensions = array(
     
    208224      }
    209225    }
    210     mkdir($this->destinationDir);
     226    if(!mkdir_recursive($this->destinationDir)){
     227      throw new Exception ('The project directory could not be created.');
     228    }
    211229
    212230    // Extract the archive.
     
    496514    // Set up shared folder if it doesn't exist.
    497515    if (!is_dir($this->edgeDir . '/edge_includes')) {
    498       mkdir($this->edgeDir . '/edge_includes');
     516      mkdir_recursive($this->edgeDir . '/edge_includes');
    499517    }
    500518
     
    570588    // Check if list is valid.
    571589    if (!preg_match('/^([a-zA-Z0-9]{2,6}\|)*([a-zA-Z0-9]{2,6})$/', $allowed_extensions)) {
    572       $allowed_extensions = 'js|png|jpg|gif|svg';
     590      $allowed_extensions = 'js|png|jpg|gif|svg|css';
    573591    }
    574592
     
    582600      $rel_dir = substr($dir, strlen($src) + 1);
    583601      if (!file_exists($dest . '/' . $rel_dir)) {
    584         mkdir($dest . '/' . $rel_dir);
     602        mkdir_recursive($dest . '/' . $rel_dir);
    585603      }
    586604      // TODO: Feedback if file couldn't be moved.
  • edge-suite/trunk/includes/edge-suite-comp.inc

    r587841 r594166  
    3939  if (!is_dir(EDGE_SUITE_COMP_PROJECT_DIR)) {
    4040    if (!is_dir(EDGE_SUITE_PUBLIC_DIR)) {
    41       mkdir(EDGE_SUITE_PUBLIC_DIR);
    42     }
    43     mkdir(EDGE_SUITE_COMP_PROJECT_DIR);
     41      mkdir_recursive(EDGE_SUITE_PUBLIC_DIR);
     42    }
     43    mkdir_recursive(EDGE_SUITE_COMP_PROJECT_DIR);
    4444  }
    4545
  • edge-suite/trunk/includes/edge-suite-general.php

    r587841 r594166  
    1818}
    1919
     20function mkdir_recursive($path){
     21  if (wp_mkdir_p($path)) {
     22    return true;
     23  }
     24  else{
     25    return $path . " could not be created.";
     26  }
     27}
     28
     29function dir_is_writable($path){
     30  global $wp_filesystem;
     31  return $wp_filesystem->is_writable($path);
     32}
    2033
    2134function check_plain($text) {
Note: See TracChangeset for help on using the changeset viewer.