Exemplo n.º 1
0
    private static function Resources($directory = '/', $return_link, $extensions = array(), $first_call = true)
    {
        $PopUp_System = '';
        if (\is_dir($directory)) {
            $file = \scandir($directory);
            \natcasesort($file);
            $files = $dirs = $ListaFiles = array();
            foreach ($file as $this_file) {
                if (is_dir("{$directory}/{$this_file}")) {
                    $dirs[] = self::DirFix($this_file);
                } else {
                    $files[] = self::DirFix($this_file);
                }
            }
            $file = array_merge($dirs, $files);
            if (!empty($extensions)) {
                foreach (\array_keys($file) as $key) {
                    if (!\is_dir("{$directory}/{$file[$key]}")) {
                        $ext = \substr($file[$key], strrpos($file[$key], ".") + 1);
                        if (!\in_array($ext, $extensions)) {
                            unset($file[$key]);
                        }
                    }
                }
            }
            if (count($file) > 0) {
                $ProtectedDirectory = array('Audios', 'Banners', 'Documentos', 'Documents', 'Video', 'esp', 'eng', 'por', 'bra', 'ita', 'Products', 'Productos', 'icons', 'images', 'svn', 'git');
                $PopUp_System = "<ul";
                if ($first_call) {
                    $PopUp_System .= " class=\"PopUp_System\"";
                    $first_call = false;
                }
                $PopUp_System .= ">";
                $num = 900;
                $SKTURL_FileSystems = str_replace('_FileSystems/', '', \SKTURL_FileSystems);
                foreach ($file as $this_file) {
                    if ($this_file != "." && $this_file != "..") {
                        if (\is_dir("{$directory}/{$this_file}")) {
                            // Directory
                            if (\in_array($this_file, $ProtectedDirectory)) {
                                $Options = '<div class="OptionsNav"></div>';
                            } else {
                                $Options = '<div class="OptionsNav">
                                            <ul>
                                                <li class="RenameFolder"><span rel="' . Code::Encode($directory . '/' . $this_file) . '" title="Renombrar Carpeta \'' . $this_file . '\'" class="folder-rename"><i class="skt-icon-rewrite"></i></span></li>
                                                <li class="DeleteFolder"><span rel="' . $directory . '/' . $this_file . '" title="Borrar Carpeta \'' . $this_file . '\'" class="folder-delete"><i class="skt-icon-close"></i></span></li>
                                            </ul>
                                        </div>';
                            }
                            $ListaFiles[$this_file] = '
                        <li><a href="' . \SKT_URL_BASE . 'SKTFiles/' . Code::Encode($directory . '/' . \urlencode($this_file)) . '/">
                        <div class="divpnglist"><i class="skt-icon-folder"></i><img class="hidden" src="' . \SKTURL_assets . 'img/icons/dir.png" alt="' . self::DirFix(Code::RemoveLocalFS($this_file)) . '" /></div>
			<div class="Dirname">' . self::DirFix(Code::RemoveLocalFS(\str_replace('_', ' ', $this_file))) . '</div><div class="tip"></div></a>' . $Options . '</li>';
                            $Options = '';
                            //RECURSIVO
                            //$PopUp_System .= self::Directory("$directory/$this_file", $return_link ,$extensions, false);
                        } else {
                            // File
                            $ext = \substr($this_file, strrpos($this_file, ".") + 1);
                            $F = new FileDataRecovery();
                            $F->File("{$directory}/{$this_file}");
                            $File_Order = \CmsDev\AdminFilesystem\Metadata::File_Order("{$directory}/{$this_file}");
                            $click = \str_replace("[this]", self::DirFix(Code::Encode("{$directory}/" . \urlencode($this_file))), $return_link);
                            $click = \str_replace("[name]", self::DirFix($this_file), $click);
                            $click = \str_replace("[w]", $F->size('w', false), $click);
                            $click = \str_replace("[h]", $F->size('h', false), $click);
                            $click = \str_replace("/_FileSystems", '_FileSystems', $click);
                            $click = \str_replace(\URL_VERSION . "AdminFiles", '_FileSystems', $click);
                            $trumb = \str_replace('../../', '', \htmlspecialchars($directory . "/" . $this_file));
                            $trumbAlt = \str_replace('../../', '', \htmlspecialchars($this_file));
                            $bbase = \basename($_SERVER['SCRIPT_FILENAME']);
                            $typeOfFile = $ViewImage = '';
                            /*
                             * IMAGENES
                             */
                            if ($ext == 'png' || $ext == 'gif' || $ext == 'jpg') {
                                $ViewImage = "<li class=\"View\"><a href=\"" . $SKTURL_FileSystems . "SKTSize/" . self::DirFix($trumb) . "\" rel=\"prettyPhoto[mixed]\" title=\"View: " . $trumbAlt . "\"><i class=\"skt-icon-expand\"></i></a></li>";
                                $typeOfFile = $F->size('w', false) . " x " . $F->size('h', false) . ' - Orden:' . $File_Order;
                                $IMG = '<div class="divpnglist"><img src="' . $SKTURL_FileSystems . 'SKTSize/' . self::DirFix($trumb) . '|120x120" alt="' . $trumbAlt . '" /><div class="Dirname">' . str_replace('_', ' ', self::DirFix($this_file)) . '' . self::file_info("{$directory}/{$this_file}", 'kb') . $typeOfFile . '</div></div>';
                                $Tips = '<div class="tip"></div>';
                                /*
                                 * OTROS ARCHIVOS
                                 */
                            } else {
                                $icon = $ext;
                                $URLDownload = \SERVER_DIR . '/' . $SKTURL_FileSystems . '_FileSystems/' . self::DirFix($trumb);
                                $ViewImage = "<li class=\"Download\"><a href=\"" . $URLDownload . "\" class=\"Ver\" title=\"Descargar\"><i class=\"skt-icon-download-cloud\"></i></a></li>";
                                $typeOfFile = "<br />" . $F->kb('kb', true);
                                $IMG = '<div class="divpnglist"><i class="skt-icon-' . $icon . '" ></i><div class="Dirname">' . \str_replace('_', ' ', self::DirFix($this_file)) . '' . self::file_info("{$directory}/{$this_file}", 'kb') . '</div></div>';
                                $Tips = '<div class="tip"></div>';
                            }
                            $FileOrder = $F->DataTag('FileOrder');
                            $ListaFiles[$FileOrder] = '
                    <li class="animate8 fileItem" rel="' . Code::Encode(Code::RemoveLocalFS($trumb)) . '" id="listItem_' . Code::Encode(self::DirFix($trumbAlt)) . '">
                        <div class="skt-icon-move"></div>
                        <a href="' . $click . '" class="atooltip" title="' . self::DirFix($trumbAlt) . '" >' . $IMG . '' . $Tips . '</a>
                        <div class="OptionsNav">
                            <ul>
                                <li class="RenameFile"><span class="Rename-file" rel="' . Code::Encode($directory . '/' . $this_file) . '" title="Renombrar Archivo \'' . $this_file . '\'" >
                                    <i class="skt-icon-rewrite"></i></span></li>
                                ' . $ViewImage . '
                                <li class="Tags">' . self::file_info("{$directory}/{$this_file}", 'tags') . '</li>
                                <li class="Delete">' . self::file_deleteBtn("{$directory}/{$this_file}") . '</li>
                                <li class="Move"><i class="skt-icon-move"></i></li>
                            </ul>
                        </div>
                    </li>';
                        }
                    }
                }
            }
            $ListaFilesR = '';
            if (\count($ListaFiles) > 0) {
                \krsort($ListaFiles);
                foreach (\array_reverse($ListaFiles) as $key => $val) {
                    $ListaFilesR .= $val;
                }
                $PopUp_SystemEnd = "</ul>";
                return $PopUp_System . $ListaFilesR . $PopUp_SystemEnd;
            } else {
                echo '<h3 style="talign:center; padding:35px;">No se encontraron archivos en esta carpeta</h3>';
            }
        } else {
            //umask(0000);
            //echo '*************** NO EXISTE ******************'.$directory.'************************* NO EXISTE *************';
            //mkdir($directory . "", 0777);
            //$file = scandir($directory);
        }
    }
Exemplo n.º 2
0
 private static function FolderSystemUL_dir($directory, $return_link, $extensions = array(), $first_call = true)
 {
     $LOC = \LOCAL_FILESYSTEM;
     $FolderSystemUL = '';
     $file = scandir($directory);
     natcasesort($file);
     $files = $dirs = array();
     foreach ($file as $this_file) {
         if (is_dir("{$directory}/{$this_file}")) {
             $dirs[] = $this_file;
         } else {
             $files[] = $this_file;
         }
     }
     $file = array_merge($dirs, $files);
     if (!empty($extensions)) {
         foreach (array_keys($file) as $key) {
             if (!is_dir("{$directory}/{$file[$key]}")) {
                 $ext = substr($file[$key], strrpos($file[$key], ".") + 1);
                 if (!in_array($ext, $extensions)) {
                     unset($file[$key]);
                 }
             }
         }
     }
     if (count($file) > 2) {
         // Use 2 instead of 0 to account for . and .. "directories"
         $FolderSystemUL = "<ul";
         if ($first_call) {
             $FolderSystemUL .= " class=\"FolderSystemUL\"";
             $first_call = false;
         }
         $FolderSystemUL .= '>';
         if (static::$root == 0) {
             $FolderSystemUL .= '<li class="pft-directory">
             <span class="skt-icon-folder iconfolder iconmore"></span>
             <a href="javascript:SKTFSys.ViewFolderList(\'/\');">
                 <span>Ra&iacute;z</span>
             </a>
         </li>';
             static::$root = 1;
         }
         foreach ($file as $this_file) {
             if ($this_file != "." && $this_file != ".." && $this_file != "icons") {
                 $F = new FileDataRecovery();
                 $FLocalFile = str_replace('../../', '/', $directory);
                 $FLocalFile = $LOC . $FLocalFile;
                 $FLocalFile = str_replace(\URL_VERSION . 'AdminFilesystem/', '', $FLocalFile);
                 $FLocalFile = $FLocalFile . '/' . $this_file;
                 $F->File($FLocalFile);
                 if (is_dir("{$directory}/{$this_file}")) {
                     // Directory
                     $link = str_replace("[link]", Code::Encode("{$directory}/" . $this_file), $return_link);
                     $link = str_replace("[this]", Code::Encode("{$directory}/" . $this_file), $link);
                     $FolderSystemUL .= "<li class=\"pft-directory\"><span class=\"skt-icon-folder iconfolder\"></span><a href=\"" . $link . "\"><span>" . htmlspecialchars($this_file) . "</span></a>";
                     $FolderSystemUL .= self::FolderSystemUL_dir("{$directory}/{$this_file}", $return_link, $extensions, false);
                     $FolderSystemUL .= "</li>";
                 } else {
                     // File
                     $typeFile = 'rel="no"';
                     $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1);
                     if ($ext == 'ext-gif' || $ext == 'ext-jpg' || $ext == 'ext-jpeg' || $ext == 'ext-png') {
                         $typeFile = 'rel="image"';
                         $link = str_replace("[link]", Code::Encode("{$directory}/" . $this_file), $return_link);
                         $FolderSystemUL .= "<li class=\"pft-file " . \strtolower($ext) . "\"  " . $typeFile . " title=\"" . \str_replace('../../', '', $directory) . "/" . $this_file . "\" rev=\"" . $F->kb('kb', false) . "\"><a href=\"" . $link . "\" ><span>" . \htmlspecialchars($this_file) . "" . $F->kb('kb') . "</span></a></li>";
                     } else {
                         $typeFile = 'rel="download"';
                         $link = str_replace("[link]", Code::Encode("{$directory}/" . $this_file), $return_link);
                         $FolderSystemUL .= "<li class=\"pft-file " . \strtolower($ext) . "\"  " . $typeFile . " title=\"" . \str_replace('../../', '', $directory) . "/" . $this_file . "\"  rev=\"" . $F->kb('kb', false) . "\"><a href=\"" . $link . "\"><span>" . \htmlspecialchars($this_file) . "" . $F->kb('kb') . "</span></a></li>";
                     }
                 }
             }
         }
         $FolderSystemUL .= "</ul>";
     }
     return $FolderSystemUL;
 }