Changeset 51

Show
Ignore:
Timestamp:
05/03/08 10:32:31 (2 years ago)
Author:
royger
Message:

* New xmlrpc factory, 2 classes added:

  • torrent.cls.php
  • multicall.cls.php

Every torrent creates a torrent object, which contains the functions for calling all the necessary methods. Also a transparent cache was added.

* Cleaned most of the classes of unnecessary php code.
* Command interface finished, most actions are done through AJAX calls using the Commands.cls.php class. Fixes #16.
* This build is tested to work with Mozilla Firefox 2.0.0.14 and Safari 3.1.1 (5525.18) using Mac OS X. Same results expected (although not tested) under Windows.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wtorrent/cls/rtorrent.cls.php

    r49 r51  
    2121{ 
    2222        protected $client; 
     23        protected $multicall; 
     24        protected $torrents; 
     25        protected $data; 
     26         
    2327        private $menu = array('Main' => 'ListT', 
    2428                                                'Add Torrent' => 'AddT', 
     
    3640    /////////////////////////////////// C O N S T R U C T O R A S  Y  D E S T R U C T O R A /////////////////////////////////// 
    3741 
    38     public function __construct( ) 
    39     { 
    40         parent::__construct( ); 
    41         if(isset($this->_request['logout'])) $this->logout(); 
    42         if(isset($this->_request['user_login'])) $this->login($this->_request['userf'], $this->_request['passwdf']); 
    43     } 
    44  
    45     protected function construct( ){} 
    46  
    47          
     42        public function __construct( ) 
     43        { 
     44                parent::__construct( ); 
     45                if(isset($this->_request['logout'])) $this->logout(); 
     46                if(isset($this->_request['user_login'])) $this->login($this->_request['userf'], $this->_request['passwdf']); 
     47        } 
     48        private function checkError($result) 
     49        { 
     50                if($result->errno == '0') 
     51                        return true; 
     52                else 
     53                        return false; 
     54        } 
     55        protected function construct( ){} 
    4856 
    4957        public function registrado( ) 
    5058        { 
    51                 return !is_null( $this->_sesion->id_user ); 
     59                       return !is_null( $this->_sesion->id_user ); 
    5260        } 
    5361        public function compLogin($user, $passwd) 
    54    
     62       
    5563                $passwd = md5($passwd); 
    5664                $sql = "select id from tor_passwd where user = '$user' and passwd = '$passwd'"; 
     
    5967                { 
    6068                        $num = $result->numRows(); 
    61                  
     69 
    6270                        if($num > 0) 
    6371                                $return = $result->current(); 
    6472                        else 
    6573                                $return = false; 
    66                  
    67                 } else { 
    68                                 $return = false; 
    69                 } 
    70                 return $return; 
    71     } 
     74                } else { 
     75                        $return = false; 
     76                } 
     77                return $return; 
     78        } 
    7279        public function getUser( ) 
    7380        { 
    7481                return $this->_sesion->user; 
    7582        } 
    76  
    7783        public function getIdUser( ) 
    7884        { 
     
    108114                return $return; 
    109115        } 
    110          
    111  
    112116        public function login( $user, $password ) 
    113117        {        
     
    137141                } 
    138142        } 
     143        private function getPrivate() 
     144        { 
     145                $tt = array(); 
     146                $sql = "select hash, user from torrents"; 
     147                $result = $this->_db->query($sql); 
     148                $torr = $result->fetchAll(); 
     149                foreach($torr as $torrent) 
     150                        $tt[$torrent['hash']] = $torrent['user']; 
     151                         
     152                return $tt; 
     153        } 
    139154        public function setClient() 
    140155        { 
    141156                $this->client = new xmlrpc_client(RT_DIR, RT_HOST, RT_PORT); 
    142                 //$this->client->setDebug(2); 
     157                $this->multicall = new multicall($this->client, $this->data); 
     158 
    143159                if(RT_AUTH) 
    144160                        $this->client->setCredentials(RT_USER, RT_PASSWD); 
    145         $this->client->return_type = 'phpvals'; 
    146         $this->client->no_multicall = NO_MULTICALL; 
     161     
     162                $this->client->return_type = 'phpvals'; 
     163    $this->client->no_multicall = NO_MULTICALL; 
    147164         
    148        $message = new xmlrpcmsg("system.pid"); 
    149                 $result = $this->client->send($message); 
    150                 // print_r($result); 
     165    $message = new xmlrpcmsg("system.pid"); 
     166                $result = $this->client->send($message); 
     167 
    151168                if($result->errno != 0) 
    152169                { 
    153170                        $this->addMessage($this->_str['err_conn']); 
    154171                        return false; 
    155                 } else 
     172                } else { 
     173                        $this->setTorrents(); 
    156174                        return true; 
     175                } 
     176        } 
     177        /* Initializes torrent objects */ 
     178        protected function setTorrents() { 
     179                $message = new xmlrpcmsg("d.multicall", array(new xmlrpcval('default', 'string'),new xmlrpcval('d.get_hash=', 'string'))); 
     180                $result = $this->client->send($message); 
     181                if(is_array($result->val)) 
     182                { 
     183                        foreach($result->val as $hash) 
     184                        { 
     185                                $this->torrents[$hash[0]] = new torrent($hash[0], $this->client, $this->multicall, $this->data[$hash[0]]); 
     186                        } 
     187                        /* Mark torrents as public/private and assign owners */ 
     188                        $private_torrents = $this->getPrivate(); 
     189                        $hashes = $this->getHashes(); 
     190                        foreach($hashes as $hash) 
     191                        { 
     192                                if(array_key_exists($hash, $private_torrents)) 
     193                                { 
     194                                        $this->data[$hash]['private'] = true; 
     195                                        $this->data[$hash]['owner'] = $private_torrents[$hash]; 
     196                                } else { 
     197                                        $this->data[$hash]['private'] = false; 
     198                                        $this->data[$hash]['owner'] = 0; 
     199                                } 
     200                        } 
     201                } 
     202        } 
     203        protected function getHashes() 
     204        { 
     205                return array_keys($this->torrents); 
     206        } 
     207        protected function erase_db($hash) 
     208        { 
     209                $sql = "delete from torrents where hash = '" . $hash . "'"; 
     210                $this->_db->query($sql); 
    157211        } 
    158212        protected function setPerm() 
    159213        { 
    160214                $this->admin = false; 
     215        } 
     216        /* xmlrpc rtorrent admin functions (not torrent related ) */ 
     217        protected function set_download_rate($limit) 
     218        { 
     219                $message = new xmlrpcmsg("set_download_rate", array(new xmlrpcval($limit, 'int'))); 
     220                $result = $this->client->send($message); 
     221                 
     222                if($this->checkError($result)) 
     223                { 
     224                        $return = true; 
     225                } else { 
     226                        $return = false; 
     227                } 
     228                return $return; 
     229        } 
     230        protected function set_upload_rate($limit) 
     231        { 
     232                $message = new xmlrpcmsg("set_download_rate", array(new xmlrpcval($limit, 'int'))); 
     233                $result = $this->client->send($message); 
     234                 
     235                if($this->checkError($result)) 
     236                { 
     237                        $return = true; 
     238                } else { 
     239                        $return = false; 
     240                } 
     241                return $return; 
    161242        } 
    162243} 
  • trunk/wtorrent/home/cls/Commands.cls.php

    r36 r51  
    1818class Commands extends rtorrent 
    1919{ 
    20     /////////////////////////////////// C O N S T R U C T O R A S  Y  D E S T R U C T O R A /////////////////////////////////// 
     20        public function construct() 
     21        { 
     22                if(isset($this->_request['command']) && $this->_request['command'] != '' && isset($this->_request['param']) && $this->_request['param'] != '')  
     23                { 
     24                        if(!$this->setClient()) 
     25                                return false; 
    2126 
    22     public function construct() 
    23         { 
    24         if(isset($this->_request['command']) && $this->_request['command'] != '' && isset($this->_request['param']) && $this->_request['param'] != '')  
    25         { 
    26                 if(!$this->setClient()) 
    27                         return false; 
    28                          
    29                 switch($this->_request['command']) 
    30                 { 
    31                         case 'start': 
    32                                 $this->start($this->_request['param']); 
    33                                 break; 
    34                         case 'stop': 
    35                                 $this->stop($this->_request['param']); 
    36                                 break; 
    37                         case 'close': 
    38                                 $this->close($this->_request['param']); 
    39                                 break; 
    40                         case 'erase': 
    41                                 $this->erase($this->_request['param']); 
    42                                 break; 
    43                         case 'chash': 
    44                                 $this->chash($this->_request['param']); 
    45                                 break; 
    46                         case 'set_down_limit': 
    47                                 $this->setDownLimit($this->_request['param']); 
    48                                 break; 
    49                         case 'set_up_limit': 
    50                                 $this->setUploadLimit($this->_request['param']); 
    51                                 break; 
    52                         case 'files': 
    53                                 $this->changeFiles($this->_request['param'], $this->_request['param1'], $this->_request['param2']); 
    54                                 break; 
    55                         case 'info': 
    56                                 $this->changePriority($this->_request['param'], $this->_request['param1']); 
    57                                 break; 
    58                         case 'trackers': 
    59                                 $this->changeTrackers($this->_request['param'], $this->_request['param1'], $this->_request['param2']); 
    60                                 break; 
    61                         default: 
    62                                 $this->addMessage($this->_str['command_error']); 
    63                                 break; 
    64                                  
    65                 } 
    66         } else { 
    67                 $this->addMessage($this->_str['command_error']); 
    68         } 
     27                        switch($this->_request['command']) 
     28                        { 
     29                                case 'start': 
     30                                $this->start($this->_request['param']); 
     31                                break; 
     32                                case 'stop': 
     33                                $this->stop($this->_request['param']); 
     34                                break; 
     35                                case 'close': 
     36                                $this->close($this->_request['param']); 
     37                                break; 
     38                                case 'erase': 
     39                                $this->erase($this->_request['param']); 
     40                                break; 
     41                                case 'chash': 
     42                                $this->chash($this->_request['param']); 
     43                                break; 
     44                                case 'set_down_limit': 
     45                                $this->setDownLimit($this->_request['param']); 
     46                                break; 
     47                                case 'set_up_limit': 
     48                                $this->setUploadLimit($this->_request['param']); 
     49                                break; 
     50                                case 'files': 
     51                                $this->changeFiles($this->_request['param'], $this->_request['param1'], $this->_request['param2']); 
     52                                break; 
     53                                case 'info': 
     54                                $this->changePriority($this->_request['param'], $this->_request['param1']); 
     55                                break; 
     56                                case 'trackers': 
     57                                $this->changeTrackers($this->_request['param'], $this->_request['param1'], $this->_request['param2']); 
     58                                break; 
     59                                default: 
     60                                $this->addMessage($this->_str['command_error']); 
     61                                break; 
     62 
     63                        } 
     64                } else { 
     65                        $this->addMessage($this->_str['command_error']); 
     66                } 
    6967        } 
    7068        private function stop($hashes) 
     69        { 
     70                $hashes = explode('~', $hashes); 
     71                if(!is_array($hashes)) 
     72                        $hashes = array($hashes); 
     73 
     74                foreach($hashes as $hash) 
     75                { 
     76                        $this->torrents[$hash]->stop(true); 
     77                } 
     78                $this->multicall->call(); 
     79 
     80                $this->addMessage($this->_str['info_tor_stop']); 
     81        } 
     82        private function close($hashes) 
     83        { 
     84                $hashes = explode('~', $hashes); 
     85                if(!is_array($hashes)) 
     86                        $hashes = array($hashes); 
     87 
     88                foreach($hashes as $hash) 
     89                { 
     90                        $this->torrents[$hash]->close(true); 
     91                } 
     92                $this->multicall->call(); 
     93 
     94                $this->addMessage($this->_str['info_tor_close']); 
     95        } 
     96        private function chash($hashes) 
     97        { 
     98                $hashes = explode('~', $hashes); 
     99        if(!is_array($hashes)) 
     100                $hashes = array($hashes); 
     101         
     102        foreach($hashes as $hash) 
     103        { 
     104                $this->torrents[$hash]->check_hash(true); 
     105        } 
     106                $this->multicall->call(); 
     107         
     108        $this->addMessage($this->_str['info_tor_chash']); 
     109        } 
     110        private function start($hashes) 
     111        { 
     112                $hashes = explode('~', $hashes); 
     113        if(!is_array($hashes)) 
     114                $hashes = array($hashes); 
     115         
     116        foreach($hashes as $hash) 
     117        { 
     118                $this->torrents[$hash]->start(true); 
     119        } 
     120                $this->multicall->call(); 
     121         
     122        $this->addMessage($this->_str['info_tor_start']); 
     123        } 
     124  private function erase($hashes) 
     125        { 
     126        $hashes = explode('~', $hashes); 
     127    if(!is_array($hashes)) 
     128        $hashes = array($hashes); 
     129         
     130    foreach($hashes as $hash) 
    71131    { 
    72         $hashes = explode('~', $hashes); 
    73         if(!is_array($hashes)) 
    74                $hashes = array($hashes); 
     132        $this->torrents[$hash]->erase(); 
     133                        $this->erase_db($hash); 
     134    } 
    75135         
    76         foreach($hashes as $hash) 
    77         { 
    78                 $message = new xmlrpcmsg("d.stop", array(new xmlrpcval($hash, 'string'))); 
    79                 $result = $this->client->send($message); 
    80         } 
    81          
    82         $this->addMessage($this->_str['info_tor_stop']); 
    83     } 
    84     private function close($hashes) 
    85     { 
    86         $hashes = explode('~', $hashes); 
    87         if(!is_array($hashes)) 
    88                 $hashes = array($hashes); 
    89          
    90         foreach($hashes as $hash) 
    91         { 
    92                 $message = new xmlrpcmsg("d.close", array(new xmlrpcval($hash, 'string'))); 
    93                 $result = $this->client->send($message); 
    94         } 
    95          
    96         $this->addMessage($this->_str['info_tor_close']); 
    97     } 
    98     private function chash($hashes) 
    99     { 
    100         $hashes = explode('~', $hashes); 
    101         if(!is_array($hashes)) 
    102                 $hashes = array($hashes); 
    103          
    104         foreach($hashes as $hash) 
    105         { 
    106                 $message = new xmlrpcmsg("d.check_hash", array(new xmlrpcval($hash, 'string'))); 
    107                 $result = $this->client->send($message); 
    108         } 
    109          
    110         $this->addMessage($this->_str['info_tor_chash']); 
    111     } 
    112     private function start($hashes) 
    113     { 
    114         $hashes = explode('~', $hashes); 
    115         if(!is_array($hashes)) 
    116                 $hashes = array($hashes); 
    117          
    118         foreach($hashes as $hash) 
    119         { 
    120                 $message = new xmlrpcmsg("d.start", array(new xmlrpcval($hash, 'string'))); 
    121                         $result = $this->client->send($message); 
    122         } 
    123          
    124         $this->addMessage($this->_str['info_tor_start']); 
    125     } 
    126     private function erase($hashes) 
    127     { 
    128         $hashes = explode('~', $hashes); 
    129         if(!is_array($hashes)) 
    130                 $hashes = array($hashes); 
    131          
    132         foreach($hashes as $hash) 
    133         { 
    134                 $message = new xmlrpcmsg("d.erase", array(new xmlrpcval($hash, 'string'))); 
    135                         $result = $this->client->send($message); 
    136                         $sql = "delete from torrents where hash = '" . $hash . "'"; 
    137                         $this->_db->query($sql); 
    138         } 
    139          
    140         $this->addMessage($this->_str['info_tor_erase']); 
    141     } 
    142     private function setDownLimit($limit) 
    143     { 
    144         $message = new xmlrpcmsg("set_download_rate", array(new xmlrpcval($limit*1024, 'int'))); 
    145                 $result = $this->client->send($message); 
    146                 //print_r($result); 
    147                 if($result->errno == 0) 
     136    $this->addMessage($this->_str['info_tor_erase']); 
     137        } 
     138        private function setDownLimit($limit) 
     139        { 
     140        $result = $this->set_download_rate($limit*1024); 
     141                if($result) 
    148142                        $this->addMessage($this->_str['info_down_limit']); 
    149143                else 
    150144                        $this->addMessage($this->_str['err_down_limit']);        
    151     } 
    152     private function setUploadLimit($limit) 
    153     { 
    154         $message = new xmlrpcmsg("set_upload_rate", array(new xmlrpcval($limit*1024, 'int'))); 
    155                 $result = $this->client->send($message); 
    156                 if($result->errno == 0) 
    157                         $this->addMessage($this->_str['info_up_limit']); 
     145        } 
     146  private function setUploadLimit($limit) 
     147        { 
     148        $result = $this->set_upload_rate($limit*1024); 
     149                if($result) 
     150                        $this->addMessage($this->_str['info_down_limit']); 
    158151                else 
    159                         $this->addMessage($this->_str['err_up_limit']);         
    160    
    161     private function changeFiles($hash, $priority, $files) 
    162    
    163       $files = explode('~', $files); 
     152                        $this->addMessage($this->_str['err_down_limit']); 
     153       
     154  private function changeFiles($hash, $priority, $files) 
     155       
     156              $files = explode('~', $files); 
    164157         
    165       foreach($files as $param) 
    166                         $array_post[] = new xmlrpcmsg('f.set_priority', array(new xmlrpcval($hash, 'string'), new xmlrpcval($param, 'int'), new xmlrpcval($priority, 'int'))); 
     158              foreach($files as $param) 
     159                        $this->torrents[$hash]->f_set_priority($param, $priority, true); 
    167160                 
    168                 $result = $this->client->multicall($array_post); 
     161                $result = $this->multicall->call(); 
    169162                 
    170                 if($result->errno == 0
     163                if($result
    171164                        $this->addMessage($this->_str['info_ch_files']); 
    172165                else 
    173166                        $this->addMessage($this->_str['err_ch_files']); 
    174167                          
    175                 $mesage = new xmlrpcmsg('d.update_priorities', array(new xmlrpcval($hash, 'string'))); 
    176                 $this->client->send($mesage); 
    177     } 
    178     private function changePriority($hash, $priority) 
    179     { 
    180         $message = new xmlrpcmsg("d.set_priority", array(new xmlrpcval($hash, 'string'), new xmlrpcval($priority, 'int'))); 
    181                 $result = $this->client->send($message); 
    182                 if($result->errno == 0) 
     168                $this->torrents[$hash]->update_priorities(); 
     169        } 
     170  private function changePriority($hash, $priority) 
     171        { 
     172                $result = $this->torrents[$hash]->d_set_priority($priority); 
     173                 
     174                if($result) 
    183175                        $this->addMessage($this->_str['info_pr']); 
    184         else  
    185                 $this->addMessage($this->_str['err_pr']); 
    186     } 
    187     private function changeTrackers($hash, $enabled, $t_index) 
    188     { 
    189         $t_index = explode('~', $t_index); 
    190         //print_r($f_index); 
     176    else  
     177                        $this->addMessage($this->_str['err_pr']); 
     178        } 
     179  private function changeTrackers($hash, $enabled, $trackers) 
     180        { 
     181                $trackers = explode('~', $trackers); 
    191182         
    192        foreach($t_index as $param) 
    193                         $array_post[] = new xmlrpcmsg('t.set_enabled', array(new xmlrpcval($hash, 'string'), new xmlrpcval($param, 'int'), new xmlrpcval($enabled, 'int'))); 
     183               foreach($trackers as $param) 
     184                        $this->torrents[$hash]->t_set_enabled($param, $enabled, true); 
    194185                 
    195                 //print_r($array_post);         
    196                 $responses = $this->client->multicall($array_post); 
     186                $this->multicall->call(); 
     187                 
    197188                $this->addMessage($this->_str['info_ch_trackers']); 
    198    
     189       
    199190} 
    200191?> 
  • trunk/wtorrent/home/cls/Feeds.cls.php

    r4 r51  
    1818class Feeds extends rtorrent 
    1919{ 
    20         /*private  $torrents; 
    21     private  $info_dowload = array('default',  
    22                                                         'd.get_hash=',  
    23                                                         'd.get_name=', 
    24                                                                 'd.get_down_rate=', 
    25                                                                 'd.get_up_rate=', 
    26                                                                 'd.get_chunk_size=', 
    27                                                                 'd.get_completed_chunks=', 
    28                                                                 'd.get_size_chunks=', 
    29                                                                 'd.get_state=', 
    30                                                                 'd.get_peers_accounted=', 
    31                                                                 'd.get_peers_complete=', 
    32                                                                 'd.is_hash_checking=', 
    33                                                                 'd.get_ratio=', 
    34                                                                 'd.get_tracker_size='); 
    35         private $info_tracker = array('', 
    36                                                                 "", 
    37                                                                 't.get_scrape_complete=', 
    38                                                                 't.get_scrape_incomplete=');*/ 
    3920        private $info = array(); 
    4021        private $feeds = array(); 
    4122        private $view_feed = false; 
    4223 
    43     public function construct() 
     24       public function construct() 
    4425        { 
    4526                if(!$this->setClient()) 
     
    9172                        $this->feeds[$i]['feed'] = new SimplePie(); 
    9273                        $this->feeds[$i]['feed']->set_feed_url($result[$i]['url']); 
    93                         $this->feeds[$i]['feed']->set_cache_location(DIR_TPL_COMPILE); 
     74                        $this->feeds[$i]['feed']->set_cache_location(rtrim(DIR_TPL_COMPILE, '/')); 
    9475                        $this->feeds[$i]['feed']->init(); 
    9576                        $this->feeds[$i]['feed']->handle_content_type(); 
     
    141122                return $this->info[$index]['title']; 
    142123        } 
    143         public function getUpLimit() 
    144         { 
    145                 $message = new xmlrpcmsg("get_upload_rate"); 
    146                 $result = $this->client->send($message); 
    147                 return round($result->val/1024, 1); 
    148         } 
    149         public function getDownLimit() 
    150         { 
    151                 $message = new xmlrpcmsg("get_download_rate"); 
    152                 $result = $this->client->send($message); 
    153                 return round($result->val/1024, 1); 
    154         } 
    155         public function getName($hash) 
    156         { 
    157                 return $this->torrents[$hash]['name']; 
    158         } 
    159         public function getDownRate($hash) 
    160         { 
    161                 return $this->torrents[$hash]['down_rate']; 
    162         } 
    163         public function getUpRate($hash) 
    164         { 
    165                 return $this->torrents[$hash]['up_rate']; 
    166         } 
    167         public function getState($hash) 
    168         { 
    169                 return $this->torrents[$hash]['state']; 
    170         } 
    171         public function getConnPeers($hash) 
    172         { 
    173                 return $this->torrents[$hash]['peers']; 
    174         } 
    175         public function getConnSeeds($hash) 
    176         { 
    177                 return $this->torrents[$hash]['seeds']; 
    178         } 
    179         public function getTotalPeers($hash) 
    180         { 
    181                 return $this->torrents[$hash]['peers_scrape']; 
    182         } 
    183         public function getTotalSeeds($hash) 
    184         { 
    185                 return $this->torrents[$hash]['seeds_scrape']; 
    186         } 
    187         public function getPercent($hash) 
    188         { 
    189                 return $this->torrents[$hash]['percent']; 
    190         } 
    191         public function getRatio($hash) 
    192         { 
    193                 return $this->torrents[$hash]['ratio']; 
    194         } 
    195         public function isHashChecking($hash) 
    196         { 
    197                 return $this->torrents[$hash]['is_hash_checking']; 
    198         } 
    199         public function getETA($hash) 
    200         { 
    201                 return $this->torrents[$hash]['ETA']; 
    202         } 
    203         public function getSize($hash) 
    204         { 
    205                 return $this->getCorrectUnits($this->torrents[$hash]['size_in_chunks'] * $this->torrents[$hash]['chunk_size']); 
    206         } 
    207         public function getDone($hash) 
    208         { 
    209                 return $this->getCorrectUnits($this->torrents[$hash]['completed_chunks'] * $this->torrents[$hash]['chunk_size']); 
    210         } 
    211         private function getCorrectUnits($size) 
    212     { 
    213                 $size_units = 'bytes'; 
    214                 if($size >= 1024) 
    215                 { 
    216                 $size /= 1024; 
    217                 $size_units = 'Kb'; 
    218                 } 
    219                 if($size >= 1024) 
    220                 { 
    221             $size /= 1024; 
    222             $size_units = 'Mb'; 
    223         } 
    224                 if($size >= 1024) 
    225         { 
    226             $size /= 1024; 
    227             $size_units = 'Gb'; 
    228         } 
    229         return round($size, 2) .  $size_units; 
    230  
    231     } 
    232         private function getPrivate() 
    233         { 
    234                 $tt = array(); 
    235                 $sql = "select hash, user from torrents"; 
    236                 $result = $this->_db->query($sql); 
    237                 $torr = $result->fetchAll(); 
    238                 foreach($torr as $torrent) 
    239                         $tt[$torrent['hash']] = $torrent['user']; 
    240                          
    241                 return $tt; 
    242         } 
    243      
    244124        private function fetchFeeds() 
    245     { 
    246         $num_feeds = count($this->feeds); 
    247         for($i = 0; $i < $num_feeds;$i++) 
    248         { 
    249                 $this->info[$i]['title'] = $this->feeds[$i]['feed']->get_title(); 
    250                 $this->info[$i]['description'] = $this->feeds[$i]['feed']->get_description(); 
    251                 $this->info[$i]['id'] = $this->feeds[$i]['id']; 
    252                 /*foreach ($this->feeds[$i]->get_items() as $key => $item) 
    253                 { 
    254                         $this->info[$i]['items'][$key]['title'] = $item->get_title(); 
    255                         $this->info[$i]['items'][$key]['description'] = $item->get_description(); 
    256                         $this->info[$i]['items'][$key]['link'] = $item->get_link(); 
    257                         $this->info[$i]['items'][$key]['date'] = $item->get_date("U"); 
    258                 }*/ 
    259         } 
    260     } 
    261     /*private function formatETA($time) 
    262     { 
    263                 $time = $time/1000; 
    264                 $sec = sprintf("%02d",floor(($time/60 - floor($time/60))*60)); 
    265                 $min =  sprintf("%02d",floor(($time/3600 - floor($time/3600))*60)); 
    266                 $hour =  sprintf("%02d",floor(($time/216000 - floor($time/216000))*60)); 
    267          
    268                 if($hour > 23) 
    269                 { 
    270                         $days = floor($hour/24) . "d "; 
    271                         $hour = sprintf("%02d",floor(($hour/24 - floor($hour/24))*24)); 
    272                 } else { 
    273                         $days = ''; 
    274                 } 
    275  
    276                 return $days . $hour.':'.$min.':'.$sec; 
    277     } 
    278     private function stop($hashes) 
    279     { 
    280         if(is_array($hashes)) 
    281                 $hashes = array_keys($hashes); 
    282         else  
    283                 $hashes = array($hashes); 
    284          
    285         foreach($hashes as $hash) 
    286         { 
    287                 $message = new xmlrpcmsg("d.stop", array(new xmlrpcval($hash, 'string'))); 
    288                         $result = $this->client->send($message); 
    289         } 
    290          
    291         $this->addMessage($this->_str['info_tor_stop']); 
    292     } 
    293     private function start($hashes) 
    294     { 
    295         if(is_array($hashes)) 
    296                 $hashes = array_keys($hashes); 
    297         else  
    298                 $hashes = array($hashes); 
    299          
    300         foreach($hashes as $hash) 
    301         { 
    302                 $message = new xmlrpcmsg("d.start", array(new xmlrpcval($hash, 'string'))); 
    303                         $result = $this->client->send($message); 
    304         } 
    305          
    306         $this->addMessage($this->_str['info_tor_start']); 
    307     } 
    308     private function erase($hashes) 
    309     { 
    310         if(is_array($hashes)) 
    311                 $hashes = array_keys($hashes); 
    312         else  
    313                 $hashes = array($hashes); 
    314          
    315         foreach($hashes as $hash) 
    316         { 
    317                 $message = new xmlrpcmsg("d.erase", array(new xmlrpcval($hash, 'string'))); 
    318                         $result = $this->client->send($message); 
    319                         $sql = "delete from torrents where hash = '" . $hash . "'"; 
    320                         $this->_db->query($sql); 
    321         } 
    322          
    323         $this->addMessage($this->_str['info_tor_erase']); 
    324     } 
    325     private function setDownLimit($limit) 
    326     { 
    327         $message = new xmlrpcmsg("set_download_rate", array(new xmlrpcval($limit*1024, 'int'))); 
    328                 $result = $this->client->send($message); 
    329                 //print_r($result); 
    330                 if($result->errno == 0) 
    331                         $this->addMessage($this->_str['info_down_limit']); 
    332                 else 
    333                         $this->addMessage($this->_str['err_down_limit']);        
    334     } 
    335     private function setUploadLimit($limit) 
    336     { 
    337         $message = new xmlrpcmsg("set_upload_rate", array(new xmlrpcval($limit*1024, 'int'))); 
    338                 $result = $this->client->send($message); 
    339                 if($result->errno == 0) 
    340                         $this->addMessage($this->_str['info_up_limit']); 
    341                 else 
    342                         $this->addMessage($this->_str['err_up_limit']);  
    343     }*/ 
    344     private function AddFeed($feed_url) 
    345     { 
    346         $sql = "INSERT INTO feeds(url, user) VALUES('$feed_url' , '". $this->getIdUser() . "');"; 
    347         $this->_db->query($sql); 
    348         $this->addMessage($this->_str['info_add_feed']); 
    349     } 
    350     private function DeleteFeed($id) 
    351     { 
    352         $sql = "DELETE FROM feeds WHERE user = '". $this->getIdUser() . "' AND id = '$id';"; 
    353         $this->_db->query($sql); 
    354         $this->addMessage($this->_str['info_erase_feed']); 
    355     } 
     125        { 
     126        $num_feeds = count($this->feeds); 
     127        for($i = 0; $i < $num_feeds;$i++) 
     128        { 
     129                $this->info[$i]['title'] = $this->feeds[$i]['feed']->get_title(); 
     130                $this->info[$i]['description'] = $this->feeds[$i]['feed']->get_description(); 
     131                $this->info[$i]['id'] = $this->feeds[$i]['id']; 
     132                /*foreach ($this->feeds[$i]->get_items() as $key => $item) 
     133                { 
     134                        $this->info[$i]['items'][$key]['title'] = $item->get_title(); 
     135                        $this->info[$i]['items'][$key]['description'] = $item->get_description(); 
     136                        $this->info[$i]['items'][$key]['link'] = $item->get_link(); 
     137                        $this->info[$i]['items'][$key]['date'] = $item->get_date("U"); 
     138                }*/ 
     139        } 
     140  } 
     141  private function AddFeed($feed_url) 
     142  { 
     143        $sql = "INSERT INTO feeds(url, user) VALUES('$feed_url' , '". $this->getIdUser() . "');"; 
     144        $this->_db->query($sql); 
     145        $this->addMessage($this->_str['info_add_feed']); 
     146  } 
     147  private function DeleteFeed($id) 
     148  { 
     149        $sql = "DELETE FROM feeds WHERE user = '". $this->getIdUser() . "' AND id = '$id';"; 
     150        $this->_db->query($sql); 
     151        $this->addMessage($this->_str['info_erase_feed']); 
     152  } 
    356153} 
    357154?> 
  • trunk/wtorrent/home/cls/Files.cls.php

    r4 r51  
    1818class Files extends rtorrent 
    1919{ 
    20         private  $files; 
    21         private  $hash; 
    22         private  $info_files = array('', '', 
    23                                                                 'f.get_path=',  
    24                                                         'f.get_completed_chunks=',  
    25                                                         'f.get_size_chunks=', 
    26                                                         'f.get_priority='); 
    27     private $position = 0; 
     20        private $hash; 
    2821 
    29     public function construct() 
     22       public function construct() 
    3023        { 
    3124                $this->hash = $this->_request['hash']; 
     
    3427                        return false; 
    3528                         
    36                 if(isset($this->_request['ch_pr']) && count($this->_request['files']) > 0) $this->changePriorities($this->_request['files'], $this->_request['priority'], $this->hash); 
    37                 $this->getTorrents($this->_request['hash']); 
     29                $array_f = array('f.get_path', 'f.get_completed_chunks', 'f.get_size_chunks','f.get_priority'); 
     30                $this->multicall->f_multicall($this->hash, $array_f); 
    3831        } 
    39          
    40          
    4132        public function getHash() 
    4233        { 
     
    4536        public function getFiles() 
    4637        { 
    47                 return $this->files; 
    48         } 
    49         public function getName() 
    50         { 
    51                 return $this->details['name']; 
    52         } 
    53         public function getTorrent() 
    54         { 
    55                 return $this->details['torrent_file']; 
    56         } 
    57         public function getDataPath() 
    58         { 
    59                 return $this->details['data_path']; 
    60         } 
    61         public function getPercent() 
    62         { 
    63                 return $this->details['percent']; 
    64         } 
    65         public function getRatio() 
    66         { 
    67                 return $this->details['ratio']; 
     38                $num = $this->torrents[$this->hash]->get_size_files(); 
     39                for($i = 0; $i < $num; $i++) 
     40        {                
     41                $files[$i]['name'] = $this->torrents[$this->hash]->f_get_path($i); 
     42                $files[$i]['size_in_chunks'] = $this->torrents[$this->hash]->f_get_size_chunks($i); 
     43                $files[$i]['completed_chunks'] = $this->torrents[$this->hash]->f_get_completed_chunks($i); 
     44                $files[$i]['priority'] = $this->torrents[$this->hash]->f_get_priority($i); 
     45                $files[$i]['percent'] = floor(($files[$i]['completed_chunks']/$files[$i]['size_in_chunks'])*100); 
     46                $files[$i]['size'] = $files[$i]['size_in_chunks'] * $this->torrents[$this->hash]->get_chunk_size(); 
     47                $files[$i]['size_done'] = $files[$i]['completed_chunks'] * $this->torrents[$this->hash]->get_chunk_size(); 
     48        } 
     49                return $files; 
    6850        } 
    6951        public function getSize($key) 
    7052        { 
    71                 return $this->getCorrectUnits($this->files[$key]['size']); 
     53                return $this->getCorrectUnits($this->torrents[$this->hash]->f_get_size_chunks($key) * $this->torrents[$this->hash]->get_chunk_size()); 
    7254        } 
    7355        public function getDone($key) 
    7456        { 
    75                 return $this->getCorrectUnits($this->files[$key]['size_done']); 
    76         } 
    77         public function getUp() 
    78         { 
    79                 return $this->getCorrectUnits($this->details['bytes_up']); 
     57                return $this->getCorrectUnits($this->torrents[$this->hash]->f_get_completed_chunks($key) * $this->torrents[$this->hash]->get_chunk_size()); 
    8058        } 
    8159        public function getPriorityStr($key) 
    8260        { 
    83                 switch($this->files[$key]['priority']
     61                switch($this->torrents[$this->hash]->f_get_priority($key)
    8462                { 
    8563                        case 0: 
     
    9977        } 
    10078        private function getCorrectUnits($size) 
    101     
     79      
    10280                $size_units = 'bytes'; 
    10381                if($size >= 1024) 
    10482                { 
    105               $size /= 1024; 
    106               $size_units = 'Kb'; 
     83              $size /= 1024; 
     84              $size_units = 'Kb'; 
    10785                } 
    10886                if($size >= 1024) 
    10987                { 
    110             $size /= 1024; 
    111             $size_units = 'Mb'; 
    112        
     88       $size /= 1024; 
     89      $size_units = 'Mb'; 
     90               
    11391                if($size >= 1024) 
    114         { 
    115             $size /= 1024; 
    116             $size_units = 'Gb'; 
    117         } 
    118         return round($size, 2) .  $size_units; 
    119  
    120     } 
    121  
    122         private function getTorrents($hash) 
    12392    { 
    124          
    125         $this->info_files[0] = $hash; 
    126          
    127                 foreach($this->info_files as $param) 
    128                         $array_post[] = new xmlrpcval($param, 'string'); 
    129                  
    130                 // Get chunk size 
    131                 $message = new xmlrpcmsg("d.get_chunk_size", array(new xmlrpcval($hash, 'string'))); 
    132                 $result = $this->client->send($message); 
    133                 $chunk_size = $result->val; 
    134                 // Get file info 
    135         $message = new xmlrpcmsg("f.multicall", $array_post); 
    136                 $result = $this->client->send($message); 
    137         //print_r($result); 
    138         foreach($result->val as $key => $file) 
    139         { 
    140                 if(SCRAMBLE === true) 
    141                         $file[0] = $this->scramble($file[0]); 
    142                          
    143                 $this->files[$key]['name'] = $file[0]; 
    144                 $this->files[$key]['size_in_chunks'] = $file[2]; 
    145                 $this->files[$key]['completed_chunks'] = $file[1]; 
    146                 $this->files[$key]['priority'] = $file[3]; 
    147                 $this->files[$key]['percent'] = floor(($this->files[$key]['completed_chunks']/$this->files[$key]['size_in_chunks'])*100); 
    148                 $this->files[$key]['size'] = $this->files[$key]['size_in_chunks'] * $chunk_size; 
    149                 $this->files[$key]['size_done'] = $this->files[$key]['completed_chunks'] * $chunk_size; 
    150         } 
    151         //print_r($this->files); 
    152     } 
    153     private function changePriorities($files, $priorities, $hash) 
    154     { 
    155         $f_index = array_keys($files); 
    156         //print_r($f_index); 
    157          
    158         foreach($f_index as $param) 
    159                         $array_post[] = new xmlrpcmsg('f.set_priority', array(new xmlrpcval($hash, 'string'), new xmlrpcval($param, 'int'), new xmlrpcval($priorities, 'int'))); 
    160                  
    161                 //print_r($array_post);  
    162                 $responses = $this->client->multicall($array_post); 
    163                  
    164                 $mesage = new xmlrpcmsg('d.update_priorities', array(new xmlrpcval($hash, 'string'))); 
    165                 $this->client->send($mesage); 
    166     } 
     93        $size /= 1024; 
     94      $size_units = 'Gb'; 
     95                } 
     96    return round($size, 1) .  $size_units; 
     97  } 
    16798} 
    16899?> 
  • trunk/wtorrent/home/cls/General.cls.php

    r4 r51  
    1818class General extends rtorrent 
    1919{ 
    20         private  $details; 
    2120        private  $hash; 
    22         private  $info_general = array('d.get_name', 
    23                                                                         'd.get_tied_to_file', 
    24                                                                         'd.get_base_path', 
    25                                                                         'd.get_down_rate', 
    26                                                                         'd.get_up_rate', 
    27                                                                         'd.get_chunk_size', 
    28                                                                         'd.get_completed_chunks', 
    29                                                                         'd.get_size_chunks', 
    30                                                                         'd.get_ratio', 
    31                                                                         'd.get_peers_max', 
    32                                                                         'd.get_peers_min', 
    33                                                                         'd.get_priority', 
    34                                                                         'd.get_message'); 
    35     /////////////////////////////////// C O N S T R U C T O R A S  Y  D E S T R U C T O R A /////////////////////////////////// 
    36  
    37     public function construct() 
    38     { 
     21         
     22        public function construct() 
     23        { 
    3924                $this->hash = $this->_request['hash']; 
    4025         
    4126                if(!$this->setClient()) 
    4227                        return false; 
    43                  
    44                 if(isset($this->_request['ch_pr'])) $this->changePriority($this->hash, $this->_request['priority']); 
    45                  
    46         $this->getTorrents($this->hash); 
    4728        } 
    48  
    4929        ////////////////////////////////////////////////// C O N S U L T O R A S ////////////////////////////////////////////////// 
    5030        public function getHash() 
     
    5434        public function getName() 
    5535        { 
    56                 return $this->details['name']
     36                return $this->torrents[$hash]->get_name()
    5737        } 
    5838        public function getTorrent() 
    5939        { 
    60                 return $this->details['torrent_file']
     40                return '/' . ltrim($this->torrents[$this->hash]->get_tied_to_file(), '/')
    6141        } 
    6242        public function getDataPath() 
    6343        { 
    64                 return $this->details['data_path']
     44                return $this->torrents[$this->hash]->get_base_path()
    6545        } 
    6646        public function getPercent() 
    6747        { 
    68                 return $this->details['percent']
     48                return floor(($this->torrents[$this->hash]->get_completed_chunks() / $this->torrents[$this->hash]->get_size_chunks())*100)
    6949        } 
    7050        public function getRatio() 
    7151        { 
    72                 return $this->details['ratio']
     52                return round($this->torrents[$this->hash]->get_ratio()/1000,2)
    7353        } 
    7454        public function getSize() 
    7555        { 
    76                 return $this->getCorrectUnits($this->details['size_in_chunks'] * $this->details['chunk_size']); 
     56                return $this->getCorrectUnits($this->torrents[$this->hash]->get_size_chunks() * $this->torrents[$this->hash]->get_chunk_size()); 
    7757        } 
    7858        public function getDone() 
    7959        { 
    80                 return $this->getCorrectUnits($this->details['completed_chunks'] * $this->details['chunk_size']); 
     60                return $this->getCorrectUnits($this->torrents[$this->hash]->get_completed_chunks() * $this->torrents[$this->hash]->get_chunk_size()); 
    8161        } 
    8262        public function getUp() 
    8363        { 
    84                 return $this->getCorrectUnits($this->details['bytes_up']); 
     64                return $this->getCorrectUnits($this->torrents[$this->hash]->get_completed_chunks() * $this->torrents[$this->hash]->get_chunk_size() * $this->getRatio()); 
    8565        } 
    8666        public function getMaxPeers() 
    8767        { 
    88                 return $this->details['peers_max']
     68                return $this->torrents[$this->hash]->get_peers_max()
    8969        } 
    9070        public function getMinPeers() 
    9171        { 
    92                 return $this->details['peers_min']
     72                return $this->torrents[$this->hash]->get_peers_min()
    9373        } 
    9474        public function getPriorityStr() 
    9575        { 
    96                 switch($this->details['priority']
     76                switch($this->torrents[$this->hash]->d_get_priority()
    9777                { 
    9878                        case 1: 
     
    11696        public function getPriority() 
    11797        { 
    118                 return $this->details['priority']
     98                return $this->torrents[$this->hash]->d_get_priority()
    11999        } 
    120100        public function getMessage() 
    121101        { 
    122                 return $this->details['message']
     102                return $this->torrents[$this->hash]->get_message()
    123103        } 
    124104        private function getCorrectUnits($size) 
    125     
     105      
    126106                $size_units = 'bytes'; 
    127107                if($size >= 1024) 
    128108                { 
    129               $size /= 1024; 
    130               $size_units = 'Kb'; 
     109              $size /= 1024; 
     110              $size_units = 'Kb'; 
    131111                } 
    132112                if($size >= 1024) 
    133113                { 
    134             $size /= 1024; 
    135             $size_units = 'Mb'; 
    136        
     114       $size /= 1024; 
     115      $size_units = 'Mb'; 
     116               
    137117                if($size >= 1024) 
    138         { 
    139             $size /= 1024; 
    140             $size_units = 'Gb'; 
    141         } 
    142         return round($size, 2) .  $size_units; 
    143  
    144     } 
    145         //////////////////////////////////////////////// M O D I F I C A D O R A S //////////////////////////////////////////////// 
    146         private function getTorrents($hash) 
    147118    { 
    148         foreach($this->info_general as $param) 
    149                         $array_post[] = new xmlrpcmsg($param, array(new xmlrpcval($hash, 'string'))); 
    150                          
    151                 $responses = $this->client->multicall($array_post);       
    152          
    153         //print_r($responses); 
    154                  
    155             if(SCRAMBLE === true) 
    156             { 
    157                 $tor_name[1] = $this->scramble($tor_name[1]); 
    158                 $tor_file[1] = $this->scramble($tor_file[1]); 
    159                 $tor_base_path[1] = $this->scramble($tor_base_path[1]); 
    160             } 
    161              
    162             $this->details['id'] = $tor_id; 
    163             $this->details['name'] = $responses[0]->val; 
    164             $this->details['torrent_file'] = '/' . ltrim($responses[1]->val, '/'); 
    165             $this->details['data_path'] = $responses[2]->val; 
    166             $this->details['bytes_done'] = $responses[5]->val * $responses[6]->val; 
    167             $this->details['chunk_size'] = $responses[5]->val; 
    168             $this->details['completed_chunks'] = $responses[6]->val; 
    169             $this->details['size_in_chunks'] = $responses[7]->val; 
    170             $this->details['peers_max'] = $responses[9]->val; 
    171             $this->details['peers_min'] = $responses[10]->val; 
    172             $this->details['priority'] = $responses[11]->val; 
    173             $this->details['message'] = $responses[12]->val; 
    174             $this->details['missing_chunks'] = $this->details['size_in_chunks'] - $this->details['completed_chunks']; 
    175             $this->details['missing_bytes'] = $this->details['missing_chunks'] * $this->details['chunk_size']; 
    176             //$this->details['seeds'] = $tor_completed[1]; 
    177             //$this->details['peers'] = $tor_peers[1]; 
    178             $this->details['ratio'] = round($responses[8]->val/1000,2); 
    179             $this->details['bytes_up'] = $this->details['bytes_done'] * $this->details['ratio']; 
    180             $this->details['bytes_total'] = $this->details['chunk_size'] * $this->details['size_in_chunks']; 
    181             //$this->details['num_trackers'] = $tor_num_trackers[1]; 
    182  
    183             if($this->details['completed_chunks'] < $this->details['size_in_chunks']) 
    184             { 
    185                     $this->details['percent'] = floor(($this->details['completed_chunks']/$this->details['size_in_chunks'])*100); 
    186             } else { 
    187             $this->details['percent'] = 100; 
    188             } 
    189     } 
    190     private function changePriority($hash, $priority) 
    191     { 
    192         if($hash != '' && $priority >= 0 && $priority <= 3) 
    193         { 
    194                 $message = new xmlrpcmsg("d.set_priority", array(new xmlrpcval($hash, 'string'), new xmlrpcval($priority, 'int'))); 
    195                         $result = $this->client->send($message); 
    196                         $this->addMessage($this->_str['info_pr']); 
    197         } else { 
    198                 $this->addMessage($this->_str['err_pr']); 
    199         } 
    200     } 
     119        $size /= 1024; 
     120      $size_units = 'Gb'; 
     121                } 
     122    return round($size, 1) .  $size_units; 
     123  } 
    201124} 
    202125?> 
  • trunk/wtorrent/home/cls/ListT.cls.php

    r50 r51  
    1919{ 
    2020        private  $view; 
    21         private  $torrents = array(); 
    2221        private  $MAX_LENGTH_NAME = 55; 
    23   private  $info_dowload = array('default',  
    24                                                         'd.get_hash=',  
    25                                                         'd.get_name=', 
    26                                                                 'd.get_down_rate=', 
    27                                                                 'd.get_up_rate=', 
    28                                                                 'd.get_chunk_size=', 
    29                                                                 'd.get_completed_chunks=', 
    30                                                                 'd.get_size_chunks=', 
    31                                                                 'd.get_state=', 
    32                                                                 'd.get_peers_accounted=', 
    33                                                                 'd.get_peers_complete=', 
    34                                                                 'd.is_hash_checking=', 
    35                                                                 'd.get_ratio=', 
    36                                                                 'd.get_tracker_size=', 
    37                                                                 'd.is_active=', 
    38                                                                 'd.is_open=', 
    39                 'd.get_message=', 
    40                 'd.get_creation_date=', 
    41                                                         ); 
    42         private $info_tracker = array('', 
    43                                                                 "", 
    44                                                                 't.get_scrape_complete=', 
    45                                                                 't.get_scrape_incomplete='); 
    46  
    47     public function construct() 
     22  
     23  public function construct() 
    4824        { 
    4925                if($this->_request['view'] == 'public') $this->view = 'public'; 
     
    5430                        return false; 
    5531                 
     32                /* d multicall with all the necessary info to generate the torrent list */ 
     33                $array_d = array('d.get_name', 'd.get_down_rate', 'd.get_up_rate', 'd.get_chunk_size','d.get_completed_chunks','d.get_size_chunks','d.get_state','d.get_peers_accounted','d.get_peers_complete','d.is_hash_checking','d.get_ratio','d.get_tracker_size','d.is_active','d.is_open','d.get_message','d.get_creation_date'); 
     34                $this->multicall->d_multicall($array_d); 
     35                // t multicall 
     36                $array_t = array('t.get_scrape_complete', 't.get_scrape_incomplete'); 
     37                $hashes = $this->getHashes(); // Retrieve hashes 
     38                foreach($hashes as $hash) 
     39                        $this->multicall->t_multicall($hash, $array_t); 
     40                 
    5641                if(isset($this->_request['start'])) $this->start($this->_request['start']); 
    5742                if(isset($this->_request['stop'])) $this->stop($this->_request['stop']); 
    5843                if(isset($this->_request['erase'])) $this->erase($this->_request['erase']); 
    59                  
    60                 $this->getTorrents(); 
    6144        } 
    6245 
     
    6750        public function getPublicHashes() 
    6851        { 
    69                 $tor_hashes = array_keys($this->torrents); 
    70                 foreach($tor_hashes as $hash) 
    71                         if($this->torrents[$hash]['private'] === false) 
     52                $hashes = $this->getHashes(); 
     53                foreach($hashes as $hash) 
     54                        if($this->torrents[$hash]->get_private() === false) 
    7255                                $return[] = $hash; 
    7356                                 
     
    7659        public function getPublicHashesNum() 
    7760        { 
    78                 $tor_hashes = array_keys($this->torrents); 
     61                $hashes = $this->getHashes(); 
    7962                $i = 0; 
    80                 foreach($tor_hashes as $hash) 
    81                         if($this->torrents[$hash]['private'] === false) 
     63                foreach($hashes as $hash) 
     64                        if($this->torrents[$hash]->get_private() === false) 
    8265                                $i++; 
    8366                                 
     
    8669        public function getPrivateHashes() 
    8770        { 
    88                 $tor_hashes = array_keys($this->torrents); 
    89                 foreach($tor_hashes as $hash) 
    90                         if($this->torrents[$hash]['private'] === true
     71                $hashes = $this->getHashes(); 
     72                foreach($hashes as $hash) 
     73                        if(($this->torrents[$hash]->get_private() === true) && ($this->torrents[$hash]->get_owner() == $this->getIdUser())
    9174                                $return[] = $hash; 
    9275                                 
     
    9578        public function getPrivateHashesNum() 
    9679        { 
    97                 $tor_hashes = array_keys($this->torrents); 
     80                $hashes = $this->getHashes(); 
    9881                $i = 0; 
    99                 foreach($tor_hashes as $hash) 
    100                        if($this->torrents[$hash]['private'] === true
    101                                $i++; 
     82                foreach($hashes as $hash) 
     83                if(($this->torrents[$hash]->get_private() === false) && ($this->torrents[$hash]->get_owner() == $this->getIdUser())
     84                        $i++; 
    10285                                 
    10386                return $i; 
     
    10588        public function getName($hash) 
    10689        { 
    107                 // Just in case the torrent name is too long return a shortened version. 
    108                 $name = $this->torrents[$hash]['name']
     90                // Just in case the torrent name is too long return a shortened version. (THIS SHOULD BE DONE IN THE TEMPLATE WITH SMARTY TRUNCATE) 
     91                $name = $this->torrents[$hash]->get_name()
    10992                if(strlen($name) > $this->MAX_LENGTH_NAME){ 
    11093                        $name = substr($name, 0, $this->MAX_LENGTH_NAME) . ' ...'; 
     
    11295                return $name; 
    11396        } 
    114         // public function getTags($hash) 
    115         // { 
    116         //      return $this->torrents[$hash]['tags']; 
    117         // } 
    11897        public function getState($hash) 
    11998        { 
    120                 return $this->torrents[$hash]['state']
     99                return $this->torrents[$hash]->get_state()
    121100        } 
    122101        public function getOpen($hash) 
    123102        { 
    124                 return $this->torrents[$hash]['is_open']; 
    125         } 
    126         public function getActive($hash) 
    127         { 
    128                 return $this->torrents[$hash]['is_active']; 
     103                return $this->torrents[$hash]->is_open(); 
    129104        } 
    130105        public function getConnPeers($hash) 
    131106        { 
    132                 return $this->torrents[$hash]['peers']
     107                return $this->torrents[$hash]->get_peers_accounted()
    133108        } 
    134109        public function getConnSeeds($hash) 
    135110        { 
    136                 return $this->torrents[$hash]['seeds']
     111                return $this->torrents[$hash]->get_peers_complete()
    137112        } 
    138113        public function getTotalPeers($hash) 
    139114        { 
    140                 return $this->torrents[$hash]['peers_scrape']; 
     115                $peers = 0; 
     116                $num = $this->torrents[$hash]->get_tracker_size(); 
     117                 
     118                for($i = 0; $i < $num; $i++) 
     119                { 
     120                        $t_peers = $this->torrents[$hash]->t_get_scrape_incomplete($i); 
     121                        $peers += $t_peers; 
     122                } 
     123                         
     124                return $peers; 
    141125        } 
    142126        public function getTotalSeeds($hash) 
    143127        { 
    144                 return $this->torrents[$hash]['seeds_scrape']; 
     128                $seeds = 0; 
     129                $num = $this->torrents[$hash]->get_tracker_size(); 
     130                 
     131                for($i = 0; $i < $num; $i++) 
     132                { 
     133                        $t_seeds = $this->torrents[$hash]->t_get_scrape_complete($i); 
     134                        $seeds += $t_seeds; 
     135                } 
     136                 
     137                return $seeds; 
    145138        } 
    146139        public function getDownRate($hash) 
    147140        { 
    148                 return $this->torrents[$hash]['down_rate']
     141                return round($this->torrents[$hash]->get_down_rate()/1024,2)
    149142        } 
    150143        public function getUpRate($hash) 
    151144        { 
    152                 return $this->torrents[$hash]['up_rate']
     145                return round($this->torrents[$hash]->get_up_rate()/1024,2)
    153146        } 
    154147        public function getPercent($hash) 
    155148        { 
    156                 return $this->torrents[$hash]['percent']
     149                return floor(($this->torrents[$hash]->get_completed_chunks()/$this->torrents[$hash]->get_size_chunks())*100)
    157150        } 
    158151        public function getRatio($hash) 
    159152        { 
    160                 return $this->torrents[$hash]['ratio']
     153                return round($this->torrents[$hash]->get_ratio()/1000,2)
    161154        } 
    162155        public function isHashChecking($hash) 
    163156        { 
    164                 return $this->torrents[$hash]['is_hash_checking']
     157                return $this->torrents[$hash]->is_hash_checking()
    165158        } 
    166159        public function getETA($hash) 
    167160        { 
    168                 return $this->torrents[$hash]['ETA']; 
     161                $return = '--'; 
     162                if(($this->getPercent($hash) != 100) && ($this->torrents[$hash]->get_down_rate() != 0)) 
     163                        $return = $this->formatETA(ceil((($this->torrents[$hash]->get_size_chunks() - $this->torrents[$hash]->get_completed_chunks()) * $this->torrents[$hash]->get_chunk_size() / 1024) / $this->torrents[$hash]->get_down_rate())); 
     164                 
     165                return $return; 
    169166        } 
    170167        public function getSize($hash) 
    171168        { 
    172                 return $this->getCorrectUnits($this->torrents[$hash]['size_in_chunks'] * $this->torrents[$hash]['chunk_size']); 
     169                return $this->getCorrectUnits($this->torrents[$hash]->get_size_chunks() * $this->torrents[$hash]->get_chunk_size()); 
    173170        } 
    174171        public function getDone($hash) 
    175172        { 
    176                 return $this->getCorrectUnits($this->torrents[$hash]['completed_chunks'] * $this->torrents[$hash]['chunk_size']); 
    177         } 
    178     public function getTstate($hash) 
    179     { 
    180         return $this->torrents[$hash]['tstate']; 
    181     } 
    182     public function getTstyle($hash) 
    183     { 
    184         switch($this->torrents[$hash]['tstate']) 
    185         { 
    186                 case 'downloading': 
    187                         $return = 'green'; 
    188                         break; 
    189                 case 'stopped': 
    190                         $return = 'black'; 
    191                         break; 
    192                 case 'seeding': 
    193                         $return = 'blue'; 
    194                         break; 
    195                 case 'closed': 
    196                         $return = 'black'; 
    197                         break; 
    198                 case 'message': 
    199                         $return = 'red'; 
    200                         break; 
    201                 case 'chash': 
    202                         $return = 'yellow'; 
    203                         break; 
    204         } 
    205         return $return; 
    206     } 
    207     public function getMessage($hash) 
    208     { 
    209         return $this->torrents[$hash]['message']; 
    210     } 
    211     public function getTooltipText($hash) 
    212     { 
    213         if($this->getTstate($hash) == 'message') 
    214             $return = $this->getMessage($hash); 
    215         else 
    216             $return = null; 
    217         return $return; 
    218     } 
    219     public function getCreationDate($hash) 
    220     { 
    221         return $this->torrents[$hash]['creation_date']; 
    222     } 
     173                return $this->getCorrectUnits($this->torrents[$hash]->get_completed_chunks() * $this->torrents[$hash]->get_chunk_size()); 
     174        } 
     175        public function getTstate($hash) 
     176        { 
     177                if($this->torrents[$hash]->get_state() == 0) 
     178                { 
     179                        $return = 'stopped'; 
     180                } else { 
     181                        if($this->getPercent($hash) != 100){ 
     182                                $return = 'downloading'; 
     183                        } else { 
     184                                $return = 'seeding'; 
     185                        } 
     186                } 
     187                if($this->torrents[$hash]->is_open() != 1) 
     188                        $return = 'closed'; 
     189 
     190                if(($this->torrents[$hash]->get_message() != '') && ($this->torrents[$hash]->get_message() != 'Tracker: [Tried all trackers.]')) 
     191                        $return = 'message'; 
     192 
     193                if($this->torrents[$hash]->is_hash_checking() == 1) 
     194                        $return = 'chash'; 
     195        } 
     196        public function getTstyle($hash) 
     197        { 
     198                switch($this->getTstate($hash)) 
     199                { 
     200                        case 'downloading': 
     201                        $return = 'green'; 
     202                        break; 
     203                        case 'stopped': 
     204                        $return = 'black'; 
     205                        break; 
     206                        case 'seeding': 
     207                        $return = 'blue'; 
     208                        break; 
     209                        case 'closed': 
     210                        $return = 'black'; 
     211                        break; 
     212                        case 'message': 
     213                        $return = 'red'; 
     214                        break; 
     215                        case 'chash': 
     216                        $return = 'yellow'; 
     217                        break; 
     218                } 
     219                return $return; 
     220        } 
     221        public function getMessage($hash) 
     222        { 
     223                return $this->torrents[$hash]->get_message(); 
     224        } 
     225        public function getTooltipText($hash) 
     226        { 
     227       if($this->getTstate($hash) == 'message') 
     228           $return = $this->getMessage($hash); 
     229       else 
     230           $return = null; 
     231       return $return; 
     232        } 
     233  public function getCreationDate($hash) 
     234        { 
     235        return $this->torrents[$hash]->get_creation_date(); 
     236  } 
    223237        private function getCorrectUnits($size) 
    224     
     238      
    225239                $size_units = 'bytes'; 
    226240                if($size >= 1024) 
    227241                { 
    228               $size /= 1024; 
    229               $size_units = 'Kb'; 
     242              $size /= 1024; 
     243              $size_units = 'Kb'; 
    230244                } 
    231245                if($size >= 1024) 
    232246                { 
    233             $size /= 1024; 
    234             $size_units = 'Mb'; 
    235        
     247       $size /= 1024; 
     248      $size_units = 'Mb'; 
     249               
    236250                if($size >= 1024) 
    237         { 
    238             $size /= 1024; 
    239             $size_units = 'Gb'; 
    240         } 
    241         return round($size, 1) .  $size_units; 
    242  
     251    { 
     252        $size /= 1024; 
     253      $size_units = 'Gb'; 
     254                } 
     255    return round($size, 1) .  $size_units; 
     256  } 
     257        private function formatETA($time) 
     258        { 
     259                if (!is_array($periods)) { 
     260       $periods = array ( 
     261         'weeks'     => 604800, 
     262         'days'      => 86400, 
     263         'hours'     => 3600, 
     264         'minutes'   => 60, 
     265         ); 
    243266    } 
    244         private function getPrivate() 
    245         { 
    246                 $tt = array(); 
    247                 $sql = "select hash, user from torrents"; 
    248                 $result = $this->_db->query($sql); 
    249                 $torr = $result->fetchAll(); 
    250                 foreach($torr as $torrent) 
    251                         $tt[$torrent['hash']] = $torrent['user']; 
    252                          
    253                 return $tt; 
    254         } 
    255  
    256         private function getTorrents() 
    257         { 
    258                 //define("XMLRPC_DEBUG", 1); 
    259                 //$this->client->setDebug(2); 
    260                 foreach($this->info_dowload as $param) 
    261                         $array_post[] = new xmlrpcval($param, 'string'); 
    262  
    263                 //print_r(XMLRPC_prepare($array_post)); 
    264                 //print_r(XMLRPC_prepare($array_multi));  
    265  
    266                 //$result = XMLRPC_request(RT_HOST , '/RPC2', 'd.multicall' ,$array_post); 
    267                 $message = new xmlrpcmsg("d.multicall", $array_post); 
    268                 $result = $this->client->send($message); 
    269                 //print_r($result); 
    270                 // Multicall for tracker info (reduces load time on big torrent list 
    271                         $array_post = array(); 
    272                         foreach($this->info_tracker as $param) 
    273                                 $array_post[] = new xmlrpcval($param, 'string'); 
    274  
    275                         if(count($result->val)) { 
    276                                 foreach($result->val as $torrent) 
    277                                 { 
    278                                         $array_post[0] = new xmlrpcval($torrent[0], 'string'); 
    279                                         $messages[] = new xmlrpcmsg("t.multicall", $array_post); 
    280                                 } 
    281                                 if(count($messages) > 0) 
    282                                         $Tresponses = $this->client->multicall($messages); 
    283                                 //print_r($responses); 
    284                                 foreach($result->val as $key => $torrent) 
    285                                 { 
    286                                         // Check if the torrent is private and if the user can see it 
    287                                         $private = false; 
    288                                         $pr_torrent = $this->getPrivate(); 
    289                                         if(array_key_exists($torrent[0], $pr_torrent)) 
    290                                         { 
    291                                                 $private = true; 
    292                                                 if($pr_torrent[$torrent[0]] != $this->getIdUser()) 
    293                                                         continue; 
    294                                         } 
    295                                         $this->torrents[$torrent[0]]['private'] = $private; 
    296                                         $this->torrents[$torrent[0]]['name'] = $torrent[1]; 
    297                                         $this->torrents[$torrent[0]]['down_rate'] = round($torrent[2]/1024,2); 
    298                                         $this->torrents[$torrent[0]]['up_rate'] = round($torrent[3]/1024,2); 
    299                                         $this->torrents[$torrent[0]]['chunk_size'] = $torrent[4]; 
    300                                         $this->torrents[$torrent[0]]['completed_chunks'] = $torrent[5]; 
    301                                         $this->torrents[$torrent[0]]['size_in_chunks'] = $torrent[6]; 
    302                                         $this->torrents[$torrent[0]]['state'] = $torrent[7]; 
    303                                         $this->torrents[$torrent[0]]['peers'] = $torrent[8]; 
    304                                         $this->torrents[$torrent[0]]['seeds'] = $torrent[9]; 
    305                                         $this->torrents[$torrent[0]]['is_hash_checking'] = $torrent[10]; 
    306                                         $this->torrents[$torrent[0]]['ratio'] = round($torrent[11]/1000,2); 
    307                                         $this->torrents[$torrent[0]]['num_trackers'] = $torrent[12]; 
    308                                         $this->torrents[$torrent[0]]['is_active'] = $torrent[13]; 
    309                                         $this->torrents[$torrent[0]]['is_open'] = $torrent[14]; 
    310                                         $this->torrents[$torrent[0]]['message'] = $torrent[15]; 
    311                                         $this->torrents[$torrent[0]]['creation_date'] = $torrent[16]; 
    312  
    313                                         $this->torrents[$torrent[0]]['percent'] = floor(($this->torrents[$torrent[0]]['completed_chunks']/$this->torrents[$torrent[0]]['size_in_chunks'])*100); 
    314  
    315                                         $this->torrents[$torrent[0]]['ETA'] = '--'; 
    316                                         if(($this->torrents[$torrent[0]]['percent'] != 100) && ($this->torrents[$torrent[0]]['down_rate'] != 0)) 
    317                                                 $this->torrents[$torrent[0]]['ETA'] = $this->formatETA(ceil((($this->torrents[$torrent[0]]['size_in_chunks'] - $this->torrents[$torrent[0]]['completed_chunks']) * $this->torrents[$torrent[0]]['chunk_size'] / 1024) / $torrent[2])); 
    318  
    319                                         if($this->torrents[$torrent[0]]['state'] == 0) 
    320                                         { 
    321                                                 $this->torrents[$torrent[0]]['tstate'] = 'stopped'; 
    322                                         } else { 
    323                                                 if($this->torrents[$torrent[0]]['percent'] != 100){ 
    324                                                         $this->torrents[$torrent[0]]['tstate'] = 'downloading'; 
    325                                                 } else { 
    326                                                         $this->torrents[$torrent[0]]['tstate'] = 'seeding'; 
    327                                                 } 
    328                                         } 
    329                                         if($this->torrents[$torrent[0]]['is_open'] != 1) 
    330                                                 $this->torrents[$torrent[0]]['tstate'] = 'closed'; 
    331  
    332                                         if(($this->torrents[$torrent[0]]['message'] != '') && ($this->torrents[$torrent[0]]['message'] != 'Tracker: [Tried all trackers.]')) 
    333                                                 $this->torrents[$torrent[0]]['tstate'] = 'message'; 
    334                                          
    335                                         if($this->torrents[$torrent[0]]['is_hash_checking'] == 1) 
    336                                                 $this->torrents[$torrent[0]]['tstate'] = 'chash';                     
    337  
    338                                         foreach($Tresponses[$key]->val as $tracker) 
    339                                         { 
    340                                                 $this->torrents[$torrent[0]]['seeds_scrape'] += $tracker[0]; 
    341                                                 $this->torrents[$torrent[0]]['peers_scrape'] += $tracker[1]; 
    342                                         } 
    343                                         // $this->torrents[$torrent[0]]['tags'] = Array(); 
    344                                         // $sql = "SELECT tagid FROM tags_torrents WHERE hash = '" . $torrent[0] . "';"; 
    345                                         // $res = $this->_db->query( $sql ); 
    346                                         //                      $result = $res->fetchAll(); 
    347                                         // foreach($result as $tag){ 
    348                                                 //      $sql = "SELECT value FROM tags WHERE id = '" . $tag['tagid'] . "';"; // Falta afegir lo del user 
    349                                                 //      $res = $this->_db->query( $sql ); 
    350                                                 //      $rslt = $res->fetch(); 
    351                                                 //      array_push($this->torrents[$torrent[0]]['tags'], $rslt['value']); 
    352                                                 // } 
    353  
    354                                         } 
    355  
    356                                 } 
    357                                 //print_r($this->torrents); 
    358                                 //XMLRPC_debug_print();*/ 
    359                         } 
    360     private function formatETA($time) 
     267 
     268    $seconds = (float) $time * 1000; 
     269    foreach ($periods as $period => $value)  
    361270    { 
    362       if (!is_array($periods)) { 
    363         $periods = array ( 
    364           'weeks'     => 604800, 
    365           'days'      => 86400, 
    366           'hours'     => 3600, 
    367           'minutes'   => 60, 
    368           ); 
    369       } 
    370   
    371       $seconds = (float) $time * 1000; 
    372       foreach ($periods as $period => $value)  
    373       { 
    374         $count = floor($seconds / $value); 
    375         if ($count == 0)  
    376           continue; 
    377   
    378         $values[$period] = $count; 
    379         $seconds = $seconds % $value; 
    380       } 
    381   
    382       foreach ($values as $key => $value)  
    383       { 
    384         $segment_name = substr($key, 0, 1); 
    385         $segment = $value . $segment_name;  
    386         // If ETA is weeks away, don't display minutes:        
    387         if ($key == "minutes") 
    388           if ($values["weeks"] >= 1) 
    389             $segment = ""; 
    390          
    391         $array[] = $segment; 
    392       } 
    393       // If ETA is more then 30 weeks away, display "inf" instead of precise ETA:  
    394       if ($values["weeks"] > 30) 
    395         $str = "inf"; 
    396       else 
    397         $str = implode('', $array); 
     271      $count = floor($seconds / $value); 
     272      if ($count == 0)  
     273        continue; 
     274 
     275      $values[$period] = $count; 
     276      $seconds = $seconds % $value; 
     277    } 
     278 
     279    foreach ($values as $key => $value)  
     280    { 
     281      $segment_name = substr($key, 0, 1); 
     282      $segment = $value . $segment_name;  
     283      // If ETA is weeks away, don't display minutes:        
     284      if ($key == "minutes") 
     285        if ($values["weeks"] >= 1) 
     286          $segment = ""; 
    398287       
    399       return $str
     288      $array[] = $segment
    400289    } 
     290     // If ETA is more then 30 weeks away, display "inf" instead of precise ETA:  
     291    if ($values["weeks"] > 30) 
     292      $str = "inf"; 
     293    else 
     294      $str = implode('', $array); 
     295      
     296    return $str; 
     297  } 
    401298} 
    402299?> 
  • trunk/wtorrent/home/cls/Tracker.cls.php

    r4 r51  
    1818class Tracker extends rtorrent 
    1919{ 
    20         private  $trackers; 
    21         private  $info_trackers = array('', '', 
    22                                                                 't.get_url=',  
    23                                                         't.get_normal_interval=', 
    24                                                         't.get_scrape_time_last=',  
    25                                                         't.get_scrape_complete=', 
    26                                                         't.get_scrape_incomplete=', 
    27                                                         't.is_enabled='); 
    28     
     20        private $hash; 
    2921 
    30     public function construct() 
     22       public function construct() 
    3123        { 
    3224                $this->hash = $this->_request['hash']; 
     
    3527                        return false; 
    3628                         
    37                 if(isset($this->_request['ch_tr']) && count($this->_request['trackers']) > 0) $this->changeEnabled($this->_request['trackers'], $this->_request['active'], $this->hash); 
    38                 $this->getTorrents($this->_request['hash']); 
    39                  
     29                $array_t = array('t.get_url', 't.get_normal_interval','t.get_scrape_time_last', 't.get_scrape_complete','t.get_scrape_incomplete','t.is_enabled'); 
     30                $this->multicall->t_multicall($this->hash, $array_t); 
    4031        } 
    41  
    4232        public function getHash() 
    4333        { 
     
    4636        public function getTrackers() 
    4737        { 
    48                 return $this->trackers; 
     38                $num = $this->torrents[$this->hash]->get_tracker_size(); 
     39                for($i = 0; $i < $num; $i++) 
     40                { 
     41                        $trackers[$i]['url'] = $this->torrents[$this->hash]->t_get_url($i); 
     42                        $trackers[$i]['scrape_completed'] = $this->torrents[$this->hash]->t_get_scrape_complete($i); 
     43                        $trackers[$i]['scrape_incomplete'] = $this->torrents[$this->hash]->t_get_scrape_incomplete($i); 
     44                        $trackers[$i]['enabled'] = $this->torrents[$this->hash]->t_is_enabled($i); 
     45                } 
     46                return $trackers; 
    4947        } 
    50         public function getName() 
    51         { 
    52                 return $this->details['name']; 
    53         } 
    54         public function getTorrent() 
    55         { 
    56                 return $this->details['torrent_file']; 
    57         } 
    58         public function getDataPath() 
    59         { 
    60                 return $this->details['data_path']; 
    61         } 
    62         public function getPercent() 
    63         { 
    64                 return $this->details['percent']; 
    65         } 
    66         public function getRatio() 
    67         { 
    68                 return $this->details['ratio']; 
    69         } 
    70         public function getSize() 
    71         { 
    72                 return $this->getCorrectUnits($this->details['size_in_chunks'] * $this->details['chunk_size']); 
    73         } 
    74         public function getDone() 
    75         { 
    76                 return $this->getCorrectUnits($this->details['completed_chunks'] * $this->details['chunk_size']); 
    77         } 
    78         public function getUp() 
    79         { 
    80                 return $this->getCorrectUnits($this->details['bytes_up']); 
    81         } 
    82         private function getCorrectUnits($size) 
    83     { 
    84                 $size_units = 'bytes'; 
    85                 if($size >= 1024) 
    86                 { 
    87                 $size /= 1024; 
    88                 $size_units = 'Kb'; 
    89                 } 
    90                 if($size >= 1024) 
    91                 { 
    92             $size /= 1024; 
    93             $size_units = 'Mb'; 
    94         } 
    95                 if($size >= 1024) 
    96         { 
    97             $size /= 1024; 
    98             $size_units = 'Gb'; 
    99         } 
    100         return round($size, 2) .  $size_units; 
    101  
    102     } 
    103          
    104         private function getTorrents($hash) 
    105     { 
    106         //define("XMLRPC_DEBUG", 1); 
    107          
    108         $this->info_trackers[0] = $hash; 
    109          
    110                 foreach($this->info_trackers as $param) 
    111                         $array_post[] = new xmlrpcval($param, 'string'); 
    112                  
    113                 $message = new xmlrpcmsg("t.multicall", $array_post); 
    114                 $result = $this->client->send($message); 
    115         //print_r($result); 
    116         foreach($result->val as $key => $tracker) 
    117         { 
    118                 if(SCRAMBLE === true) 
    119                         $tracker[0] = $this->scramble($tracker[0]); 
    120                  
    121                 $sc_time = time() - $tracker[2]; 
    122                 //echo $sc_time . " " . $tracker[1] . " " . time() . " " . $tracker[2]; 
    123                 if($sc_time > $tracker[1]) 
    124                         $enabled = 0; 
    125                 else 
    126                         $enabled = 1; 
    127                          
    128                 $this->trackers[$key]['url'] = $tracker[0]; 
    129                 $this->trackers[$key]['scrape_completed'] = $tracker[3]; 
    130                 $this->trackers[$key]['scrape_incomplete'] = $tracker[4]; 
    131                 $this->trackers[$key]['enabled'] = $tracker[5]; 
    132         } 
    133         //print_r($this->files); 
    134         //XMLRPC_debug_print(); 
    135     } 
    136     private function changeEnabled($trackers, $enabled, $hash) 
    137     { 
    138         $t_index = array_keys($trackers); 
    139         //print_r($f_index); 
    140          
    141         foreach($t_index as $param) 
    142                         $array_post[] = new xmlrpcmsg('t.set_enabled', array(new xmlrpcval($hash, 'string'), new xmlrpcval($param, 'int'), new xmlrpcval($enabled, 'int'))); 
    143                  
    144                 //print_r($array_post);  
    145                 $responses = $this->client->multicall($array_post); 
    146     } 
    14748} 
    14849?> 
  • trunk/wtorrent/home/css/estil.css

    r39 r51  
    6868        cursor: default; 
    6969        display: none; 
     70        height: 12px; 
    7071} 
    7172.messages:hover { 
  • trunk/wtorrent/home/js/javasc.js

    r49 r51  
    177177        ajaxCall(frame, call[0]); 
    178178        // Update the page (after 500ms to give rtorrent time to process the command (also set the frame to loading) 
    179         loadingContent(call[1]); 
    180         window.setTimeout("load('" + call[1] + "', '" + call[2] + "')", 500); 
     179        //loadingContent(call[1]); 
     180        window.setTimeout("load('" + call[1] + "', '" + call[2] + "')", 100); 
    181181} 
    182182 
  • trunk/wtorrent/lib/inc/includes.inc.php

    r4 r51  
    2222require_once( 'lib/cls/Web.cls.php'); 
    2323require_once( 'cls/rtorrent.cls.php' ); 
     24require_once( 'cls/torrent.cls.php' ); 
     25require_once( 'cls/multicall.cls.php' ); 
    2426require_once( 'lib/xmlrpc/xmlrpc.inc.php' ); 
    2527require_once( 'lib/inc/utils.inc.php' );