function listDirectoryContents($rootDir, $userName, $subDir = '', $level = 0, $fileNameClass = 'fileNameUnsure') { // We'll check if direct downloads are enabled. $activated_direct_download = config_getConfiguration()->getAllowDirectDownload(); // We need to get that info from the configuration file. global $url_to_direct_download_dir; $scanDir = "{$rootDir}/{$userName}/{$subDir}"; //grab contents of directory $userDirContents = scandir($scanDir); $noFiles = true; echo '<div id="dir_' . str_replace('/', '_', $subDir) . '"'; if ($level != 0) { echo ' style="display:none;"'; } echo '>'; foreach ($userDirContents as $userDirItem) { if ($userDirItem != '.' && $userDirItem != '..' && substr($userDirItem, strlen($userDirItem) - strlen('.torrent')) != '.torrent') { $noFiles = false; //check for a corresponding .torrent file if ($level == 0) { if (in_array($userDirItem . '.torrent', $userDirContents)) { $fileNameClass = 'fileName'; } else { $fileNameClass = 'fileNameUnsure'; } } // If direct downloads are activated, we display the direct URL to the file. if ($activated_direct_download) { $downloadLink = $url_to_direct_download_dir . $userName . '/' . $subDir . $userDirItem; } else { $downloadLink = 'download.php?user='******'&file=' . urlencode($subDir . $userDirItem); } if (isset($_GET['user'])) { $deleteLink = 'archive.php?user='******'&deleteFile=' . urlencode($subDir . $userDirItem); } else { $deleteLink = 'archive.php?deleteFile=' . urlencode($subDir . $userDirItem); } $torrentDirPath = "{$scanDir}/{$userDirItem}"; $torrentDir = "{$subDir}{$userDirItem}/"; if (is_dir($torrentDirPath)) { $torrentDirId = str_replace('/', '_', $torrentDir); $topIdString = 'id="top_' . $torrentDirId . '" '; $collapseLink = '<a onclick="collapseDirectory(\'' . $torrentDirId . '\');"><img id="img_' . $torrentDirId . '" src="master/images/plus.gif" alt="Directory Expander"/></a> '; $downloadLinkTitle = 'Download ZIP archive of this directory'; $deleteLinkTitle = 'Delete this directory'; } else { $topIdString = ''; $collapseLink = ''; $downloadLinkTitle = 'Download this file'; $deleteLinkTitle = 'Delete this file'; } ?> <div class="file"> <div <?php echo $topIdString; ?> class="<?php echo $fileNameClass; ?> "><?php for ($i = 0; $i < $level; $i++) { echo ' '; } echo $collapseLink; ?> <a href="<?php echo $downloadLink; ?> " title="<?php echo $downloadLinkTitle; ?> "><?php echo $userDirItem; ?> </a></div> <div class="fileActions"><a href="<?php echo $deleteLink; ?> " title="<?php echo $deleteLinkTitle; ?> ">Delete</a></div> </div> <div><img src="master/images/single.gif" width="100%" height="1px" alt="Separator" /></div> <?php if (is_dir($torrentDirPath)) { listDirectoryContents($rootDir, $userName, $torrentDir, $level + 1, $fileNameClass); } } } echo '</div>'; if ($noFiles and $level == 0) { echo '<div class="divStatus">There are no downloaded files in this download directory.</div>'; } }
if (empty($_SESSION['user'])) { echo '<div id="divStatus">You must be logged in to load a Torrent.<br /><br /> <input type="button" value="Close" onclick="javascript:window.close()"/></div>'; } else { // Are there torrent files or URL to process ? // --------------------------------------------------------------- if (isset($_FILES['torrentFile']['name']) || isset($_POST['url'])) { // This variable will get true once we know we need to add torrents // to the download queue. $loadTorrent = false; // We initialise those variables as we're going to need them later. $torrentNames = array(); $uploadFiles = array(); // Get download directory from config require_once 'lib/configuration.php'; $uploadRoot = config_getConfiguration()->getDownloadLocation(); // Change to config-specified directory $uploadDir = $uploadRoot . DIRECTORY_SEPARATOR . (string) $_SESSION['user']; // Create download directory if it doesn't exist if (!file_exists($uploadDir)) { mkdir($uploadDir); } require_once 'lib/torrent.php'; // Torrent files were uploaded directly // ------------------------------------ if (isset($_FILES['torrentFile']['name'])) { // We iterate on those to finish their uploading for ($i = 0; $i < count($_FILES['torrentFile']['name']); $i++) { // A quick check on the filename ... if (stristr($_FILES['torrentFile']['name'][$i], '.torrent')) { // get the actual name of the torrent
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once 'configuration.php'; // Temp directory fix $f = __FILE__; if (is_link($f)) { $f = readlink($f); } // Unix compatibility $appPath = dirname($f) . "/"; if (!isset($basedir)) { $basedir = "./"; } // check for config file if (!file_exists($appPath . '../../config/configuration.xml') || !file_exists($appPath . '../../config/users.xml')) { header('Location: ./install.php'); } else { require_once 'torrentmodules/' . config_getConfiguration()->getTorrentModule() . '/torrent_functions.php'; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ $f = __FILE__; if (is_link($f)) { $f = readlink($f); } // Unix compatibility $appPath = dirname($f) . "/"; require_once $appPath . 'configuration.php'; //read settings from XML $xmlConfig = config_getConfiguration(); //write settings to Torrent Module require_once $appPath . 'torrent_module_loader.php'; $torrentModule = new TorrentFunctions('localhost'); $torrentModule->writeSetting(TorrentSetting::MaxDownloadSpeed, $xmlConfig->getMaxDownloadSpeed()); $torrentModule->writeSetting(TorrentSetting::MaxUploadSpeed, $xmlConfig->getMaxUploadSpeed()); $torrentModule->writeSetting(TorrentSetting::MaxDownloads, $xmlConfig->getMaxDownloads()); $torrentModule->writeSetting(TorrentSetting::MaxUploads, $xmlConfig->getMaxUploads()); $torrentModule->writeSetting(TorrentSetting::MaxActiveTorrents, $xmlConfig->getMaxActiveTorrents()); $torrentModule->writeSetting(TorrentSetting::TcpPort, $xmlConfig->getTcpPort()); $torrentModule->writeSetting(TorrentSetting::UdpPort, $xmlConfig->getUdpPort());
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once 'lib/configuration.php'; $fileName = $_GET['file']; $xmlConfig = config_getConfiguration(); $filePath = config_getConfiguration()->getDownloadLocation() . '/' . $_GET['user'] . '/' . $fileName; $fileNameSplit = split('/', $fileName); $fileName = $fileNameSplit[count($fileNameSplit) - 1]; if (file_exists($filePath)) { //allow lots of time (an hour) to create the ZIP archive //or for the client to download the file set_time_limit(3600); // If the file is actually a directory, we're going to create a zip archive // to allow an easy download. if (is_dir($filePath)) { // We're going to need the zip function. require_once 'lib/zip.php'; // We create our zip archive ... $zipfile = "{$filePath}.zip"; $zip = new ZipArchive(); if ($zip->open($zipfile, ZIPARCHIVE::OVERWRITE) !== true) {
<?php } ?> </div> <!-- The auto downloading information <div id="divAutoDownloader" class="header"> <div id="divAutoDownloadLogo" class="header"> <img src="master/images/bannerAutoDownload.gif" alt="Torrents" /> </div> <div id="divAutoLeftSide" class="header"> </div> </div> --> <!-- Drive Information --> <?php require_once 'lib/configuration.php'; require_once 'lib/driveSpace.php'; $path = config_getConfiguration()->getDownloadLocation(); $freeSpace = GetFreeSpace($path); $totalSpace = GetTotalSpace($path); $percent = GetUsedSpace($freeSpace, $totalSpace); ?> <div id="divDriveInformation"> <div id="divDriveInformationLogo"><img src="master/images/driveInformation.gif" alt="DriveInformation" /></div> <div class="center"> <div id="divDriveInformationStatus"><?php print "<img src=\"master/images/driveStatus.gif\" width=\"{$percent}%\" height=\"16px\" alt=\"Drive Free Space\" />"; ?> </div> <div id="divDriveInformationText"><?php echo round($freeSpace / 1024 / 1024 / 1024, 2) . " GB / " . round($totalSpace / 1024 / 1024 / 1024, 2) . " GB free (" . $percent . "% used)"; ?>
//read settings from XML $xmlConfig = config_getConfiguration(); // We're going to save the settings. if (count($_POST)) { // Let's first check for errors. $errors = array(); // If direct download has been allowed, we need to create a symlink to // the directory where they are stored. if ($_POST['allowDirectDownload'] == 'yes') { // Does it exist yet ? if (!is_dir($symlink_to_direct_download_dir)) { // We're going to create it ... $r = symlink(config_getConfiguration()->getDownloadLocation(), $symlink_to_direct_download_dir); // But that can fail ! if ($r == false) { $errors[] = "<strong>Unable to create a symlink to the downloaded files\r\n\tdirectory.</strong><br />You either need to create a symlink\r\n\t<code>downloaded-files</code> in the <code>site/</code> directory pointing to\r\n\t<code>" . config_getConfiguration()->getDownloadLocation() . "</code> or allow\r\n\twrite access to Apache on the <code>site/</code> directory."; } } } else { // We won't need this symlink anymore. unlink($symlink_to_direct_download_dir); } // If everything went fine, we can save everything. if (empty($errors)) { //write settings to XML $xmlConfig->setDownloadLocation($_POST['downloadLocation']); $xmlConfig->setTorrentModule($_POST['torrentModule']); $xmlConfig->setMaxDownloadSpeed($_POST['maxDownloadSpeed']); $xmlConfig->setMaxUploadSpeed($_POST['maxUploadSpeed']); $xmlConfig->setMaxDownloads($_POST['maxDownloads']); $xmlConfig->setMaxUploads($_POST['maxUploads']);