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


+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  [TF21] Specific save path
« previous next »
Pages: 1 2 3 [4] Go Down Reply Notify of replies Send this topic Print
Author Topic: [TF21] Specific save path  (Read 6163 times)
ryaner
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 919





View Profile Personal Message (Offline)
« Reply #45 on: 04-30-2006, 19:59:31 » Reply with quote

You need to go into admin and enable the hack Smiley
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
coldfire
Jr. Member
**
Offline Offline

Posts: 64






View Profile Personal Message (Offline)
« Reply #46 on: 05-02-2006, 04:59:07 » Reply with quote

Some people don't read the posts, as I already said that 3 posts ago.
Guess I'll edit the first post and write that in big red chars, so perhaps people will stop asking Wink
Report to moderator   Logged

Gentoo 2005-r1, TF 2.1 final + Specific Save Path, Multi-Upload and Page Refresh Countdown Timer hacks, 120GB dedicated to TF
Scorpwanna
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 5



View Profile Email Personal Message (Offline)
« Reply #47 on: 06-20-2006, 19:09:42 » Reply with quote

I'm having the same problems as others. I've added to the mysql database, downloaded your files and copied the old ones and replaced them with yours, downloaded the multi thing. Set the Show Directory Tree to "true". When I go to add "or would the proper term be "upload" a torrent I get nothing about asking me where to save it too. Even gonig to the Run Torrent thing and typing in the path myself, it still goes to the default location for the user.
Report to moderator   Logged
klootz
Newbie
*
Offline Offline

TF Base: Linux 1.x
Posts: 16



View Profile Personal Message (Offline)
« Reply #48 on: 11-23-2006, 23:17:29 » Reply with quote

i get this error


Error

SQL query:

IINSERT INTO `tf_settings` ( `tf_key` , `tf_value` ) VALUES (
'showdirtree', '0'
), (
'maxdepth', '0'
)

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IINSERT INTO `tf_settings` ( `tf_key` , `tf_value` )
VALUES (
'showdirtree', '' at line 1

MYSQL 4.1.10
TFlux 2.1
« Last Edit: 11-23-2006, 23:20:14 by klootz » Report to moderator   Logged

| Apache 1.3.37 (Unix) | PHP 4.4.3 | MYSQL  4.1.21-standard | TF 2.1 |
TF2.1 Hacks: Multi-Upload, CHMOD, Specify Directory, Page Auto Refresh Countdown |

Solved! - 2GB limit! (http://beranger.org/index.php?article=1410) TF Love
sleeper
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 4



View Profile Email Personal Message (Offline)
« Reply #49 on: 12-08-2006, 17:48:10 » Reply with quote

hi! thnx for this great hack! i'm loving it!  TF Love

but, IMO it would be even better if the path when starting a torrent would be relative to the users download directory.

for example:
with current hack i get a path like:
    "/home/torrents/<user>/"
    "/home/torrents/<user>/opensource/"
    "/home/torrents/<user>/mp3/"
what i would like is to be like this:
   "<user>/"
   "<user>/opensource/"
   "<user>/mp3/"

any idea how i could do this?

thnx!
Report to moderator   Logged
sleeper
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 4



View Profile Email Personal Message (Offline)
« Reply #50 on: 12-11-2006, 04:27:29 » Reply with quote

just one more thing...
i've noticed that when i start a torrent from the "normal" user and set a path for it, it still goes to the default location of that user. but when i add a torrent from the normal users account, and start it from an admin account and set a path, the torrent will download to the specified path.
so there seems to be a problem with this hack and the normal user accounts.

anyone else noticed this?  Undecided
Report to moderator   Logged
coldfire
Jr. Member
**
Offline Offline

Posts: 64






View Profile Personal Message (Offline)
« Reply #51 on: 12-29-2006, 11:39:12 » Reply with quote

If I remember well my code (and it's been a long time since I last watch it), I do checks to see if user is administrator, so it should be the reason why it doesn't work for normal users
Report to moderator   Logged

Gentoo 2005-r1, TF 2.1 final + Specific Save Path, Multi-Upload and Page Refresh Countdown Timer hacks, 120GB dedicated to TF
Polde
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 3



View Profile Personal Message (Offline)
« Reply #52 on: 02-09-2007, 06:25:29 » Reply with quote

Hello,

Is this working with TorrentFlux 2.3?

Thx

Report to moderator   Logged
morsub4u
Newbie
*
Offline Offline

Posts: 40

morsub4u



View Profile Personal Message (Offline)
« Reply #53 on: 03-16-2007, 15:54:57 » Reply with quote

Yes.  This does work with TF2.3.  I have just finished installing it, and it works great.

There are a few modifications that need to be taken into consideration with the patching of the 4 PHP files.  I had to figure out where some of the code was supposed to go since the line numbers do not match any more.  This is to be expected though.

So, after all is said and done, with a little bit of work, this can be adapted to work with TF 2.3.

Thanks again for this hack!!
Report to moderator   Logged

Linux distrobution - Mandrake 10.2 (3.4.3-3mdk)
TorrentFlux version - 2.3
Python version - 2.4
PHP Version - 4.3.10
BitTornado Version - 0.3.13
Webserver software and version - Apache 2.0
mikerackhabit
Newbie
*
Offline Offline

Posts: 1



View Profile Email Personal Message (Offline)
« Reply #54 on: 05-03-2007, 19:31:58 » Reply with quote

I hacked this up to make it work in TF 2.3, here is the patch file that should be run from the torrentflux root dir, i.e.:

Code:
user@host:/var/www/torrentflux$ patch -p0 < savePatch.patch

You also need to make the mysql change mentioned in the first post of this topic

Changes I made to the original code:
- Now creates the directory you specify, or gives an error on the popup page if it couldn't create the directory
- Now works with the queue manager.  Note that the directory is created immediately, not when the torrent actually starts
- Few other cleanup things

Let me know if you run into any problems using this patch and thanks to coldfire for the original!

patch:
Code:
diff -ur html.old/admin.php html/admin.php
--- html.old/admin.php 2006-12-12 19:29:56.000000000 -0800
+++ html/admin.php 2007-05-03 21:00:29.000000000 -0700
@@ -1230,6 +1230,10 @@
             msg = msg + "* Port Range is not valid.\n";
             document.theForm.minport.focus();
         }
+ if (isNumber(document.theForm.maxdepth.value) == false)
+        {
+                    msg = msg + "* Max Depth must be a valid number.\n" ;
+        }
 
         if (msg != "")
         {
@@ -1661,6 +1665,34 @@
                 <input name="sharekill" type="Text" maxlength="3" value="<?php    echo($cfg["sharekill"]); ?>" size="3">%
             </td>
         </tr>
+    <tr>
+           <td align="left" width="350" valign="top"><strong>Show Directory Tree</strong><br>
+           Show Directory Tree when you are going to start a torrent,
+           allowing you to select the path where you want
+           to download the file(s).
+           </td>
+           <td valign="top">
+               <select name="showdirtree">
+                       <option value="1">true</option>
+                       <option value="0" <?php
+                       if (!$cfg["showdirtree"])
+                       {
+                           echo "selected";
+                       }
+                       ?>>false</option>
+               </select>
+           </td>
+        </tr>
+        <tr>
+           <td align="left" width="350" valign="top"><strong>Max Depth in Directory Tree</strong><br>
+           Set the max depth of subfolders in your user directory when
+           displaying directory tree. Set it to 0 if you want to
+           display all subfolders.
+           </td>
+           <td valign="top">
+               <input name="maxdepth" type="Text" maxlength="1" value="<?php   echo ($cfg["maxdepth"]); ?>" size="1">
+           </td>
+        </tr>
         </table>
         <br>
         <input type="Submit" value="Update Settings">
diff -ur html.old/functions.php html/functions.php
--- html.old/functions.php 2006-12-11 21:07:57.000000000 -0800
+++ html/functions.php 2007-05-03 21:00:30.000000000 -0700
@@ -1922,10 +1922,11 @@
 }
 
 //**************************************************************************
-function writeQinfo($fileName,$command)
+function writeQinfo($fileName,$command,$savepath)
 {
     $fp = fopen($fileName.".Qinfo","w");
-    fwrite($fp, $command);
+    fwrite($fp, $command."\n");
+    fwrite($fp, $savepath);
     fflush($fp);
     fclose($fp);
 }
@@ -2188,7 +2189,8 @@
 
     if (checkQManager() == 0)
     {
-    $cmd1 = "cd " . $cfg["path"] . "TFQUSERNAME";
+      //$cmd1 = "cd " . $cfg["path"] . "TFQUSERNAME";
+    $cmd1 = "cd " . "TFQSAVEPATH";
 
     if (! array_key_exists("pythonCmd",$cfg))
     {
@@ -2200,14 +2202,14 @@
         insertSetting("debugTorrents",false);
     }
 
-        if (!$cfg["debugTorrents"])
-        {
-            $pyCmd = $cfg["pythonCmd"] . " -OO";
-        }
-        else
-        {
-            $pyCmd = $cfg["pythonCmd"];
-        }
+    if (!$cfg["debugTorrents"])
+    {
+         $pyCmd = $cfg["pythonCmd"] . " -OO";
+    }
+    else
+    {
+         $pyCmd = $cfg["pythonCmd"];
+    }
 
         $btphp = "'" . $cmd1. "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .$cfg["btphpbin"] . " '";
         $command = $pyCmd . " " . $cfg["tfQManager"] . " ".$cfg["torrent_file_path"]."queue/ ".escapeshellarg($maxServerThreads)." ".escapeshellarg($maxUserThreads)." ".escapeshellarg($sleepInterval)." ".$btphp." > /dev/null &";
@@ -2668,4 +2670,76 @@
         }
     }
 }
+
+function dirTree2($dir, $maxdepth)
+{
+        echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+        if (is_numeric ($maxdepth))
+        {
+                if ($maxdepth == 0)
+                {
+                        $last = exec ("du ".$dir." | cut -f 2- | sort", $retval) ;
+                        for ($i = 1; $i < (count ($retval) - 1); $i++)
+                        {
+                                echo "<option value=\"".$retval[$i]."\">".$retval[$i]."</option>\n" ;
+                        }
+                }
+                else if ($maxdepth > 0)
+                {
+                        $last = exec ("du --max-depth=".$maxdepth." ".$dir." | cut -f 2- | sort", $retval) ;
+                        for ($i = 1; $i < (count ($retval) - 1); $i++)
+                        {
+                                echo "<option value=\"".$retval[$i]."\">".$retval[$i]."</option>\n" ;
+                        }
+                }
+                else
+                {
+                        echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+                }
+        }
+        else
+        {
+                echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+        }
+        return $retval ;
+}
+
+//*********************************************************
+// ensureDownloadDir()
+function ensureDownloadDir($path)
+{
+  $plen = strlen($path)-1;
+  $lpos = strrpos($path,"/");
+  if ($lpos === false)
+    return false;
+  if($lpos == $plen) {
+    $path = substr($path,0,$plen);
+    $lpos = strrpos($path,"/");
+  }
+  $parent_dir = substr($path,0,$lpos);
+  if (!is_dir($path))
+    {
+      if (is_writable($parent_dir))
+ {
+   mkdir($path, 0777);
+   return true;
+ }
+      else if (is_dir($parent_dir)) // is a dir but can't write to it
+ {
+   return false;
+ }
+      else
+ {
+   if (ensureDownloadDir($parent_dir))
+     {
+       mkdir($path, 0777);
+       return true;
+     }
+   else
+     return false;
+ }
+    }
+  return true;
+}
+
 ?>
diff -ur html.old/index.php html/index.php
--- html.old/index.php 2006-12-11 21:48:54.000000000 -0800
+++ html/index.php 2007-05-03 21:00:30.000000000 -0700
@@ -198,29 +198,39 @@
         $alias = getAliasName($torrent);
         $owner = getOwner($torrent);
 
+    $savepath = getRequestVar('savepath') ;
+    if (empty($savepath))
+    {
+          $savepath = $cfg['path'].$owner ;
+    }
+
         // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
         // This is to help manage user downloads by their user names
         //if the user's path doesnt exist, create it
-        if (!is_dir($cfg["path"]."/".$owner))
-        {
-            if (is_writable($cfg["path"]))
-            {
-                mkdir($cfg["path"]."/".$owner, 0777);
-            }
-            else
-            {
-                AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable.");
-                if (IsAdmin())
-                {
-                    header("location: admin.php?op=configSettings");
-                    exit();
-                }
-                else
-                {
-                    $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not writable) -- please contact an admin.<br>";
-                }
-            }
-        }
+        if (!ensureDownloadDir($savepath))
+ {
+   AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable.");
+   if ($cfg['path'].$owner == $savepath)
+   {
+     if (IsAdmin())
+     {
+       header("location: admin.php?op=configSettings");
+       exit();
+     }
+     else
+     {
+       $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not writable) -- please contact an admin.<br>";
+       header("location: startpop.php?torrent=".$torrent."&messages=".$messages);
+       exit();
+     }
+   }
+   else
+   {
+     $messages .= "<b>Error</b> -- ".$savepath." is not writable<br>";    
+     header("location: startpop.php?torrent=".$torrent."&messages=".$messages);
+     exit();
+   }
+ }
 
         // create AliasFile object and write out the stat file
         $af = new AliasFile($cfg["torrent_file_path"].$alias.".stat", $owner);
@@ -278,7 +288,8 @@
                     $pyCmd = escapeshellarg($cfg["pythonCmd"]);
                 }
 
-                $command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
+                //$command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
+ $command = "cd " . $savepath . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
             }
 
         }
@@ -295,7 +306,7 @@
 
         if($af->running == "3")
         {
-            writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command);
+            writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command,$savepath);
             AuditAction($cfg["constants"]["queued_torrent"], $torrent."<br>Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest);
             AuditAction($cfg["constants"]["queued_torrent"], $command);
         }
@@ -677,7 +688,7 @@
 }
 function StartTorrent(name_file)
 {
-    myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=530')
+    myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=<?php echo ($cfg["showdirtree"]?'670':'530')?>')
 }
 function ConfirmDelete(file)
 {
diff -ur html.old/setpriority.php html/setpriority.php
--- html.old/setpriority.php 2006-10-19 06:54:26.000000000 -0700
+++ html/setpriority.php 2007-05-03 21:00:30.000000000 -0700
@@ -53,8 +53,9 @@
         $fileName = $cfg["torrent_file_path"].$alias.".prio";
 
         $result = array();
-        $files = array();
-        $files = array_filter(getRequestVar('files'),"getFile");
+        $files = getRequestVar('files');
+ if ($files != '')
+   $files = array_filter($files,"getFile");
 
         // if there are files to get then process and create a prio file.
         if (count($files) > 0)
diff -ur html.old/startpop.php html/startpop.php
--- html.old/startpop.php 2006-12-11 19:29:46.000000000 -0800
+++ html/startpop.php 2007-05-03 21:00:30.000000000 -0700
@@ -163,6 +163,19 @@
 <body bgcolor="<?php echo $cfg["body_data_bg"]; ?>">
 
 <div align="center">
+<?php
+$messages = $_REQUEST["messages"];
+if ($messages != "")
+{
+?>
+<table border="1" cellpadding="10" bgcolor="#ff9b9b">
+<tr>
+    <td><div align="center"><?php echo $messages ?></div></td>
+</tr>
+</table><br><br>
+<?php
+}
+?>
 <strong><?php echo $displayName ?></strong><br>
 <table width="98%" border="0" cellpadding="0" cellspacing="0">
 <tr><form name="theForm" target="_parent" action="index.php" method="POST">
@@ -233,7 +246,29 @@
         <tr>
             <td colspan="4" align="center"><div ID="sharekiller" align="center" style="visibility:hidden;">Keep seeding until Sharing is: <input type="Text" name="sharekill" maxlength="4" size="4" value="<?php echo $cfg["sharekill"]; ?>">%<font class="tiny">  (0% will keep seeding)</font>&nbsp;</div></td>
         </tr>
+        <?php
+        if ($cfg["showdirtree"])
+        { ?>
+ <tr>
+ <td colspan="4" align="center">
+        <table>
+        <tr>
+            <td aligh="right">Save Path:</td>
+            <td colspan="3"><input type="text" name="savepath" size="45" value="<?php echo $cfg["path"].getOwner($torrent).'/' ;?>"></td>
+        </tr>
+        <tr>
+            <td align="right">Or use this path:</td>
+            <td colspan="3">
+       <select style="width:300px;" onChange="savepath.value= this.options[this.selectedIndex].value">
+         <?php $arDirTree = dirTree2 ($cfg["path"].getOwner($torrent).'/', $cfg["maxdepth"]) ; ?>
+       </select>
+     </td>
+        </tr>
+        </table>
+        <?php } ?>
         </table>
+ </td>
+ </tr>
         <br>
         &nbsp;&nbsp;&nbsp;Torrent Meta Data / Priority Selection:
     </td>
diff -ur html.old/TF_BitTornado/tfQManager.py html/TF_BitTornado/tfQManager.py
--- html.old/TF_BitTornado/tfQManager.py 2006-11-15 20:23:45.000000000 -0800
+++ html/TF_BitTornado/tfQManager.py 2007-05-03 21:00:30.000000000 -0700
@@ -10,7 +10,7 @@
 from time import time, strftime
 import thread, threading, time
 
-DEBUG = False
+DEBUG = True
 
 if __debug__: LOGFILE=open(argv[1]+"tfQManager.log","w")
 
@@ -113,6 +113,7 @@
 
                                             cmdToRun = getCommandToRun(currentFile)
                                             #if __debug__: traceMsg(" Cmd :" + cmdToRun)
+                                            dirToRunIn = getDirToRunIn(currentFile)
 
                                             if (re.search(currentUser,cmdToRun) == 0):
                                                 if __debug__: traceMsg("Incorrect User found in Cmd")
@@ -124,8 +125,9 @@
                                                 cmdToRun = execPath + cmdToRun
 
                                             cmdToRun = cmdToRun.replace('TFQUSERNAME', currentUser)
-                                            #if __debug__: traceMsg(" Cmd :" + cmdToRun)
-
+                                            cmdToRun = cmdToRun.replace('TFQSAVEPATH', dirToRunIn)
+                                            if __debug__: traceMsg(" Cmd :" + cmdToRun)
+                                               
                                             if cmdToRun != "":
                                                 #PrepStatsFile
                                                 updateStats(statsFile, '1')
@@ -346,6 +348,24 @@
     
     return cmdToExec
 
+def getDirToRunIn(currentFile):
+   
+    if __debug__: traceMsg("->getDirToRunIn (" + currentFile + ")")
+
+    #Open the File and return the Dir.
+    dirToRunIn = ""
+
+    try:
+        f=open(currentFile,'r')
+        f.readline()
+        dirToRunIn = f.readline()
+        f.close
+   
+    except:
+        dirToRunIn = ""
+   
+    return dirToRunIn
+
 
 def getFileList(fDirectory):
Report to moderator   Logged
firepong
Newbie
*
Offline Offline

Posts: 9



View Profile Personal Message (Offline)
« Reply #55 on: 05-16-2007, 20:32:52 » Reply with quote

I hacked this up to make it work in TF 2.3, here is the patch file that should be run from the torrentflux root dir, i.e.:

Code:
user@host:/var/www/torrentflux$ patch -p0 < savePatch.patch

You also need to make the mysql change mentioned in the first post of this topic

Changes I made to the original code:
- Now creates the directory you specify, or gives an error on the popup page if it couldn't create the directory
- Now works with the queue manager.  Note that the directory is created immediately, not when the torrent actually starts
- Few other cleanup things

Let me know if you run into any problems using this patch and thanks to coldfire for the original!

patch:
Code:
diff -ur html.old/admin.php html/admin.php
--- html.old/admin.php 2006-12-12 19:29:56.000000000 -0800
+++ html/admin.php 2007-05-03 21:00:29.000000000 -0700
@@ -1230,6 +1230,10 @@
             msg = msg + "* Port Range is not valid.\n";
             document.theForm.minport.focus();
         }
+ if (isNumber(document.theForm.maxdepth.value) == false)
+        {
+                    msg = msg + "* Max Depth must be a valid number.\n" ;
+        }
 
         if (msg != "")
         {
@@ -1661,6 +1665,34 @@
                 <input name="sharekill" type="Text" maxlength="3" value="<?php    echo($cfg["sharekill"]); ?>" size="3">%
             </td>
         </tr>
+    <tr>
+           <td align="left" width="350" valign="top"><strong>Show Directory Tree</strong><br>
+           Show Directory Tree when you are going to start a torrent,
+           allowing you to select the path where you want
+           to download the file(s).
+           </td>
+           <td valign="top">
+               <select name="showdirtree">
+                       <option value="1">true</option>
+                       <option value="0" <?php
+                       if (!$cfg["showdirtree"])
+                       {
+                           echo "selected";
+                       }
+                       ?>>false</option>
+               </select>
+           </td>
+        </tr>
+        <tr>
+           <td align="left" width="350" valign="top"><strong>Max Depth in Directory Tree</strong><br>
+           Set the max depth of subfolders in your user directory when
+           displaying directory tree. Set it to 0 if you want to
+           display all subfolders.
+           </td>
+           <td valign="top">
+               <input name="maxdepth" type="Text" maxlength="1" value="<?php   echo ($cfg["maxdepth"]); ?>" size="1">
+           </td>
+        </tr>
         </table>
         <br>
         <input type="Submit" value="Update Settings">
diff -ur html.old/functions.php html/functions.php
--- html.old/functions.php 2006-12-11 21:07:57.000000000 -0800
+++ html/functions.php 2007-05-03 21:00:30.000000000 -0700
@@ -1922,10 +1922,11 @@
 }
 
 //**************************************************************************
-function writeQinfo($fileName,$command)
+function writeQinfo($fileName,$command,$savepath)
 {
     $fp = fopen($fileName.".Qinfo","w");
-    fwrite($fp, $command);
+    fwrite($fp, $command."\n");
+    fwrite($fp, $savepath);
     fflush($fp);
     fclose($fp);
 }
@@ -2188,7 +2189,8 @@
 
     if (checkQManager() == 0)
     {
-    $cmd1 = "cd " . $cfg["path"] . "TFQUSERNAME";
+      //$cmd1 = "cd " . $cfg["path"] . "TFQUSERNAME";
+    $cmd1 = "cd " . "TFQSAVEPATH";
 
     if (! array_key_exists("pythonCmd",$cfg))
     {
@@ -2200,14 +2202,14 @@
         insertSetting("debugTorrents",false);
     }
 
-        if (!$cfg["debugTorrents"])
-        {
-            $pyCmd = $cfg["pythonCmd"] . " -OO";
-        }
-        else
-        {
-            $pyCmd = $cfg["pythonCmd"];
-        }
+    if (!$cfg["debugTorrents"])
+    {
+         $pyCmd = $cfg["pythonCmd"] . " -OO";
+    }
+    else
+    {
+         $pyCmd = $cfg["pythonCmd"];
+    }
 
         $btphp = "'" . $cmd1. "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .$cfg["btphpbin"] . " '";
         $command = $pyCmd . " " . $cfg["tfQManager"] . " ".$cfg["torrent_file_path"]."queue/ ".escapeshellarg($maxServerThreads)." ".escapeshellarg($maxUserThreads)." ".escapeshellarg($sleepInterval)." ".$btphp." > /dev/null &";
@@ -2668,4 +2670,76 @@
         }
     }
 }
+
+function dirTree2($dir, $maxdepth)
+{
+        echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+        if (is_numeric ($maxdepth))
+        {
+                if ($maxdepth == 0)
+                {
+                        $last = exec ("du ".$dir." | cut -f 2- | sort", $retval) ;
+                        for ($i = 1; $i < (count ($retval) - 1); $i++)
+                        {
+                                echo "<option value=\"".$retval[$i]."\">".$retval[$i]."</option>\n" ;
+                        }
+                }
+                else if ($maxdepth > 0)
+                {
+                        $last = exec ("du --max-depth=".$maxdepth." ".$dir." | cut -f 2- | sort", $retval) ;
+                        for ($i = 1; $i < (count ($retval) - 1); $i++)
+                        {
+                                echo "<option value=\"".$retval[$i]."\">".$retval[$i]."</option>\n" ;
+                        }
+                }
+                else
+                {
+                        echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+                }
+        }
+        else
+        {
+                echo "<option value=\"".$dir."\">".$dir."</option>\n" ;
+        }
+        return $retval ;
+}
+
+//*********************************************************
+// ensureDownloadDir()
+function ensureDownloadDir($path)
+{
+  $plen = strlen($path)-1;
+  $lpos = strrpos($path,"/");
+  if ($lpos === false)
+    return false;
+  if($lpos == $plen) {
+    $path = substr($path,0,$plen);
+    $lpos = strrpos($path,"/");
+  }
+  $parent_dir = substr($path,0,$lpos);
+  if (!is_dir($path))
+    {
+      if (is_writable($parent_dir))
+ {
+   mkdir($path, 0777);
+   return true;
+ }
+      else if (is_dir($parent_dir)) // is a dir but can't write to it
+ {
+   return false;
+ }
+      else
+ {
+   if (ensureDownloadDir($parent_dir))
+     {
+       mkdir($path, 0777);
+       return true;
+     }
+   else
+     return false;
+ }
+    }
+  return true;
+}
+
 ?>
diff -ur html.old/index.php html/index.php
--- html.old/index.php 2006-12-11 21:48:54.000000000 -0800
+++ html/index.php 2007-05-03 21:00:30.000000000 -0700
@@ -198,29 +198,39 @@
         $alias = getAliasName($torrent);
         $owner = getOwner($torrent);
 
+    $savepath = getRequestVar('savepath') ;
+    if (empty($savepath))
+    {
+          $savepath = $cfg['path'].$owner ;
+    }
+
         // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
         // This is to help manage user downloads by their user names
         //if the user's path doesnt exist, create it
-        if (!is_dir($cfg["path"]."/".$owner))
-        {
-            if (is_writable($cfg["path"]))
-            {
-                mkdir($cfg["path"]."/".$owner, 0777);
-            }
-            else
-            {
-                AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable.");
-                if (IsAdmin())
-                {
-                    header("location: admin.php?op=configSettings");
-                    exit();
-                }
-                else
-                {
-                    $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not writable) -- please contact an admin.<br>";
-                }
-            }
-        }
+        if (!ensureDownloadDir($savepath))
+ {
+   AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable.");
+   if ($cfg['path'].$owner == $savepath)
+   {
+     if (IsAdmin())
+     {
+       header("location: admin.php?op=configSettings");
+       exit();
+     }
+     else
+     {
+       $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not writable) -- please contact an admin.<br>";
+       header("location: startpop.php?torrent=".$torrent."&messages=".$messages);
+       exit();
+     }
+   }
+   else
+   {
+     $messages .= "<b>Error</b> -- ".$savepath." is not writable<br>";    
+     header("location: startpop.php?torrent=".$torrent."&messages=".$messages);
+     exit();
+   }
+ }
 
         // create AliasFile object and write out the stat file
         $af = new AliasFile($cfg["torrent_file_path"].$alias.".stat", $owner);
@@ -278,7 +288,8 @@
                     $pyCmd = escapeshellarg($cfg["pythonCmd"]);
                 }
 
-                $command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
+                //$command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
+ $command = "cd " . $savepath . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command;
             }
 
         }
@@ -295,7 +306,7 @@
 
         if($af->running == "3")
         {
-            writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command);
+            writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command,$savepath);
             AuditAction($cfg["constants"]["queued_torrent"], $torrent."<br>Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest);
             AuditAction($cfg["constants"]["queued_torrent"], $command);
         }
@@ -677,7 +688,7 @@
 }
 function StartTorrent(name_file)
 {
-    myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=530')
+    myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=<?php echo ($cfg["showdirtree"]?'670':'530')?>')
 }
 function ConfirmDelete(file)
 {
diff -ur html.old/setpriority.php html/setpriority.php
--- html.old/setpriority.php 2006-10-19 06:54:26.000000000 -0700
+++ html/setpriority.php 2007-05-03 21:00:30.000000000 -0700
@@ -53,8 +53,9 @@
         $fileName = $cfg["torrent_file_path"].$alias.".prio";
 
         $result = array();
-        $files = array();
-        $files = array_filter(getRequestVar('files'),"getFile");
+        $files = getRequestVar('files');
+ if ($files != '')
+   $files = array_filter($files,"getFile");
 
         // if there are files to get then process and create a prio file.
         if (count($files) > 0)
diff -ur html.old/startpop.php html/startpop.php
--- html.old/startpop.php 2006-12-11 19:29:46.000000000 -0800
+++ html/startpop.php 2007-05-03 21:00:30.000000000 -0700
@@ -163,6 +163,19 @@
 <body bgcolor="<?php echo $cfg["body_data_bg"]; ?>">
 
 <div align="center">
+<?php
+$messages = $_REQUEST["messages"];
+if ($messages != "")
+{
+?>
+<table border="1" cellpadding="10" bgcolor="#ff9b9b">
+<tr>
+    <td><div align="center"><?php echo $messages ?></div></td>
+</tr>
+</table><br><br>
+<?php
+}
+?>
 <strong><?php echo $displayName ?></strong><br>
 <table width="98%" border="0" cellpadding="0" cellspacing="0">
 <tr><form name="theForm" target="_parent" action="index.php" method="POST">
@@ -233,7 +246,29 @@
         <tr>
             <td colspan="4" align="center"><div ID="sharekiller" align="center" style="visibility:hidden;">Keep seeding until Sharing is: <input type="Text" name="sharekill" maxlength="4" size="4" value="<?php echo $cfg["sharekill"]; ?>">%<font class="tiny">  (0% will keep seeding)</font>&nbsp;</div></td>
         </tr>
+        <?php
+        if ($cfg["showdirtree"])
+        { ?>
+ <tr>
+ <td colspan="4" align="center">
+        <table>
+        <tr>
+            <td aligh="right">Save Path:</td>
+            <td colspan="3"><input type="text" name="savepath" size="45" value="<?php echo $cfg["path"].getOwner($torrent).'/' ;?>"></td>
+        </tr>
+        <tr>
+            <td align="right">Or use this path:</td>
+            <td colspan="3">
+       <select style="width:300px;" onChange="savepath.value= this.options[this.selectedIndex].value">
+         <?php $arDirTree = dirTree2 ($cfg["path"].getOwner($torrent).'/', $cfg["maxdepth"]) ; ?>
+       </select>
+     </td>
+        </tr>
+        </table>
+        <?php } ?>
         </table>
+ </td>
+ </tr>
         <br>
         &nbsp;&nbsp;&nbsp;Torrent Meta Data / Priority Selection:
     </td>
diff -ur html.old/TF_BitTornado/tfQManager.py html/TF_BitTornado/tfQManager.py
--- html.old/TF_BitTornado/tfQManager.py 2006-11-15 20:23:45.000000000 -0800
+++ html/TF_BitTornado/tfQManager.py 2007-05-03 21:00:30.000000000 -0700
@@ -10,7 +10,7 @@
 from time import time, strftime
 import thread, threading, time
 
-DEBUG = False
+DEBUG = True
 
 if __debug__: LOGFILE=open(argv[1]+"tfQManager.log","w")
 
@@ -113,6 +113,7 @@
 
                                             cmdToRun = getCommandToRun(currentFile)
                                             #if __debug__: traceMsg(" Cmd :" + cmdToRun)
+                                            dirToRunIn = getDirToRunIn(currentFile)
 
                                             if (re.search(currentUser,cmdToRun) == 0):
                                                 if __debug__: traceMsg("Incorrect User found in Cmd")
@@ -124,8 +125,9 @@
                                                 cmdToRun = execPath + cmdToRun
 
                                             cmdToRun = cmdToRun.replace('TFQUSERNAME', currentUser)
-                                            #if __debug__: traceMsg(" Cmd :" + cmdToRun)
-
+                                            cmdToRun = cmdToRun.replace('TFQSAVEPATH', dirToRunIn)
+                                            if __debug__: traceMsg(" Cmd :" + cmdToRun)
+                                               
                                             if cmdToRun != "":
                                                 #PrepStatsFile
                                                 updateStats(statsFile, '1')
@@ -346,6 +348,24 @@
     
     return cmdToExec
 
+def getDirToRunIn(currentFile):
+   
+    if __debug__: traceMsg("->getDirToRunIn (" + currentFile + ")")
+
+    #Open the File and return the Dir.
+    dirToRunIn = ""
+
+    try:
+        f=open(currentFile,'r')
+        f.readline()
+        dirToRunIn = f.readline()
+        f.close
+   
+    except:
+        dirToRunIn = ""
+   
+    return dirToRunIn
+
 
 def getFileList(fDirectory):

Is there any way you can post where those go. I have no idea what that patch file is for so...
What I mean by where they go is post where the files go before and after what part of the code in each of the files. I tryed to get it to work myself with torrentflux, but it never would work. It would get close, but would screw up and you couldnt start a torrent.
Report to moderator   Logged
Searcher
Full Member
***
Offline Offline

Posts: 131

114552

View Profile WWW Personal Message (Offline)
« Reply #56 on: 05-17-2007, 08:21:12 » Reply with quote

the command is
Code:
patch -p0 < savePatch.patch

and the affected files are admin.php, index.php, setpriority.php, starpop.php and TF_BitTornado/tfQManager.py

while the patch expects you to have these files under ./html/ folder from where you run the patch file (oh yeah, someone creating the patch hasn't thought about others Wink

So create a folder html in the directory where your patch resides, copy the mentioned files there (i hope i didn't miss any) and run the command. Then if you see a success copy them back to TF

OR

manually edit the patch file, remove the /html/ part and execute it in your TF root folder..
Report to moderator   Logged
patt2k
Newbie
*
Offline Offline

Posts: 9



View Profile Email Personal Message (Offline)
« Reply #57 on: 05-19-2007, 19:02:13 » Reply with quote

I cant install it on newest version of tl ?;//

help plzz i need this thing
Report to moderator   Logged
Pages: 1 2 3 [4] 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