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


+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.0 Hacks
| | |-+  Stop/Resume all active torrents
« previous next »
Pages: 1 2 3 [All] Go Down Reply Notify of replies Send this topic Print
Author Topic: Stop/Resume all active torrents  (Read 11598 times)
darknite
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 39






View Profile WWW Personal Message (Offline)
« on: 11-05-2005, 08:21:22 » Reply with quote

found this one via Google cache, since I had it installed, and lost me txt file, I needed to find it again.. (Thanks IHateMyISP for the original code)


index.php

Place this in one of the "<script>" areas.

Code:
function ConfirmStopAll()
{
return confirm("Stop all torrents?");
}

Place this segment of code after the "//if a file was to be deleted then delete it" statement...

Code:
// Did the user issue the stop all command?
if(isset($stopall) && IsAdmin($cfg["user"]) == true)
{
include_once("AliasFile.php");
$dirName = $cfg["torrent_file_path"];
$screenStatus = shell_exec("ps x -w -w");
$arList = array();
$totals = array_fill(1, 5, 0);
$file_filter = getFileFilter($cfg["file_types_array"]);
$handle = opendir($dirName);
$lastUser = "";

while($entry = readdir($handle))
{
 if ($entry != "." && $entry != "..")
 {
  if (is_dir($dirName."/".$entry))
  {
   // don''t do a thing
  }
  else
  {
   if (ereg($file_filter, $entry))
   {
    $key = filemtime($dirName."/".$entry).md5($entry);
    $arList[$key] = $entry;
   }
  }
 }
}

foreach($arList as $entry)
{
 $the_user = getOwner($entry);
 $alias = getAliasName($entry).".stat";
 $af = new AliasFile($cfg["torrent_file_path"].$alias, $the_user);
 if ($af->running != "2" && $af->time_left != "Torrent Died")
 {
  if($af->percent_done < 100)
  {
   // The torrent is being stopped but is not completed dowloading
   $af->percent_done = ($af->percent_done + 100)*-1;
   $af->running = "0";
   $af->time_left = "Torrent Stopped";
  }
  else
  {
   // Torrent was seeding and is now being stopped
   $af->percent_done = 100;
   $af->running = "0";
   $af->time_left = "Download Succeeded!";
  }
  // Write out the new Stat File
  $af->WriteFile();
 }
}

AuditAction("ADMIN", "Stop All Torrents");

header("location: index.php");
}

here's the resume all, (for those that want this, it was a second post on the old thread, it goes right after the above code)

Code:
// Did the user issue the resume all command?
if(isset($resumeall) && IsAdmin($cfg["user"]) == true)
{
 include_once("AliasFile.php");
 $dirName = $cfg["torrent_file_path"];
 $screenStatus = shell_exec("ps x -w -w");
 $arList = array();
 $totals = array_fill(1, 5, 0);
 $file_filter = getFileFilter($cfg["file_types_array"]);
 $handle = opendir($dirName);
 $lastUser = "";

 while($entry = readdir($handle))
 {
   if ($entry != "." && $entry != "..")
   {
     if (is_dir($dirName."/".$entry))
     {
       // don''t do a thing
     }
     else
     {
       if (ereg($file_filter, $entry))
       {
         $key = filemtime($dirName."/".$entry).md5($entry);
         $arList[$key] = $entry;
       }
     }
   }
 }

 foreach($arList as $entry)
 {
   $the_user = getOwner($entry);
   $alias = getAliasName($entry).".stat";
   $af = new AliasFile($cfg["torrent_file_path"].$alias, $the_user);

   if (($af->running == 0 && $af->percent_done < 100) || ($af->running == 1 && $af->percent_done == 0 && $af->time_left == ""))
   {
     $af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
     $command = "cd " . $cfg["path"] . $the_user . "; HOME=".$cfg["path"]."; export HOME; nohup " .$cfg["btphpbin"] . " ".$cfg["torrent_dies_when_done"]." -1 ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." ".$cfg["cmd_options"]." > /dev/null &";
     $result = exec($command);
     $af->WriteFile();
   }
 }

 AuditAction("ADMIN", "Start All Torrents");

 header("location: index.php");
}

This next bit of code is really up to you as to where you put it.

Code:
<?php if(IsAdmin($cfg["user"]))
{
 echo '<a href="?stopall=now"><img src="images/stop_all.gif" width="25" height="25" onClick="return ConfirmStopAll()" border="0" /></a>&nbsp;';
}
?>

and the resume all link..

Code:
echo '<a href="?resumeall=now"><img src="images/resume.gif" width="32" height="32" border="0" alt="Start/Resume All Torrents"></a>';

and the button..

Report to moderator   Logged

SERVER: Slackware-current | AMD Athlon 1Ghz | 512MB | Apache 1.3 | PHP 4.4.1 | MySQL 4.1.14 | TF 2.1 | NAS: AMD AthlonXP 2800+ | 1024MB| 1.12TB Storage | TF: 2.1 Mod/Hacks: Realname Links/Multi-upload/multi-search/Transfer stats/Cookied Login/Ajax Details
IhatemyISP
Forum Code Monkey
Administrator
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 842






View Profile WWW Email Personal Message (Offline)
« Reply #1 on: 11-05-2005, 09:48:45 » Reply with quote

Thanks for digging that up Smiley
Report to moderator   Logged

Pentium III 667mhz | 155GB RAID 0 | 256MB RAM | Redhat 7.3 - 2.4.18-3 | Python 2.4.1 | PHP 5.1.4 (cgi-fcgi) | Lighttpd 1.4.11
mb.Tab
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 556


Gotta love my Avatar !!

169560841 mb.Tab@web.de andreas11b



View Profile WWW Email Personal Message (Offline)
« Reply #2 on: 11-05-2005, 16:32:39 » Reply with quote

Yeah thanks for it........but id love to see
that one of you, trying it by myself but dont think that the results will be good as yours would be,
adds this to the "Delete Torrent & Data" hack with the checkboxes and stuff..
see my pic in the request thread for it....Smiley

mb.Tab
Report to moderator   Logged

darknite
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 39






View Profile WWW Personal Message (Offline)
« Reply #3 on: 11-05-2005, 19:16:54 » Reply with quote

it could probably be done, but I have no interest/need in doing it.. the only time I use this functionality is when I really do want to stop/start all my torrents at once..

more often than not, I use it when the server is getting hit hard and I need to "pause" the torrents to do a compile of something.
Report to moderator   Logged

SERVER: Slackware-current | AMD Athlon 1Ghz | 512MB | Apache 1.3 | PHP 4.4.1 | MySQL 4.1.14 | TF 2.1 | NAS: AMD AthlonXP 2800+ | 1024MB| 1.12TB Storage | TF: 2.1 Mod/Hacks: Realname Links/Multi-upload/multi-search/Transfer stats/Cookied Login/Ajax Details
creinhardt
Newbie
*
Offline Offline

Posts: 10



View Profile Personal Message (Offline)
« Reply #4 on: 11-16-2005, 22:48:03 » Reply with quote

is resume not working for anyone else?
Report to moderator   Logged
ACDonovan
Newbie
*
Offline Offline

Posts: 12



View Profile Personal Message (Offline)
« Reply #5 on: 01-07-2006, 12:56:49 » Reply with quote

you forgot the resume button
Report to moderator   Logged
Evilempireinc
Newbie
*
Offline Offline

Posts: 1



View Profile Personal Message (Offline)
« Reply #6 on: 01-16-2006, 17:23:30 » Reply with quote

hmm. The hack works, but any torrents that were seeding when I stopped just go back to the 'DONE' state.
Any ideas on how to make them resume seeding when the resume all link is clicked?
Report to moderator   Logged
tRiBUN
Newbie
*
Offline Offline

Posts: 16



View Profile Personal Message (Offline)
« Reply #7 on: 01-28-2006, 09:43:37 » Reply with quote

here some new stop and resume buttons (16x16 Pixels) for all Wink

the changed code, cause of pixel size:
stop all button:
Code:
<?php if(IsAdmin($cfg["user"]))
{
 echo '<a href="?stopall=now"><img src="images/stop_all.gif" width="16" height="16" onClick="return ConfirmStopAll()" border="0" /></a>';
}
?>
resume button:
Code:
echo '<a href="?resumeall=now"><img src="images/resume.gif" width="16" height="16" border="0" alt="Start/Resume All Torrents"></a>';


* stop_all.gif (0.87 KB, 16x16 - viewed 538 times.)

* resume.gif (0.92 KB, 16x16 - viewed 533 times.)
« Last Edit: 01-28-2006, 09:45:13 by tRiBUN » Report to moderator   Logged
$chwede
Jr. Member
**
Offline Offline

Posts: 53



View Profile Personal Message (Offline)
« Reply #8 on: 01-28-2006, 17:30:00 » Reply with quote

How is the code, that all "ready" torrents, are continued....
Report to moderator   Logged
Cyberax
Newbie
*
Offline Offline

Posts: 2



View Profile Personal Message (Offline)
« Reply #9 on: 01-30-2006, 15:03:05 » Reply with quote

Any ideas on a commandline pause/resume method, I have an asterisk server (pbx+ voIP) and it would be good to pause the torrents before answering a call, then resume them after the call. At current I have to kill the torrents and then manually resume them via the php pages.
Report to moderator   Logged
ryaner
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 919





View Profile Personal Message (Offline)
« Reply #10 on: 01-30-2006, 16:18:44 » Reply with quote

Any ideas on a commandline pause/resume method, I have an asterisk server (pbx+ voIP) and it would be good to pause the torrents before answering a call, then resume them after the call. At current I have to kill the torrents and then manually resume them via the php pages.

Put the start/stop methods in a file of their own and run that file when you want to do each? If your only going to be stopping the torrents for a short length of time your prob better installing something like trickle and using it to effectively stop them for as long as you need, that way you wont lose all the peers etc
Report to moderator   Logged

SERVER: Debian Sarge 2.6.16| AMD XP2000+ | 1.5GB Ram  | 1.6T - Raid 5 | TF 2.1 | Apache 2.0.54 | PHP 4.3.10 | MySQL 4.1.11 | Mod/Hacks: XFER Transfer Stats/Multi Torrent Delete/Seed Time Hack/Ajax Details/Torrent Details/RSS Hack
horst
Newbie
*
Offline Offline

Posts: 11



View Profile Email Personal Message (Offline)
« Reply #11 on: 02-22-2006, 16:54:21 » Reply with quote

nice script, but how can i resume the seeded torrents?
Report to moderator   Logged
khr0n0s
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 66



View Profile Personal Message (Offline)
« Reply #12 on: 02-25-2006, 05:53:50 » Reply with quote

This would be way better if the resume button also worked to resume seeding of torrents. Could someone help with this please?
Report to moderator   Logged

FreeBSD 6.0 | torrentflux_2.1-b4rt-93
tRiBUN
Newbie
*
Offline Offline

Posts: 16



View Profile Personal Message (Offline)
« Reply #13 on: 02-25-2006, 06:19:02 » Reply with quote

Right this would be a very nice function. But i think it's not as easy as the stop resume function. Because the Stop function does'nt save the share ratio and that's not god for resume. I've thought about a new Table for resume values where the Primary key is the Username and Torrentname. But i've never learned php, so i could'nt programm this, but i have an new button for the one who is making this real pause function.


* pause.gif (0.87 KB, 16x16 - viewed 386 times.)
Report to moderator   Logged
khr0n0s
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 66



View Profile Personal Message (Offline)
« Reply #14 on: 02-28-2006, 06:26:01 » Reply with quote

I am quite tidy with my torrents, and those which have finished seeding I remove quite quickly. So in my opinion resuming ALL torrents would be better than just resuming those which haven't finished downloading. Is there something I could change to make that happen?
Report to moderator   Logged

FreeBSD 6.0 | torrentflux_2.1-b4rt-93
meilon
Newbie
*
Offline Offline

Posts: 7



View Profile Personal Message (Offline)
« Reply #15 on: 03-29-2006, 13:19:21 » Reply with quote

Yeah, it is possible Cheesy
Change this code from
// Did the user issue the resume all command?
if(isset($resumeall) && IsAdmin($cfg["user"]) == true)
{
 include_once(
"AliasFile.php");
 
$dirName $cfg["torrent_file_path"];
 
$screenStatus shell_exec("ps x -w -w");
 
$arList = array();
 
$totals array_fill(150);
 
$file_filter getFileFilter($cfg["file_types_array"]);
 
$handle opendir($dirName);
 
$lastUser "";

 while(
$entry readdir($handle))
 {
   if (
$entry != "." && $entry != "..")
   {
     if (
is_dir($dirName."/".$entry))
     {
       
// don''t do a thing
     
}
     else
     {
       if (
ereg($file_filter$entry))
       {
         
$key filemtime($dirName."/".$entry).md5($entry);
         
$arList[$key] = $entry;
       }
     }
   }
 }

 foreach(
$arList as $entry)
 {
   
$the_user getOwner($entry);
   
$alias getAliasName($entry).".stat";
   
$af = new AliasFile($cfg["torrent_file_path"].$alias$the_user);

   if ((
$af->running == && $af->percent_done 100) || ($af->running == && $af->percent_done == && $af->time_left == ""))
   {
     
$af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
     
$command "cd " $cfg["path"] . $the_user "; HOME=".$cfg["path"]."; export HOME; nohup " .$cfg["btphpbin"] . " ".$cfg["torrent_dies_when_done"]." -1 ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." ".$cfg["cmd_options"]." > /dev/null &";
     
$result exec($command);
     
$af->WriteFile();
   }
 }

 
AuditAction("ADMIN""Start All Torrents");

 
header("location: index.php");
}
to this:
// Did the user issue the resume all command?
if(isset($resumeall) && IsAdmin($cfg["user"]) == true)
{
 include_once(
"AliasFile.php");
 
$dirName $cfg["torrent_file_path"];
 
$screenStatus shell_exec("ps x -w -w");
 
$arList = array();
 
$totals array_fill(150);
 
$file_filter getFileFilter($cfg["file_types_array"]);
 
$handle opendir($dirName);
 
$lastUser "";

 while(
$entry readdir($handle))
 {
   if (
$entry != "." && $entry != "..")
   {
     if (
is_dir($dirName."/".$entry))
     {
       
// don''t do a thing
     
}
     else
     {
       if (
ereg($file_filter$entry))
       {
         
$key filemtime($dirName."/".$entry).md5($entry);
         
$arList[$key] = $entry;
       }
     }
   }
 }

 foreach(
$arList as $entry)
 {
   
$the_user getOwner($entry);
   
$alias getAliasName($entry).".stat";
   
$af = new AliasFile($cfg["torrent_file_path"].$alias$the_user);

   if ((
$af->running == && $af->percent_done 100) || ($af->running == && $af->percent_done == && $af->time_left == ""))
   {
     
$af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
     
$command "cd " $cfg["path"] . $the_user "; HOME=".$cfg["path"]."; export HOME; nohup " .$cfg["btphpbin"] . " ".$cfg["torrent_dies_when_done"]." -1 ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." ".$cfg["cmd_options"]." > /dev/null &";
     
$result exec($command);
     
$af->WriteFile();
   } elseif (
$af->running == && $af->percent_done == 100) {
     
$af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
     
$command "cd " $cfg["path"] . $the_user "; HOME=".$cfg["path"]."; export HOME; nohup " .$cfg["btphpbin"] . " ".$cfg["torrent_dies_when_done"]." 400 ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." ".$cfg["cmd_options"]." > /dev/null &";
     
$result exec($command);
     
$af->WriteFile();
   }
 }

 
AuditAction("ADMIN""Start All Torrents");

 
header("location: index.php");
}
The 400 in the second long row is the sharekill. normaly it is set to -1 so it doesn't start the torrent. if you have another sharekill, denn set it here. But it still doesn't takes the shareratio from the seed before! I am workin on it....

-meilon
« Last Edit: 03-29-2006, 13:21:26 by meilon » Report to moderator   Logged
3dfx
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 42



View Profile Personal Message (Offline)
« Reply #16 on: 04-04-2006, 13:37:35 » Reply with quote

How to start all torrent including NEW ?
Report to moderator   Logged

Apache 2.2.0 (migrating to lighttpd) + PHP 5.1.2 + MySQL 5.0.19 + Python 2.4.3 + RedHat 9.0

TF 2.1-b4rt-84
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile Email Personal Message (Offline)
« Reply #17 on: 04-13-2006, 19:12:41 » Reply with quote

why it doesn't work in 2.1?
Report to moderator   Logged

gunn0r
Newbie
*
Offline Offline

Posts: 29


G.I.R.



View Profile Personal Message (Offline)
« Reply #18 on: 05-14-2006, 17:01:01 » Reply with quote

why it doesn't work in 2.1?
I also tried the code, but it does not seem to work on TF 2.1?!  Shocked

Can anyone help us here?
Report to moderator   Logged

Don't eat yellow snow.
overhacked
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 3



View Profile Personal Message (Offline)
« Reply #19 on: 06-28-2006, 00:14:49 » Reply with quote

I've updated the code for TF 2.1 and added a feature where you can run, from the localhost only, a script that starts or stops all torrents without having to log in as a torrent flux user. Example:

Code:
wget -o /dev/null -O /dev/null --background --quiet --wait=3 --retry-connrefused --ignore-length --bind-address=127.0.0.1 'http://localhost/~torrentflux/index.php?resumeall=now' &>/dev/null

Two image files must be installed as images/resumeall.png and images/stopall.png, respectively.:



The following file is in patch format and should be run with patch -Np1 < patchfile in the torrentflux directory:

Code:
diff -x config.php -Naur TF2.1/functions.php TF2.1-resumeall/functions.php
--- TF2.1/functions.php 2006-04-05 00:58:14.000000000 -0400
+++ TF2.1-resumeall/functions.php 2006-06-27 23:11:38.000000000 -0400
@@ -94,6 +94,23 @@
 
     $create_time = time();
 
+    /*
+     * Allow localhost clients to issue
+     * stopall and resumeall commands without
+     * logging in.
+     */
+    if(($cfg["ip"] == '127.0.0.1')
+       && (array_key_exists('resumeall',$_GET)
+           || array_key_exists('stopall',$_GET))
+       // prevent other params from being modified
+       && (count($_GET) == 1)
+      )
+    {
+        $cfg["theme"] = $cfg["default_theme"];
+        $cfg["language_file"] = $cfg["default_language"];
+        return;
+    }
+
     if(!isset($_SESSION['user']))
     {
         header('location: login.php');
diff -x config.php -Naur TF2.1/index.php TF2.1-resumeall/index.php
--- TF2.1/index.php 2006-04-01 00:15:07.000000000 -0500
+++ TF2.1-resumeall/index.php 2006-06-28 00:01:57.000000000 -0400
@@ -477,6 +477,168 @@
 }  // End File Upload
 
 
+// Did the user issue the stop all command?
+$stopall = getRequestVar('stopall');
+
+if (!($stopall == '') && IsAdmin($cfg["user"]) == true)
+{
+    include_once("AliasFile.php");
+    include_once("RunningTorrent.php");
+    $dirName = $cfg["torrent_file_path"];
+    $screenStatus = shell_exec("ps x -w -w");
+    $arList = array();
+    $totals = array_fill(1, 5, 0);
+    $file_filter = getFileFilter($cfg["file_types_array"]);
+    $handle = opendir($dirName);
+    $lastUser = "";
+    while ($entry = readdir($handle))
+    {
+        if ($entry != "." && $entry != "..")
+        {
+            if (is_dir($dirName."/".$entry))
+            {
+                // don't do a thing
+            } else {
+                if (ereg($file_filter, $entry))
+                {
+                    $key = filemtime($dirName."/".$entry).md5($entry);
+                    $arList[$key] = $entry;
+                }
+            }
+        }
+    }
+    foreach($arList as $entry)  {
+        $the_user = getOwner($entry);
+        $alias = getAliasName($entry).".stat";
+        $af = new AliasFile($cfg["torrent_file_path"].$alias, $the_user);
+        if ($af->running != "2" && $af->time_left != "Torrent Died")
+        {
+            if ($af->percent_done < 100)
+            {
+                // The torrent is being stopped but is not completed dowloading
+                $af->percent_done = ($af->percent_done + 100) * -1;
+                $af->running = "0";
+                $af->time_left = "Torrent Stopped";
+            } else {
+                // Torrent was seeding and is now being stopped
+                $af->percent_done = 100;
+                $af->running = "0";
+                $af->time_left = "Download Succeeded!";
+            }
+
+            // see if the torrent process is hung.
+            if (!is_file($cfg["torrent_file_path"].$alias_file.".pid"))
+            {
+                $runningTorrents = getRunningTorrents();
+                foreach ($runningTorrents as $key => $value)
+                {
+                    $rt = new RunningTorrent($value);
+                    if ($rt->statFile == $alias_file) {
+                        AuditAction($cfg["constants"]["error"], "Posible Hung Process " . $rt->processId);
+                    //    $result = exec("kill ".$rt->processId);
+                    }
+                }
+            }
+
+            // Write out the new Stat File
+            $af->WriteFile();
+        }
+    }
+    AuditAction("ADMIN", "Stop All Torrents");
+    header("location: index.php");
+}
+
+// Did the user issue the resume all command?
+$resumeall = getRequestVar('resumeall');
+
+if (
+    (
+        !($resumeall == '') &&
+        (
+            IsAdmin($cfg["user"]) ||
+            ($cfg["ip"] == '127.0.0.1') // Allows resuming at startup
+        )
+    ) == true
+   )
+{
+    include_once("AliasFile.php");
+    $dirName = $cfg["torrent_file_path"];
+    $screenStatus = shell_exec("ps x -w -w");
+    $arList = array();
+    $totals = array_fill(1, 5, 0);
+    $file_filter = getFileFilter($cfg["file_types_array"]);
+    $handle = opendir($dirName);
+    $lastUser = "";
+    while ($entry = readdir($handle))
+    {
+        if ($entry != "." && $entry != "..")
+        {
+            if (is_dir($dirName."/".$entry))
+            {
+                // don't do a thing
+            } else {
+                if (ereg($file_filter, $entry))
+                {
+                    $key = filemtime($dirName."/".$entry).md5($entry);
+                    $arList[$key] = $entry;
+                }
+            }
+        }
+    }
+    foreach($arList as $entry)
+    {
+        $the_user = getOwner($entry);
+        $alias = getAliasName($entry).".stat";
+        $af = new AliasFile($cfg["torrent_file_path"].$alias, $the_user);
+        if (
+            ($af->running == 0 && $af->percent_done <= 100) ||
+            ($af->running == 1 && $af->percent_done == 0 && $af->time_left == "")
+           )
+        {
+            $superseeder = ($af->percent_done < 100 ? 0 : 1); // become a superseeder if the xfer is done
+            $af->StartTorrentFile();   // this only writes out the stat file (does not start torrent)
+            //$command = "cd ".$cfg["path"].$the_user."; HOME=".$cfg["path"]."; export HOME; nohup ".$cfg["btphpbin"]." ".$cfg["torrent_dies_when_done"]." -1 ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." --super_seeder ".$superseeder." ".$cfg["cmd_options"]." > /dev/null &";
+            $command = $cfg["torrent_dies_when_done"]." ".$cfg["sharekill"]." ".$cfg["torrent_file_path"].$alias." ".$the_user." --responsefile '".$cfg["torrent_file_path"].$entry."' --display_interval 5 --max_download_rate ". $cfg["max_download_rate"]." --max_upload_rate ".$cfg["max_upload_rate"]." --max_uploads ".$cfg["max_uploads"]." --minport ".$cfg["minport"]." --maxport ".$cfg["maxport"]." --rerequest_interval ".$cfg["rerequest_interval"]." --super_seeder ".$superseeder;
+
+            if(file_exists($cfg["torrent_file_path"].$alias.".prio")) {
+                $priolist = explode(',',file_get_contents($cfg["torrent_file_path"].$alias.".prio"));
+                $priolist = implode(',',array_slice($priolist,1,$priolist[0]));
+                $command .= " --priority ".$priolist;
+            }
+
+            $command .= " ".$cfg["cmd_options"]." > /dev/null &";
+            if (! array_key_exists("pythonCmd", $cfg))
+            {
+                insertSetting("pythonCmd","/usr/bin/python");
+            }
+
+            if (! array_key_exists("debugTorrents", $cfg))
+            {
+                insertSetting("debugTorrents", "0");
+            }
+
+            if (!$cfg["debugTorrents"])
+            {
+                $pyCmd = $cfg["pythonCmd"] . " -OO";
+            }else{
+                $pyCmd = $cfg["pythonCmd"];
+            }
+
+            $command = "cd " . $cfg["path"] . $the_user . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .$cfg["btphpbin"] . " " . $command;
+            $result = exec($command);
+
+            // slow down and wait for threads to kick off.
+            // otherwise on fast servers it will kill stop it before it gets a chance to run.
+            sleep(1);
+
+            $af->WriteFile();
+        }
+    }
+    AuditAction("ADMIN", "Start All Torrents");
+
+    header("location: index.php");
+}
+
 // if a file was set to be deleted then delete it
 $delfile = getRequestVar('delfile');
 if(! $delfile == '')
@@ -668,6 +830,10 @@
 {
     myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=530')
 }
+function ConfirmStopAll()
+{
+    return confirm("Stop all torrents?");
+}
 function ConfirmDelete(file)
 {
     return confirm("<?php echo _ABOUTTODELETE ?>: " + file)
@@ -833,6 +999,14 @@
     <img src="images/folder.gif" width="16" height="16" title="" border="0" align="absmiddle"><?php echo _DIRECTORYLIST ?></a>
      |
     <a href="dir.php?dir=<?php echo $cfg["user"] ?>"><img src="images/folder.gif" width="16" height="16" title="My Directory" border="0" align="absmiddle">My Directory</a>
+     |
+    <?php if(IsAdmin($cfg["user"]))
+    {
+    echo 'All: ';
+    echo '<a href="?resumeall=now"><img src="images/resumeall.png" width="16" height="16" border="0" alt="Start/Resume All Torrents" title="Start/Resume All Torrents"/></a>&nbsp;';
+    echo '<a href="?stopall=now"><img src="images/stopall.png" width="16" height="16" onClick="return ConfirmStopAll()" border="0" alt="Stop All Torrents" title="Stop All Torrents" /></a>';
+    }
+    ?>
     </font>
     </div>
     </td>

For Windows users, I'll try and get some information together as to how the patch can be applied if you don't figure it out.  TF Love
Report to moderator   Logged
rascalli
Jr. Member
**
Offline Offline

Posts: 53



View Profile Personal Message (Offline)
« Reply #20 on: 06-30-2006, 00:32:04 » Reply with quote

@overhacked .. that would be great .. as I am stuck to windows .. and just love TF   TF Love ..... but are missing some of the great linux TF features ...

Like this & Save path .. and I am not that handy with coding , but will manage I guess
Report to moderator   Logged
deadkenny
Newbie
*
Offline Offline

Posts: 13



View Profile Personal Message (Offline)
« Reply #21 on: 07-01-2006, 19:27:03 » Reply with quote

overhacked  - I tried your patch but it failed when trying to apply it (this is on the standard 2.1 install)...

patching file functions.php
Hunk #1 FAILED at 94.
1 out of 1 hunk FAILED -- saving rejects to file functions.php.rej
patching file index.php
Hunk #1 FAILED at 477.
Hunk #2 FAILED at 830.
Hunk #3 FAILED at 999.
patch unexpectedly ends in middle of line
3 out of 3 hunks FAILED -- saving rejects to file index.php.rej
patch unexpectedly ends in middle of line
Report to moderator   Logged
okamikaze
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 2



View Profile Personal Message (Offline)
« Reply #22 on: 07-03-2006, 17:05:57 » Reply with quote

Hi!

  I've manually altered the files Functions.php and Index.php, based on the diff files, and It worked as a charm, just lost statistics. As I have normally between 50-80 active torrents all the time, this was very usefull for me. Thanks a lot!!!!

I am trying to make a working diff/patch, if I manage to do It I'll post here.

[]'s

OKamikaze
Report to moderator   Logged
collectiveb
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 1



View Profile Personal Message (Offline)
« Reply #23 on: 07-05-2006, 12:43:27 » Reply with quote

Hi All

I have also got it (almost) working by editing the .php files by hand.

When I say almost working I mean it can stop and restart all the torrents by using the mouse on the icons , it also resumes from a wget command , but I`ll be damned if I can get it to stop via wget.

Both wget commands are identical except for the resumeall or stopall bit.

Does it work properly for you okamikaze ?
If so can you post your 2 x .php files somewhere or mail them to me ?

Thanks
Mark
Report to moderator   Logged
okamikaze
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 2



View Profile Personal Message (Offline)
« Reply #24 on: 07-07-2006, 08:59:09 » Reply with quote

Hi,

  I didn't try the wget stuff, but looking at the code, I found some differences between stopall and resumeall that should be analyzed.

In the diff file we have:

For Stopall:

+if (!($stopall == '') && IsAdmin($cfg["user"]) == true)
+{

and for Resumeall


if (
+    (
+        !($resumeall == '') &&
+        (
+            IsAdmin($cfg["user"]) ||
+            ($cfg["ip"] == '127.0.0.1') // Allows resuming at startup
+        )
+    ) == true
+   )
+{

As you can see, in resumeall there is a check for a localhost connection, that is not present in the stopall part. I'm just guessing, bu maybe if you change stopall to:

+if (
+    (
+        !($stopall == '') &&
+    (
+        IsAdmin($cfg["user"]) ||
+            ($cfg["ip"] == '127.0.0.1') // Allows stopping at startup
+    )
+     ) == true
+    )
+{

It may work ok. You can give it a try.

PS: Didn't test this, but looks ok.
[]'s

OKamikaze

Report to moderator   Logged
P1N3R
Newbie
*
Offline Offline

Posts: 3



View Profile Email Personal Message (Offline)
« Reply #25 on: 08-29-2006, 12:37:01 » Reply with quote

Would it be at all possible just to stop downloads that are active, and not ones that are seeding. I am on a monitored internet connection where only the downloads are metered during 8am - 6pm, so uploads are fine. Also, at the same time would it be possible to limit the overall speed of upload during a set time?

Please let me know, as to if it would work Smiley

Thanks,

P1
Report to moderator   Logged
crazee_canuck
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 1



View Profile Email Personal Message (Offline)
« Reply #26 on: 09-13-2006, 00:01:25 » Reply with quote

The following file is in patch format and should be run with patch -Np1 < patchfile in the torrentflux directory:

You actually need
Code:
patch -Np1 -F 3 < patchfile

With that command line I receive:

Code:
# patch -Np1 -F 3 < patchfile
patching file functions.php
Hunk #1 succeeded at 94 with fuzz 3.
patching file index.php
Hunk #1 succeeded at 477 with fuzz 3.
Hunk #2 succeeded at 830 with fuzz 3.
Hunk #3 succeeded at 999 with fuzz 3.

Thanks for this "hack" Wink
Report to moderator   Logged
sleeper
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 4



View Profile Email Personal Message (Offline)
« Reply #27 on: 09-17-2006, 03:45:15 » Reply with quote

thank you!
thank you!
thank you!
 TF Love
Report to moderator   Logged
Workshed
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 10



View Profile Personal Message (Offline)
« Reply #28 on: 11-21-2006, 13:36:53 » Reply with quote

Is there any way to make this hack still respect the queuing system when it resumes all of the torrents?
Report to moderator   Logged
OriginalP
Newbie
*
Offline Offline

Posts: 4




View Profile WWW Email Personal Message (Offline)
« Reply #29 on: 12-10-2006, 05:25:45 » Reply with quote

When i start/resume my torrents, also hash checking starts, freezing my system (i have a lot of torrents...)
 
I have installed "skip hash check hack" on my TF 2.2

What can i do to avoid hash checking while starting/resuming all my torrents?

Tnx
Report to moderator   Logged
gabel
Newbie
*
Offline Offline

Posts: 3



View Profile Personal Message (Offline)
« Reply #30 on: 02-28-2007, 18:48:37 » Reply with quote

The STOP Script works fine for windows, but as expected the resume all wont work in coz of the shell_exec commando.

I've tryd to get it working with the command from index.php but TF just mess up when i try to start..

Can someone give an example for windows resume all script?

I'm using TF-Win 2.0-beta.

*UPDATE*

ok - the problem theems to be bigger - it wont work coz the *.exe doesnt exist.. that means ones need to rewrite the resume function ;/ -- anybody out there who did?
« Last Edit: 02-28-2007, 19:56:24 by gabel » Report to moderator   Logged
gabel
Newbie
*
Offline Offline

Posts: 3



View Profile Personal Message (Offline)
« Reply #31 on: 02-28-2007, 23:22:35 » Reply with quote

ok i got it working --- finally.. heres the code.. it is a bit specific, coz i set hard values for some things u might get out of ur config

after all i sorrow to change debian into a win 2k3 server  Embarrassed so many tf features missing there   Cry Cry

Resume Script for TF-Win 2.0-beta (not linux):

put in after
Code:
// if a file was set to be deleted then delete it

Code:
// Did the user issue the resume all command?
if(isset($resumeall) && IsAdmin($cfg["user"]) == true)
{
 include_once("AliasFile.php");
 $dirName = $cfg["torrent_file_path"];
 //$screenStatus = shell_exec("ps x -w -w");
 $arList = array();
 $totals = array_fill(1, 5, 0);
 $file_filter = getFileFilter($cfg["file_types_array"]);
 $handle = opendir($dirName);
 $lastUser = "";

 while($entry = readdir($handle))
 {
   if ($entry != "." && $entry != "..")
   {
     if (is_dir($dirName."/".$entry))
     {
       // don''t do a thing
     }
     else
     {
       if (ereg($file_filter, $entry))
       {
         $key = filemtime($dirName."/".$entry).md5($entry);
         $arList[$key] = $entry;
       }
     }
   }
 }

 foreach($arList as $entry)
 {
   $owner = getOwner($entry);
   $alias = getAliasName($entry);
   
    $execname = 'bt'.$alias.'.exe';

// Change dir to binaries
@chdir($cfg["btbindir"]);

// Delete all the bt*.exe in the binary dir
@$temp = exec('del bt*.exe');

// Make an unique exe
@copy($cfg["btphpbin"], $execname);

// Change dir to downloadpath
@chdir($cfg["path"]);

    // Add the extra var for bittornado version
if (usingTornado()) {
$bittornadoadd = "--selector_enabled 0 ";
}
else
$bittornadoadd = "";

   
   $af = new AliasFile($cfg["torrent_file_path"].$alias.".stat", $the_user);

   if (($af->running == 0 && $af->percent_done < 100) || ($af->running == 1 && $af->percent_done == 0 && $af->time_left == ""))
   {
     $af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)

$winpath = str_replace('/','\\',$cfg["path"]);



$command = 'cd '.$winpath.$owner.' & start '.$cfg["btbindir"].$execname." Ture -1 ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile \"".$cfg["torrent_file_path"].$entry."\" --display_interval 5 --max_download_rate 1000 --max_upload_rate 8 --max_uploads 7 --minport 61000 --maxport 61300 --super_seeder 0 ".$cfg["cmd_options"];

$result = Proc_Close (Proc_Open ($command, Array (), $foo));
     //$result = exec($command);
     $af->WriteFile();
   }
 }

 AuditAction("ADMIN", "Start All Torrents");

 header("location: index.php");
}


put in after (or where u want it)
Code:
<body
following code:
Code:
<?php if(IsAdmin($cfg["user"]))
{
echo '<a href="?resumeall=now"><img src="images/start.jpg" border="0" alt="Start/Resume All Torrents"></a></center>';
 }
?>
Report to moderator   Logged
alpha2
Newbie
*
Offline Offline

Posts: 5



View Profile Personal Message (Offline)
« Reply #32 on: 04-12-2007, 11:41:28 » Reply with quote

i use tf 2.3 , can some tell me where to find the patch directroy ? ^^

i tried in tf directory but command not found :>

and the name of the file must be patchfile ? with no ending ?
Report to moderator   Logged
Pages: 1 2 3 [All] 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