TorrentTube for CyberHype 1.0

Может кому пригодится.
Модификация для CyberHype 1.0
Торренты берутся из папки с торрентами, отдельной папки создавать не надо.

в details.php ищем:


$res = sql_query ( "SELECT torrents.poster, torrents.screenshot1, torrents.screenshot2, torrents.screenshot3, torrents.screenshot4, torrents.reliz, torrents.dops, torrents.trailer, torrents.moderated, torrents.moderatedby, torrents.moderatorname, torrents.seeders, torrents.hide, torrents.report, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, torrents.free, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, categories.name AS cat_name, incat.name AS incat_name, users.username, users.group, thanks.userid AS tuid FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN thanks ON torrents.id = thanks.torrentid AND thanks.userid = '$CURUSER[id]' LEFT JOIN incat ON torrents.incat = incat.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id" ) or sqlerr ( __FILE__, __LINE__ );

добавляем туда выборку категорий torrents.category, чтоб получилось так:


$res = sql_query ( "SELECT torrents.category, torrents.poster, torrents.screenshot1, torrents.screenshot2, torrents.screenshot3, torrents.screenshot4, torrents.reliz, torrents.dops, torrents.trailer, torrents.moderated, torrents.moderatedby, torrents.moderatorname, torrents.seeders, torrents.hide, torrents.report, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, torrents.free, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, categories.name AS cat_name, incat.name AS incat_name, users.username, users.group, thanks.userid AS tuid FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN thanks ON torrents.id = thanks.torrentid AND thanks.userid = '$CURUSER[id]' LEFT JOIN incat ON torrents.incat = incat.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id" ) or sqlerr ( __FILE__, __LINE__ );

далее ищем:


	} else {
		stdhead ( $tracker_lang ['comments_for'] . " \"" . $row ["name"] . "\"" );
		print ( "<h1>" . $tracker_lang ['comments_for'] . " <a href=details.php?id=$id>" . $row ["name"] . "</a></h1>\n" );
	}

после вставляем:


		//*****************Begin P2P Stream mod*********************
	if (($row["category"] == "AAAA" && $row["numfiles"] == "1")) {	
	begin_frame ("Смотреть Онлайн");
			require_once('ts_client.php');
			define('API_KEY', 'XXXX');
			define('ZONE_ID', YYYY);
			$client = new TS_Client(API_KEY);
			// BEGIN Добавляем аннонсеры
			$fn = "$torrent_dir/$id.torrent";
			if (! $row || ! is_file ( $fn ) || ! is_readable ( $fn ))
				stderr ( $tracker_lang ['error'], $tracker_lang ['unable_to_read_torrent'] );
			require_once "include/benc.php";			
			$dict = bdec_file ( $fn, (1024 * 1024) );
			$dict ['value'] ['announce'] ['value'] = $announce_urls [0] . "?passkey=$CURUSER[passkey]"; 
			$dict ['value'] ['announce'] ['string'] = strlen ( $dict ['value'] ['announce'] ['value'] ) . ":" . $dict ['value'] ['announce'] ['value'];
			$dict ['value'] ['announce'] ['strlen'] = strlen ( $dict ['value'] ['announce'] ['string'] );			
			// END Добавляем аннонсеры
			$torrent_data = ( benc ( $dict ) );			
			$content_name = $row['save_as'];
			$duration = 5580;
			$content_uid = $client->add_content(ZONE_ID, base64_encode($torrent_data), $content_name, $duration);			
			$on = "<div id=\"content\" style=\"position: relative; width: 550px; height: 400px; margin: 0 auto; background: #000 no-repeat 0 0;\">
			<div id=\"ts_player\" style=\"width: 100%; height: 100%; color: #fff; text-align: center;\">Подождите, идет загрузка плеера...</div>
			<script type=\"text/javascript\">
			var tsHost = ((\"https:\" == document.location.protocol) ? \"https://\" : \"http://\");
			document.write(unescape(\"%3Cscript src='\" + tsHost + \"torrentstream.net/p/" . $content_uid . "' type='text/javascript'%3E%3C/script%3E\"));
			</script>
			<script type=\"text/javascript\">
			tsplayer(\"ts_player\", {width: \"550px\", height: \"400px\"});
			</script>			
			</div>";            
			print $on;			
	end_frame ();
	}
	//******************End P2P Stream mod**********************

AAAA - ID категории которой доступен проигрыватель.
XXXX - Код партнера
YYYY - ID площадки.

ts_client.php - брать тут: http://torrentstream.net/download/?product=tsclient&version=latest и загрузить в корень.

Не забываем про библиотеку Curl .
в Windows подключается так:
php.ini расскоментировать или добавить extension=php_curl.dll
в Linux Компилить PHP сборку с этой библиотекой.
Проверить включена она или нет, можно через phpinfo()

Хотя может и необязательно, должно работать и без curl