[Скрипт] IPB+tracker

У кого-то имеется русский нормальный мануал?
Просто мануал в формате pdf не серьёзно...Тем более там было такое что одна часть кода на одной странице, другая на другой.

Мне нефик делать ушёл опять ковыряться с бубном.
 
Такс...

Когда я прошлый раз делал, тоже не загружало торрент...И я пошёл методом исключения.
Ошибка в файле class_attach.php (другого логически не может быть)
PHP:
<?php
/*
+---------------------------------------------------------------------------
|   Invision Power Dynamic v1.0.0
|   ========================================
|   by Matthew Mecham
|   (c) 2004 Invision Power Services
|   http://nulled.cc
|   ========================================
+---------------------------------------------------------------------------
|   INVISION POWER DYNAMIC IS NOT FREE SOFTWARE!
|   http://nulled.cc
+---------------------------------------------------------------------------
|   > $Id$
|   > $Revision: 4 $
|   > $Date: 2005-10-10 14:21:32 +0100 (Mon, 10 Oct 2005) $
+---------------------------------------------------------------------------
|
|   > ATTACH FUNCTIONS
|   > Script written by Matt Mecham
|   > Date started: Monday 19th December 2005, 13:53
|
+---------------------------------------------------------------------------
*/
/**
* Attach Class
* Handles various uploading functions
*
* <code>
* Possible Error strings:
* - upload_no_file		 (No file was selected to upload)
* - upload_failed        (Upload failed for unspecified reason)
* - upload_too_big       (Upload is bigger than space left)
* - invalid_mime_type    (Upload is not allowed)
* - no_upload_dir        (Upload dir is not installed)
* - no_upload_dir_perms  (Upload dir is not writeable)
* </code>
*/
if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Некорректный адрес</h1>Вы не имеете доступа к этому файлу напрямую. Если вы недавно обновляли форум, вы должны обновить все соответствующие файлы.";
	exit();
}
class class_attach
{
	/**
	* Global ipsclass
	* @var	object
	*/
	var $ipsclass;
	/**
	* Global html class
	* @var	object
	*/
	var $html;
	/**
	* Plugin Class
	* @var object
	*/
	var $type    = '';
	/**
	* Plugin Class
	* @var object
	*/
	var $plugin  = '';
	/**
	* Post key
	* @var string
	*/
	var $attach_post_key = '';
	/**
	* Relationship ID
	* @var string
	*/
	var $attach_rel_id   = '';
	/**
	* Return variables
	* @var array 	[ 'allow_uploads', 'space_allowed', 'space_allowed_human', 'space_used', 'space_used_human', 'space_left', 'space_left_human' ]
	*/
	var $attach_stats = array();
	/**
	* Lang array
	* Internal language array
	* @var array
	*/
	var $language    = array( 'unlimited'   => 'Неограничено',
	 						  'not_allowed' => 'Загрузка запрещена' );
	/**
	* Error array
	* @var string
	*/
	var $error = "";
	/**
	* Full upload path
	*/
	var $upload_path = '';
	/**
	* Upload part part (from /uploads)
	*/
	var $upload_dir  = '';
	/**
	* Extra upload form url
	*/
	var $extra_upload_form_url = '';
	/**
	* Custom settings
	*/
	var $settings = array( 'siu_thumb'                 => 0,
						   'siu_height'                => 0,
						   'siu_width'                 => 0,
						   'allow_monthly_upload_dirs' => 0,
						   'upload_dir'                => '' );
	// INIT
	/**
	* Initiates class
	*/
	function init()
	{
		//-----------------------------------------
		// Start the settings
		//-----------------------------------------
		$this->settings['siu_thumb'] 				 = $this->ipsclass->vars['siu_thumb'];
		$this->settings['siu_height'] 				 = $this->ipsclass->vars['siu_height'];
		$this->settings['siu_width'] 				 = $this->ipsclass->vars['siu_width'];
		$this->settings['allow_monthly_upload_dirs'] = SAFE_MODE_ON ? 0 : ( $this->ipsclass->vars['safe_mode_skins'] ? 0 : 1 );
		$this->settings['upload_dir'] 				 = $this->ipsclass->vars['upload_dir'];
		//-----------------------------------------
		// Load plug in
		//-----------------------------------------
		if ( $this->type )
		{
			$this->load_plugin();
		}
		//-----------------------------------------
		// Finalize the settings
		//-----------------------------------------
		foreach( $this->settings as $item => $value )
		{
			$this->settings[ $item ] = ( isset( $this->plugin->settings[ $item ] ) ) ? $this->plugin->settings[ $item ] : $value;
		}
		//-----------------------------------------
		// Got a different upload dir?
		//-----------------------------------------
		/*if ( $this->settings['upload_dir'] != $this->ipsclass->vars['upload_dir'] )
		{
			$this->settings['allow_monthly_upload_dirs'] = 0;
		}*/
		//-----------------------------------------
		// Fix up URL tokens
		//-----------------------------------------
		foreach( $this->ipsclass->input as $k => $v )
		{
			if ( preg_match( "#^--ff--#", $k ) )
			{
			 	$this->ipsclass->input[ str_replace( '--ff--', '', $k ) ] = $v;
			}
		}
		//-----------------------------------------
		// Sort out upload dir
		//-----------------------------------------
		$this->upload_path  = $this->settings['upload_dir'];
		# Preserve original path
		$this->_upload_path = $this->upload_path;
	}
	// Show Attachment
	/**
	* Show the attachment (or force download)
	*
	* @param	int		Attachment ID (The main attach id)
	* @return	void
	*/
	function show_attachment( $attach_id )
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$sql_data        = array();
		//-----------------------------------------
		// Get attach data...
		//-----------------------------------------
		$attachment = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*',
																		'from'   => 'attachments',
																		'where'  => 'attach_id='.intval( $attach_id ) ) );
		if ( ! $attachment['attach_id'] )
		{
			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
		}
		//-----------------------------------------
		// Load correct plug in...
		//-----------------------------------------
		$this->type = $attachment['attach_rel_module'];
		$this->load_plugin();
		//-----------------------------------------
		// Get SQL data from plugin
		//-----------------------------------------
		$attach = $this->plugin->show_attachment_get_sql_data( $attach_id );
		//-----------------------------------------
		// Got a reply?
		//-----------------------------------------
		if ( $attach === FALSE OR ! is_array( $attach ) )
		{
			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
		}
		//-----------------------------------------
		// Got a rel id?
		//-----------------------------------------
		if ( ! $attach['attach_rel_id'] AND $attach['attach_member_id'] != $this->ipsclass->member['id'] )
		{
			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'err_attach_not_attached' ) );
		}
		if ( is_array( $attach ) AND count( $attach ) )
		{
			//-----------------------------------------
			// Got attachment types?
			//-----------------------------------------
			if ( ! is_array( $this->ipsclass->cache['attachtypes'] ) )
			{
				$this->ipsclass->cache['attachtypes'] = array();
				$this->ipsclass->DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype', 'from' => 'attachments_type' ) );
				$this->ipsclass->DB->simple_exec();
				while ( $r = $this->ipsclass->DB->fetch_row() )
				{
					$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;
				}
			}
			//-----------------------------------------
	        // Show attachment
	        //-----------------------------------------
			$this->_upload_path = ( isset( $this->plugin->settings[ 'upload_dir' ] )  ) ? $this->plugin->settings[ 'upload_dir' ] : $this->settings[ 'upload_dir' ];
	        $file = $this->_upload_path."/".$attach['attach_location'];
			if ( file_exists( $file ) and ( $this->ipsclass->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'] != "" ) )
			{
				//-----------------------------------------
				// Update the "hits"..
				//-----------------------------------------
				$this->ipsclass->DB->build_and_exec_query( array( 'update' => 'attachments',
															      'set'    => "attach_hits=attach_hits+1",
															      'where'  => "attach_id=".$attach_id ) );
				//-----------------------------------------
				// Open and display the file..
				//-----------------------------------------
				header( "Content-Type: ".$this->ipsclass->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'] );
				header( "Content-Disposition: inline; filename=\"".$attach['attach_file']."\"" );
				header( "Content-Length: ".(string)(filesize( $file ) ) );
				/*
			    +--------------------------------------------------------------------------
			    |   IPBTracker v2.x
			    |   =============================================
			    |   by Jaggi
			    |   (c) 2002 - 2007 IPBTracker.eu.
			    |   =============================================
			    +---------------------------------------------------------------------------
			    +---------------------------------------------------------------------------
			    |
			    |   > This code will edit the torrent on download
			    |   > Adds passkey
			    |   > Automatically changes announce url to one set in admincp. 
			    |   > benc.php is a GPL licenced and may be used freely, this doesn't apply 
			    |   - to the rest of the code in this script. 
			    +--------------------------------------------------------------------------
			    */
			    if ( $attach['attach_ext'] == 'torrent' && !empty( $attach['torrent_id'] ) )
			    {
					require ROOT_PATH."sources/lib/func_benc.php";
 	  				$this->lib   = new func_benc( $this );
   					$this->lib->ipsclass =& $this->ipsclass;
					$dict = $this->lib->bdec_file( $file, filesize( $file ) );
				   	//-------------------------------------------------
				   	// Does Member Exist
				   	//-------------------------------------------------
					$rsql = $this->ipsclass->DB->query("SELECT torrent_pass 
							 							FROM users 
							 							WHERE uid='" . intval( $this->ipsclass->member['id'] ) . "' 
							 							LIMIT 1
							 						   ");
					$this->ipsclass->DB->simple_exec();
					$r = $this->ipsclass->DB->fetch_row( $rsql );
					if ( !$this->ipsclass->DB->get_num_rows() )
					{
						//-------------------------------------------------
						// Store passkey and create members tracker details
						//-------------------------------------------------
						$r['torrent_pass'] = $this->ipsclass->generate_torrent_pass();
						$this->ipsclass->DB->query("INSERT INTO users (uid, name, email, added, peers_limit, torrent_pass) 
													VALUES ('" . $this->ipsclass->member['id'] . "',
							  								'" . $this->ipsclass->member['name'] . "',
							  								'" . $this->ipsclass->member['email'] . "',
							  								'" . time() . "',
							  								'1',
															'" . $r['torrent_pass'] . "' )
							  						");
					}
					else if ( $r['torrent_pass'] == '' )
					{
						//-------------------------------------------------
						// No passkey? give them one!
						//-------------------------------------------------
						$r['torrent_pass'] = $this->ipsclass->generate_torrent_pass();
						$ssql = $this->ipsclass->DB->query("UPDATE users 
												    		SET torrent_pass ='" . $r['torrent_pass'] . "' 
								  							WHERE uid='" . intval( $this->ipsclass->member['id'] ) . "'
								  						   ");					
					}
			   		if ( $this->ipsclass->vars['add_passkey'] )
					{
				   		//-------------------------------------------------
				   		// Compile passkey and announce URL. 
				   		//-------------------------------------------------
						$announce_url = preg_replace( "/^(http:\/\/.*?:\d+)(\/announce)/is", "$1/{$r['torrent_pass']}$2", $this->ipsclass->vars['announce_url'] );
					}				
					if ( !$this->ipsclass->member['id'] || !$this->ipsclass->vars['add_passkey'] )
					{
						$r['torrent_pass'] = '';	
						$announce_url = $this->ipsclass->vars['announce_url'];
					}
				    //-------------------------------------------------
				    // Add passkey URL.
				    //-------------------------------------------------   
					$dict['value']['announce']['value'] = $announce_url;
					$dict['value']['announce']['string'] = strlen( $dict['value']['announce']['value'] ) . ":" . $dict['value']['announce']['value'];
					$dict['value']['announce']['strlen'] = strlen( $dict['value']['announce']['string'] );
				   	//-------------------------------------------------
				   	// End and wrap everything up. 
				   	//-------------------------------------------------
					$fn = $this->lib->benc($dict);
				   	header( "Content-Type: ".$this->ipsclass->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'] );
					header( "Content-Disposition: inline; filename=\"".$attach['attach_file']."\"" );
					header( "Content-Length: ".(string)(strlen( $fn ) ) );
					print $fn;
					exit();
			   }
			   	//-------------------------------------------------
			   	// End of IPBTracker Modification. 
			   	//-------------------------------------------------				
				//print $contents;
				//readfile( $file );
        		@ob_end_clean();
				if( $fh = fopen( $file, 'rb' ) )
				{
		            while( !feof($fh) )
		            {
		                echo fread( $fh, 4096 );
		                flush();
		                @ob_flush();
		            }
            		@fclose( $fh );
        		}
				exit();
			}
			else
			{
				//-----------------------------------------
				// File does not exist..
				//-----------------------------------------
				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
			}
		}
		else
		{
			//-----------------------------------------
			// No permission?
			//-----------------------------------------
			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
		}
	}
	// Render attachments
	/**
	* Swaps the HTML for the nice attachments.
	*
	* @param	array Array of HTML blocks to convert: [ rel_id => $html ]
	* @return	array Array of converted HTML blocks and attach code: [ id => array[ html => '', attach_html => '' ] ]
	*/
	function render_attachments( $html, $rel_ids=array(), $skin_name='skin_topic' )
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$attach_ids              = array();
		$map_attach_id_to_rel_id = array();
		$final_out               = array();
		$final_blocks            = array();
		$_seen                   = 0;
		//-----------------------------------------
		// Check..
		//-----------------------------------------
		if ( ! is_array( $rel_ids ) AND isset( $rel_ids ) )
		{
			$rel_ids = array( $rel_ids );
		}
		//-----------------------------------------
		// Parse HTML blocks for attach ids
		// [attachment=32:attachFail.gif]
		//-----------------------------------------
		preg_match_all( "#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is", $html, $match );
		if ( is_array( $match[0] ) and count( $match[0] ) )
		{
			for ( $i = 0 ; $i < count( $match[0] ) ; $i++ )
			{
				if ( intval($match[1][$i]) == $match[1][$i] )
				{
					$attach_ids[ $match[1][$i] ] = $match[1][$i];
				}
			}
		}
		//-----------------------------------------
		// Get data from the plug in
		//-----------------------------------------
		$rows = $this->plugin->render_attachment_get_sql_data( $attach_ids, $rel_ids, $this->attach_post_key );
		//-----------------------------------------
		// Got anything?
		//-----------------------------------------
		if ( is_array( $rows ) AND count( $rows ) )
		{
			//-----------------------------------------
			// Got attachment types?
			//-----------------------------------------
			if ( ! is_array( $this->ipsclass->cache['attachtypes'] ) )
			{
				$this->ipsclass->cache['attachtypes'] = array();
				$this->ipsclass->DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_img', 'from' => 'attachments_type' ) );
				$outer = $this->ipsclass->DB->simple_exec();
				while ( $r = $this->ipsclass->DB->fetch_row( $outer ) )
				{
					$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;
				}
			}
			$_seen_rows = 0;
			//preg_match_all( "#\[attachment=(\d+)\:(?:[^\]]+?)[\n|\]]#is", $html, $matches );
			foreach( $rows as $_attach_id => $row )
			//foreach( $matches[1] as $html_attachid )
			{
				//-----------------------------------------
				// INIT
				//-----------------------------------------
				//$_attach_id = $html_attachid;
				$row		= $rows[ $_attach_id ];
				if( $this->attach_rel_id != $row['attach_rel_id'] )
				{
					// Reset if we are onto a new post..
					$_seen_rows	= 0;
					$_seen 		= 0;
				}
				$this->attach_rel_id = $row['attach_rel_id'];
				if ( ! isset( $final_blocks[ $row['attach_rel_id'] ] ) )
				{
					$final_blocks[ $row['attach_rel_id'] ] = array( 'attach' => '', 'thumb' => '', 'image' => '' );
				}
				//-----------------------------------------
				// Is it an image, and are we viewing the image in the post?
				//-----------------------------------------
				if ( $this->ipsclass->vars['show_img_upload'] and $row['attach_is_image'] )
				{
					if ( $this->settings['siu_thumb'] AND $row['attach_thumb_location'] AND $row['attach_thumb_width'] )
					{
						//-----------------------------------------
						// Make sure we've not seen this ID
						//-----------------------------------------
						$row['_attach_id'] = $row['attach_id'] . '-' . preg_replace( "#[\.\s]#", "-", microtime() );
						$not_inline = $_seen_rows > 0 ? $_seen_rows%$this->ipsclass->vars['topic_attach_no_per_row'] : 1;
						$tmp = $this->ipsclass->compiled_templates[ $skin_name ]->Show_attachments_img_thumb( array( 't_location'  => $row['attach_thumb_location'],
																											  		 't_width'     => $row['attach_thumb_width'],
																											  		 't_height'    => $row['attach_thumb_height'],
																											         'o_width'     => $row['attach_img_width'],
																											  		 'o_height'    => $row['attach_img_height'],
																											  	     'attach_id'   => $row['attach_id'],
																													 '_attach_id'  => $row['_attach_id'],
																											    	 'file_size'   => $this->ipsclass->size_format( $row['attach_filesize'] ),
																											  		 'attach_hits' => $row['attach_hits'],
																											  		 'location'    => $row['attach_file'],
																													 'type'        => $this->type,
																													 'notinline'   => $not_inline,
																										)	);
						//-----------------------------------------
						// Convert HTML
						//-----------------------------------------
						$_count = substr_count( $html, '[attachment='.$row['attach_id'].':' );
						if ( $_count > 1 )
						{
							# More than 1 of the same thumbnail to show?
							$this->_current = array( 'type'      => $this->type,
													 'row'       => $row,
													 'skin_name' => $skin_name );
							$html = preg_replace_callback( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", array( &$this, '_parse_thumbnail_inline' ), $html );
						}
						else if ( $_count )
						{
							# Just the one, then?
							$html = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $html );
						}
						else
						{
							# None. :(
							$_seen++;
							if ( $_seen == $this->ipsclass->vars['topic_attach_no_per_row'] )
							{
								$tmp .= "\n<br />\n";
								$_seen = 0;
							}
							$final_blocks[ $row['attach_rel_id'] ]['thumb'] .= $tmp . ' ';
						}
					}
					else
					{
						//-----------------------------------------
						// Standard size..
						//-----------------------------------------
						$tmp = $this->ipsclass->compiled_templates[ $skin_name ]->Show_attachments_img( $row['attach_location'] );
						if ( strstr( $html, '[attachment='.$row['attach_id'].':' ) )
						{
							$html = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $html );
						}
						else
						{
							$final_blocks[ $row['attach_rel_id'] ]['image'] .= $tmp . ' ';
						}
					}
				}
				else
				{
					//-----------------------------------------
					// Full attachment thingy
					//-----------------------------------------
		/*
					+--------------------------------------------------------------------------
					|   IPBTracker v2.x
					|   =============================================
					|   by Jaggi
					|   (c) 2002 - 2007 IPBTracke.eu.
					|   =============================================
					+---------------------------------------------------------------------------
					+---------------------------------------------------------------------------
					|
					|   > This Code Displays Files and Statistics and Member Statistics. 
					|   > Date started: 17/02/07  
					+--------------------------------------------------------------------------
					*/
					//-------------------------------------------------
					// Start the Member Info Mod
					//-------------------------------------------------
					if ( $row['attach_ext'] == 'torrent' && !empty( $row['torrent_id'] ) )
					{
						$row['fsize'] = $this->ipsclass->size_format( $row['fullsize'] ); // Fix Size
						//-------------------------------------------------
						// All in good health?
						//-------------------------------------------------
						if ( $row['leechers'] == 0 )
						{
							$row['health'] = ( $row['seeders'] == 0 ) ? 0 : 5;
						}
						else
						{
							$row['health'] = round( $row['seeders'] / $row['leechers'] * 10 );
							$row['health'] = ceil( $row['health'] / 20 );
							if ( $row['health'] < 0 ) $row['health'] = 0;
							if ( $row['health'] > 5 ) $row['health'] = 5;
						}
						$row['health'] = $this->ipsclass->vars['img_url'] . '/h' . $row['health'] .'.gif';
						$details = $this->ipsclass->compiled_templates[ $skin_name ]->details_box( $row );
						//-------------------------------------------------
						// Unserialize the files data and make purdy... 
						//-------------------------------------------------
						$files = $this->ipsclass->compiled_templates[ $skin_name ]->torrent_files_start( $row ); // Start Rows
						$attach_files = unserialize( $this->ipsclass->txt_stripslashes( $row['attach_files'] ) );
						if ( $attach_files )
						{			
							foreach ( $attach_files as $k => $v )
							{
								$row['filename'] = $v[0];
								$row['size'] = $this->ipsclass->size_format( $v[1] ); // Fix Size				
								$files .= $this->ipsclass->compiled_templates[ $skin_name ]->torrent_files_rows( $row ); // Start Data					
							}
						}	
						$files .= $this->ipsclass->compiled_templates[ $skin_name ]->torrent_files_end(); // End Rows
						//-------------------------------------------------
						// End Of Files Statistics Modification
						//-------------------------------------------------
						/*
						+--------------------------------------------------------------------------
						|   > This code displays user statistics under torrents in thread. 
						|   > Date started: 17/12/2005
						+--------------------------------------------------------------------------
						*/
						//-----------------------------------------
						// Another Super Query
						// Queries For Statistics Table. 
						//-----------------------------------------
						$ssql = $this->ipsclass->DB->query("SELECT  x.*, t.fid, x.fid, t.filename, t.size, u.uid, u.name, m.id, m.name, m.mgroup, m.members_display_name  
															FROM xbt_files_users x
															LEFT JOIN torrents t ON (x.fid=t.fid)
															LEFT JOIN users u ON (x.uid=u.uid)
															LEFT JOIN ".SQL_PREFIX."members m ON (m.id=u.uid)
															WHERE t.fid = '".$row['torrent_id']."' AND x.active=1
															ORDER BY x.left ASC
															");
						$this->ipsclass->DB->simple_exec();
						$stats = $this->ipsclass->compiled_templates[ $skin_name ]->torrent_stats_start( $row ); // Start Rows
						while ( $data = $this->ipsclass->DB->fetch_row( $ssql ) )
						{								
							//-----------------------------------------
							// Tell It How To Make A Ratio
							//-----------------------------------------
							$data['ratio'] = $this->ipsclass->ratio( $data['uploaded'], $data['downloaded'] ); // Make Ratio
							$data['downloaded'] = $this->ipsclass->size_format( $data['downloaded'] ); // Fix Size
							$data['uploaded'] = $this->ipsclass->size_format( $data['uploaded'] ); // Fix Size
							$data['members_display_name'] = $this->ipsclass->make_name_formatted( $data['members_display_name'], $data['mgroup'] );
							//-------------------------------------------------
							// Code The Percentage Bar
							//-------------------------------------------------
							$data['progress'] = round( 100 * ( 1 -($data['left'] / $data['size'] ) ), 2 ); 
							$percent = sprintf( '%.2f', $data['progress'] ); 
							$data['width']  = $data['progress'] > 0 ? intval( $data['progress'] ) : 0;
							//-----------------------------------------
							// Sort Seeders and Leechers
							//-----------------------------------------
							if ( $data['left'] == 0 ) //Seeders
							{
								$data['downloaded'] = "<font color=#008000>" . $data['downloaded'] . '</font>';
								$data['uploaded'] = "<font color=#008000>" . $data['uploaded'] . "</font>";
								$data['ratio'] = "<font color=#008000>" . $data['ratio'] . "</font>";
								$data['connected'] = "<font color=#008000>" . $this->ipsclass->get_date( $data['mtime'], 'LONG' ) . "</font>";
							}
							else //Leechers
							{
								$data['downloaded'] = "<font color=#0000FF>" . $data['downloaded'] . '</font>';
								$data['uploaded'] = "<font color=#0000FF>" . $data['uploaded'] . "</font>";
								$data['ratio'] = "<font color=#0000FF>" . $data['ratio'] . "</font>";
								$data['connected'] = "<font color=#0000FF>" . $this->ipsclass->get_date( $data['mtime'], 'LONG' ) . "</font>";
							}
						//-----------------------------------------
						// Parse Output
						//-----------------------------------------	
						$stats .= $this->ipsclass->compiled_templates[ $skin_name ]->torrent_stats_rows( $data, $width, $progress );
						}							
					$stats .= $this->ipsclass->compiled_templates[ $skin_name ]->torrent_stats_end();
				}
				else
				{
					unset( $details, $files, $stats );
				}
				//-------------------------------------------------
				// End Of IPBTracker Modification
				//-------------------------------------------------			
					$tmp = $this->ipsclass->compiled_templates[ $skin_name ]->Show_attachments( array (
																										'attach_hits'  => $row['attach_hits'],
																										'mime_image'   => $this->ipsclass->cache['attachtypes'][ $row['attach_ext'] ]['atype_img'],
																										'attach_file'  => $row['attach_file'],
																										'attach_id'    => $row['attach_id'],
																										'type'         => $this->type,
																										'file_size'    => $this->ipsclass->size_format( $row['attach_filesize'] ),
																							  )  	  );
					//-------------------------------------------------
					// Start Of IPBTracker Modification
					// - Send output
					//-------------------------------------------------	
					$tmp .= $details; 	
					$tmp .= $stats;		
					//-------------------------------------------------
					// End Of IPBTracker Modification
					//-------------------------------------------------					
					if ( strstr( $html, '[attachment='.$row['attach_id'].':' ) )
					{
						$html = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $html );
					}
					else
					{
						$final_blocks[ $row['attach_rel_id'] ]['attach'] .= $tmp . ' ';
					}
				}
				$_seen_rows++;
			}
			//-----------------------------------------
			// Anthing to add?
			//-----------------------------------------
			if ( count( $final_blocks ) )
			{
				foreach( $final_blocks as $rel_id => $type )
				{
					$temp_out = "";
					if ( $final_blocks[ $rel_id ]['thumb'] )
					{
						$temp_out .= $this->ipsclass->compiled_templates[ $skin_name ]->show_attachment_title( $this->ipsclass->lang['attach_thumbs'], $final_blocks[ $rel_id ]['thumb'] );
					}
					if ( $final_blocks[ $rel_id ]['image'] )
					{
						$temp_out .= $this->ipsclass->compiled_templates[ $skin_name ]->show_attachment_title( $this->ipsclass->lang['attach_images'], $final_blocks[ $rel_id ]['image'] );
					}
					if ( $final_blocks[ $rel_id ]['attach'] )
					{
						$temp_out .= $this->ipsclass->compiled_templates[ $skin_name ]->show_attachment_title( $this->ipsclass->lang['attach_normal'], $final_blocks[ $rel_id ]['attach'] );
					}
					if ( $temp_out )
					{
						$html = str_replace( "<!--IBF.ATTACHMENT_". $rel_id. "-->", $temp_out, $html );
					}
				}
			}
		}
		return $html;
	}
	// Remove uploaded file (BULK)
	/**
	* Removes an attachment.
	*/
	function bulk_remove_attachment( $attach_rel_ids=array() )
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$attachments = array();
		//-----------------------------------------
		// Got an ID?
		//-----------------------------------------
		if ( ! is_array( $attach_rel_ids ) or ! count( $attach_rel_ids ) )
		{
			return FALSE;
		}
		//-----------------------------------------
		// Make sure we've got permission
		//-----------------------------------------
		if ( $this->plugin->return_bulk_remove_permission( $attach_rel_ids ) === TRUE )
		{
			//-----------------------------------------
			// Get stuff
			//-----------------------------------------
			$this->ipsclass->DB->build_query( array( 'select' => '*',
													 'from'   => 'attachments',
													 'where'  => 'attach_rel_id IN ('.implode(",",$attach_rel_ids).") AND attach_rel_module='".$this->type."'" ) );
			$this->ipsclass->DB->exec_query();
			while( $_row = $this->ipsclass->DB->fetch_row() )
			{
				$attachments[ $_row['attach_id'] ] = $_row;
			}
			foreach( $attachments as $attach_id => $attachment )
			{
				//-----------------------------------------
				// Remove from the filesystem
				//-----------------------------------------
				if ( $attachment['attach_location'] )
				{
					@unlink( $this->_upload_path."/".$attachment['attach_location'] );
				}
				if ( $attachment['attach_thumb_location'] )
				{
					@unlink( $this->_upload_path."/".$attachment['attach_thumb_location'] );
				}
				//-----------------------------------------
				// Allow the module to clean up any items
				//-----------------------------------------
				$this->plugin->remove_attachment_clean_up( $attachment );
			}
			//-----------------------------------------
			// Remove from the DB
			//-----------------------------------------
			$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'attachments',
															  'where'  => 'attach_rel_id IN ('.implode(",",$attach_rel_ids).") AND attach_rel_module='".$this->type."'" ) );
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	// Remove uploaded file
	/**
	* Removes an attachment.
	*/
	function remove_attachment()
	{
		//-----------------------------------------
		// Got an ID?
		//-----------------------------------------
		if ( ! $this->attach_id )
		{
			return FALSE;
		}
		//-----------------------------------------
		// Get DB row
		//-----------------------------------------
		$attachment = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*',
																		'from'   => 'attachments',
																		'where'  => 'attach_id='.$this->attach_id." AND attach_rel_module='".$this->type."'" ) );
		if ( ! $attachment['attach_id'] )
		{
			return FALSE;
		}
		//-----------------------------------------
		// Make sure we've got permission
		//-----------------------------------------
		if ( $this->plugin->return_remove_permission( $attachment ) === TRUE )
		{
			//-----------------------------------------
			// Remove from the DB
			//-----------------------------------------
			$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'attachments',
															  'where'  => 'attach_id='.$attachment['attach_id'] ) );
			//-----------------------------------------
			// Remove from the filesystem
			//-----------------------------------------
			if ( $attachment['attach_location'] )
			{
				@unlink( $this->_upload_path."/".$attachment['attach_location'] );
			}
			if ( $attachment['attach_thumb_location'] )
			{
				@unlink( $this->_upload_path."/".$attachment['attach_thumb_location'] );
			}
			//-----------------------------------------
			// Allow the module to clean up any items
			//-----------------------------------------
			$this->plugin->remove_attachment_clean_up( $attachment );
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	// Post Process upload
	/**
	* Converts post-key attachments into rel_id / rel_module attachments
	* by adding in the correct ID, etc
	*/
	function post_process_upload( $args=array() )
	{
		if ( ! $this->attach_post_key or ! $this->attach_rel_id )
		{
			return FALSE;
		}
		//-----------------------------------------
		// Got any to update?
		//-----------------------------------------
		$this->ipsclass->DB->do_update( 'attachments', array( 'attach_rel_id'     => $this->attach_rel_id,
			  										 		  'attach_rel_module' => $this->type ), "attach_post_key='". $this->attach_post_key ."'" );
		//-----------------------------------------
		// Update module specific?
		//-----------------------------------------
		return $this->plugin->post_process_upload( $this->attach_post_key, $this->attach_rel_id, $args );
	}
	// Process upload
	/**
	* Uploads and saves file
	*/
	function process_upload()
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$this->error = '';
		$this->get_upload_form_settings();
		//-----------------------------------------
		// Check upload dir
		//-----------------------------------------
		if ( ! $this->check_upload_dir() )
		{
			if ( $this->error )
			{
				return;
			}
		}
		//-----------------------------------------
		// Got attachment types?
		//-----------------------------------------
		if ( ! isset( $this->ipsclass->cache['attachtypes'] ) OR ! is_array( $this->ipsclass->cache['attachtypes'] ) )
		{
			$this->ipsclass->cache['attachtypes'] = array();
			$this->ipsclass->DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img',
														  'from'   => 'attachments_type',
														  'where'  => "atype_photo=1 OR atype_post=1" ) );
			$this->ipsclass->DB->simple_exec();
			while ( $r = $this->ipsclass->DB->fetch_row() )
			{
				$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;
			}
		}
		//-----------------------------------------
		// Can upload?
		//-----------------------------------------
		if ( ! $this->attach_stats['allow_uploads'] )
		{
			$this->error = 'no_upload_permission';
			return;
		}
		//-----------------------------------------
		// Set up array
		//-----------------------------------------
	$attach_data = array( 
							  'attach_ext'            => "",
							  'attach_file'           => "",
							  'attach_location'       => "",
							  'attach_thumb_location' => "",
							  'attach_hits'           => 0,
							  'attach_date'           => time(),
							  'attach_temp'           => 0,
							  'attach_post_key'       => $this->attach_post_key,
							  'attach_member_id'      => $this->ipsclass->member['id'],
							  'attach_rel_id'         => $this->attach_rel_id,
							  'attach_rel_module'     => $this->type,
							  'attach_filesize'       => 0,
							  'attach_files'		  => "",
							  'torrent_id'			  => "",
							);
		//-----------------------------------------
		// Load the library
		//-----------------------------------------
		require_once( KERNEL_PATH.'class_upload.php' );
		$upload = new class_upload();
		//-----------------------------------------
		// Set up the variables
		//-----------------------------------------
		$upload->out_file_name    = $this->type.'-'.$this->ipsclass->member['id'].'-'.time();
		$upload->out_file_dir     = $this->upload_path;
		$upload->max_file_size    = $this->attach_stats['max_single_upload'] ? $this->attach_stats['max_single_upload'] : 1000000000;
		$upload->make_script_safe = 1;
		$upload->force_data_ext   = 'ipb';
		//-----------------------------------------
		// Populate allowed extensions
		//-----------------------------------------
		if ( is_array( $this->ipsclass->cache['attachtypes'] ) and count( $this->ipsclass->cache['attachtypes'] ) )
		{
			foreach( $this->ipsclass->cache['attachtypes'] as $idx => $data )
			{
				if ( $data['atype_post'] )
				{
					$upload->allowed_file_ext[] = $data['atype_extension'];
				}
			}
		}
		//-----------------------------------------
		// Upload...
		//-----------------------------------------
		$upload->upload_process();
		//-----------------------------------------
		// Error?
		//-----------------------------------------
		if ( $upload->error_no )
		{
			switch( $upload->error_no )
			{
				case 1:
					// No upload
					$this->error = 'upload_no_file';
					return $attach_data;
					break;
				case 2:
					// Invalid file ext
					$this->error = 'invalid_mime_type';
					return $attach_data;
					break;
				case 3:
					// Too big...
					$this->error = 'upload_too_big';
					return $attach_data;
					break;
				case 4:
					// Cannot move uploaded file
					$this->error = 'upload_failed';
					return $attach_data;
					break;
				case 5:
					// Possible XSS attack (image isn't an image)
					$this->error = 'upload_failed';
					return $attach_data;
					break;
			}
		}
		//-----------------------------------------
		// Still here?
		//-----------------------------------------
		if ( $upload->saved_upload_name and @file_exists( $upload->saved_upload_name ) )
		{
			//-----------------------------------------
			// Strip off { } and [ ]
			//-----------------------------------------
			$upload->original_file_name = preg_replace( "#[\[\]\{\}]#", "", $upload->original_file_name );
			$attach_data['attach_filesize']   = @filesize( $upload->saved_upload_name  );
			$attach_data['attach_location']   = $this->upload_dir . $upload->parsed_file_name;
			$attach_data['attach_file']       = $upload->original_file_name;
			$attach_data['attach_is_image']   = $upload->is_image;
			$attach_data['attach_ext']        = $upload->real_file_extension;
			if ( $attach_data['attach_is_image'] == 1 )
			{
				require_once( KERNEL_PATH.'class_image.php' );
				$image = new class_image();
				$image->in_type        = 'file';
				$image->out_type       = 'file';
				$image->in_file_dir    = $this->upload_path;
				$image->in_file_name   = $upload->parsed_file_name;
				$image->desired_width  = $this->settings['siu_width'];
				$image->desired_height = $this->settings['siu_height'];
				$image->gd_version     = $this->ipsclass->vars['gd_version'];
				if ( $this->settings['siu_thumb'] )
				{
					$thumb_data = $image->generate_thumbnail();
				}
				if ( $thumb_data['thumb_location'] )
				{
					$attach_data['attach_img_width']      = $thumb_data['original_width'];
					$attach_data['attach_img_height']     = $thumb_data['original_height'];
					$attach_data['attach_thumb_width']    = $thumb_data['thumb_width'];
					$attach_data['attach_thumb_height']   = $thumb_data['thumb_height'];
					$attach_data['attach_thumb_location'] = $this->upload_dir . $thumb_data['thumb_location'];
				}
			}
			/*
			+------------------------------------------------------------------------------
			|   IPBTracker v2.x
			|   =============================================
			|   by Jaggi
			|   (c) 2002 - 2007 IPBTracker.eu.
			|   =============================================
			+-------------------------------------------------------------------------------
			+-------------------------------------------------------------------------------
			|
			|   > This code will upload a torrent onto a XBT Tracker
			|   > Only works with anonymous_connect = 0
			|   > Date Started: 15/02/07
			|	> benc.php is a GPL licenced and may be used freely, some of the decoding  
			| 	- array is also GPL licenced and may be used freely, gain permission if unsure
			| 	- as the rest of the script is NOT GPL licenced. 
			+--------------------------------------------------------------------------------
			*/
			if ( $attach_data['attach_ext'] == 'torrent' )
			{
				require ROOT_PATH."sources/lib/func_benc.php";
 	  			$this->lib   = new func_benc($this);
   				$this->lib->ipsclass =& $this->ipsclass;
				//-----------------------------------------
        		// Gather Torrent Information
        		//-----------------------------------------
				$torrent = $this->lib->bdec_file($upload->saved_upload_name, 1 << 20);
                if ( !isset( $torrent ) )
				{
					$this->error = 'missing_length';
					return $attach;
				}
				$attach['info_hash'] = pack('H*', sha1($torrent['value']['info']['string']));
				$attach['name'] = str_replace('.torrent', '', $attach_data['attach_file'] ); 
				$piece_count = $torrent['value']['info']['value']['pieces']['strlen'] / 20;
				$piece_length = $torrent['value']['info']['value']['piece length']['value'];
				$attach['size'] = $piece_count * $piece_length;
				$attach['tracker'] = $torrent['value']['announce']['value'];
				$attach['announce_list'] = $torrent['value']['announce-list']['value'];
				if ( $attach['announce_list'] )
				{
					$this->error = 'invalid_announce_list';
					return;
				}
				if ( $attach['tracker'] != $this->ipsclass->vars['announce_url'] )
				{
					$this->error = 'invalid_announce';
					return;
				}
				//-----------------------------------------
        		// Gather Files Information 
        		//-----------------------------------------
				list( $ann, $info ) = $this->lib->dict_check( $torrent, "announce(string):info" );
				list( $dname, $plen, $pieces ) = $this->lib->dict_check( $info, "name(string):piece length(integer):pieces(string)" );	
				$filelist = array();
				$size = $this->lib->dict_get( $info, "length", "integer" );
				// Invalid Torrent Hash
				if ( strlen( $attach['info_hash'] ) != 20 )
				{
					$this->error = 'invalid_hash';
					return;
				}
				if ( strlen( $pieces ) % 20 != 0 )
				{
					// Invalid Torrent pieces
					$this->error = 'invalid_pieces';
					return;
				}
				if ( isset( $size ) ) 
				{
					$filelist[] = array( $dname, $size );
					$attach['type'] = "single";
				}
				else 
				{
					$flist = $this->lib->dict_get( $info, "files", "list" );
					$size = 0;
						// Missing Length
						if ( !isset( $flist ) )
     					{
							$this->error = 'missing_length';
							return;
    					}
						// No files in torrent
						if ( !count( $flist ) )
						{
							$this->error = 'no_files';
							return;
						}
					foreach ($flist as $fn) 
					{
						list( $ll, $ff ) = $this->lib->dict_check( $fn, "length(integer):path(list)" );
						$size += $ll;
						$ffa = array();
						foreach ( $ff as $ffe ) 
						{
							if ( $ffe["type"] != "string" )
							{
								// Invalid Name
								$this->error = 'name_error';
								return;
							}
							$ffa[] = $ffe["value"];
						}
						if ( !count( $ffa ) )
						{
							// Invalid Name
							$this->error = 'name_error';
							return;
						}
						$ffe = implode( "/", $ffa );
						$filelist[] = array( $ffe, $ll );
					}
					$attach['type'] = "multi";
				}
				//-----------------------------------------
        		// Serialize the file info
        		//-----------------------------------------
				$attach_data['attach_files'] = serialize( $filelist );				
				$attach['numfiles'] = count( $filelist ); 
				//-----------------------------------------
        		// Check if Exists and Insert information
        		//-----------------------------------------
				$this->ipsclass->DB->query("SELECT info_hash FROM torrents WHERE info_hash='". addslashes( $attach['info_hash'] ) ."'");
				if ( !$this->ipsclass->DB->get_num_rows() )
				{				
					$this->ipsclass->DB->query("INSERT INTO torrents ( filename, info_hash, name, size, numfiles, type, added, oid ) 																									
												VALUES ( '".$attach_data['attach_file']."', 
														 '".addslashes($attach['info_hash'])."', 
														 '".$attach['name']."', 
														 '".$attach['size']."', 
														 '".$attach['numfiles']."', 
														 '".$attach['type']."', 
														 '".time()."',
														 '".intval( $attach_data['attach_member_id'] )."') 
												"); 
					$attach_data['torrent_id'] = $this->ipsclass->DB->get_insert_id();
				   	//-------------------------------------------------
				   	// Does Member Exist
				   	//-------------------------------------------------
					$asql = $this->ipsclass->DB->query("SELECT uid 
														FROM users
														WHERE uid='" . intval( $attach_data['attach_member_id'] ) . "' 
														LIMIT 1
													   ");
					$this->ipsclass->DB->simple_exec();
					if ( !$this->ipsclass->DB->get_num_rows() )
					{
						$this->ipsclass->DB->query("INSERT INTO users (uid, name, email, added, peers_limit) 
													VALUES ('" . $this->ipsclass->member['id'] . "',
							  								'" . $this->ipsclass->member['name'] . "',
							  								'" . $this->ipsclass->member['email'] . "',
							  								'" . time() . "',
							  								'1' )
							  						");
					}
					//-----------------------------------------
					// If on give user a upload bonus, set in acp
					//-----------------------------------------
					if ( $this->ipsclass->vars['upload_bonus'] != 0 )
					{
						$this->ipsclass->DB->query("SELECT uploaded FROM users WHERE uid='" . $attach_data['attach_member_id'] . "' "); 
						$sql = $this->ipsclass->DB->fetch_row();
						$this->ipsclass->DB->query("UPDATE users SET uploaded='" . $sql['uploaded'] ."' + '" . $this->ipsclass->vars['upload_bonus'] . "' WHERE uid=".$attach_data['attach_member_id'] ); 
					}
				}
				else
				{
					// This Torrent Already Exists
					$this->error = 'already_ul';
					return;
				}	
			}	
			//-----------------------------------------
        	// End of IPBTracker Modification
        	//-----------------------------------------			
			//-----------------------------------------
			// Add into Database
			//-----------------------------------------
			$this->ipsclass->DB->do_insert( 'attachments', $attach_data );
			$newid = $this->ipsclass->DB->get_insert_id();
			return $newid;
		}	
	}
	// Upload form stuff
	/**
	* Gets stuff required for the upload form
	*/
	function get_upload_form_settings()
	{
		//-----------------------------------------
		// Collect settings from the plug-in
		//-----------------------------------------
		$stats = $this->plugin->get_space_allowance( $this->attach_post_key );
		//-----------------------------------------
		// Format and return...
		//-----------------------------------------
		$this->attach_stats['space_used']                = $stats['space_used'];
		$this->attach_stats['space_used_human']          = $this->ipsclass->size_format( $stats['space_used'] );
		$this->attach_stats['total_space_allowed']       = $stats['total_space_allowed'] ? $stats['total_space_allowed'] : $stats['max_single_upload'];
		$this->attach_stats['max_single_upload']         = $stats['max_single_upload'];
		$this->attach_stats['max_single_upload_human']   = $this->attach_stats['max_single_upload']   ? $this->ipsclass->size_format( $stats['max_single_upload'] )   : $this->language[ 'unlimited' ];
		$this->attach_stats['total_space_allowed_human'] = $this->attach_stats['total_space_allowed'] ? $this->ipsclass->size_format( $this->attach_stats['total_space_allowed'] ) : $this->language[ 'unlimited' ];
		if ( $stats['space_allowed'] == 0 )
		{
			//-----------------------------------------
			// Unlimited...
			//-----------------------------------------
			$this->attach_stats['allow_uploads']             = 1;
			$this->attach_stats['space_allowed']             = 'unlimited';
			$this->attach_stats['space_allowed_human']       = $this->language[ 'unlimited' ];
			$this->attach_stats['space_left']                = 'unlimited';
			$this->attach_stats['space_left_human']          = $this->language[ 'unlimited' ];
			$this->attach_stats['total_space_allowed_human'] = $this->language[ 'unlimited' ];
			//$this->attach_stats['space_used_human']          = $this->language[ 'unlimited' ];
		}
		else if ( $stats['space_allowed'] == -1 )
		{
			//-----------------------------------------
			// None
			//-----------------------------------------
			$this->attach_stats['allow_uploads']       = 0;
			$this->attach_stats['space_allowed']       = 'not_allowed';
			$this->attach_stats['space_allowed_human'] = $this->language[ 'not_allowed' ];
			$this->attach_stats['space_left']          = 'not_allowed';
			$this->attach_stats['space_left_human']    = $this->language[ 'not_allowed' ];
		}
		else
		{
			//-----------------------------------------
			// Set figure
			//-----------------------------------------
			$this->attach_stats['allow_uploads']       = 1;
			$this->attach_stats['space_left']          = $stats['space_left'];
			$this->attach_stats['space_left_human']    = $this->ipsclass->size_format( $stats['space_left'] );
		}
	}
	// Check uploads dir
	/**
	* Checks the upload dir
	* See above. It's not rocket science
	*
	* @return void
	*/
	function check_upload_dir()
	{
		//-----------------------------------------
		// Check dir exists...
		//-----------------------------------------
		if ( ! file_exists( $this->upload_path ) )
		{
			if ( @mkdir( $this->upload_path, 0777 ) )
			{
				@chmod( $this->upload_path, 0777 );
			}
			else
			{
				$this->error = "no_upload_dir";
				return false;
			}
		}
		else if ( ! is_writeable( $this->upload_path ) )
		{
			$this->error = "no_upload_dir_perms";
			return false;
		}
		//-----------------------------------------
		// Try and create a new monthly dir
		// eg: monthly_12_2005
		//-----------------------------------------
		$this_month = "monthly_" . gmdate( "m_Y", time() );
		//-----------------------------------------
		// Already a dir?
		//-----------------------------------------
		if ( $this->settings['allow_monthly_upload_dirs'] )
		{
			$path = $this->upload_path . "/" . $this_month;
			if ( ! file_exists( $path ) )
			{
				if ( @mkdir( $path, 0777 ) )
				{
					@chmod( $path, 0777 );
					# Set path and dir correct
					$this->upload_path .= "/" . $this_month;
					$this->upload_dir   = $this_month."/";
				}
				//-----------------------------------------
				// Was it really made or was it lying?
				//-----------------------------------------
				if ( ! file_exists( $path ) )
				{
					$this->upload_path = $this->_upload_path;
					$this->upload_dir  = '/';
				}
			}
			else
			{
				# Set path and dir correct
				$this->upload_path .= "/" . $this_month;
				$this->upload_dir   = $this_month."/";
			}
		}
		return true;
	}
	// Load plug-in class
	/**
	* Loads child extends class.
	*/
	function load_plugin()
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$this->type = $this->ipsclass->txt_alphanumerical_clean( $this->type );
		//-----------------------------------------
		// Load...
		//-----------------------------------------
		$file  = ROOT_PATH . 'sources/classes/attach/plugin_'.$this->type.'.php';
		$class = 'plugin_'.$this->type;
		if ( ! is_object( $this->plugin ) )
		{
			if ( file_exists( $file ) )
			{
				require_once( $file );
				$this->plugin           =  new $class;
				$this->plugin->ipsclass =& $this->ipsclass;
				$this->plugin->get_settings();
			}
			else
			{
				print "Could not locate $file";
				exit();
			}
		}
	}
	// Parse thumbnail attachments inline
	/**
	* Swaps the HTML for the nice attachments.
	*
	* @param	array  Array of matches from preg_replace_callback
	* @return	string HTML
	*/
	function _parse_thumbnail_inline( $matches )
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		$row       = $this->_current['row'];
		$skin_name = $this->_current['skin_name'];
		//-----------------------------------------
		// Generate random ID
		//-----------------------------------------
		$row['_attach_id'] = $row['attach_id'] . '-' . preg_replace( "#[\.\s]#", "-", microtime() );
		//-----------------------------------------
		// Build HTML
		//-----------------------------------------
		$tmp = $this->ipsclass->compiled_templates[ $skin_name ]->Show_attachments_img_thumb( array( 't_location'  => $row['attach_thumb_location'],
																							  		 't_width'     => $row['attach_thumb_width'],
																							  		 't_height'    => $row['attach_thumb_height'],
																							         'o_width'     => $row['attach_img_width'],
																							  		 'o_height'    => $row['attach_img_height'],
																							  	     'attach_id'   => $row['attach_id'],
																									 '_attach_id'  => $row['_attach_id'],
																							    	 'file_size'   => $this->ipsclass->size_format( $row['attach_filesize'] ),
																							  		 'attach_hits' => $row['attach_hits'],
																							  		 'location'    => $row['attach_file'],
																									 'type'        => $this->_current['type'],
																						)	);
		return $tmp;
	}
}
?>
Основной код
PHP:
/*
			    +--------------------------------------------------------------------------
			    |   IPBTracker v2.x
			    |   =============================================
			    |   by Jaggi
			    |   (c) 2002 - 2007 IPBTracker.eu.
			    |   =============================================
			    +---------------------------------------------------------------------------
			    +---------------------------------------------------------------------------
			    |
			    |   > This code will edit the torrent on download
			    |   > Adds passkey
			    |   > Automatically changes announce url to one set in admincp. 
			    |   > benc.php is a GPL licenced and may be used freely, this doesn't apply 
			    |   - to the rest of the code in this script. 
			    +--------------------------------------------------------------------------
			    */
			  
			    if ( $attach['attach_ext'] == 'torrent' && !empty( $attach['torrent_id'] ) )
			    {
					require ROOT_PATH."sources/lib/func_benc.php";
 	  				$this->lib   = new func_benc( $this );
   					$this->lib->ipsclass =& $this->ipsclass;
					$dict = $this->lib->bdec_file( $file, filesize( $file ) );
			   
				   	//-------------------------------------------------
				   	// Does Member Exist
				   	//-------------------------------------------------
				   
					$rsql = $this->ipsclass->DB->query("SELECT torrent_pass 
							 							FROM users 
							 							WHERE uid='" . intval( $this->ipsclass->member['id'] ) . "' 
							 							LIMIT 1
							 						   ");
					
					$this->ipsclass->DB->simple_exec();
					
					$r = $this->ipsclass->DB->fetch_row( $rsql );
				  			
					if ( !$this->ipsclass->DB->get_num_rows() )
					{
						//-------------------------------------------------
						// Store passkey and create members tracker details
						//-------------------------------------------------
						
						$r['torrent_pass'] = $this->ipsclass->generate_torrent_pass();
						$this->ipsclass->DB->query("INSERT INTO users (uid, name, email, added, peers_limit, torrent_pass) 
													VALUES ('" . $this->ipsclass->member['id'] . "',
							  								'" . $this->ipsclass->member['name'] . "',
							  								'" . $this->ipsclass->member['email'] . "',
							  								'" . time() . "',
							  								'1',
															'" . $r['torrent_pass'] . "' )
							  						");
					}
					else if ( $r['torrent_pass'] == '' )
					{
						//-------------------------------------------------
						// No passkey? give them one!
						//-------------------------------------------------
						
						$r['torrent_pass'] = $this->ipsclass->generate_torrent_pass();
					 
						$ssql = $this->ipsclass->DB->query("UPDATE users 
												    		SET torrent_pass ='" . $r['torrent_pass'] . "' 
								  							WHERE uid='" . intval( $this->ipsclass->member['id'] ) . "'
								  						   ");					
					}
							
			   		if ( $this->ipsclass->vars['add_passkey'] )
					{
				   		//-------------------------------------------------
				   		// Compile passkey and announce URL. 
				   		//-------------------------------------------------
						
						$announce_url = preg_replace( "/^(http:\/\/.*?:\d+)(\/announce)/is", "$1/{$r['torrent_pass']}$2", $this->ipsclass->vars['announce_url'] );
					}				

					if ( !$this->ipsclass->member['id'] || !$this->ipsclass->vars['add_passkey'] )
					{
						$r['torrent_pass'] = '';	
						$announce_url = $this->ipsclass->vars['announce_url'];
					}
					
				    //-------------------------------------------------
				    // Add passkey URL.
				    //-------------------------------------------------   
				  
					$dict['value']['announce']['value'] = $announce_url;
					$dict['value']['announce']['string'] = strlen( $dict['value']['announce']['value'] ) . ":" . $dict['value']['announce']['value'];
					$dict['value']['announce']['strlen'] = strlen( $dict['value']['announce']['string'] );
			   
				   	//-------------------------------------------------
				   	// End and wrap everything up. 
				   	//-------------------------------------------------
				   
					$fn = $this->lib->benc($dict);
									   
				   	header( "Content-Type: ".$this->ipsclass->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'] );
					header( "Content-Disposition: inline; filename=\"".$attach['attach_file']."\"" );
					header( "Content-Length: ".(string)(strlen( $fn ) ) );
					
					print $fn;
					exit();
			   }
			  
			   	//-------------------------------------------------
			   	// End of IPBTracker Modification. 
			   	//-------------------------------------------------
Или может выложить форум и базу?
 
Насколько я понял самый простой способ это - прикрутить вот это:

к форуму IPB:

но другой вопрос как это сделать то? с помощью IPBTracker 2.0 Public Beta 2?

Другое дело если кто нибудь выложит более менее внятную инструкцию, хоть в *.doc или *.rtf или *.txt (или любом другом более менее "copy&paste working" формате)
Была одна инструкция... уже не помню в вебе где-то, но там было немного неясно :ah: ну если быть точнее автор указывал что и как делать, но часто забывал указать "где именно" я ещё не такой знаток PHP и уж тем более С++ на котором XBT, чтобы понять как всё это совместно работает.
Короче веду всё дело к тому чтобы кто нибудь собрался с мозгами сел и напечатал как всё это делается дабы дальше не флудить в данную тему на счет руководства... :confused:
 
Спасибо за трекеры.
 
Вопрос возник, по структуре баз данных версий IPB 2.3.х и 3.0.х. Если кому интересно, накрылась интеграция у друга со сборкой kinokpk. Нужно переписать старую, посмотрел поверхностно, хотелось бы уточнить. А может все таки есть у кого уже готовый скрипт? :ah:
 
IPB Trace?

Добавлено через 41 секунду
Есть норм трекер на 2,3,6?

Добавлено через 12 минут
Ребята подскажите, какой лучше на ипбшку 2.3.6?
IPBTracker 2.0
Publiс Beta 1 Public Beta 2
Бета 1 или Бета 2?
 
Если бы ты внимательно читал тему а не пытался тупо набивать посты, то давно бы понял что куда и как.
 
IPB Trace?
Добавлено через 41 секунду
Есть норм трекер на 2,3,6?
Добавлено через 12 минут
Ребята подскажите, какой лучше на ипбшку 2.3.6?
IPBTracker 2.0
Publiс Beta 1 Public Beta 2
Бета 1 или Бета 2?

Конечно Бету 2. Бета 1 посырее будет намного.
 
Если бы ты внимательно читал тему а не пытался тупо набивать посты, то давно бы понял что куда и как.
Я ее внимательно читал, много что было не понятно и понятно.

Добавлено через 2 минуты
Конечно Бету 2. Бета 1 посырее будет намного.
Уху, спасибо большое. Ток вот еще один вопрос, Какую версию Отсюда взять-то? Для просмотра ссылки Войди или Зарегистрируйся Или не моглибы темку скинуть про настройки и тд. Заранее спасибо.
 
Назад
Сверху