コード例 #1
0
ファイル: dir.php プロジェクト: BackupTheBerlios/tf-b4rt-svn
function ListDirectory($dirName)
{
    global $dirModified, $dir, $cfg;
    $bgLight = $cfg["bgLight"];
    $bgDark = $cfg["bgDark"];
    $entrys = array();
    $bg = $bgLight;
    $dirName = stripslashes($dirName);
    if (isset($dir)) {
        //setup default parent directory URL
        $parentURL = "dir.php";
        //get the real parentURL
        if (preg_match("/^(.+)\\/.+\$/", $dir, $matches) == 1) {
            $parentURL = "dir.php?dir=" . urlencode($matches[1]);
        }
        echo "<a href=\"" . $parentURL . "\"><img src=\"images/up_dir.gif\" width=16 height=16 title=\"" . _BACKTOPARRENT . "\" border=0>[" . _BACKTOPARRENT . "]</a>";
    }
    //echo "<table cellpadding=2 width=740>";
    /* --- Multi Delete Hack --- */
    echo '<table cellpadding="2"" width="740">';
    echo '<form action="multi.php" method="post" name="multidir">';
    $handle = opendir($dirName);
    while ($entry = readdir($handle)) {
        $entrys[] = $entry;
    }
    natsort($entrys);
    foreach ($entrys as $entry) {
        //if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != ".") {
        if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != "." && $entry != "lost+found") {
            if (@is_dir($dirName . $entry)) {
                echo "<tr bgcolor=\"" . $bg . "\"><td><a href=\"dir.php?dir=" . urlencode($dir . $entry) . "\"><img src=\"images/folder2.gif\" width=\"16\" height=\"16\" title=\"" . $entry . "\" border=\"0\" align=\"absmiddle\">" . $entry . "</a></td>";
                // Some Stats dir hack
                // b4rt-5
                if ($cfg['enable_dirstats'] == 1) {
                    $dudir = shell_exec($cfg['bin_du'] . " -sk -h " . correctFileName($dirName . $entry));
                    $dusize = explode("\t", $dudir);
                    $arStat = @lstat($dirName . $entry);
                    $timeStamp = @filemtime($dirName . $entry);
                    //$timeStamp = $arStat[10];
                    echo "<td align=\"right\">" . $dusize[0] . "B</td>";
                    echo "<td width=140>" . @date("m-d-Y h:i a", $timeStamp) . "</td>";
                } else {
                    echo "<td>&nbsp;</td>";
                    echo "<td>&nbsp;</td>";
                }
                echo "<td align=\"right\" nowrap>";
                // rename hack
                include 'rename_dir_extension.php';
                // move hack
                include 'move_dir_extension.php';
                // b4rt-5 : SFV Check
                if ($cfg['enable_sfvcheck'] == 1) {
                    if (false !== ($sfv = findSFV($dirName . $entry))) {
                        echo '<a href="javascript:CheckSFV(\'' . $sfv[dir] . '\',\'' . $sfv[sfv] . '\')"><img ' . 'src="images/sfv_enabled.gif" border="0" ' . 'width="16" height="16" alt="sfv check torrent"></a>';
                    } else {
                        echo '<img src="images/sfv_disabled.gif" border="0" width="16" height="16" alt="sfv check torrent (no sfv found)">';
                    }
                }
                // b4rt-5 : SFV Check
                // maketorrentt
                if ($cfg["enable_maketorrent"]) {
                    echo "<a href=\"JavaScript:MakeTorrent('maketorrent.php?path=" . urlencode($dir . $entry) . "')\"><img src=\"images/make.gif\" width=16 height=16 title=\"Make Torrent\" border=0></a>";
                }
                // download
                if ($cfg["enable_file_download"]) {
                    echo "<a href=\"dir.php?tar=" . urlencode($dir . $entry) . "\"><img src=\"images/tar_down.gif\" width=16 height=16 title=\"Download as " . $cfg["package_type"] . "\" border=0></a>";
                }
                // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
                // this is so only the owner of the file(s) or admin can delete
                // only give admins and users who "own" this directory
                // the ability to delete sub directories
                if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) {
                    //echo "<a href=\"dir.php?del=".urlencode($dir.$entry)."\" onclick=\"return ConfirmDelete('".addslashes($entry)."')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a>";
                    /* --- Multi Delete Hack --- */
                    /* checkbox appended to line */
                    echo "<a href=\"dir.php?del=" . urlencode($dir . $entry) . "\" onclick=\"return ConfirmDelete('" . addslashes($entry) . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a><input type=\"checkbox\" name=\"file[]\" value=\"" . urlencode($dir . $entry) . "\">";
                    /* --- Multi Delete Hack --- */
                } else {
                    echo "&nbsp;";
                }
                echo "</td></tr>\n";
                if ($bg == $bgLight) {
                    $bg = $bgDark;
                } else {
                    $bg = $bgLight;
                }
            }
        }
    }
    closedir($handle);
    $entrys = array();
    $handle = opendir($dirName);
    while ($entry = readdir($handle)) {
        $entrys[] = $entry;
    }
    natsort($entrys);
    foreach ($entrys as $entry) {
        if ($entry != "." && $entry != "..") {
            if (@is_dir($dirName . $entry)) {
                // Do nothing
            } else {
                $arStat = @lstat($dirName . $entry);
                $arStat[7] = $arStat[7] == 0 ? @file_size($dirName . $entry) : $arStat[7];
                if (array_key_exists(10, $arStat)) {
                    $timeStamp = @filemtime($dirName . $entry);
                } else {
                    $timeStamp = "";
                }
                $fileSize = number_format($arStat[7] / 1024);
                // Code added by Remko Jantzen to assign an icon per file-type. But when not
                // available all stays the same.
                $image = "images/time.gif";
                $imageOption = "images/files/" . getExtension($entry) . ".png";
                if (file_exists("./" . $imageOption)) {
                    $image = $imageOption;
                }
                echo "<tr bgcolor=\"" . $bg . "\">";
                echo "<td>";
                // Can users download files?
                if ($cfg["enable_file_download"]) {
                    // Yes, let them download
                    echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >";
                    echo "<img src=\"" . $image . "\" width=\"16\" height=\"16\" alt=\"" . $entry . "\" border=\"0\"></a>";
                    echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >" . $entry . "</a>";
                } else {
                    // No, just show the name
                    echo "<img src=\"" . $image . "\" width=\"16\" height=\"16\" alt=\"" . $entry . "\" border=\"0\">";
                    echo $entry;
                }
                echo "</td>";
                echo "<td align=\"right\">" . $fileSize . " KB</td>";
                // b4rt-5
                // Some Stats dir hack
                if ($cfg['enable_dirstats'] == 1) {
                    echo "<td width=140>" . @date("m-d-Y h:i a", $timeStamp) . "</td>";
                } else {
                    echo "<td>" . @date("m-d-Y g:i a", $timeStamp) . "</td>";
                }
                // b4rt-5
                echo "<td align=\"right\" nowrap>";
                // rename hack
                include 'rename_dir_extension.php';
                // move hack
                include 'move_dir_extension.php';
                // b4rt
                if ($cfg['enable_rar'] == 1) {
                    // R.D. - Display links for unzip/unrar
                    //**************************************************************************************************************
                    if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) {
                        if (strpos($entry, '.rar') !== FALSE and strpos($entry, '.Part') === FALSE or strpos($entry, '.part01.rar') !== FALSE or strpos($entry, '.part1.rar') !== FALSE) {
                            echo "<a href=\"javascript:UncompDetails('uncomp.php?file=" . urlencode($dir . $entry) . "&dir=" . urlencode($dir) . "&type=rar')\"><img src=\"images/rar_enabled.gif\" width=16 height=16 title=\"Unrar\" border=0></a>";
                        }
                        if (strpos($dir . $entry, '.zip') !== FALSE) {
                            echo "<a href=\"javascript:UncompDetails('uncomp.php?file=" . urlencode($dir . $entry) . "&dir=" . urlencode($dir) . "&type=zip')\"><img src=\"images/zip.png\" width=16 height=16 title=\"Unzip\" border=0></a>";
                        }
                    }
                    //**************************************************************************************************************
                }
                // b4rt
                // nfo
                if ($cfg["enable_view_nfo"] && (substr(strtolower($entry), -4) == ".nfo" || substr(strtolower($entry), -4) == ".txt" || substr(strtolower($entry), -4) == ".log")) {
                    echo "<a href=\"viewnfo.php?path=" . urlencode(addslashes($dir . $entry)) . "\"><img src=\"images/view_nfo.gif\" width=16 height=16 title=\"View '{$entry}'\" border=0></a>";
                }
                // maketorrent
                if ($cfg["enable_maketorrent"]) {
                    echo "<a href=\"JavaScript:MakeTorrent('maketorrent.php?path=" . urlencode($dir . $entry) . "')\"><img src=\"images/make.gif\" width=16 height=16 title=\"Make Torrent\" border=0></a>";
                }
                // download
                if ($cfg["enable_file_download"]) {
                    // Show the download button
                    echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >";
                    echo "<img src=\"images/download_owner.gif\" width=16 height=16 title=\"Download\" border=0>";
                    echo "</a>";
                }
                // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
                // this is so only the owner of the file(s) or admin can delete
                // only give admins and users who "own" this directory
                // the ability to delete files
                if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) {
                    //echo "<a href=\"dir.php?del=".urlencode($dir.$entry)."\" onclick=\"return ConfirmDelete('".addslashes($entry)."')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a>";
                    /* --- Multi Delete Hack --- */
                    /* checkbox appended to line */
                    echo "<a href=\"dir.php?del=" . urlencode($dir . $entry) . "\" onclick=\"return ConfirmDelete('" . addslashes($entry) . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a><input type=\"checkbox\" name=\"file[]\" value=\"" . urlencode($dir . $entry) . "\">";
                    /* --- Multi Delete Hack --- */
                } else {
                    echo "&nbsp;";
                }
                echo "</td></tr>\n";
                if ($bg == $bgLight) {
                    $bg = $bgDark;
                } else {
                    $bg = $bgLight;
                }
            }
        }
    }
    // b4rt-5
    # Some Stats dir hack
    closedir($handle);
    /* --- Multi Delete Hack --- */
    echo '<input type="hidden" name="action" value="fileDelete" />';
    echo '<tr><td align="right" colspan="4"><a href="javascript:document.multidir.submit()" onclick="return ConfirmDelete(\'Multiple Files\')"><img src="images/delete_on.gif" title="Delete" border="0" height="16" width="16"></a><input type="checkbox" onclick="checkCheck(this);" /></td></tr>';
    echo "</form>";
    /* --- Multi Delete Hack --- */
    echo "</table>";
    if ($cfg['enable_dirstats'] == 1) {
        $cmd = $cfg['bin_du'] . " -ch \"" . $dirName . "\" | " . $cfg['bin_grep'] . " \"total\"";
        $du = shell_exec($cmd);
        echo '<table cellpadding="0" width="740">';
        $du2 = substr($du, 0, -7);
        echo "<tr bgcolor=#ececec>";
        echo "<td align=\"center\">" . _TDDU . " " . $du2 . "B</td></tr>";
        echo "</table>";
    }
    // b4rt-5
}
コード例 #2
0
ファイル: dir.php プロジェクト: ThYpHo0n/torrentflux
         $ssz += @trim(1024.0 * shell_exec('du -ksL ' . tfb_shellencode($slink)));
         $date = "";
     }
     $size = formatBytesTokBMBGBTB(sprintf("%.0f", $ssz));
     if (strstr($size, "G")) {
         $size = "<b>{$size}</b>";
     }
     $timeStamp = $stat['mtime'];
     $date = date($cfg['_DATETIMEFORMAT'], $timeStamp);
     if ($timeStamp + 86400 * 2 > time()) {
         $isrecent = 1;
     }
 }
 if (is_dir($dirName . $entry)) {
     // sfv
     if ($cfg['enable_sfvcheck'] == 1 && false !== ($sfv = findSFV($dirName . $entry))) {
         $show_sfv = 1;
         $sfvdir = $sfv['dir'];
         $sfvsfv = $sfv['sfv'];
     }
     $isdir = 1;
     $show_nfo = 0;
     $show_rar = 0;
     /* disabled here, unzip only for current dir
     		$show_rar = ($cfg["enable_rar"] == 1) && ($aclWrite == 1) && (false !== ($zip = findArchives($dirName.$entry)) );
     		if ($show_rar) {
     			$zip = array_pop($zip);
     			$show_rar = isRar($zip);
     		}
     		*/
     $image = "";