From 5cf210c9459bd601c5d4291786f595e711daa009 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Tue, 5 Apr 2011 20:37:55 +0000 Subject: add torrent links (tmb) --- downloads.ini | 3 +++ downloads.php | 11 +++++++---- en/downloads/dl.php | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/downloads.ini b/downloads.ini index ddbf16734..ca8eb6cd3 100644 --- a/downloads.ini +++ b/downloads.ini @@ -12,6 +12,7 @@ lang = All supported md5 = a1e32b5617184c59b462a5d9a67e53ad sha1 = f3cac56973a54871c0a21b89f0ec18e447670e2a path = iso/cauldron/mageia-dvd-1-Beta1-i586.iso +torrent = iso/cauldron/torrents/Mageia-1-Beta-1-i586-dvd.torrent [dvd-x86_64] name = 64bit DVD @@ -20,6 +21,7 @@ lang = All supported md5 = 6365a5eb6b9d599f0b1e58ee6d09948f sha1 = 579b60f570ae30f8ddbc46b00a2b9177cd80031a path = iso/cauldron/mageia-dvd-1-Beta1-x86_64.iso +torrent = iso/cauldron/torrents/Mageia-1-Beta-1-x_86_64-dvd.torrent [cd-dualarch] name = Dual arch CD @@ -28,6 +30,7 @@ lang = All supported md5 = 687ffabed3cc2deff71c8156cea84438 sha1 = d7b4d4337bfdae311081267601c6b053b46858c8 path = iso/cauldron/mageia-dual-1-Beta1.iso +torrent = iso/cauldron/torrents/Mageia-1-Beta-1-dual-arch-cd.torrent ;[live-kde-europa-cd-i586] ;name = Live KDE CD diff --git a/downloads.php b/downloads.php index 7076aa8d1..0286ce2e1 100644 --- a/downloads.php +++ b/downloads.php @@ -32,11 +32,10 @@ $tmpl = <<%s %s %s - +%s T; //%s -//%s $s = ''; $glob = array_shift($prods); @@ -46,14 +45,17 @@ foreach ($prods as $k => $p) { $iso = sprintf('%s-%s', $glob['prefix'], $k); $dl_link = sprintf('/%s/downloads/dl.php?product=%s', $locale, $iso); - $bt_link = sprintf('/%s/downloads/dl.php?product=%s&torrent=1', $locale, $iso); + $bt_link = isset($p['torrent']) ? + sprintf('/%s/downloads/dl.php?product=%s&torrent=1', $locale, $iso) : + null; + $pop = rand(0,5); $s .= sprintf($tmpl, '', //($i == 0) ? ' class="reco"' : '', $p['name'], $p['lang'], $p['size'], //$pop, $pop, $dl_link, $_t['download'], - $bt_link, $_t['download']); + $bt_link, !is_null($bt_link) ? $_t['download'] : ''); $i++; } @@ -66,6 +68,7 @@ $dl_table = <<{$_t['language']} {$_t['size']} {$_t['link']} + BitTorrent diff --git a/en/downloads/dl.php b/en/downloads/dl.php index 635f73eea..1ca6ccef5 100644 --- a/en/downloads/dl.php +++ b/en/downloads/dl.php @@ -32,10 +32,21 @@ $product_iso = $product . '.iso'; $wsd = new Downloads('en', null); $a = $wsd->prepare_download(null, true); -if (isset($p['path'])) - $dl_link = sprintf('%s/%s', $a['mirror_url'], $p['path']); -else - $dl_link = sprintf('%s/%s/%s', $a['mirror_url'], 'iso/cauldron', $product_iso); +if ($torrent) { + if (isset($p['torrent'])) { + $dl_link = sprintf('%s/%s', $a['mirror_url'], $p['torrent']); + } + else { + header('Location: /downloads/'); + die; + } +} +else { + if (isset($p['path'])) + $dl_link = sprintf('%s/%s', $a['mirror_url'], $p['path']); + else + $dl_link = sprintf('%s/%s/%s', $a['mirror_url'], 'iso/cauldron', $product_iso); +} // @fixme (rda) actually, http-equiv="refresh" is deprecated behaviour now. // @fixme (rda) see http://www.w3.org/TR/WCAG10-HTML-TECHS/#meta-element -- cgit v1.2.1