Difference between revisions of "Torrentflux"

From LinuxMCE
Jump to: navigation, search
m
Line 1: Line 1:
 
[[Category: Tutorials]]
 
[[Category: Tutorials]]
= Torrentflux =
 
 
 
I wanted to make the use of torrents a little easier. So  installed torrentflux (apt-get install 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:
 
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]*/*
Add to lines to the bottom of the sudoers file:
+
www-data        ALL=(root) NOPASSWD: /bin/mv /var/cache/torrentflux/[a-zA-Z0-9]*/* /home/public/data/*
sudo vi /etc/sudoers
+
<pre>
+
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/*
+
</pre>
+
  
 
add the following code to the file /usr/share/torrentflux/www/dir.php. I have put it just above:
 
add the following code to the file /usr/share/torrentflux/www/dir.php. I have put it just above:
<pre>
 
// Are we to unrar something?
 
$rar = getRequestVar('rar');
 
if ($rar != "")
 
{
 
  
 +
// Are we to unrar something?
 +
$rar = getRequestVar('rar');
 +
if ($rar != "")
 +
{
 
         $current = "";
 
         $current = "";
 
 
         $rar = stripslashes(stripslashes($rar));
 
         $rar = stripslashes(stripslashes($rar));
 
 
         $command = "cd ". escapeshellarg(dirname($cfg["path"] . $rar)) ."; /usr/bin/unrar x " . escapeshellarg($cfg["path"] . $rar);
 
         $command = "cd ". escapeshellarg(dirname($cfg["path"] . $rar)) ."; /usr/bin/unrar x " . escapeshellarg($cfg["path"] . $rar);
 
         passthru($command);
 
         passthru($command);
 
         session_write_close();
 
         session_write_close();
}
+
}
 
+
// Are we to move something?
 
+
$move = getRequestVar('move');
// Are we to move something?
+
if ($move != "")
$move = getRequestVar('move');
+
{
if ($move != "")
+
{
+
 
+
 
         $current = "";
 
         $current = "";
 
 
         $move = stripslashes(stripslashes($move));
 
         $move = stripslashes(stripslashes($move));
 
 
         $command = "chmod -R 775 " . $cfg["path"] . $move;
 
         $command = "chmod -R 775 " . $cfg["path"] . $move;
 
         $result = exec($command);
 
         $result = exec($command);
 
 
         $command = "sudo chown root:public " . $cfg["path"] . $move;
 
         $command = "sudo chown root:public " . $cfg["path"] . $move;
 
         $result .= exec($command);
 
         $result .= exec($command);
 
 
         $command = "sudo mv '" . $cfg["path"] . $move . "' " . "'/home/public/data/videos/www/'";
 
         $command = "sudo mv '" . $cfg["path"] . $move . "' " . "'/home/public/data/videos/www/'";
 
         $result .= exec($command);
 
         $result .= exec($command);
 
 
         header("Location: dir.php?dir=".urlencode($dir));
 
         header("Location: dir.php?dir=".urlencode($dir));
}
+
}
 
+
// Are we to rename something?
// Are we to rename something?
+
$rename = getRequestVar('rename');
$rename = getRequestVar('rename');
+
$toname = getRequestVar('toname');
$toname = getRequestVar('toname');
+
if ($rename != "" && $toname != "")
if ($rename != "" && $toname != "")
+
{
{
+
 
         echo "<pre>" . $rename . " to: " . $toname . "&lt;/pre>";
 
         echo "<pre>" . $rename . " to: " . $toname . "&lt;/pre>";
 
         $current = "";
 
         $current = "";
 
 
         $rename  = stripslashes(stripslashes($rename));
 
         $rename  = stripslashes(stripslashes($rename));
 
         $toname = stripslashes(stripslashes($toname));
 
         $toname = stripslashes(stripslashes($toname));
 
 
         $command = "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"] . "/" . $toname . "'";
 
         $command = "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"] . "/" . $toname . "'";
 
         $result .= exec($command);
 
         $result .= exec($command);
 
 
         echo "<pre>" . "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"]  . "/" . $toname . "'" . "&lt;/pre>";
 
         echo "<pre>" . "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"]  . "/" . $toname . "'" . "&lt;/pre>";
}
+
}
  
</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\">"
  
 
Then just below this:
 
<pre>
 
                echo "</td>";
 
                echo "<td align=\"right\">".$fileSize." KB</td>";
 
                echo "<td>".date("m-d-Y g:i a", $timeStamp)."</td>";
 
                echo "<td align=\"right\">"
 
</pre>
 
 
add this code:
 
add this code:
<pre>
+
if( 1 == 1 )
                if( 1 == 1 )
+
{
                {
+
 
                         echo "<a href=\"dir.php?dir=".urlencode($dir)."&move=".urlencode($dir.$entry)."\" >";
 
                         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 "<img src=\"images/folder.png\" width=\"16\" height=\"16\" title=\"move to linuxMCE\" border=\"0\"></a>";
                }
+
}
 
+
echo "<a href=\"javascript:popRename('" . urlencode(addslashes($dir.$entry))  ."');\">rn</a>";
 
+
if( ( substr( strtolower($entry), -4 ) == ".rar" ) )
                echo "<a href=\"javascript:popRename('" . urlencode(addslashes($dir.$entry))  ."');\">rn</a>";
+
{
 
+
 
+
 
+
                if( ( substr( strtolower($entry), -4 ) == ".rar" ) )
+
                {
+
 
                         echo "<a href=\"dir.php?rar=".urlencode($dir.$entry)."\" >";
 
                         echo "<a href=\"dir.php?rar=".urlencode($dir.$entry)."\" >";
 
                         echo "<img src=\"".$image."\" width=\"16\" height=\"16\" title=\"unrar\" border=\"0\"></a>";
 
                         echo "<img src=\"".$image."\" width=\"16\" height=\"16\" title=\"unrar\" border=\"0\"></a>";
                }
+
}
  
 +
after:
  
 +
$dirName = stripslashes($dirName);
 +
if (isset($dir))
 +
{
  
 
 
</pre>
 
 
 
 
after:
 
<pre>
 
    $dirName = stripslashes($dirName);
 
 
    if (isset($dir))
 
    {
 
</pre>
 
  
 
put the code:
 
put the code:
<pre>
 
$javascript = <<<JSPOPRENAME
 
<script type='text/javascript' language='javascript'>
 
function popRename(name){
 
  
 +
$javascript = <<<JSPOPRENAME
 +
<script type='text/javascript' language='javascript'>
 +
function popRename(name){
 
         newwindow2=window.open('','name','height=100,width=550');
 
         newwindow2=window.open('','name','height=100,width=550');
 
         var tmp = newwindow2.document;
 
         var tmp = newwindow2.document;
Line 134: Line 94:
 
         tmp.write('</body></html>');
 
         tmp.write('</body></html>');
 
         tmp.close();
 
         tmp.close();
} </script>
+
} </script>
 
+
JSPOPRENAME;
JSPOPRENAME;
+
echo $javascript;
 
+
echo $javascript;
+
 
+
 
+
</pre>
+

Revision as of 18:58, 6 November 2011

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 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/www/'";
       $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 "
" . $rename . " to: " . $toname . "</pre>";
        $current = "";
        $rename  = stripslashes(stripslashes($rename));
        $toname = stripslashes(stripslashes($toname));
        $command = "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"] . "/" . $toname . "'";
        $result .= exec($command);
        echo "<pre>" . "mv '" . $cfg["path"] . $rename . "' '" . $cfg["path"]  . "/" . $toname . "'" . "</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 "<a href=\"javascript:popRename('" . urlencode(addslashes($dir.$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:

 $javascript = <<<JSPOPRENAME
 <script type='text/javascript' language='javascript'>
 function popRename(name){
        newwindow2=window.open('','name','height=100,width=550');
        var tmp = newwindow2.document;
        tmp.write('<html><head><title>rename ' + name + '</title>');
        tmp.write('<script type=\'text/javascript\' language=\'javascript\'>function getname(obj) {');
        tmp.write('window.location=\'dir.php?rename=' + escape(name) + '&toname=\' + escape(obj.childNodes[0].value);');
        tmp.write('self.close();');
        tmp.write('}</scr' + 'ipt>');
        tmp.write('</head><body><p>type new name below and press enter</p>');
        tmp.write('<form action="javascript:getname(document.getElementById(\'myform\'));" name="myform" id="myform">');
        tmp.write('<input style="width: 450px" type="text" value="' + name + '"></form>');
        tmp.write('<p>refresh the original page to see the results.</p>');
        tmp.write('</body></html>');
        tmp.close();
 } </script>
 JSPOPRENAME;
 echo $javascript;