Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Icon on file list
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / Old v2 Tpoics

2021-04-13 09:11:33
Wondering if it is possible to fix in a smooth and fast way.

If we have a file list at the end of torrent data and it shows some files in different file formats (eg mp3, mkv, mp4, txt, img etc.) it is possible to add an extra column with the file icon so that at the file name is an appropriate icon next to what the images below show

TT V3 (or TT V 2.08)



Desired



Thanks guys




www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-04-13 13:54:47
The trick here is to substr() and strstr() the file name so the file extension can be pulled and handled for the appropriate icon. Call apron a array pre-defined (your own)
2021-04-13 17:49:01
Yes, somethin on that way, I maked two of tables who can "construct" this MOD (maybe)


--
-- Table structure for table `torrent_extensions`
--

CREATE TABLE IF NOT EXISTS `torrent_extensions` (
 `extension_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
 `group_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
 `extension` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT '',
 PRIMARY KEY (`extension_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `extensions` (`extension_id`, `group_id`, `extension`) VALUES
(1, 1, 'gif'),
(2, 1, 'png'),
(3, 1, 'jpeg'),
(4, 1, 'jpg'),
(5, 1, 'tif'),
(6, 1, 'tiff'),
(7, 1, 'tga'),
(8, 2, 'gtar'),
(9, 2, 'gz'),
(10, 2, 'tar'),
(11, 2, 'zip'),
(12, 2, 'rar'),
(13, 2, 'ace'),
(14, 2, 'torrent'),
(15, 2, 'tgz'),
(16, 2, 'bz2'),
(17, 2, '7z'),
(18, 3, 'txt'),
(19, 3, 'c'),
(20, 3, 'h'),
(21, 3, 'cpp'),
(22, 3, 'hpp'),
(23, 3, 'diz'),
(24, 3, 'csv'),
(25, 3, 'ini'),
(26, 3, 'log'),
(27, 3, 'js'),
(28, 3, 'xml'),
(29, 4, 'xls'),
(30, 4, 'xlsx'),
(31, 4, 'xlsm'),
(32, 4, 'xlsb'),
(33, 4, 'doc'),
(34, 4, 'docx'),
(35, 4, 'docm'),
(36, 4, 'dot'),
(37, 4, 'dotx'),
(38, 4, 'dotm'),
(39, 4, 'pdf'),
(40, 4, 'ai'),
(41, 4, 'ps'),
(42, 4, 'ppt'),
(43, 4, 'pptx'),
(44, 4, 'pptm'),
(45, 4, 'odg'),
(46, 4, 'odp'),
(47, 4, 'ods'),
(48, 4, 'odt'),
(49, 4, 'rtf'),
(50, 5, 'rm'),
(51, 5, 'ram'),
(52, 6, 'wma'),
(53, 6, 'wmv'),
(54, 7, 'swf'),
(55, 8, 'mov'),
(56, 8, 'm4v'),
(57, 8, 'm4a'),
(58, 8, 'mp4'),
(59, 8, '3gp'),
(60, 8, '3g2'),
(61, 8, 'qt'),
(62, 9, 'mpeg'),
(63, 9, 'mpg'),
(64, 9, 'mp3'),
(65, 9, 'ogg'),
(66, 9, 'ogm'),
(67, 9, 'php');


extensions.sql
File missing



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2021-04-13 17:49:57
2021-04-13 17:49:29
I can attache just a one file at time


--
-- Table structure for table `torrent_extension_groups`
--

CREATE TABLE IF NOT EXISTS `torrent_extension_groups` (
 `group_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
 `group_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
 `cat_id` tinyint(2) NOT NULL DEFAULT '0',
 `allow_group` tinyint(1) unsigned NOT NULL DEFAULT '0',
 `download_mode` tinyint(1) unsigned NOT NULL DEFAULT '1',
 `upload_icon` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
 `max_filesize` int(20) unsigned NOT NULL DEFAULT '0',
 `allowed_forums` text COLLATE utf8_bin NOT NULL,
 `allow_in_pm` tinyint(1) unsigned NOT NULL DEFAULT '0',
 PRIMARY KEY (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


INSERT INTO `extension_groups` (`group_id`, `group_name`, `cat_id`, `allow_group`, `download_mode`, `upload_icon`, `max_filesize`, `allowed_forums`, `allow_in_pm`) VALUES
(1, 'GROUP_IMAGES', 0, 0, 1, '', 0, '', 1),
(2, 'GROUP_ARCHIVES', 0, 0, 1, '', 0, '', 1),
(3, 'GROUP_PLAIN_TEXT', 0, 1, 1, '', 0, '', 1),
(4, 'GROUP_DOCUMENTS', 1, 1, 1, '', 0, '', 1),
(5, 'GROUP_REAL_MEDIA', 3, 0, 1, '', 0, '', 1),
(6, 'GROUP_WINDOWS_MEDIA', 2, 0, 1, '', 0, '', 1),
(7, 'GROUP_FLASH_FILES', 5, 0, 1, '', 0, '', 0),
(8, 'GROUP_QUICKTIME_MEDIA', 6, 0, 1, '', 0, '', 0),
(9, 'GROUP_DOWNLOADABLE_FILES', 0, 0, 1, '', 0, '', 0);
extensions_goups.sql
File missing



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2021-04-13 17:50:31
2021-04-14 01:34:31
Just attach your PHP code responsible for the filename / size etc. For example, this is mine (on my own code). Yours will be similar. No need for extra tables, we just check the string on the filename array key, and detect filetype with 1 of 3 ways (i prefer substr() method)

Are you using PHP 8? If you are, then we can use str_contains()


// Determine torrent icon by file extension - PHP 8
$filetype_icon = '';
if (str_contains($file['path'][0], 'mp3')) {
  $filetype_icon = 'somemusicicon.png';
} else if (str_contains($file['path'][0], 'mp4')) {
   $filetype_icon = 'somemovieicon.png';
} else if (str_contains($file['path'][0], 'avi')) {
   $filetype_icon = 'somemusicicon2.png';
}


and save a lot of time. Otherwise we need to use:

$filetypecheck = substr($fileinfo, 0, strpos($fileinfo, '.'))
if ($filetypecheck !== false && $filetypecheck == 'mp3') {
  $filetype_icon = 'somemusicicon.png';
}else if ($filetypecheck !== false && $filetypecheck == 'mp4') {
  $filetype_icon = 'somemovieicon.png';
}else if ($filetypecheck !== false && $filetypecheck == 'avi') {
  $filetype_icon = 'somemovieicon2.png';
}


The rundown

print("<table align='center' cellpadding='0' cellspacing='0' border='0' width='100%'><tr><th class='table_head' align='left'>File</th><th width='50' class='table_head'>Size</th></tr></table>");
if ($arr !== false && array_key_exists('info', $arr)) {
   if (array_key_exists('files', $arr['info'])) {
       foreach ($arr['info']['files'] as $file) {
           if (array_key_exists('path', $file)) {
               printf("<span class=\"material-icons\" style=\"color:%s;vertical-align:bottom\">description</span> <span>%s</span>", $color, html_escape(implode('/', $file['path'])));
               printf("<br/>");
           }
       }
   } else if (array_key_exists('name', $arr['info'])) {
       printf("<span class=\"material-icons\" style=\"color:%s;vertical-align:bottom\">description</span> <span>%s</span>", $color, html_escape($arr['info']['name']));
       printf("<br/>");
   }
}
Last edited by STorrents2020 on 2021-04-14 01:48:34
2021-04-14 05:59:32
Wooow, that was fast answer mate, thanks.

I don't use PHP 8, because this version of TT can use just PHP 5.6 (sad I know, :( )

I can try it and come back to you if it be fixed


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-04-14 11:43:27
Due to my very "limited" knowledge of both PHP and SQL, I encountered some difficulties in implementing this code in torrent-details.php for TT V2.08 and PHP 5.6. Some of the code details don’t “fit” in some sense to the code system I have on the script.

I would be very grateful if you could clarify a bit how to implement and run it in reality

Thanks


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-04-15 22:54:46
I fiddled around with this idea. I borrowed a bit of storrents code and went just a little differently. Feel free to try this in torrent-details.php. Below is my entire fileslist code
echo "<br /><br /><b>".T_("FILE_LIST").":</b> <img src='images/plus.gif' id='pic1' onclick='klappe_torrent(1)' alt='' /><div id='k1' style='display: none;'><table align='center' cellpadding='0' cellspacing='0' class='table_table' border='1' width='100%'><tr><th width='50' class='table_head'> ".T_("TYPE")."</th><th class='table_head' align='left'> ".T_("FILE")."</th><th width='50' class='table_head'> ".T_("SIZE")."</th></tr>";
$fres = SQL_Query_exec("SELECT * FROM `files` WHERE `torrent` = $id ORDER BY `path` ASC");
if (mysqli_num_rows($fres)) {
   while ($frow = mysqli_fetch_assoc($fres)) {
$ext = pathinfo($frow['path'], PATHINFO_EXTENSION);
if ($ext !== false && $ext == 'mp3') {
$filetype_icon = "<img width=40 height=40 src=/images/mp3.png>";
 }else if ($ext !== false && $ext == 'mp4') {
$filetype_icon = "<img width=40 height=40 src=/images/mp4.png>";
 }else if ($ext !== false && $ext == 'png') {
$filetype_icon = "<img width=40 height=40 src=/images/png.png>";
 }else if ($ext !== false && $ext == 'mkv') {
$filetype_icon = "<img width=40 height=40 src=/images/mkv.png>";
 }else if ($ext !== false && $ext == 'avi') {
$filetype_icon = "<img width=40 height=40 src=/images/avi.png>";
 }else if ($ext !== false && $ext == 'nfo') {
$filetype_icon = "<img width=40 height=40 src=/images/nfo.png>";
}
       echo "<tr><td class='table_col1'>".$filetype_icon."</td><td class='table_col1'>".htmlspecialchars($frow['path'])."</td><td class='table_col2'>".mksize($frow['filesize'])."</td></tr>";
   }
}else{
   echo "<tr><td class='table_col1'>".htmlspecialchars($row["name"])."</td><td class='table_col2'>".mksize($row["size"])."</td></tr>";
}
echo "</table></div>";

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-11-30 22:47:23
2021-04-15 23:44:47
Looks good! More media-based approach and the safety of pathinfo(), good choice.

Just define a default or empty variable to satisfy fallback and/or page warnings.
2021-04-16 00:46:27
Thanks Storrents. I didnt even think about a fallback since I was just fiddling and adding all options as I found them
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-04-16 00:52:00
2021-04-16 00:58:14
updated images to use if you wish
images.zip
File missing

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2021-04-16 07:34:44
Hi guys, you are awesome ... nice work like always.
Instead of .png or .gif images I have put in flat icons so it be easier for me


Once time guys thanks a lot




www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2021-04-16 10:51:56
2021-04-18 17:10:54
Thanks you!  :D
2021-05-24 16:18:20
hello gang i noticed that if my extensions are in uppercase it does not show the correct image So I share with you my fix that works # 1
---------------------------------
allo gang j'ai remarqué que si mes extensions sont en majuscule il ne montre pas la bonne image Donc, je vous partage ma correction qui fonctionne #1

$ext == 'mp3' add || $ext == 'My Ext'

Exemple:
if ($ext !== false && $ext == 'mp3' || $ext == 'FMP3'){
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/mp3.png>";
}else if ($ext !== false && $ext == 'flac' || $ext == 'FLAC') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/flac.png>";
}else if ($ext !== false && $ext == 'mp4' || $ext == 'MP4') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/mp4.png>";
}else if ($ext !== false && $ext == 'm3u' || $ext == 'M3U') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/m3u.png>";
}else if ($ext !== false && $ext == 'pdf' || $ext == 'PDF') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/pdf.png>";
}else if ($ext !== false && $ext == 'jpg' || $ext == 'JPG') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/jpg.png>";
}else if ($ext !== false && $ext == 'png' || $ext == 'PNG') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/png.png>";
}else if ($ext !== false && $ext == 'txt' || $ext == 'TXT') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/txt.png>";
}else if ($ext !== false && $ext == 'lng' || $ext == 'LNH') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/lng.png>";
}else if ($ext !== false && $ext == 'btskin' || $ext == 'BTSKIN') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/btskin.png>";
}else if ($ext !== false && $ext == 'epub' || $ext == 'EPUB') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/epub.png>";
}else if ($ext !== false && $ext == 'bmp' || $ext == 'BMP') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/bmp.png>";
}else if ($ext !== false && $ext == 'conf' || $ext == 'CONF') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/conf.png>";
}else if ($ext !== false && $ext == 'dll' || $ext == 'DLL') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/dll.png>";
}else if ($ext !== false && $ext == 'ini' || $ext == 'INI') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/ini.png>";
}else if ($ext !== false && $ext == 'dat' || $ext == 'DAT') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/dat.png>";
}else if ($ext !== false && $ext == 'apk' || $ext == 'APK') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/apk.png>";
}else if ($ext !== false && $ext == '7z' || $ext == '7Z') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/7z.png>";
}else if ($ext !== false && $ext == 'zip' || $ext == 'ZIP') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/zip.png>";
}else if ($ext !== false && $ext == 'rar' || $ext == 'RAR') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/rar.png>";
}else if ($ext !== false && $ext == 'exe' || $ext == 'EXE') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/exe.png>";
}else if ($ext !== false && $ext == 'iso' || $ext == 'ISO') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/iso.png>";
}else if ($ext !== false && $ext == 'mkv' || $ext == 'MKV') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/mkv.png>";
}else if ($ext !== false && $ext == 'avi' || $ext == 'AVI') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/avi.png>";
}else if ($ext !== false && $ext == 'url' || $ext == 'URL') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/url.png>";
}else if ($ext !== false && $ext == 'NFO' || 'nfo' || $ext == 'NFO') {
$filetype_icon = "<img width=100 height=30 src=/images/Torrents/nfo.png>";
}


Last edited by spiritblue on 2021-05-24 16:19:38
2021-05-24 17:04:16
Thanks spiritblue and others guys, how to fix folder icon?

If we have some foder in torrents like that
torrent==>Folder A-side==>sound.mp3
torrent==>Folder B-side==>sound.flac
torrent==>Folder A-side==>sound.wav

ect ect ....



Regards to all of you


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2021-05-24 17:07:09
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728