Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
<?php
2
 
3
/*************************************************************
4
*  TorrentFlux PHP Torrent Manager
5
*  www.torrentflux.com
6
**************************************************************/
7
/*
8
    This file is part of TorrentFlux.
9
 
10
    TorrentFlux is free software; you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation; either version 2 of the License, or
13
    (at your option) any later version.
14
 
15
    TorrentFlux is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with TorrentFlux; if not, write to the Free Software
22
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
*/
24
 
25
class RunningTorrent
26
{
27
    var $statFile = "";
28
    var $torrentFile = "";
29
    var $filePath = "";
30
    var $torrentOwner = "";
31
    var $processId = "";
32
    var $args = "";
33
 
34
    function RunningTorrent( $psLine )
35
    {
36
        global $cfg;
37
        if (strlen($psLine) > 0)
38
        {
39
            while (strpos($psLine,"  ") > 0)
40
            {
41
                $psLine = str_replace("  ",' ',trim($psLine));
42
            }
43
 
44
            $arr = split(' ',$psLine);
45
 
46
            $this->processId = $arr[0];
47
 
48
            foreach($arr as $key =>$value)
49
            {
50
                if ($key == 0)
51
                {
52
                    $startArgs = false;
53
                }
54
                if ($value == $cfg["btphpbin"])
55
                {
56
                    $offset = 2;
57
                    if(!strpos($arr[$key+$offset],"/",1) > 0)
58
                    {
59
                        $offset += 1;
60
                    }
61
                    if(!strpos($arr[$key+$offset],"/",1) > 0)
62
                    {
63
                        $offset += 1;
64
                    }
65
                    $this->filePath = substr($arr[$key+$offset],0,strrpos($arr[$key+$offset],"/")+1);
66
                    $this->statFile = str_replace($this->filePath,'',$arr[$key+$offset]);
67
                    $this->torrentOwner = $arr[$key+$offset+1];
68
                }
69
                if ($value == '--display_interval')
70
                {
71
                    $startArgs = true;
72
                }
73
                if ($startArgs)  
74
                {  
75
                    if (!empty($value))  
76
                    {  
77
                        if (strpos($value,"-",1) > 0)  
78
                        {  
79
                            if(array_key_exists($key+1,$arr))
80
                            {
81
                                if(strpos($value,"priority") > 0)
82
                                {
83
                                    $this->args .= "\n file ".$value." set";
84
                                }
85
                                else
86
                                {
87
                                    $this->args .= $value.":".$arr[$key+1].",";  
88
                                }
89
                            }
90
                            else
91
                            {
92
                                $this->args .= "";
93
                            }
94
                        }  
95
                    }  
96
                } 
97
                if ($value == '--responsefile')
98
                {
99
                    $this->torrentFile = str_replace($this->filePath,'',$arr[$key+1]);
100
                }
101
            }
102
            $this->args = str_replace("--","",$this->args);
103
            $this->args = substr($this->args,0,strlen($this->args));
104
        }
105
    }
106
 
107
    //----------------------------------------------------------------
108
    // Private Function to put the variables into a string for writing to file
109
    function BuildAdminOutput()
110
    {
111
        $output = "<tr>";
112
        $output .= "<td><div class=\"tiny\">";
113
        $output .= $this->torrentOwner;
114
        $output .= "</div></td>";
115
        $output .= "<td><div align=center><div class=\"tiny\" align=\"left\">";
116
        $output .= str_replace(array(".stat"),"",$this->statFile);
117
        $output .= "<br>".$this->args."</div></td>";
118
        $output .= "<td><a href=\"index.php?alias_file=".$this->statFile;
119
        $output .= "&kill=".$this->processId;
120
        $output .= "&kill_torrent=".urlencode($this->torrentFile);
121
        $output .= "&return=admin\">";
122
        $output .= "<img src=\"images/kill.gif\" width=16 height=16 title=\""._FORCESTOP."\" border=0></a></td>";
123
        $output .= "</tr>";
124
        $output .= "\n";
125
 
126
        return $output;
127
 
128
    }
129
}
130
 
131
?>