Beispiel #1
0
            } else {
                echo '<div id="divStatus">The URL was left empty.</div><br />';
                $loadContent = true;
            }
        }
        // There are torrents to upload ...
        // --------------------------------
        if ($loadTorrent) {
            require_once 'lib/torrent_module_loader.php';
            $torrentModule = new TorrentFunctions('localhost');
            $errors = array();
            // We iterate on the files we need to upload.
            foreach ($uploadFiles as $i => $uploadFile) {
                $uploadFile = $uploadFiles[$i];
                $torrentName = $torrentNames[$i];
                $torrentModule->addTorrentByFile($uploadFile, $uploadDir);
                $torrent = new Torrent($_SESSION['user'], $torrentName, 'not defined');
                // We add the torrent to the queue and check for an error.
                $r = torrent_addTorrent($torrent);
                if (!$r) {
                    $errors[] = $torrentName;
                }
            }
            if (count($errors) > 0) {
                echo '<div id="divStatus">There was an issue with the following
					torrents, they may have already been downloaded by either you or
					another user :<br />' . implode(', ', $errors) . '<br />' . '<input type="button" value="Close" onclick="javascript:window.close()"/></div>';
            } else {
                $howManyFiles = count($uploadFiles);
                if ($howManyFiles == 1) {
                    echo '<div id="divStatus">The torrent was successfully loaded.<br /><br />
} else {
    require_once 'lib/user.php';
    $userAuthLevel = user_getUserByUsername($_SESSION['user'])->getAuthLevel();
    if ($userAuthLevel == 'Admin' || $userAuthLevel == 'Power User' || $userName == $_SESSION['user']) {
        //get download directory from config
        require_once 'lib/configuration.php';
        $downloadDir = config_getConfiguration()->getDownloadLocation();
        //change to config-specified directory
        $userDir = $downloadDir . '/' . $userName;
        //process Torrent actions
        //process Torrent load
        if (isset($_GET['loadTorrent'])) {
            //add Torrent to Torrent Module
            require_once 'lib/torrent_module_loader.php';
            $torrentModule = new TorrentFunctions('localhost');
            $torrentModule->addTorrentByFile($userDir . '/' . $_GET['loadTorrent'], $userDir);
            //add Torrent to XML database
            require_once 'lib/torrent.php';
            $torrent = new Torrent($userName, torrent_getTorrentNameFromFileName($userDir . '/' . $_GET['loadTorrent'], $_GET['loadTorrent']), 'not defined');
            torrent_addTorrent($torrent);
            echo '	<div class="divStatus">' . $_GET['loadTorrent'] . ' loaded.</div>' . "\n";
        }
        //process Torrent delete
        if (isset($_GET['deleteTorrent'])) {
            //delete Torrent from file system
            unlink($userDir . '/' . $_GET['deleteTorrent']);
            echo '	<div class="divStatus">' . $_GET['deleteTorrent'] . ' deleted.</div>' . "\n";
        }
        ?>
	<div class="rowHeadings">
			<div class="headingFilename">Filename</div>