Torrentflux

From LinuxMCE
Revision as of 14:29, 13 September 2008 by Esperanto (Talk | contribs)

Jump to: navigation, search

Torrentflux

I wanted to make the use of torrents a little easier. So installed torrentflux (apt-get install torrentflux).

To het an extra folder button to move the files to the media directory and an unrar (you need to install it also) button via the webinterface I changed the following:


Add to lines to the bottom of the sudoers file: sudo vi /etc/sudoers

www-data        ALL=(root) NOPASSWD: /bin/chown root\:public /var/cache/torrentflux/[a-zA-Z0-9]*/*
www-data        ALL=(root) NOPASSWD: /bin/mv /var/cache/torrentflux/[a-zA-Z0-9]*/* /home/public/data/*

add the following code to the file /usr/share/torrentflux/www/dir.php. I have put it just above:

// Are we to delete something?
if ($del != "")

the code:

// Are we to unrar something?
$rar = getRequestVar('rar');
if ($rar != "")
{

        $current = "";

        $rar = stripslashes(stripslashes($rar));

        $command = "cd ". escapeshellarg(dirname($cfg["path"] . $rar)) ."; /usr/bin/unrar x " . escapeshellarg($cfg["path"] . $rar);
        passthru($command);
        session_write_close();
}


// Are we to move something?
$move = getRequestVar('move');
if ($move != "")
{

        $current = "";

        $move = stripslashes(stripslashes($move));

        $command = "chmod -R 775 " . $cfg["path"] . $move;
        $result = exec($command);

        $command = "sudo chown root:public " . $cfg["path"] . $move;
        $result .= exec($command);

        $command = "sudo mv " . $cfg["path"] . $move . " " . "/home/public/data/videos/";
        $result .= exec($command);

        header("Location: dir.php?dir=".urlencode($dir));
}

// Are we to rename something?
$rename = getRequestVar('rename');
$toname = getRequestVar('toname');
if ($rename != "" && $toname != "")
{
        echo "<pre>" . $rename . " to: " . $toname . "
";
       $current = "";
       $rename  = stripslashes(stripslashes($rename));
       $toname = stripslashes(stripslashes($toname));
       $command = "mv " . $cfg["path"] . $rename . " " . $cfg["path"] . toname;
       $result .= exec($command);
echo "
" . "mv " . $cfg["path"] . $rename . " " . $cfg["path"] . dirname($rename) . "/" . $toname .  "
";
       header("Location: dir.php?dir=".urlencode($dir));

}


</pre>


Then just below this:

                echo "</td>";
                echo "<td align=\"right\">".$fileSize." KB</td>";
                echo "<td>".date("m-d-Y g:i a", $timeStamp)."</td>";
                echo "<td align=\"right\">"

add this code:

                if( 1 == 1 )
                {
                        echo "<a href=\"dir.php?dir=".urlencode($dir)."&move=".urlencode($dir.$entry)."\" >";
                        echo "<img src=\"images/folder.png\" width=\"16\" height=\"16\" title=\"move to linuxMCE\" border=\"0\"></a>";
                }

echo "<form style=\"display:none\" action=\"javascript:get(document.getElementById('" . $entry ."'), '" . urlencode(addslashes($dir.$entry)) ."');\" name=\"" . $entry ."\" id=\"" . $entry ."\">";
echo '<input type="text" value="'. $entry . '"></form>';
echo "<a href=\"javascript:show(document.getElementById('" . $entry ."'));\">rn</a>";

                if( ( substr( strtolower($entry), -4 ) == ".rar" ) )
                {
                        echo "<a href=\"dir.php?rar=".urlencode($dir.$entry)."\" >";
                        echo "<img src=\"".$image."\" width=\"16\" height=\"16\" title=\"unrar\" border=\"0\"></a>";
                }





after:

    $dirName = stripslashes($dirName);

    if (isset($dir))
    {

put the code:

echo " <script type='text/javascript' language='javascript'>";
echo "function show(obj) {";
echo "  obj.style.display = 'inline';";
echo "} ";

echo "function get(obj,name) {";

echo " window.location='dir.php?dir=".urlencode($dir)."&rename=' + name + '&toname=' + obj.childNodes[0].value  ;";
echo "} </script>";