TorrentFlux.com Hey, OppTupacShakur, you have 11 messages, 0 are new.
06-27-2007, 12:43:52
Home Help Search Profile Logout donate chat
News:


+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  Move torrents upon deletion
« previous next »
Pages: [1] Go Down Reply Notify of replies Send this topic Print
Author Topic: Move torrents upon deletion  (Read 1417 times)
Juxe
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 1



View Profile Email Personal Message (Offline)
« on: 09-29-2006, 18:29:22 » Reply with quote

its only a start, but it's functional. I couldn't find a working version of this or enough of a lead so I made my own. Here ya go.
Add this to your index.php by searching for delfile and editing there. I only added 3 lines near the top of this. Make sure you create a folder called 'completed' in the same  folder as the user folders or change the path or name or whatever.
Code:
$delfile = getRequestVar('delfile');
if(! $delfile == '')
{
    $alias_file = getRequestVar('alias_file');
    if (($cfg["user"] == getOwner($delfile)) || IsAdmin())
    {
$command = "mv \"".$cfg["path"].$cfg["user"]."/".get_data_name($delfile,false)."\" ".$cfg["path"]."completed/"; //get the raw command for moving the file to the completed folder
$output = shell_exec($command); //execute move command, store output in $output
echo $output; //it apparently needs this to be happy and work. Got me.
        @unlink($cfg["torrent_file_path"].$delfile);
        @unlink($cfg["torrent_file_path"].$alias_file);
        // try to remove the QInfo if in case it was queued.
        @unlink($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo");
        // try to remove the pid file
        @unlink($cfg["torrent_file_path"].$alias_file.".pid");
        @unlink($cfg["torrent_file_path"].getAliasName($delfile).".prio");

        AuditAction($cfg["constants"]["delete_torrent"], $delfile);

$alias = getAliasName($delfile);

header("location: index.php");
        exit();
    }
    else
    {
        AuditAction($cfg["constants"]["error"], $cfg["user"]." attempted to delete ".$delfile);
    }
}

Also add this to the end of your functions.php file.
Code:
function array_search_partial($needlestring, $haystackarray)
{
   if (is_array($haystackarray)) {  // confirms array
       $needlelength = strlen($needlestring);  // length of string needle
       foreach ($haystackarray as $arraykey => $arrayvalue) {  // gets array value
           $arraypart = substr($arrayvalue, 0, $needlelength);  // first characters of array value
           if ($needlestring == $arraypart) {  // did we find a match
               return $arraykey;  // return will stop loop
           }  // end match conditional
       }  // end loop
   }  // end array check
   return false;  // no matches found if this far
}

function get_data_name($torrent, $allowSave=false)
{
    global $cfg;
        $list = shell_exec("cd " . $cfg["torrent_file_path"]."; " . $cfg["pythonCmd"] . " -OO " . $cfg["btshowmetainfo"]." \"".$torrent."\""); //this gets all the 'details.php' data.
$array = explode("\n",$list); //explodes the raw data into an array for searching, delimited by a newline
$key = array_search_partial("directory name: ", $array); //uses the above function to search for the array entry starting with 'directory name:' for the data path
$filename = ltrim($array[$key],"directory name: "); //trims the front off of the array value to get just the directory name
if(!$key) { //if a directory was not found...
$key = array_search_partial("file name.....:", $array); //search for a file name
$filename = ltrim($array[$key],"file name.....: "); //trim the front for file name alone
}
return $filename; //return the filename
}

Note that this does not check to see if the torrent completed or anything, just when you delete it from the home page it moves the files. I may add that in if no one else does.
Report to moderator   Logged
dug
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 2



View Profile Email Personal Message (Offline)
« Reply #1 on: 11-23-2006, 19:26:37 » Reply with quote

Fantastic! Works great! Thanks, I may add in a few functions if anyone finds them useful and post them in here of course.

Dug
Report to moderator   Logged
bugmen0t
Newbie
*
Offline Offline

Posts: 9



View Profile Personal Message (Offline)
« Reply #2 on: 03-24-2007, 11:55:03 » Reply with quote

not really, does not work with 2.1 (rights, everything was fine)

Report to moderator   Logged
alpha2
Newbie
*
Offline Offline

Posts: 5



View Profile Personal Message (Offline)
« Reply #3 on: 04-14-2007, 07:39:49 » Reply with quote

works nice (-:!
Report to moderator   Logged
blu_alchemist
Newbie
*
Offline Offline

Posts: 4



View Profile Email Personal Message (Offline)
« Reply #4 on: 06-08-2007, 02:38:59 » Reply with quote

I tried the mod and it did not work so i figured to modify the $af->time_left = "Completed!"; strings and add a 1,2,3,etc to tell them apart when i realized that when i modify these values i see nothing at all. I can add html to the bottom of the page so i know its the modified page but the "Completed!" string never changes to what i modified it to (i modified every $af->time_left = string)

Anybody know in what file and were the download completed function is located??

Im using v2.3 btw
Report to moderator   Logged
Pages: [1] Go Up Reply Notify of replies Send this topic Print 
« previous next »
Jump to:  


Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP