Example #1
0
 // 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
             $torrentNames[] = torrent_getTorrentNameFromFileName($_FILES['torrentFile']['tmp_name'][$i], $_FILES['torrentFile']['name'][$i]);
             $uploadFiles[] = $uploadDir . DIRECTORY_SEPARATOR . $torrentNames[$i] . '.torrent';
             // the uploader breaks permissions
             move_uploaded_file($_FILES['torrentFile']['tmp_name'][$i], $uploadFiles[$i]);
             $loadTorrent = true;
         } else {
             echo '<div id="divStatus">The file you uploaded is not a Torrent.</div><br />';
             $loadContent = true;
         }
     }
     // ... A URL was provided
     // ----------------------
 } else {
     if (!empty($_POST['url'])) {
         // We need to download the file contents first, let's decide how :
         // ---------------------------------------------------------------
Example #2
0
    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>
			<div class="headingActions">Actions</div>
	</div>
	<div><img src="master/images/single.gif" width="100%" height="1px" alt="Separator" /></div>