function recursive_chmod($path, $filePerm = 0644, $dirPerm = 0755)
{
    // Check if the path exists
    if (!file_exists($path)) {
        return FALSE;
    }
    // See whether this is a file
    if (is_file($path)) {
        // Chmod the file with our given filepermissions
        chmod($path, $filePerm);
        // If this is a directory...
    } elseif (is_dir($path)) {
        // Then get an array of the contents
        $foldersAndFiles = scandir($path);
        // Remove "." and ".." from the list
        $entries = array_slice($foldersAndFiles, 2);
        // Parse every result...
        foreach ($entries as $entry) {
            // And call this function again recursively, with the same permissions
            recursive_chmod($path . "/" . $entry, $filePerm, $dirPerm);
        }
        // When we are done with the contents of the directory, we chmod the directory itself
        chmod($path, $dirPerm);
    }
    // Everything seemed to work out well, return TRUE
    return TRUE;
}
Example #2
0
 function uncompress_app($app)
 {
     $this->ci->load->library('unzip');
     $save_file = APPPATH . 'modules/' . $app;
     $extract = $this->unzip->extract('./uploads/apps/' . $app . '.zip', APPPATH . 'modules');
     $single_file = explode("/", $extract[0]);
     rename(APPPATH . 'modules/' . $single_file[2], $save_file);
     recursive_chmod($save_file, 0644, 0755);
     return $extract;
 }
 function uncompress()
 {
     $this->load->library('unzip');
     $name = $this->uri->segment(3);
     $save_file = APPPATH . 'modules/' . $name;
     $extract = $this->unzip->extract('./uploads/apps/' . $name . '.zip', APPPATH . 'modules');
     $single_file = explode("/", $extract[0]);
     rename(APPPATH . 'modules/' . $single_file[2], $save_file);
     print_r($extract);
     recursive_chmod($save_file, 0644, 0755);
 }
function recursive_chmod($path, $mod = 0777)
{
    if (is_dir($path) && $path != '/') {
        recursive_chmod(dirname($path));
        //echo "chmod: ".$path." - ".$mod."<br>";
        chmod($path, $mod);
    }
}