Beispiel #1
0
             // Get the actual name of the torrent
             $torrentNames[] = torrent_getTorrentNameFromFileData($contents);
             $uploadFiles[] = $uploadDir . DIRECTORY_SEPARATOR . $torrentNames[0] . '.torrent';
             file_put_contents($uploadFiles[0], $contents);
             $loadTorrent = true;
         }
     } 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
    echo '<div class="divStatus">You must be logged in to view an archive.<br /><br /><input type="button" value="Close" onclick="javascript:window.close()"/></div>';
} 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">
 } else {
     //get this user's access level
     require_once 'lib/user.php';
     $userName = $_SESSION['user'];
     $userAuthLevel = user_getUserByUsername($userName)->getAuthLevel();
     $torrentName = $_GET['name'];
     //get owner of the Torrent
     require_once 'lib/torrent.php';
     $torrentUser = torrent_getTorrentByName($torrentName)->getUserName();
     //check if the user the owner of the Torrent, an admin, or a power user
     if ($userAuthLevel != 'Admin' && $userAuthLevel != 'Power User' && $userName != $torrentUser) {
         echo '<div id="divStatus">You do not have permission to configure this Torrent.</div><br/><input type="button" value="Close" onClick="javascript:window.close()"/>';
     } else {
         //setup Torrent Module
         require_once 'lib/torrent_module_loader.php';
         $torrentModule = new TorrentFunctions('localhost');
         //user is saving settings
         if (count($_POST)) {
             //map form values to constant values
             $priorities = array('normal' => TorrentPriority::Normal, 'high' => TorrentPriority::High, 'doNotDownload' => TorrentPriority::DoNotDownload);
             //set Torrent's priority
             $torrentModule->setTorrentPriority($torrentName, $priorities[$_POST['priority']]);
             //set Torrent's maximum download speed
             $torrentModule->setTorrentSpeedLimit($torrentName, TorrentSpeed::Download, $_POST['maxDownload']);
             //set Torrent's maximum upload speed
             $torrentModule->setTorrentSpeedLimit($torrentName, TorrentSpeed::Upload, $_POST['maxUpload']);
             echo '<div id="divStatus">Settings applied.</div>';
         }
         //shorten Torrent name to fit
         if (strlen($torrentName) > 42) {
             $shortTorrentName = substr($torrentName, 0, 39) . '...';
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());
Beispiel #5
0
require_once 'lib/torrent_module_loader.php';
require_once 'lib/torrent.php';
session_start();
//immediately redirect if nobody is logged in
if (empty($_SESSION['user'])) {
    include "master.php";
}
//set autoRefresh session variable if it is unset
if (empty($_SESSION['autoRefresh'])) {
    $_SESSION['autoRefresh'] = "on";
}
require_once 'lib/user.php';
//user info
$userName = $_SESSION['user'];
$userAuthLevel = user_getUserByUsername($userName)->getAuthLevel();
$torrentManagerModule = new TorrentFunctions('localhost');
//process get operations
if (count($_GET) > 0) {
    //assume the torrent name resides in the last GET variable
    foreach ($_GET as $getVar) {
        $torrentName = $getVar;
    }
    // Handle auto refreshing
    if ($_GET['autoRefresh'] == "off") {
        $_SESSION['autoRefresh'] = "off";
    }
    if ($_GET['autoRefresh'] == "on") {
        $_SESSION['autoRefresh'] = "on";
    }
    // Handle torrent information
    if ($userAuthLevel == 'Admin' || $userAuthLevel == 'Power User' || $userName == torrent_getTorrentByName($torrentName)->getUserName()) {
Beispiel #6
0
            //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']);
            $xmlConfig->setMaxActiveTorrents($_POST['maxActiveTorrents']);
            $xmlConfig->setTcpPort($_POST['tcpPort']);
            $xmlConfig->setUdpPort($_POST['udpPort']);
            $xmlConfig->setHideOtherUsers($_POST['hideOtherUsers']);
            $xmlConfig->setAllowDirectDownload($_POST['allowDirectDownload']);
            config_setConfiguration($xmlConfig);
            //write settings to Torrent Module
            require_once '../lib/torrent_module_loader.php';
            $torrentModule = new TorrentFunctions('localhost');
            $torrentModule->writeSetting(TorrentSetting::MaxDownloadSpeed, $_POST['maxDownloadSpeed']);
            $torrentModule->writeSetting(TorrentSetting::MaxUploadSpeed, $_POST['maxUploadSpeed']);
            $torrentModule->writeSetting(TorrentSetting::MaxDownloads, $_POST['maxDownloads']);
            $torrentModule->writeSetting(TorrentSetting::MaxUploads, $_POST['maxUploads']);
            $torrentModule->writeSetting(TorrentSetting::MaxActiveTorrents, $_POST['maxActiveTorrents']);
            $torrentModule->writeSetting(TorrentSetting::TcpPort, $_POST['tcpPort']);
            $torrentModule->writeSetting(TorrentSetting::UdpPort, $_POST['udpPort']);
            ?>
			
			<div id="divStatus">Settings saved.</div>
			<br />
			
		<?php 
        } else {
            ?>