View Single Post
  #1  
Old 14th February 2014, 16:32
Ruffneck Ruffneck is offline
Senior Member
 
Join Date: Feb 2008
Posts: 71
Default Problem with class_torrent.php
am try rip upload.php and class_torrent.php ftom TS 7.2

but i have this error !

An error has occured!: Could not find info dictionary

somebody can help ?:(

upload.php

PHP Code:
<?php
/**
*
* @ iDezender 7.0
* @ Developed by Qarizma
*
* @   Visit our website:
* @   www.iRadikal.com
* @   For cheap decoding service :)
* @   And for the ionCube Decoder!
*
*/
function TS_Match($string$find) {
      return (
strpos$string$find ) === false false true);
   }

   function 
TS_Global($name '') {
      return (isset( 
$_GET['' $name] ) ? (!is_array$_GET['' $name] ) ? trim$_GET['' $name] ) : $_GET['' $name]) : (isset( $_POST['' $name] ) ? (!is_array$_POST['' $name] ) ? trim$_POST['' $name] ) : $_POST['' $name]) : ''));
   }
   
   function 
show_upload_errors() 
   {
      global 
$UploadErrors;
      global 
$lang;
      global 
$BASEURL;
      global 
$pic_base_url;

      if (
count$UploadErrors )) 
      {
         
$Errors '';
         foreach (
$UploadErrors as $Error) {
            
$Errors .= '<img src="' $pic_base_url 'error.gif" border="0" alt="" title="" /> ' $Error '<br />';
         }

         echo 
show_notice$Errors1$lang->upload['error'] );
         unset( 
$Errors );
      }

   }

   
define'TU_VERSION''3.0.7 by xam' );
   
define'THIS_SCRIPT''upload.php' );
   require( 
'./global.php' );
   
  require_once 
INC_PATH '/class_language.php';
  
$lang = new trackerlanguage ();
  
$lang->set_path (INC_PATH '/languages');
  if ((empty (
$_COOKIE['ts_language']) OR !file_exists (INC_PATH '/languages/' $_COOKIE['ts_language'])))
  {
    
$lang->set_language ($defaultlanguage);
  }
  else
  {
    
$lang->set_language ($_COOKIE['ts_language']);
  }
  
$lang->load ('global');

   if (!isset( 
$CURUSER )) {
      
print_no_permission(  );
   }

   @
ini_set'upload_max_filesize', (1000 $max_torrent_size $max_torrent_size 10485760) );
   @
ini_set'memory_limit''20000M' );
   
$lang->load'upload' );
   
   require_once( 
INC_PATH '/editor.php' );
   
   
$is_mod is_mod($usergroups);

    
$announce_urls = array ();
    
$announce_urls[] = 'http://' $_SERVER['HTTP_HOST'] . '/announce.php';
   
$externalscrape 'yes';
   
$use_torrent_details 'no';
   
$xbt_active 'no';
   
$search_before_upload 'no';
   
   
$ModerateTorrent = ($usergroups['canupload'] == 'moderate' true false);
   
$CanUploadExternalTorrent = (( $usergroups['canexternal'] == 'yes' AND $externalscrape == 'yes' ) ? true false);
   
$AnnounceURL trim( ($xbt_active == 'yes' $xbt_announce_url '/' $CURUSER['passkey'] . '/announce' $announce_urls['0'] . '?passkey=' $CURUSER['passkey']) );
   
$postoptions '';
   
$postoptionstitle '';
   
$UploadErrors = array(  );

   if (( isset( 
$_GET['id'] ) AND is_valid_id$_GET['id'] ) )) 
   {
      if (
$EditTorrentID intvalTS_Global'id' ) )) 
      {
         
$Query $db->sql_query'SELECT * FROM torrents WHERE id = ' $db->sqlesc$EditTorrentID ) );

         if (
$db->num_rows$Query )) {
            
$EditTorrent mysqli_fetch_assoc$Query );

            if (( 
$EditTorrent['owner'] != $CURUSER['id'] AND !$is_mod )) 
            {
               
print_no_permissiontrue );
            }

            
$name $EditTorrent['name'];
            
$descr $EditTorrent['descr'];
            
$IsExternalTorrent = (( $EditTorrent['ts_external'] == 'yes' AND $CanUploadExternalTorrent ) ? true false);
            
$category intval$EditTorrent['category'] );
            
$t_image_url $EditTorrent['t_image'];
            
$t_link $EditTorrent['t_link'];

            if (( 
$t_link AND preg_match'@http:\/\/www.imdb.com\/title\/(.*)\/@isU'$t_link$result ) )) 
            {
               
$t_link $result['0'];
               unset( 
$result );
            }

            
            
$anonymous $EditTorrent['anonymous'];
            
$free $EditTorrent['free'];
            
$silver $EditTorrent['silver'];
            
$doubleupload $EditTorrent['doubleupload'];
            
$allowcomments $EditTorrent['allowcomments'];
            
$sticky $EditTorrent['sticky'];
            
$isrequest $EditTorrent['isrequest'];
            
$isnuked $EditTorrent['isnuked'];
            
$WhyNuked $EditTorrent['WhyNuked'];

            if (
$use_torrent_details == 'yes'
            {
               
$query $db->sql_query'SELECT * FROM ts_torrents_details WHERE tid = ' $db->sqlesc$EditTorrentID ) );

               if (
$db->num_rows$query )) {
                  
$videot explode'~'mysql_result$query0'video_info' ) );
                  
$video['codec'] = (isset( $videot['0'] ) ? $videot['0'] : '');
                  
$video['bitrate'] = (isset( $videot['1'] ) ? $videot['1'] : '');
                  
$video['resulation'] = (isset( $videot['2'] ) ? $videot['2'] : '');
                  
$video['length'] = (isset( $videot['3'] ) ? $videot['3'] : '');
                  
$video['quality'] = (isset( $videot['4'] ) ? $videot['4'] : '');
                  
$audiot explode'~'mysql_result$query0'audio_info' ) );
                  
$audio['codec'] = (isset( $audiot['0'] ) ? $audiot['0'] : '');
                  
$audio['bitrate'] = (isset( $audiot['1'] ) ? $audiot['1'] : '');
                  
$audio['frequency'] = (isset( $audiot['2'] ) ? $audiot['2'] : '');
                  
$audio['language'] = (isset( $audiot['3'] ) ? $audiot['3'] : '');
               }
            }
         } 
else {
            
print_no_permission(  );
         }
      } 
else {
         
print_no_permission(  );
      }
   }


   
//if ($usergroups['canupload'] == 'no') {
   //   print_no_permission( false, true, $lang->upload['uploaderform'] );
   //}

   
$query $db->sql_query'SELECT userid FROM ts_u_perm WHERE userid = ' $db->sqlesc$CURUSER['id'] ) . ' AND canupload = \'0\'' );

   if (
$db->num_rows$query )) 
   {
      
print_no_permissionfalsetrue$lang->upload['uploaderform'] );
   }


   if (
strtoupper$_SERVER['REQUEST_METHOD'] ) == 'POST') {
      
$name TS_Global'subject' );
      
$descr TS_Global'message' );
      
$torrentfile $_FILES['torrentfile'];
      
$IsExternalTorrent = (( ( isset( $_POST['IsExternalTorrent'] ) AND $_POST['IsExternalTorrent'] == 'yes' ) AND $CanUploadExternalTorrent ) ? true false);
      
$nfofile $_FILES['nfofile'];
      
$UseNFOasDescr TS_Global'UseNFOasDescr' );
      
$category intvalTS_Global'category' ) );
      
$t_image_url TS_Global't_image_url' );
      
$t_image_file $_FILES['t_image_file'];
      
$t_link TS_Global't_link' );
      
$anonymous TS_Global'anonymous' );
      
$free TS_Global'free' );
      
$silver TS_Global'silver' );
      
$doubleupload TS_Global'doubleupload' );
      
$allowcomments TS_Global'allowcomments' );
      
$sticky TS_Global'sticky' );
      
$isrequest TS_Global'isrequest' );
      
$isnuked TS_Global'isnuked' );
      
$WhyNuked TS_Global'WhyNuked' );



      if (( isset( 
$nfofile['name'] ) AND !empty( $nfofile['name'] ) )) 
      {
         if (
get_extension$nfofile['name'] ) != 'nfo'
         {
            
$UploadErrors[] = $lang->upload['error10'];
         }


         if (
$nfofile['size'] == '0'
         {
            
$UploadErrors[] = $lang->upload['error11'];
         }


         if (
$nfofile['error'] != '0'
         {
            
$UploadErrors[] = $lang->upload['error6'] . ' {' intval$nfofile['error'] ) . '}';
         }


         if (!
is_file$nfofile['tmp_name'] )) 
         {
            
$UploadErrors[] = $lang->upload['error6'] . ' {' intval$nfofile['error'] ) . '}';
         }


         if (
count$UploadErrors ) == 0
         {
            
$NfoContents file_get_contents$nfofile['tmp_name'] );
         }
      }


      if (( empty( 
$name ) || strlen$name ) < )) 
      {
         if (( isset( 
$torrentfile['name'] ) AND !empty( $torrentfile['name'] ) )) 
         {
            
$name str_replace'.torrent'''$torrentfile['name'] );
         } 
else {
            
$UploadErrors[] = $lang->upload['error1'];
         }
      }


      if (( empty( 
$descr ) || strlen$descr ) < 10 )) 
      {
         if (( ( 
$UseNFOasDescr == 'yes' AND isset( $NfoContents ) ) AND !empty( $NfoContents ) )) 
         {
         } 
else {
            
$UploadErrors[] = $lang->upload['error2'];
         }
      }


      if (( ( isset( 
$torrentfile['name'] ) AND !empty( $torrentfile['name'] ) ) AND !$IsExternalTorrent )) 
      {
         
$UpdateHash true;
      }


      if (( isset( 
$EditTorrent ) AND empty( $torrentfile['name'] ) )) {
         
$torrentfile['name'] = $EditTorrent['filename'];
         
$torrentfile['type'] = 'application/x-bittorrent';
         
$torrentfile['size'] = $EditTorrent['size'];
         
$torrentfile['error'] = 0;
         
$torrentfile['tmp_name'] = $torrent_dir '/' $EditTorrentID '.torrent';
      }


      if (( isset( 
$torrentfile['name'] ) AND !empty( $torrentfile['name'] ) )) 
      {
         if (
get_extension$torrentfile['name'] ) != 'torrent') {
            
$UploadErrors[] = $lang->upload['error3'];
         }


         if (
$torrentfile['size'] == '0'
         {
            
$UploadErrors[] = $lang->upload['error5'];
         }


         if (
$torrentfile['error'] != '0'
         {
            
$UploadErrors[] = $lang->upload['error6'] . ' {' intval$torrentfile['error'] ) . '}';
         }


         if (!
is_file$torrentfile['tmp_name'] )) 
         {
            
$UploadErrors[] = $lang->upload['error6'] . ' {' intval$torrentfile['error'] ) . '}';
         }
      } 
else {
         
$UploadErrors[] = $lang->upload['error3'];
      }


      if (!
$category
      {
         
$UploadErrors[] = $lang->upload['error9'];
      }


      if (
count$UploadErrors ) == 0
      {
         require_once( 
INC_PATH '/class_torrent.php' );

         if (
$Data file_get_contents$torrentfile['tmp_name'] )) 
         {
            
//Torrent;
            
$Torrent = new Torrent();

            if (
$Torrent->load$Data )) {
               
$info_hash $Torrent->getHash();

               if (( ( ( 
$privatetrackerpatch == 'yes' AND $IsExternalTorrent ) AND $Torrent->getWhatever'announce' ) == $AnnounceURL ) AND $Torrent->getWhatever'announce-list' ) == null )) 
               {
                  
$IsExternalTorrent false;
               }


               if (( 
$privatetrackerpatch == 'yes' AND !$IsExternalTorrent )) 
               {
                  
$Torrent->removeWhatever'announce-list' );
                  
$Torrent->removeWhatever'nodes' );

                  if (
$Torrent->getPrivate(  ) != '1'
                  {
                     
$Torrent->setPrivate'1' );
                  }


                  if (
$Torrent->getWhatever'announce' ) != $AnnounceURL
                  {
                     
$Torrent->setTrackers( array( $AnnounceURL ) );
                  }
               }


               if (( 
$privatetrackerpatch != 'yes' AND !$IsExternalTorrent )) 
               {
                  if (
$Torrent->getWhatever'announce' ) != $AnnounceURL
                  {
                     
$Torrent->addTracker$AnnounceURL );
                  }
               }


               if (
strlen$Torrent->getPieces(  ) ) % 20 != 0
               {
                  
$UploadErrors[] = $lang->upload['error7'];
               }
            } 
else {
               
$UploadErrors[] = $lang->global['error'] . ': ' htmlspecialchars_uni$Torrent->error );
            }
         } 
else {
            
$UploadErrors[] = $lang->upload['error7'];
         }
      }


      if (
count$UploadErrors ) == 0
      {
         
$Torrent->setComment$lang->upload['DefaultTorrentComment'] );
         
$Torrent->setCreatedBysprintf$lang->upload['CreatedBy'], ($anonymous == 'yes' '' $CURUSER['username']) ) . ' [' $SITENAME ']' );
         
$Torrent->setSource$BASEURL );
         
$Torrent->setCreationDateTIMENOW );
         
$check_info_hash $Torrent->getHash( );

         if (
$info_hash != $check_info_hash
         {
            
$info_hash $check_info_hash;
            unset( 
$check_info_hash );
            
$UpdateHash true;
            
$Info_hash_changed true;
         }

         
$numfiles 0;
         
$size 0;
         
$IncludedFiles $Torrent->getFiles(  );
         foreach (
$IncludedFiles as $File
         {
            ++
$numfiles;
            
$size += $File->length;
         }

         
$filename str_replace'.torrent'''$torrentfile['name'] );
         
$filename MakeFriendlyText$filename );
         
$filename $filename '.torrent';
         
$UpdateSet = array( );

         if (( isset( 
$UpdateHash ) || !isset( $EditTorrent ) )) {
            
$UpdateSet[] = 'info_hash = ' $db->sqlesc$info_hash );
         }

         
$UpdateSet[] = 'name = ' $db->sqlesc$name );
         
$UpdateSet[] = 'filename = ' $db->sqlesc$filename );
         
$UpdateSet[] = 'category = ' $db->sqlesc$category );
         
$UpdateSet[] = 'size = ' $db->sqlesc$size );
         
$UpdateSet[] = 'numfiles = ' $db->sqlesc$numfiles );

         if (
$descr
         {
            
$UpdateSet[] = 'descr = ' $db->sqlesc$descr );
         }


         if (!isset( 
$EditTorrent )) 
         {
            
$UpdateSet[] = 'added = NOW()';
            
$UpdateSet[] = 'ctime = UNIX_TIMESTAMP()';
            
$UpdateSet[] = 'owner = ' $db->sqlesc$CURUSER['id'] );
         } 
else {
            
$UpdateSet[] = 'mtime = UNIX_TIMESTAMP()';
         }


         if (
$is_mod
         {
            if (
$free == 'yes'
            {
               
$UpdateSet[] = 'free = \'yes\'';
               
$UpdateSet[] = 'silver = \'no\'';
               
//$UpdateSet[] = 'download_multiplier = \'0\'';
            

else {
               if (
$silver == 'yes'
               {
                  
$UpdateSet[] = 'silver = \'yes\'';
                  
$UpdateSet[] = 'free = \'no\'';
                  
//$UpdateSet[] = 'download_multiplier = \'0.5\'';
               

else {
                  
$UpdateSet[] = 'silver = \'no\'';
                  
$UpdateSet[] = 'free = \'no\'';
                  
//$UpdateSet[] = 'download_multiplier = \'1\'';
               
}
            }


            if (
$doubleupload == 'yes'
            {
               
$UpdateSet[] = 'doubleupload = \'yes\'';
               
//$UpdateSet[] = 'upload_multiplier = \'2\'';
            

else {
               
$UpdateSet[] = 'doubleupload = \'no\'';
               
$UpdateSet[] = 'upload_multiplier = \'1\'';
            }

            
//$UpdateSet[] = '`flags` = \'' . (( ( $free == 'yes' || ( $free != 'yes' && $silver == 'yes' ) ) || $doubleupload == 'yes' ) ? 2 : 0) . '\'';

            
if ($allowcomments == 'no'
            {
               
$UpdateSet[] = 'allowcomments = \'no\'';
            } 
else {
               
$UpdateSet[] = 'allowcomments = \'yes\'';
            }


            if (
$sticky == 'yes'
            {
               
$UpdateSet[] = 'sticky = \'yes\'';
            } 
else {
               
$UpdateSet[] = 'sticky = \'no\'';
            }


            if (
$isnuked == 'yes'
            {
               
$UpdateSet[] = 'WhyNuked = ' $db->sqlesc$WhyNuked );
               
$UpdateSet[] = 'isnuked = \'yes\'';
            } 
else {
               
$UpdateSet[] = 'WhyNuked = \'\'';
               
$UpdateSet[] = 'isnuked = \'no\'';
            }
         }


         if (
$isrequest == 'yes'
         {
            
$UpdateSet[] = 'isrequest = \'yes\'';
         } 
else {
            
$UpdateSet[] = 'isrequest = \'no\'';
         }


         if (
$anonymous == 'yes'
         {
            
$UpdateSet[] = 'anonymous = \'yes\'';
         } 
else {
            
$UpdateSet[] = 'anonymous = \'no\'';
         }




         if (
$IsExternalTorrent
         {
            
$UpdateSet[] = 'ts_external = \'yes\'';
            
$UpdateSet[] = 'ts_external_url = ' $db->sqlesc$Torrent->getWhatever'announce' ) );
            
$UpdateSet[] = 'visible = \'yes\'';
         } 
else {
            
$UpdateSet[] = 'ts_external = \'no\'';
            
$UpdateSet[] = 'ts_external_url = \'\'';

            if (( !isset( 
$EditTorrent ) AND $xbt_active != 'yes' )) 
            {
               
$UpdateSet[] = 'visible = \'no\'';
            }
         }


         if (!isset( 
$EditTorrentID )) 
         {
            if (
$ModerateTorrent
            {
               
$UpdateSet[] = 'moderate = \'1\'';
            } 
else {
               
$UpdateSet[] = 'moderate = \'0\'';
            }
         }


         if (empty( 
$t_link )) 
         {
            
$UpdateSet[] = 't_link = \'\'';
         } 
else {
            if (
substr$t_link1) != '/') {
               
$t_link $t_link '/';
            }


            if (
preg_match'@^http:\/\/www.imdb.com\/title\/(.*)\/$@isU'$t_link$result )) 
            {
               if (
$result['0']) {
                  
$t_link $result['0'];
                  include_once( 
INC_PATH '/ts_imdb.php' );
                  
$UpdateSet[] = 't_link = ' $db->sqlesc$t_link );
                  unset( 
$result );
               }
            }
         }


         if (empty( 
$t_image_url )) 
         {
            
$UpdateSet[] = 't_image = \'\'';
         }

         ( 
$db->sql_query( (isset( $EditTorrent ) ? 'UPDATE' 'INSERT INTO') . ' torrents SET ' implode', '$UpdateSet ) . (isset( $EditTorrent ) ? ' WHERE id = ' $db->sqlesc$EditTorrentID ) : '') ) || stderr$lang->global['error'], $lang->upload['error13'] . ' {' htmlspecialchars_unimysql_error(  ) ) . '}' ) );

         if (isset( 
$EditTorrent )) 
         {
            
$NewTID $EditTorrentID;

            if (
is_file$torrent_dir '/' $NewTID '.torrent' )) 
            {
               @
unlink$torrent_dir '/' $NewTID '.torrent' );
            }
         } 
else {
            
$NewTID $db->insert_id();
         }


         if (!empty( 
$t_image_url )) 
         {
            
$t_image_url fix_url$t_image_url );
            
$AllowedFileTypes = array( 'jpg''gif''png' );
            
$ImageExt get_extension$t_image_url );

            if (
in_array$ImageExt$AllowedFileTypestrue )) {
               
$AllowedMimeTypes = array( 'image/jpeg''image/gif''image/png' );
               
$ImageDetails getimagesize$t_image_url );

               if (( 
$ImageDetails AND in_array$ImageDetails['mime'], $AllowedMimeTypestrue ) )) {
                  include_once( 
INC_PATH '/functions_ts_remote_connect.php' );

                  if (
$ImageContents TS_Fetch_Data$t_image_urlfalse )) {
                     
$NewImageURL $torrent_dir '/images/' $NewTID '.' $ImageExt;

                     if (
file_exists$NewImageURL )) {
                        @
unlink$NewImageURL );
                     }


                     if (
file_put_contents$NewImageURL$ImageContents )) {
                        
$COVERIMAGEUPDATED true;
                        
$db->sql_query'UPDATE torrents SET t_image = ' $db->sqlesc$BASEURL '/' $NewImageURL ) . ' WHERE id = ' $db->sqlesc$NewTID ) );
                     }
                  }
               }
            }
         }


         if (!empty( 
$t_image_file )) 
         {
            if (( ( ( 
$t_image_file['size'] AND $t_image_file['error'] === ) AND $t_image_file['tmp_name'] ) AND $t_image_file['name'] )) {
               
$t_image_url fix_url$t_image_file['name'] );
               
$AllowedFileTypes = array( 'jpg''gif''png' );
               
$ImageExt get_extension$t_image_url );

               if (
in_array$ImageExt$AllowedFileTypestrue )) {
                  
$AllowedMimeTypes = array( 'image/jpeg''image/gif''image/png' );
                  
$ImageDetails getimagesize$t_image_file['tmp_name'] );

                  if (( 
$ImageDetails AND in_array$ImageDetails['mime'], $AllowedMimeTypestrue ) )) {
                     if (
$ImageContents file_get_contents$t_image_file['tmp_name'] )) {
                        
$NewImageURL $torrent_dir '/images/' $NewTID '.' $ImageExt;

                        if (
file_exists$NewImageURL )) {
                           @
unlink$NewImageURL );
                        }


                        if (
file_put_contents$NewImageURL$ImageContents )) {
                           
$COVERIMAGEUPDATED true;
                           
$db->sql_query'UPDATE torrents SET t_image = ' $db->sqlesc$BASEURL '/' $NewImageURL ) . ' WHERE id = ' $db->sqlesc$NewTID ) );
                        }
                     }
                  }
               }
            }
         }


         if (( !isset( 
$COVERIMAGEUPDATED ) AND isset( $cover_photo_name ) )) 
         {
            
$db->sql_query'UPDATE torrents SET t_image = ' $db->sqlesc$BASEURL '/' $cover_photo_name ) . ' WHERE id = ' $db->sqlesc$NewTID ) );
         }


         if (isset( 
$EditTorrent )) 
         {
            
write_logsprintf$lang->upload['editedtorrent'], $name$CURUSER['username'] ) );
         } 
else {
            
write_logsprintf$lang->upload['newtorrent'], $name$CURUSER['username'] ) );
         }

         
$TorrentContents $Torrent->bencode();

         if (( 
$TorrentContents AND file_put_contents$torrent_dir '/' $NewTID '.torrent'$TorrentContents ) )) 
         {
            if (
$IsExternalTorrent) {
               
$externaltorrent $torrent_dir '/' $NewTID '.torrent';
               
$id $NewTID;
               include_once( 
INC_PATH '/ts_external_scrape/ts_external.php' );
            }


            if (( isset( 
$NfoContents ) AND !empty( $NfoContents ) )) {
               if (
$UseNFOasDescr == 'yes') {
                  
$NewDescr $BASEURL '/viewnfo.php?id=' $NewTID;
                  
$db->sql_query'UPDATE torrents SET descr = ' $db->sqlesc$NewDescr ) . ' WHERE id = ' $db->sqlesc$NewTID ) );
               }

               
$db->sql_query'REPLACE INTO ts_nfo (id, nfo) VALUES (' $NewTID ', ' $db->sqlesc$NfoContents ) . ')' );
            }


            if (( 
$ModerateTorrent AND !isset( $EditTorrentID ) )) 
            {
               
$msgtext sprintf$lang->upload['modmsgss'], $name$CURUSER['username'], '[URL]' $BASEURL '/details.php?id=' $NewTID '[/URL]' );
               
$message $db->sqlesc$msgtext );
               
$subject $db->sqlesc$lang->upload['modmsgs'] );
               
//( $db->sql_query( '' . 'INSERT INTO staffmessages (sender, added, msg, subject) VALUES(0, NOW(), ' . $message . ', ' . $subject . ')' ) || sqlerr( __FILE__, 705 ) );
               
stderr$lang->upload['title'], $lang->upload['mulmsg'] );
            } 
else {
               if (!isset( 
$EditTorrent )) 
               {

                  
$res $db->sql_query'SELECT name FROM categories WHERE id = ' $db->sqlesc$category ) );
                  
$cat mysql_result$res0'name' );
                  
$res $db->sql_query'' 'SELECT u.email FROM users u LEFT JOIN usergroups g ON (u.usergroup=g.gid) WHERE u.enabled=\'yes\' AND u.status=\'confirmed\' AND u.notifs LIKE \'%[cat' $category ']%\' AND u.notifs LIKE \'%[email]%\' AND u.notifs != \'\' AND g.isvipgroup=\'yes\' AND g.canemailnotify=\'yes\'' );
                  
$size mksize$size );
                  
$body sprintf$lang->upload['emailbody'], $name$size$cat, ($anonymous == 'yes' 'N/A' $CURUSER['username']), $descr$BASEURL$NewTID$SITENAME );
                  
$to '';
                  
$nmax 100;
                  
$nthis $ntotal 0;
                  
$total $db->num_rows$res );

                  if (
$total) {
                     while (
$arr mysqli_fetch_row$res )) {
                        if (
$nthis == 0) {
                           
$to $arr[0];
                        } 
else {
                           
$to .= ',' $arr[0];
                        }

                        ++
$nthis;
                        ++
$ntotal;

                        if (( 
$nthis == $nmax || $ntotal == $total )) {
                           
$sm sent_mail$tosprintf$lang->upload['emailsubject'], $SITENAME$name ), $body'ts_upload_torrent'false );
                           
$nthis 0;
                           continue;
                        }
                     }
                  }

                  

                  

                  
//if (( $tsshoutbot == 'yes' && TS_Match( $tsshoutboxoptions, 'upload' ) )) {
                  ///   $seo_link = ts_seo( $NewTID, $name, 's' );
                  //   $shoutbOT = sprintf( $lang->upload['shoutbOT'], $seo_link, $name, ($anonymous == 'yes' ? 'N/A' : $CURUSER['username']) );
                  //   require( INC_PATH . '/functions_ajax_chatbot.php' );
                  //   TSAjaxShoutBOT( $shoutbOT );
                  //}


                  
               
}
            }


            if (isset( 
$Info_hash_changed )) 
            {
               
stdhead$lang->upload['title'] );
               echo 
show_noticesprintf$lang->upload['done'], 'download.php?id=' $NewTID'details.php?id=' $NewTID ), false$lang->upload['title'] );
               
stdfoot(  );
               exit(  );
            } 
else {
               
redirect'details.php?id=' $NewTID );
               exit(  );
            }
         } 
else {
            
$UploadErrors[] = $lang->upload['error8'];
         }
      }
   }

   require( 
INC_PATH '/functions_category.php' );
   
$postoptionstitle = array( => $lang->upload['category'], => $lang->upload['cover'], => $lang->upload['t_link'], => $lang->upload['isScene1'], => $lang->upload['offensive1'], => $lang->upload['anonymous1'], => $lang->upload['isrequest1'] );
   
$postoptions = array( => ts_category_list'category', (isset( $category ) ? $category '') ), => '
      <input type="radio" name="nothingtopost" value="1" onclick="ChangeBox(this.value);" checked="checked" /> ' 
$lang->upload['cover1'] . '
      <div style="display: inline;" id="nothingtopost1">
         <br /><input type="text" name="t_image_url" id="specialboxg" size="70" value="' 
. (isset( $t_image_url ) ? htmlspecialchars_uni$t_image_url ) : '') . '" />
      </div>
      <br />
      
      <input type="radio" name="nothingtopost" value="2" onclick="ChangeBox(this.value);" /> ' 
$lang->upload['cover2'] . '
      <div style="display: none;" id="nothingtopost2">
         <br /><input type="file" name="t_image_file" id="specialboxg" size="70" />
      </div>'
=> '<input type="text" name="t_link" id="specialboxg" size="70" value="' . (isset( $t_link ) ? htmlspecialchars_uni$t_link ) : '') . '" /> ' $lang->upload['t_link2'], => '<input type="checkbox" name="anonymous" value="yes"' . (( ( isset( $anonymous ) AND $anonymous == 'yes' ) || ( TS_Match$CURUSER['options'], 'I3' ) || TS_Match$CURUSER['options'], 'I4' ) ) ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['anonymous2'], => '<input type="checkbox" name="isrequest" value="yes"' . (( isset( $isrequest ) AND $isrequest == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['isrequest2'] );

   if (
$is_mod
   {
      
$postoptionstitle[] = '<fieldset><legend>' $lang->upload['moptions'] . '</legend>';
      
$postoptions[] = '
   <table width="100%" cellpadding="4" cellspacing="0" border="0">
      <tr>
         <td class="none">
            <b>' 
$lang->upload['free1'] . '</b><br />
            <input type="checkbox" name="free" value="yes"' 
. (( isset( $free ) AND $free == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['free2'] . '
         </td>
         <td class="none">
            <b>' 
$lang->upload['silver1'] . '</b><br />
            <input type="checkbox" name="silver" value="yes"' 
. (( isset( $silver ) AND $silver == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['silver2'] . '
         </td>
      </tr>
      
      <tr>
         <td class="none">
            <b>' 
$lang->upload['doubleupload1'] . '</b><br />
            <input type="checkbox" name="doubleupload" value="yes"' 
. (( isset( $doubleupload ) AND $doubleupload == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['doubleupload2'] . '
         </td>
         <td class="none">
            <b>' 
$lang->upload['allowcomments1'] . '</b><br />
            <input type="checkbox" name="allowcomments" value="no"' 
. (( isset( $allowcomments ) AND $allowcomments == 'no' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['allowcomments2'] . '
         </td>
      </tr>

      <tr>
         <td class="none">
            <b>' 
$lang->upload['sticky1'] . '</b><br />
            <input type="checkbox" name="sticky" value="yes"' 
. (( isset( $sticky ) AND $sticky == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" /> ' $lang->upload['sticky2'] . '
         </td>
         <td class="none">
            <b>' 
$lang->upload['nuked1'] . '</b><br />
            <input type="checkbox" name="isnuked" value="yes"' 
. (( isset( $isnuked ) AND $isnuked == 'yes' ) ? ' checked="checked"' '') . ' class="inlineimg" onclick="ShowHideField(\'nukereason\');" /> ' $lang->upload['nuked2'] . '
            <div style="display:' 
. (( isset( $isnuked ) AND $isnuked == 'yes' ) ? 'inline' 'none') . ';" id="nukereason">
               <br /><b>' 
$lang->upload['nreason'] . '</b> <input type="text" name="WhyNuked" value="' . (isset( $WhyNuked ) ? htmlspecialchars_uni$WhyNuked ) : '') . '" size="40" />
            </div>
         </td>
      </tr>
   </table>
   </fieldset>'
;
   }

   
$str '';

   if (
$search_before_upload == 'yes'
   {
      
define'SUBJECT_EXTRA'' onKeyDown="SearchBeforeUpload(this);" onKeyUp="SearchBeforeUpload(this);"' );
      
$str .= '
   <script type="text/javascript" src="' 
$BASEURL '/scripts/quick_searchbu.js?v=' O_SCRIPT_VERSION '"></script>
   <script type="text/javascript">
      function SearchBeforeUpload(Whatever)
      {
         var subject = Whatever.value;
         var subjectlength = subject.length;
         var defaultContent =  \'<img src="' 
$BASEURL '/include/templates/' ts_template(  ) . '/images/loading.gif" border="0" alt="' $lang->global['pleasewait'] . '" title="' $lang->global['pleasewait'] . '" class="inlineimg" /> ' $lang->upload['sbu_wait'] . '\';

         if (subjectlength > 2)
         {
            TSGetID("search_before_upload").style.display = "inline";
            get(subject);
         }
         else
         {
            TSGetID("search_before_upload").style.display = "none";
            TSGetID("search_before_upload_results").innerHTML = defaultContent;
         }
      }
      function EnableDisableField(fName)
      {
         if(TSGetID(fName).disabled)
         {
            TSGetID(fName).disabled = "";
         }
         else
         {
            TSGetID(fName).value = "";
            TSGetID(fName).disabled = "disabled";
         }
      }
      function ShowHideField(fName)
      {
         if(TSGetID(fName).style.display == "inline")
         {
            TSGetID(fName).style.display = "none";
         }
         else
         {
            TSGetID(fName).style.display = "inline";
         }
      }
   </script>
   
   <div id="search_before_upload" style="display: none;">
      <table width="100%" align="center" border="0" cellpadding="5" cellspacing="0">
         <tr>
            <td class="thead">
               ' 
ts_collapse'sbu' ) . '
               ' 
$lang->upload['sbu'] . '
            </td>
         </tr>
         ' 
ts_collapse'sbu') . '
         <tr>
            <td>
               <div id="search_before_upload_results">                  
                  
               </div>
            </td>
         </tr>
      </table>
      <br />
   </div>'
;
   }

   
$str .= '
<div id="ts_uploading_progress">
</div>
<div id="ts_upload_form">
   <form method="post" action="' 
$_SERVER['SCRIPT_NAME'] . (isset( $EditTorrent ) ? '?id=' $EditTorrentID '') . '" name="ts_upload_torrent" enctype="multipart/form-data" onsubmit="return ProcessUpload();">';
   
$FirstTabs = array( $lang->upload['torrentfile'] => '<input type="file" name="torrentfile" id="torrentfile" onchange="checkFileName(this.value);" />' . ($CanUploadExternalTorrent ' <input type="checkbox" name="IsExternalTorrent" value="yes"' . (( isset( $IsExternalTorrent ) AND $IsExternalTorrent == true ) ? ' checked="checked"' '') . ' /> ' $lang->upload['isexternal'] : ''), $lang->upload['nfofile'] => '<input type="file" name="nfofile" id="nfofile" onchange="checknfoFileName(this.value);" /> <input type="checkbox" name="UseNFOasDescr" value="yes"' . (( isset( $UseNFOasDescr ) AND $UseNFOasDescr == 'yes' ) ? ' checked="checked"' '') . ' onclick="enableDisableTA(this.checked);" /> ' $lang->upload['UseNFOasDescr'], $lang->upload['tname'] => '<input type="text" name="subject" id="subject" style="width: 650px" value="' . (isset( $name ) ? htmlspecialchars_uni$name ) : '') . '" tabindex="1"' . (defined'SUBJECT_EXTRA' ) ? SUBJECT_EXTRA '') . ' autocomplete="off" />' );
   
$str .= insert_editorfalse'', (isset( $descr ) ? $descr ''), $lang->upload['title'], sprintf$lang->upload['title2'], $AnnounceURL ), $postoptionstitle$postoptionsfalse'', (isset( $EditTorrent ) ? $lang->upload['savechanges'] : $lang->upload['title']), ''''$FirstTabs );
   
$str .= '
   </form>
</div>
<script type="text/javascript">
   function file_get_ext(filename)
   {
      return typeof filename != "undefined" ? filename.substring(filename.lastIndexOf(".")+1, filename.length).toLowerCase() : false;
   }

   function checkFileName(path)
   {
      var ext = file_get_ext(path);
      //var fullpath = path;
      //var newpath = fullpath.substring(0, fullpath.length-8);
      //TSGetID("subject").value = newpath;

      if (!ext || ext != "torrent")
      {
         alert("' 
strip_tags$lang->upload['error3'] ) . '");
      }
   }

   function checknfoFileName(path)
   {
      var ext = file_get_ext(path);

      if (!ext || ext != "nfo")
      {
         alert("' 
strip_tags$lang->upload['error10'] ) . '");
      }
   }

   function enableDisableTA(cStatus)
   {
      if (cStatus == true)
      {
         TSGetID("message_new").disabled = "disabled";
         TSGetID("message_old").disabled = "disabled";
         TSGetID("message_new").value = "";
         TSGetID("message_old").value = "";
      }
      else
      {
         TSGetID("message_new").disabled = "";
         TSGetID("message_old").disabled = "";
      }
   }

   function ProcessUpload()
   {
      TSGetID(\'ts_uploading_progress\').innerHTML = \'<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td class="thead">' 
$lang->global['pleasewait'] . '</td></tr><tr><td><img src="include/templates/' ts_template(  ) . '/images/loading.gif" border="0" alt="" title="" class="inlineimg" /> ' trim$lang->upload['uploading'] ) . '</td></tr></table>\';
      TSGetID(\'ts_upload_form\').style.display = \'none\';
      return true;
   }

   function ChangeBox(BoxValue)
   {
      TSGetID("nothingtopost1").style.display = "none";
      TSGetID("nothingtopost2").style.display = "none";
      TSGetID("nothingtopost"+BoxValue).style.display = "inline";
   }
</script>'
;

   if (( isset( 
$upload_page_notice ) AND !empty( $upload_page_notice ) )) {
      
$str show_notice$upload_page_notice ) . $str;
   }

   
stdhead$lang->upload['title'] );
   
show_upload_errors(  );
   echo 
$str;
   
stdfoot(  );
?>
class_torrent.php

PHP Code:
<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

class Torrent
{
    
// Private class members
    
private $torrent;
    private 
$info;

    
// Public error message, $error is set if load() returns false
    
public $error;

    
// Load torrent file data
    // $data - raw torrent file contents
    
public function load( &$data )
    {
        
$this->torrent BEncode::decode$data );

        if ( 
$this->torrent->get_type() == 'error' )
        {
            
$this->error $this->torrent->get_plain();
            return 
false;
        }
        else if ( 
$this->torrent->get_type() != 'dictionary' )
        {
            
$this->error 'The file was not a valid torrent file.';
            return 
false;
        }

        
$this->info $this->torrent->get_value('info');
        if ( !
$this->info )
        {
            
$this->error 'Could not find info dictionary.';
            return 
false;
        }

        return 
true;
    }
   
   
   public function 
getWhatever$Whatever )
    {
        return 
$this->torrent->get_value$Whatever ) ? $this->torrent->get_value$Whatever )->get_plain( ) : null;
    }

    
// Get comment
    // return - string
    
public function getComment() {
        return 
$this->torrent->get_value('comment') ? $this->torrent->get_value('comment')->get_plain() : null;
    }

    
// Get creatuion date
    // return - php date
    
public function getCreationDate() {
        return  
$this->torrent->get_value('creation date') ? $this->torrent->get_value('creation date')->get_plain() : null;
    }

    
// Get created by
    // return - string
    
public function getCreatedBy() {
        return 
$this->torrent->get_value('created by') ? $this->torrent->get_value('created by')->get_plain() : null;
    }

    
// Get name
    // return - filename (single file torrent)
    //          directory (multi-file torrent)
    // see also - getFiles()
    
public function getName() {
        return 
$this->info->get_value('name')->get_plain();
    }

    
// Get piece length
    // return - int
    
public function getPieceLength() {
        return 
$this->info->get_value('piece length')->get_plain();
    }

    
// Get pieces
    // return - raw binary of peice hashes
    
public function getPieces() {
        return 
$this->info->get_value('pieces')->get_plain();
    }

    
// Get private flag
    // return - -1 public, implicit
    //           0 public, explicit
    //           1 private
    
public function getPrivate() {
        if ( 
$this->info->get_value('private') )
        {
            return 
$this->info->get_value('private')->get_plain();
        }
        return -
1;
    }

    
// Get a list of files
    // return - array of Torrent_File
    
public function getFiles() {
        
// Load files
        
$filelist = array();
        
$length $this->info->get_value('length');

        if ( 
$length )
        {
            
$file = new Torrent_File();
            
$file->name $this->info->get_value('name')->get_plain();
            
$file->length =  $this->info->get_value('length')->get_plain();
            
array_push$filelist$file );
        }
        else if ( 
$this->info->get_value('files') )
        {
            
$files $this->info->get_value('files')->get_plain();
            while ( list( 
$key$value ) = each$files ) )
            {
                
$file = new Torrent_File();

                
$path $value->get_value('path')->get_plain();
                while ( list( 
$key$value2 ) = each$path ) )
                {
                    
$file->name .= "/" $value2->get_plain();
                }
                
$file->name ltrim$file->name'/' );
                
$file->length =  $value->get_value('length')->get_plain();

                
array_push$filelist$file );
            }
        }

        return 
$filelist;
    }

    
// Get a list of trackers
    // return - array of strings
    
public function getTrackers() {
        
// Load tracker list
        
$trackerlist = array();

        if ( 
$this->torrent->get_value('announce-list') )
        {
            
$trackers $this->torrent->get_value('announce-list')->get_plain();
            while ( list( 
$key$value ) = each$trackers ) )
            {
                if ( 
is_array$value->get_plain() ) ) {
                    while ( list( 
$key$value2 ) = each$value ) )
                    {
                        while ( list( 
$key$value3 ) = each$value2 ) )
                        {
                            
array_push$trackerlist$value3->get_plain() );
                        }
                    }
                } else {
                    
array_push$trackerlist$value->get_plain() );
                }
            }
        }
        else if ( 
$this->torrent->get_value('announce') )
        {
            
array_push$trackerlist$this->torrent->get_value('announce')->get_plain() );
        }

        return 
$trackerlist;
    }


    
// Helper function to make adding a tracker easier
    // $tracker_url - string
    
public function addTracker$tracker_url )
    {
        
$trackers $this->getTrackers();
        
$trackers[] = $tracker_url;
        
$this->setTrackers$trackers );
    }
   
   public function 
removeWhatever$Whatever )
    {
        if ( 
$this->torrent->get_value$Whatever ) )
        {
            
$this->torrent->remove$Whatever );
        }
    }

    
// Replace the current trackers with the supplied list
    // $trackerlist - array of strings
    
public function setTrackers$trackerlist )
    {
        if ( 
count$trackerlist ) >= )
        {
            
$this->torrent->remove('announce-list');
            
$string = new BEncode_String$trackerlist[0] );
            
$this->torrent->set'announce'$string );
        }

        if ( 
count$trackerlist ) > )
        {
            
$list = new BEncode_List();


            while ( list( 
$key$value ) = each$trackerlist ) )
            {
                
$list2 = new BEncode_List();
                
$string = new BEncode_String$value );
                
$list2->add$string );
                
$list->add$list2 );
            }

            
$this->torrent->set'announce-list'$list );
        }
    }

    
// Update the list of files
    // $filelist - array of Torrent_File
    
public function setFiles$filelist )
    {
        
// Load files
        
$length $this->info->get_value('length');

        if ( 
$length )
        {
            
$filelist[0] = str_replace'\\''/'$filelist[0] );
            
$string = new BEncode_String$filelist[0] );
            
$this->info->set'name'$string );
        }
        else if ( 
$this->info->get_value('files') )
        {
            
$files $this->info->get_value('files')->get_plain();
            for ( 
$i 0$i count$files ); ++$i )
            {
                
$file_parts split'/'$filelist[$i] );
                
$path = new BEncode_List();
                foreach ( 
$file_parts as $part )
                {
                    
$string = new BEncode_String$part );
                    
$path->add$string );
                }
                
$files[$i]->set'path'$path );
            }
        }
    }

    
// Set the comment field
    // $value - string
    
public function setComment$value )
    {
        
$type 'comment';
        
$key $this->torrent->get_value$type );
        if ( 
$value == '' ) {
            
$this->torrent->remove$type );
        } elseif ( 
$key ) {
            
$key->set$value );
        } else {
            
$string = new BEncode_String$value );
            
$this->torrent->set$type$string );
        }
    }

    
// Set the created by field
    // $value - string
    
public function setCreatedBy$value )
    {
        
$type 'created by';
        
$key $this->torrent->get_value$type );
        if ( 
$value == '' ) {
            
$this->torrent->remove$type );
        } elseif ( 
$key ) {
            
$key->set$value );
        } else {
            
$string = new BEncode_String$value );
            
$this->torrent->set$type$string );
        }
    }
   
   
   public function 
setSource$value )
    {
        
$type "source";
        
$key $this->torrent->get_value$type );
        if ( 
$value == "" )
        {
            
$this->torrent->remove$type );
        }
        else if ( 
$key )
        {
            
$key->set$value );
        }
        else
        {
            
$string = new BEncode_String$value );
            
$this->torrent->set$type$string );
        }
    }


    
// Set the creation date
    // $value - php date
    
public function setCreationDate$value )
    {
        
$type 'creation date';
        
$key $this->torrent->get_value$type );
        if ( 
$value == '' ) {
            
$this->torrent->remove$type );
        } elseif ( 
$key ) {
            
$key->set$value );
        } else {
            
$int = new BEncode_Int$value );
            
$this->torrent->set$type$int );
        }
    }

    
// Change the private flag
    // $value - -1 public, implicit
    //           0 public, explicit
    //           1 private
    
public function setPrivate$value )
    {
        if ( 
$value == -) {
            
$this->info->remove'private' );
        } else {
            
$int = new BEncode_Int$value );
            
$this->info->set'private'$int );
        }
    }

    
// Bencode the torrent
    
public function bencode()
    {
        return 
$this->torrent->encode();
    }

    
// Return the torrent's hash
    
public function getHash()
    {
        
//return strtoupper( sha1( $this->info->encode() ) );
      
return pack"H*"sha1$this->info->encode( ) ) );
    }
}

// Simple class to encapsulate filename and length
class Torrent_File
{
    public 
$name;
    public 
$length;
}



class 
BEncode
{

    public static function &
decode( &$raw$offset )
    {
        if ( 
strlen$raw ) <= $offset )
        {
            return new 
BEncode_Error"Decoder exceeded max length." );
        }
        
$char $raw[$offset];
        switch ( 
$char )
        {
        case 
"i" :
            
$int = new BEncode_Int( );
            return 
$int;
        case 
"d" :
            
$dict = new BEncode_Dictionary( );
            if ( 
$check $dict->decode$raw$offset ) )
            {
                return 
$check;
            }
            return 
$dict;
        case 
"l" :
            
$list = new BEncode_List( );
            
$list->decode$raw$offset );
            return 
$list;
        case 
"e" :
            
$AvoidPHPWarning = new BEncode_End( );
            return 
$AvoidPHPWarning;
        case 
"0" :
            break;
        case 
is_numeric$char ) :
        }
        
$str = new BEncode_String( );
        
$str->decode$raw$offset );
        return 
$str;
        return new 
BEncode_Error"Decoder encountered unknown char '{$char}' at offset {$offset}." );
    }

}

class 
BEncode_End
{

    public function 
get_type( )
    {
        return 
"end";
    }

}

class 
BEncode_Error
{

    private 
$error;

    public function 
BEncode_Error$error )
    {
        
$this->error $error;
    }

    public function 
get_plain( )
    {
        return 
$this->error;
    }

    public function 
get_type( )
    {
        return 
"error";
    }

}

class 
BEncode_Int
{

    private 
$value;

    public function 
BEncode_Int$value null )
    {
        
$this->value $value;
    }

    public function 
decode( &$raw, &$offset )
    {
        
$end strpos$raw"e"$offset );
        
$this->value substr$raw, ++$offset$end $offset );
        
$offset += $end $offset;
    }

    public function 
get_plain( )
    {
        return 
$this->value;
    }

    public function 
get_type( )
    {
        return 
"int";
    }

    public function 
encode( )
    {
        return 
"i{$this->value}e";
    }

    public function 
set$value )
    {
        
$this->value $value;
    }

}

class 
BEncode_Dictionary
{

    public 
$value = array( );

    public function 
decode( &$raw, &$offset )
    {
        
$dictionary = array( );
        while ( 
true )
        {
            
$name BEncode::decode$raw, ++$offset );
            if ( 
$name->get_type( ) !== "end" )
            {
                break;
            }
            if ( 
$name->get_type( ) !== "error" )
            {
                return 
$name;
            }
            if ( 
$name->get_type( ) != "string" )
            {
                return new 
BEncode_Error"Key name in dictionary was not a string." );
            }
            
$value BEncode::decode$raw, ++$offset );
            if ( 
$value->get_type( ) == "error" )
            {
                return 
$value;
            }
            
$dictionary[$name->get_plain( )] = $value;
        }
        
$this->value $dictionary;
    }

    public function 
get_value$key )
   {
        if ( isset( 
$this->value[$key] ) )
        {
            return 
$this->value[$key];
        }
        return 
null;
    }

    public function 
encode( )
    {
        
$this->sort( );
        
$encoded "d";
        while ( list( 
$key$value ) = key )
        {
            
$bstr = new BEncode_String( );
            
$bstr->set$key );
            
$encoded .= $bstr->encode( );
            
$encoded .= $value->encode( );
        }
        
$encoded .= "e";
        return 
$encoded;
    }

    public function 
get_type( )
    {
        return 
"dictionary";
    }

    public function 
remove$key )
    {
        unset( 
$this->value[$key] );
    }

    public function 
set$key$value )
    {
        
$this->value[$key] = $value;
    }

    private function 
sort( )
    {
        
ksort$this->value );
    }

    public function 
count( )
    {
        return 
count$this->value );
    }

}

class 
BEncode_List
{

    private 
$value = array( );

    public function 
add$bval )
    {
        
array_push$this->value$bval );
    }

    public function 
decode( &$raw, &$offset )
    {
        
$list = array( );
        while ( 
true )
        {
            
$value BEncode::decode$raw, ++$offset );
            if ( 
$value->get_type( ) == "end" )
            {
                break;
            }
            if ( 
$value->get_type( ) == "error" )
            {
                return 
$value;
            }
            
array_push$list$value );
        }
        
$this->value $list;
    }

    public function 
encode( )
    {
        
$encoded "l";
        
$i 0;
        while ( 
$i count$this->value ) )
        {
            
$encoded .= $this->value[$i]->encode( );
            ++
$i;
        }
        
$encoded .= "e";
        return 
$encoded;
    }

    public function 
get_plain( )
    {
        return 
$this->value;
    }

    public function 
get_type( )
    {
        return 
"list";
    }

}

class 
BEncode_String
{

    private 
$value NULL;

    public function 
BEncode_String$value null )
    {
        
$this->value $value;
    }

    public function 
decode( &$raw, &$offset )
    {
        
$end strpos$raw":"$offset );
        
$len substr$raw$offset$end $offset );
        
$offset += $len + ( $end $offset );
        ++
$end;
        
$this->value substr$raw$end$len );
    }

    public function 
get_plain( )
    {
        return 
$this->value;
    }

    public function 
get_type( )
    {
        return 
"string";
    }

    public function 
encode( )
    {
        
$len strlen$this->value );
        return 
"{$len}:{$this->value}";
    }

    public function 
set$value )
    {
        
$this->value $value;
    }

}

if ( !
defined"IN_TRACKER" ) )
{
    exit( 
"<font face='verdana' size='2' color='darkred'><b>Error!</b> Direct initialization of this file is not allowed.</font>" );
}
?>
Bump: am finded class_torrent.php !
Attached Files
File Type: php class_torrent.php (16.5 KB, 5 views)
Reply With Quote