public function action($parent)
 {
     $c = $parent->config;
     $util = new Utility();
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
         $this->r = array('wrong path', 400);
         return;
     }
     $path = $c['current_path'] . $_POST['path'];
     $info = pathinfo($path);
     $base_folder = $c['current_path'] . $util->fix_dirname($_POST['path']) . "/";
     switch ($info['extension']) {
         case "zip":
             $zip = new \ZipArchive();
             if ($zip->open($path) === true) {
                 //make all the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (substr($FullFileName['name'], -1, 1) == "/") {
                         $util->create_folder($base_folder . $FullFileName['name']);
                     }
                 }
                 //unzip into the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (!(substr($FullFileName['name'], -1, 1) == "/")) {
                         $fileinfo = pathinfo($OnlyFileName);
                         if (in_array(strtolower($fileinfo['extension']), $ext)) {
                             copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']);
                         }
                     }
                 }
                 $zip->close();
             } else {
                 $this->r = array('Could not extract. File might be corrupt.', 500);
                 return;
             }
             break;
         case "gz":
             $p = new \PharData($path);
             $p->decompress();
             // creates files.tar
             break;
         case "tar":
             // unarchive from the tar
             $phar = new \PharData($path);
             $phar->decompressFiles();
             $files = array();
             $util->check_files_extensions_on_phar($phar, $files, '', $ext);
             $phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
             break;
         default:
             $this->r = array('This extension is not supported. Valid: zip, gz, tar.', 400);
             return;
             break;
     }
 }
 public function action($parent)
 {
     $util = new Utility();
     $config = $parent->config;
     $path = $parent->path;
     if ($config['create_folders']) {
         $util->create_folder($util->fix_path($path, $config['transliteration'], $config['convert_spaces'], $config['replace_with']), $util->fix_path($parent->path_thumb, $config['transliteration'], $config['convert_spaces'], $config['replace_with']));
         //check folder created
         $this->r = array('folder created', 200);
         return;
         //if not return error!
     } else {
         $this->r = array('no permissions to create folder', 400);
         return;
     }
 }
 public function render_need_name($app, $files, $twigArr, $config, $subdir, $filter, $transliteration, $thumbs_path, $get_params, $rfm_subfolder)
 {
     //need to pass in rest of required variables.
     $jplayer_ext = array("mp4", "flv", "webmv", "webma", "webm", "m4a", "m4v", "ogv", "oga", "mp3", "midi", "mid", "ogg", "wav");
     $html = "";
     $util = new Utility();
     foreach ($files as $file_array) {
         $file = $file_array['file'];
         if ($file == '.' || isset($file_array['extension']) && $file_array['extension'] != 'dir' || $file == '..' && $subdir == '' || in_array($file, $config['hidden_folders']) || $filter != '' && $n_files > $file_number_limit_js && $file != ".." && stripos($file, $filter) === false) {
             continue;
         }
         $new_name = $util->fix_filename($file, $transliteration);
         if ($file != '..' && $file != $new_name) {
             //rename
             $util->rename_folder($config['current_path'] . $subdir . $file, $new_name, $transliteration);
             $file = $new_name;
         }
         //add in thumbs folder if not exist
         if (!file_exists($thumbs_path . $subdir . $file)) {
             $util->create_folder(false, $thumbs_path . $subdir . $file);
         }
         $class_ext = 3;
         if ($file == '..' && trim($subdir) != '') {
             $src = explode("/", $subdir);
             unset($src[count($src) - 2]);
             $src = implode("/", $src);
             //if($src=='') $src="/";
             if ($src == '') {
                 $src = "";
             }
         } elseif ($file != '..') {
             $src = $subdir . $file . "/";
         }
         $twigArr['file'] = $file;
         $template = null;
         //template specifics
         $attr = array('folder_link' => "filemanager?" . $get_params . rawurlencode($src) . "&" . uniqid());
         if ($file == '..') {
             $attr['path'] = str_replace('.', '', dirname($rfm_subfolder . $subdir));
             $attr['path_thumb'] = dirname($thumbs_path . $subdir) . "/";
             $template = 'FileManager/need_name/back.html.twig';
         } else {
             $template = 'FileManager/need_name/folder.html.twig';
         }
         $twigArr['file_prevent_rename'] = false;
         $twigArr['file_prevent_delete'] = false;
         if (isset($filePermissions[$file])) {
             $twigArr['file_prevent_rename'] = isset($filePermissions[$file]['prevent_rename']) && $filePermissions[$file]['prevent_rename'];
             $twigArr['file_prevent_delete'] = isset($filePermissions[$file]['prevent_delete']) && $filePermissions[$file]['prevent_delete'];
         }
         $twigArr['file_array'] = $file_array;
         $twigArr['temp_attr'] = $attr;
         $html = $html . $app['twig']->render($template, $twigArr);
     }
     $this->two = $this->two($app, $files, $twigArr, $config, $subdir, $filter, $transliteration, $thumbs_path, $get_params, $util, $rfm_subfolder);
     return $html;
 }