##############################################################
## MOD Title: Poster Mod
## MOD Author: RomM1 http://torrentpier.me
## MOD Description:   
## MOD Version: 2.0
##
## Installation Level: Easy
## Installation Time: 5 Minutes
##############################################################
 
*** SQL ****************************************

ALTER TABLE  `bb_topics` ADD  `topic_image` VARCHAR( 255 ) NOT NULL DEFAULT  'images/no-poster.png'
 
***  config.php     ****************************************

//Poster_Mod
$bb_cfg['lenta'] = true; //  / 
$bb_cfg['lenta_posters'] = 20; //  () 
$bb_cfg['glossy'] = true; //  
$bb_cfg['not_in'] = 0; //   

***  build_cat_forums.php   ****************************************

//
// Ads
//

***   ******************************************************

//Poster_Mod
if($bb_cfg['lenta']) 
{
	$data = DB()->fetch_rowset("SELECT
			tr.topic_id, tr.size,
			t.topic_title, t.topic_image,
			f.forum_name,
			u.username, u.user_id, u.user_rank,
			pt.post_text
		FROM
			". BB_BT_TORRENTS ." tr
		LEFT JOIN ". BB_TOPICS ." t ON tr.topic_id = t.topic_id
		LEFT JOIN ". BB_FORUMS ." f ON tr.forum_id = f.forum_id
		LEFT JOIN ". BB_USERS ." u  ON tr.poster_id = u.user_id
		LEFT JOIN ". BB_POSTS_TEXT ." pt  ON tr.post_id = pt.post_id
		WHERE 
		    tr.forum_id NOT IN (".$bb_cfg['not_in'].")
		ORDER BY
			tr.reg_time DESC
		LIMIT ". $bb_cfg['lenta_posters'] ."
		");
	$this->store('poster_mod', $data);
}

***  index.php   **************************************

if ($bb_cfg['show_latest_news'])
{
	$datastore->enqueue('latest_news');
}

***   **************************************************

// Poster_Mod
if ($bb_cfg['lenta'])
{
   $datastore->enqueue('poster_mod');
}

***  ********************************************************

// Network news
if ($bb_cfg['show_network_news'])
{
    if (!$network_news = $datastore->get('network_news'))

***   ***********************************************************

// Poster_Mod
if($bb_cfg['lenta']) 
{		
	$template -> assign_vars(array(
		'POSTER_MOD_ON' => true,
    ));
	
	$poster_mod = $datastore->get('poster_mod');
	foreach ($poster_mod as $row_mod)
	{
	preg_match_all('/\[img=right\](.*?)\[\/img\]/i', $row_mod['post_text'], $poster, PREG_SET_ORDER);
    preg_match_all('/\[img=left\](.*?)\[\/img\]/i', $row_mod['post_text'], $poster2, PREG_SET_ORDER);
    preg_match_all('/\[img\](.*?)\[\/img\]/i', $row_mod['post_text'], $poster3, PREG_SET_ORDER);
	preg_match_all('/\[poster\](.*?)\[\/poster\]/i', $row_mod['post_text'], $poster4, PREG_SET_ORDER);

    $url = '';
    if (@$poster[0][1])
    {
	    $url = $poster[0][1];
    }
    elseif (@$poster2[0][1])
    {
	    $url = $poster2[0][1];
    }
    elseif (@$poster3[0][1])
    {
	    $url = $poster3[0][1];
    }
    elseif (@$poster4[0][1])
    {
	    $url = $poster4[0][1];
    }
	$template->assign_block_vars('PosterMod', array(
			'TITLE' => $row_mod['topic_title'],
			'TOPIC_ID' => $row_mod['topic_id'],
			'FORUM' => $row_mod['forum_name'],
			'SIZE' => humn_size($row_mod['size']),
			'POSTER' => profile_url(array('username' => $row_mod['username'], 'user_rank' => $row_mod['user_rank'])),
			'POSTER_IMG' => $row_mod['topic_image'],
			'POSTER_IMG_TITLE' => $url,
	));
	}
}
// Poster_Mod

***  *******************************************************

<!--/menus-->

***   **********************************************

<!-- IF SHOW_LATEST_NEWS -->
<!-- IF $bb_cfg['lenta'] -->
<!-- IF $bb_cfg['glossy'] -->
<script type="text/javascript" src="{#BB_ROOT}misc/js/glossy.js?v={$bb_cfg['js_ver']}"></script> 
<script type="text/javascript" src="{#BB_ROOT}misc/js/cvi_glossy_lib.js?v={$bb_cfg['js_ver']}"></script>
<!-- ENDIF -->
<script type="text/javascript" src="{#BB_ROOT}misc/js/jquery.mousewheel.js?v=16"></script>
<script type="text/javascript" src="{#BB_ROOT}misc/js/jquery.scrollable.js?v={$bb_cfg['js_ver']}"></script>
<script src="{#BB_ROOT}misc/js/jquery.cluetip.js?v=16" type="text/javascript"></script>

 
<script type="text/javascript">
$(document).ready(function() { 
$('a.load-local').cluetip({local:true, cursor: 'pointer',showTitle: true,arrows: true});
$('span[title]').cluetip({splitTitle: '|', arrows: true, dropShadow: false, cluetipClass: 'jtip'});
$('a.load-local-menu').cluetip({local:true, activation: 'click', cursor: 'pointer',showTitle: true,sticky: true, closePosition: 'title', width: 500, height: 500, closeText: '', cluetipClass: 'jtip'});
});
</script>
<script>
$(function() {
  $("div.scrollable").scrollable({
      size: 8,
      items: '#thumbs',
      hoverClass: 'hover',
      keyboard: true,
     loop: true,
    });
});
</script>

<table cellpadding="0" cellspacing="0" class="poster">
<tr>
<td>
<!-- prev link -->
<a class="prev"></a>
<!-- root element for scrollable -->
<div class="scrollable">
<div id="thumbs">
<!-- IF POSTER_MOD_ON -->
  <!-- BEGIN PosterMod -->
  <div class="tCenter">
<a class="load-local" href="viewtopic.php?t={PosterMod.TOPIC_ID}" rel="#loadme_{PosterMod.TOPIC_ID}" title="{PosterMod.TITLE}" onclick="top.location.href='viewtopic.php?t={PosterMod.TOPIC_ID}';"><img src="{PosterMod.POSTER_IMG}" <!-- IF $bb_cfg['glossy'] -->onload="cvi_glossy.add(this,{radius:30,nogradient:true,angle:-33,shadow:30});"<!-- ENDIF -->></a>
</div>
<div style="display: none;" id="loadme_{PosterMod.TOPIC_ID}"><center><img src="{PosterMod.POSTER_IMG_TITLE}" width="260"></center><br=clear> : <b>{PosterMod.FORUM}</b> <br> : <b>{PosterMod.POSTER}</b> <br> : <b>{PosterMod.SIZE}</b></br=clear>
</div>
<!-- END PosterMod -->
<!-- ENDIF -->
</div>
</div>
<!-- next link -->
<a class="next"></a>
</td>
</tr>
</table><!-- ENDIF --><!-- ENDIF -->

***  main.css     ***********************************

/* root element for the whole scrollable setup */
div.scrollable { 
  position:relative;
  overflow:hidden;
  width: 93%;
  height:143px;
}
#thumbs {
  position:absolute;
  width:20000em; 
  clear:both;
}
a.prev, a.next {
  margin-top:118px;
}
#thumbs div {
  float:left;
  width:110px;
  height:135px;
  color:#fff;
  cursor:pointer;
  padding: 3px 3px 3px 3px;
}
#thumbs div.hover {
  background-color:#D0DFEF;
}
#thumbs div.active {
  background-color:#6699CC;
  cursor:default;
}
div.scrollable {
  float:left;   
}
/* prev, next, prevPage and nextPage buttons */
a.prev, a.next, a.prevPage, a.nextPage {
  display:block;
  width:18px;
  height:18px;
  background:url(../images/cluetip/left.png) no-repeat;
  float:left;
  margin:55px 5px;
  cursor:pointer;
}
a.prev:hover, a.next:hover, a.prevPage:hover, a.nextPage:hover {
  background-position:0px -18px;    
}
a.disabled {
  visibility:hidden !important;   
}
a.next, a.nextPage {
  background-image:url(../images/cluetip/right.png);
  clear:right;
}
div.navi {
  margin-left:47%;
  width:250px;
  height:20px;
}
div.navi a {
  width:8px;
  height:8px;
  float:left;
  margin:3px;
  background:url(../images/cluetip/navigator.png) no-repeat;     
  cursor:pointer; 
}
div.navi a:hover {
  background-position:0 -8px;      
}
div.navi a.active {
  background-position:0 -16px;     
}
.poster {
  margin: 3px 4px 0; padding: 0 8px; width: 99%;
  background: #EFEFEF; border: solid #CFD4D8; border-width: 1px 0px;
}

/* global */
#cluetip-close img {
  border: 0;
}
#cluetip-title {
  overflow: hidden;
}
#cluetip-title #cluetip-close {
  float: right;
  position: relative;
}
#cluetip-waitimage {
  width: 43px;
  height: 11px;
  position: absolute;
  background-image: url(../images/cluetip/wait.gif);
}
.cluetip-arrows {
  display: none;
  position: absolute;
  top: 0;
  left: -11px;
  height: 22px;
  width: 11px;
  background-repeat: no-repeat;
  background-position: 0 0;
}
#cluetip-extra {
  display: none;
}
/***************************************
   =cluetipClass: 'default' 
-------------------------------------- */

.cluetip-default {
  background-color: #d9d9c2;
}
.cluetip-default #cluetip-outer {
  position: relative;
  margin: 0;
  background-color: #d9d9c2;
}
.cluetip-default h3#cluetip-title {
  margin: 0 0 5px;
  padding: 8px 10px 4px;
  font-size: 1.1em;
  font-weight: normal;
  background-color: #87876a;
  color: #fff;
}
.cluetip-default #cluetip-title a {
  color: #d9d9c2;
  font-size: 0.95em;
}  
.cluetip-default #cluetip-inner {
  padding: 10px;
}
.cluetip-default div#cluetip-close { 
  text-align: right;
  margin: 0 5px 5px;
  color: #900;
}

/* default arrows */

.clue-right-default .cluetip-arrows {
  background-image: url(../images/cluetip/darrowleft.gif);
}
.clue-left-default .cluetip-arrows {
  background-image: url(../images/cluetip/darrowright.gif);
  left: 100%;
  margin-right: -11px;
}
.clue-top-default .cluetip-arrows {
  background-image: url(../images/cluetip/darrowdown.gif);
  top: 100%;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;  
}  
.clue-bottom-default .cluetip-arrows {
  background-image: url(../images/cluetip/darrowup.gif);
  top: -11px;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;
}

/***************************************
   =cluetipClass: 'jtip'
-------------------------------------- */
.cluetip-jtip {
  background-color: transparent;
}
.cluetip-jtip #cluetip-outer {
  border: 2px solid #ccc;
  position: relative;
  background-color: #fff;
}

.cluetip-jtip h3#cluetip-title {
  margin: 0 0 5px;
  padding: 2px 5px;
  font-size: 16px;
  font-weight: normal;
  background-color: #ccc;
  color: #333;
}

.cluetip-jtip #cluetip-inner {
  padding: 0 5px 5px;
  display: inline-block;
}
.cluetip-jtip div#cluetip-close { 
  text-align: right;
  margin: 0 5px 5px;
  color: #900;
}

/* jtip arrows */

.clue-right-jtip .cluetip-arrows {
  background-image: url(../images/cluetip/arrowleft.gif);
}
.clue-left-jtip .cluetip-arrows {
  background-image: url(../images/cluetip/arrowright.gif);
  left: 100%;
  margin-right: -11px;
}
.clue-top-jtip .cluetip-arrows {
  background-image: url(../images/cluetip/arrowdown.gif);
  top: 100%;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;  
}  
.clue-bottom-jtip .cluetip-arrows {
  background-image: url(../images/cluetip/arrowup.gif);
  top: -11px;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;
}

/***************************************
   =cluetipClass: 'rounded'
-------------------------------------- */

.cluetip-rounded {
  background: transparent url(../images/cluetip/bl.gif) no-repeat 0 100%;
  margin-top: 10px;
  margin-left: 12px;
}

.cluetip-rounded #cluetip-outer {
  background: transparent url(../images/cluetip/tl.gif) no-repeat 0 0;
  margin-top: -12px;
}

.cluetip-rounded #cluetip-title {
  background-color: transparent;
  padding: 12px 12px 0;
  margin: 0 -12px 0 0;
  position: relative;
}
.cluetip-rounded #cluetip-extra {
  position: absolute;
  display: block;
  background: transparent url(../images/cluetip/tr.gif) no-repeat 100% 0;
  top: 0;
  right: 0;
  width: 12px;
  height: 30px;
  margin: -12px -12px 0 0;
}
.cluetip-rounded #cluetip-inner {
  background: url(../images/cluetip/br.gif) no-repeat 100% 100%;
  padding: 5px 12px 12px;
  margin: -18px -12px 0 0;
  position: relative;
}

.cluetip-rounded div#cluetip-close { 
  text-align: right;
  margin: 0 5px 5px;
  color: #009;
  background: transparent;
}
.cluetip-rounded div#cluetip-close a {
  color: #777;
}

/* rounded arrows */

.clue-right-rounded .cluetip-arrows {
  background-image: url(../images/cluetip/rarrowleft.gif);
}
.clue-left-rounded .cluetip-arrows {
  background-image: url(../images/cluetip/rarrowright.gif);
  left: 100%;
  margin-left: 12px;
}
.clue-top-rounded .cluetip-arrows {
  background-image: url(../images/cluetip/rarrowdown.gif);
  top: 100%;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;  
}  
.clue-bottom-rounded .cluetip-arrows {
  background-image: url(../images/cluetip/rarrowup.gif);
  top: -23px;
  left: 50%;
  margin-left: -11px;
  height: 11px;
  width: 22px;
}



/* stupid IE6 HasLayout hack */
.cluetip-rounded #cluetip-title,
.cluetip-rounded #cluetip-inner {
  zoom: 1;
}

***  functions_torrent.php   *********************************

if ($reg_mode == 'request' || $reg_mode == 'newtopic')

***   *********************************

get_thumb($post_id, $topic_id);

***  *****************************************

function send_torrent_with_passkey ($filename)

***   *********************************

function get_thumb($post_id, $topic_id) 
//      
//  _Xz_ (http://torrentpier.me/members/2-_Xz_)
{
$row = DB()->fetch_row("SELECT post_text
		FROM 
		". BB_POSTS_TEXT ."
		WHERE 
		post_id = $post_id
		");
		
preg_match_all('/\[img=right\](.*?)\[\/img\]/i', $row['post_text'], $poster, PREG_SET_ORDER);
preg_match_all('/\[img=left\](.*?)\[\/img\]/i', $row['post_text'], $poster2, PREG_SET_ORDER);
preg_match_all('/\[img\](.*?)\[\/img\]/i', $row['post_text'], $poster3, PREG_SET_ORDER);
preg_match_all('/\[poster\](.*?)\[\/poster\]/i', $row['post_text'], $poster4, PREG_SET_ORDER);

$url = '';
if (@$poster[0][1])
{
	$url = $poster[0][1];
}
elseif (@$poster2[0][1])
{
	$url = $poster2[0][1];
}
elseif (@$poster3[0][1])
{
	$url = $poster3[0][1];
}
elseif (@$poster4[0][1])
{
	$url = $poster4[0][1];
}

$filetype = substr(strrchr($url, '.'), 1);
$filename = substr($url, strrpos($url, '/'));
$no_poster = 'images/no-poster.png'; //  -.
$folder = 'thumb'; //  
$thumb_file = $folder . $filename;

//   
if (@fopen($thumb_file, "r"))
{
}
else
{
	//    
	if (@fopen($url, "r"))
	{
		//  
		@list($poster_width, $poster_height) = getimagesize($url);

	    if(!$poster_width || !$poster_height) //  
	    {
			$thumb_file = $no_poster;
	    }
	    else
	    {
		    @list($poster_width, $poster_height) = getimagesize($url);

		    if(!$poster_width && !$poster_height) //  
		    {
				$thumb_file = $no_poster;
		    }

		    switch ($filetype)
		    {
		    	case 'jpg':
				case 'jpeg':
					$poster = ImageCreateFromJPEG($url);
				  break;
				case 'png':
					$poster = ImageCreateFromPNG($url);
				  break;
				case 'gif':
					$poster = ImageCreateFromGIF($url);
				  break;
		    }

		    $max_width = 90; //  

			$thumb_width = $max_width;
			$thumb_height = ($poster_height*$max_width)/$poster_width;

		    if(($poster_width > $max_width))
		    {
		    	$thumb = imagecreatetruecolor($thumb_width, $thumb_height);

		        //   PNG,  
			    imagealphablending($thumb, false);
				imagesavealpha($thumb, true);

				imagecopyresampled($thumb, $poster, 0, 0, 0, 0, $thumb_width, $thumb_height, $poster_width, $poster_height);
		    }
		    else
		    {
		    	 $thumb = $poster;
		    }

		    // 
		    switch($filetype)
		    {
		    	case "jpg":
		    	case "jpeg":
			    	ImageJPEG($thumb, $thumb_file, 100);
					break;
				case "png":
					ImagePNG($thumb, $thumb_file);
					break;
				case "gif":
					ImageGIF($thumb, $thumb_file);
					break;
		    }
		    //
		    imagedestroy($thumb);
		    imagedestroy($poster);
	    }
	}
	else
	{
		$thumb_file = $no_poster;
	}
}
DB()->query("UPDATE " . BB_TOPICS . " SET topic_image='$thumb_file' WHERE topic_id=$topic_id");
}

***  *************************************

 functions_torrent.php   :
$no_poster = 'images/no-poster.png'; //  -.
$folder = 'thumb'; //  
$max_width = 90; //  

     -    -  . 

 DataStore.

   :)


