aboutsummaryrefslogtreecommitdiffstats
path: root/en/downloads/dl.php
blob: 9827d46dbefc5429592b091435097e4e67d68902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
*/

$product = isset($_GET['product']) ? trim(strtolower($_GET['product'])) : null;
$torrent = isset($_GET['torrent']) ? true : false;
$mirror  = isset($_GET['mirror']) ? trim(strtolower($_GET['mirror'])) : null;

define('HLANG', true);
require '../../langs.php';
require 'locales.php';

$_t = i18n::get_strings($_t, $locale, $i18n_fallback_rules);

require 'lib.php';

session_start();

if (!is_null($product)) {
    $found = false;
    foreach ($prods as $k => $p) {
        if ($product == sprintf('%s-%s', $glob['prefix'], $k)
            || $product == $k) {
            $found = true;
            break;
        }
    }
}

if (!$found) {
    header('Location: /downloads/');
    die;
}
include '../../lib/Downloads.php';

$g_mirrors   = Downloads::get_all_mirrors();
$product_iso = $product . '.iso';

$wsd = new Downloads($locale, null);
$a = $wsd->prepare_download(null, true);
$product_dl_link = null;

if ($torrent) {
    if (isset($p['torrent'])) {
        $product_dl_link = $p['torrent'];
        $dl_link = sprintf('%s/%s', $a['mirror_url'], $p['torrent']);
    }
    else {
        header('Location: /downloads/');
        die;
    }
}
else {
    $product_dl_link = isset($p['path']) ?
        $p['path'] :
        sprintf('iso/1/%s', $product_iso);

    $dl_link = sprintf('%s/%s', $a['mirror_url'], $product_dl_link);
}

$title = 'Mageia 1';
if (isset($p['page_title']))
    $title = $p['page_title'];
    
$_t['page_h1'] = sprintf($_t['page_h1'], '<em class="tag">' . $title . '</em>');
$_t['page_title'] = sprintf($_t['page_title'], '<em class="tag">' . $title . '</em>');

$dl_alt_mirrors_table = '';

$g_mirs2 = array();
foreach ($g_mirrors as $country => $mirs):
    foreach ($mirs as $mir):
        $g_mirs2[$countries[$country]][$mir['city']][] = $mir['url'];
    endforeach;
endforeach;

$g_mirrors = $g_mirs2;
ksort($g_mirrors);

foreach ($g_mirrors as $country => $cities):
    foreach ($cities as $city => $mirrors) {
        $mirs = array();
        foreach ($mirrors as $m) {
            $pm = parse_url($m);
            $alt_dl_link = sprintf('%s/%s', $m, $product_dl_link);
            $mirs[] = sprintf('%s://<a href="%s" rel="nofollow">%s</a>',
                $pm['scheme'], $alt_dl_link, $pm['host']);
        }
        $dl_alt_mirrors_table .= sprintf('<tr><td nowrap>%s</td><td>%s</td><td>%s</td></tr>', $country, $city, implode(', ', $mirs));
    }
endforeach;

$dl2_mirror_alt = sprintf($_t['dl_mirror_loc'],
        $a['mirror_url'], $a['mirror_host'], $countries[$a['country']], $a['country'])
    . ' ' . $_t['dl_alt_mirrors'];

?><!DOCTYPE html>
<html lang="<?php echo $locale; ?>">
<head>
    <meta charset="utf-8" />
    <title><?php echo $title; ?> | Mageia Downloads</title>
    <meta name="robots" content="noindex,nofollow,nosnippet">
    <link rel="stylesheet" type="text/css" href="/g/style/all.css" >
    <?php include '../../analytics.php'; ?>
    <?php if (!is_null($dl_link)): ?>
    <script>(function () { setTimeout("document.location='<?php echo $dl_link; ?>';", 3000); })();</script>
    <?php endif; ?>
</head>
<body>
    <?php echo $hsnav; ?>
    <div id="doc" class="yui-t7">
        <div id="hd" role="banner"><h1><a id="logo" href="/"><span>Mageia</span></a> <span class="lsep">&nbsp;</span> <span class="subh"><?php echo $_t['page_h1']; ?></span></h1></div>
        <div id="bd" role="main">
            <div class="yui-g"><div class="para">
                <h2><?php echo $_t['page_title']; ?></h2>
                <p><?php
                    echo
                        sprintf($_t['dl_shld_start'], '<em class="tag">' . $p['name'] . '</em>' . ($torrent ? ' (torrent)' : '')),
                        ' ', sprintf($_t['dl_size'], $p['size']),
                        ' ', sprintf($_t['alt_download'], $dl_link, $dl_link);
                ?></p>

                <div class="dlinfo">
                    <p><?php echo $dl2_mirror_alt; ?></p>
                    <?php if (isset($p['md5']) && !$torrent): ?>
                <p><?php echo $_t['signs_check_1']; ?></p>
                <div id="check-signs">
                <pre class="term">
$ md5sum <?php echo basename($product_dl_link), "\n", $p['md5'], "\n"; ?>

$ sha1sum <?php echo basename($product_dl_link), "\n", $p['sha1'], "\n"; ?>
</pre>
                <p><?php echo $_t['signs_check_2']; ?></p>
                </div>
                    <?php endif; ?>
                </div>
                <table class="dlt2 dlinfo" id="other_mirrors" style="display: none;">
                    <thead><tr><th>Country</th><th>City</th><th>Download mirrors</th></tr></thead>
                    <tbody><?php echo $dl_alt_mirrors_table; ?></tbody>
                </table>

                <hr />
        </div></div>
        <div class="yui-g">
            <div class="yui-u first"><div class="para">
                <h2>Thank <em>you</em>!</h2>
                ...
                <hr>
                <h2>Spread the word!</h2>
                <p><?php include 'dl_twitter.php'; echo dl_twitter($locale); ?></p>
                
                <hr>
            </div></div>
            <div class="yui-u"><div class="para">
                <h2>Need some help? Talk to us!</h2>
                <p><?php echo $_t['give_feedback']; ?></p>
                <p><?php echo $_t['report_bug'];  ?></p>
                <hr>
                <h2><?php echo sprintf($_t['wanttohelp?'], '<strong><a href="http://mageia.org/contribute/">', '</a></strong>'); ?></h2>
                <hr>
            </div></div>
        </div>
    </div>
<script>
document.getElementById("other_mirrors_btn").onclick = function () {
    var el = document.getElementById("other_mirrors");
    el.style.display = (el.style.display != 'none' ? 'none' : '' );
};
</script>
</body>
</html>