コード例 #1
0
	alt="Torrent Settings Logo" /></div>
<?php 
if (empty($_SESSION['user'])) {
    echo '<div id="divStatus">You must be logged in to configure a Torrent.</div><br/><input type="button" value="Close" onClick="javascript:window.close()"/>';
} else {
    if (empty($_GET['name'])) {
        echo '<div id="divStatus">No Torrent name specified.</div><br/><input type="button" value="Close" onClick="javascript:window.close()"/>';
    } 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']);
コード例 #2
0
$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()) {
        if (isset($_GET['start'])) {
            $torrentManagerModule->startTorrent($torrentName);
        }
        if (isset($_GET['stop'])) {
            $torrentManagerModule->stopTorrent($torrentName);
        }
        if (isset($_GET['remove'])) {
            $torrentManagerModule->removeTorrent($torrentName);
            torrent_removeTorrent($torrentName);
        }
    }
    header('Location: index.php');
}
// Add stylesheet for login.
$pageHead = "<link rel=\"stylesheet\" type=\"text/css\" href=\"master/css/index.css\" />";