<?
@session_start();
@error_reporting( 7 );
@ini_set( 'display_errors', true );
@ini_set( 'html_errors', false );

define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname(  __FILE__ ), 0, -12 ) );
define( 'SYSTEM_DIR', ROOT_DIR . '/system' );

include SYSTEM_DIR . '/data/config.php';
require_once SYSTEM_DIR . '/classes/mysql.php';
require_once SYSTEM_DIR . '/data/dbconfig.php';
require_once SYSTEM_DIR . '/modules/functions.php';

ini_set('default_socket_timeout', 3);
$id = intval($_REQUEST['id']);
if(!$id) die('error');

$row = $db->super_query("SELECT onserver FROM " . PREFIX . "_torrents WHERE id='{$id}'");

if( !$content ){
    require_once SYSTEM_DIR . '/classes/torrent.class.php';
    $FilesTorrent = new Torrent(ROOT_DIR.'/uploads/torrents/'.$row['onserver']);
    $content = $FilesTorrent->content();
}

foreach ($content as $cx => $v) {
    $count_filesx = count($content);
    $ssdx = mksize($v);
    // Кодировка win1251 (CP1251)
    $cx =  iconv("UTF-8", $config['charset'], $cx );
    $torrent_filesx .= "<tr>
<td align='left' bgcolor='#ffffff'>{$cx}</td>
<td align='left' bgcolor='#ffffff'>{$ssdx} / ({$v})</td>
</tr>";
}

@header("Content-type: text/html; charset={$config['charset']}");
echo "<table width='95%' cellpadding='1' cellspacing='1' class='tor' align='center'><thead><td>Файл</td><td align=\"center\">Размер</td></thead>" . $torrent_filesx . "</table>";
?>