<?
/*
$Id: mirror.php,v 1.1 2004/06/17 09:30:16 max Exp $
*/
include('include/mirrors.inc.php');
?>
<br />
<p>
	FreeSBIE betrouwt op een netwerk van mirrors om zijn ISO afbeeldingen te verdelen. Indien u sommige bandbreedte
	kan doneren, stuur een e-mail naar <a href="mailto:staff@freesbie.org">staff@FreeSBIE.org</a> en we zullen u
	de nodige informatie bezorgen om een mirror op te starten.<br /><br /> 
</p>

<h2>Hier is een lijst van de actuele mirrors:</h2>
<ul>
<?php
function masort(&$data,$sortby){
    if(is_array($sortby)){
        $sortby = join(",",$sortby);
    }

    uasort($data,create_function('$a,$b','$skeys = split(\',\',\''.$sortby.'\');
        foreach($skeys as $key){
            if(($c = strcasecmp($a[$key],$b[$key])) != 0){
                return($c);
            }
        }
        return($c); '));
}

$len = count($ftpmirror);
for($i = 0; $i < $len; $i++) {
    if($ftpmirror[$i]['realname'])
        $index = $ftpmirror[$i]['realname'];
    else
        $index = $ftpmirror[$i]['name'];
    if(!strlen($mirrors[$index]['realname'])) $mirrors[$index]['realname'] = $ftpmirror[$i]['realname'];
    if(!strlen($mirrors[$index]['ftpname'])) $mirrors[$index]['ftpname'] = $ftpmirror[$i]['name'];
    if(!strlen($mirrors[$index]['ftplink'])) $mirrors[$index]['ftplink'] = $ftpmirror[$i]['link'];
    if(!strlen($mirrors[$index]['admin'])) $mirrors[$index]['admin'] = $ftpmirror[$i]['admin'];
    if(!strlen($mirrors[$index]['comment1'])) $mirrors[$index]['comment1'] = $ftpmirror[$i]['comment1'];
    if(!strlen($mirrors[$index]['comment2'])) $mirrors[$index]['comment2'] = $ftpmirror[$i]['comment2'];
    if(!strlen($mirrors[$index]['location'])) $mirrors[$index]['location'] = $ftpmirror[$i]['location'];
    if(!strlen($mirrors[$index]['country'])) $mirrors[$index]['country'] = $ftpmirror[$i]['country'];
}
$len = count($httpmirror);
for($i = 0; $i < $len; $i++) {
    if($httpmirror[$i]['realname'])
        $index = $httpmirror[$i]['realname'];
    else
        $index = $httpmirror[$i]['name'];
    if(!strlen($mirrors[$index]['realname'])) $mirrors[$index]['realname'] = $httpmirror[$i]['realname'];
    if(!strlen($mirrors[$index]['httpname'])) $mirrors[$index]['httpname'] = $httpmirror[$i]['name'];
    if(!strlen($mirrors[$index]['httplink'])) $mirrors[$index]['httplink'] = $httpmirror[$i]['link'];
    if(!strlen($mirrors[$index]['admin'])) $mirrors[$index]['admin'] = $httpmirror[$i]['admin'];
    if(!strlen($mirrors[$index]['comment1'])) $mirrors[$index]['comment1'] = $httpmirror[$i]['comment1'];
    if(!strlen($mirrors[$index]['comment2'])) $mirrors[$index]['comment2'] = $httpmirror[$i]['comment2'];
    if(!strlen($mirrors[$index]['location'])) $mirrors[$index]['location'] = $httpmirror[$i]['location'];
    if(!strlen($mirrors[$index]['country'])) $mirrors[$index]['country'] = $httpmirror[$i]['country'];
}

$len = count($rsyncmirror);
for($i = 0; $i < $len; $i++) {
    if($rsyncmirror[$i]['realname'])
        $index = $rsyncmirror[$i]['realname'];
    else
        $index = $rsyncmirror[$i]['name'];
    if(!strlen($mirrors[$index]['realname'])) $mirrors[$index]['realname'] = $rsyncmirror[$i]['realname'];
    if(!strlen($mirrors[$index]['rsyncname'])) $mirrors[$index]['rsyncname'] = $rsyncmirror[$i]['name'];
    if(!strlen($mirrors[$index]['rsynclink'])) $mirrors[$index]['rsynclink'] = "rsync://".$rsyncmirror[$i]['name']."/".$rsyncmirror[$i]['path'];
    if(!strlen($mirrors[$index]['admin'])) $mirrors[$index]['admin'] = $rsyncmirror[$i]['admin'];
    if(!strlen($mirrors[$index]['comment1'])) $mirrors[$index]['comment1'] = $rsyncmirror[$i]['comment1'];
    if(!strlen($mirrors[$index]['comment2'])) $mirrors[$index]['comment2'] = $rsyncmirror[$i]['comment2'];
    if(!strlen($mirrors[$index]['location'])) $mirrors[$index]['location'] = $rsyncmirror[$i]['location'];
    if(!strlen($mirrors[$index]['country'])) $mirrors[$index]['country'] = $rsyncmirror[$i]['country'];
}
masort($mirrors,'country,name');

$keys=array_keys($mirrors);
$len=count($keys);
for($i=0;$i<$len;$i++) {
    print "<li>\n";
    print "<h3>".$keys[$i];
    $started=0;
    if(strlen($mirrors[$keys[$i]]['ftpname']) > 0 
       && $mirrors[$keys[$i]]['ftpname'] != $keys[$i]) {
        if(!$started) { print " <small>("; $started=1; }
        else {print ", "; }
        print $mirrors[$keys[$i]]['ftpname'];
    }
    if(strlen($mirrors[$keys[$i]]['httpname']) > 0 
       && $mirrors[$keys[$i]]['httpname'] != $keys[$i]
       && !($mirrors[$keys[$i]]['httpname'] == $mirrors[$keys[$i]]['ftpname'])) {
        if(!$started) { print " <small>("; $started=1; }
        else {print ", "; }
        print $mirrors[$keys[$i]]['httpname'];
    }
    if(strlen($mirrors[$keys[$i]]['rsyncname']) > 0 
       && $mirrors[$keys[$i]]['rsyncname'] != $keys[$i]
       && !($mirrors[$keys[$i]]['rsyncname'] == $mirrors[$keys[$i]]['ftpname'])
       && !($mirrors[$keys[$i]]['rsyncname'] == $mirrors[$keys[$i]]['httpname'])) {
        if(!$started) { print " <small>("; $started=1; }
        else {print ", "; }
        print $mirrors[$keys[$i]]['rsyncname'];
    }
    if($started) print ")</small>";
    print "</h3>\n";
    print "<ul>\n";
    print "<li>";
    if(strlen($mirrors[$keys[$i]]['ftplink']) > 0) print '<a href="'.$mirrors[$keys[$i]]['ftplink'].'">FTP</a> ';
    if(strlen($mirrors[$keys[$i]]['httplink']) > 0) print '<a href="'.$mirrors[$keys[$i]]['httplink'].'">HTTP</a> ';
    if(strlen($mirrors[$keys[$i]]['rsynclink']) > 0) print '<a href="'.$mirrors[$keys[$i]]['rsynclink'].'">Rsync</a> ';
    print "</li>\n";
    if(strlen($mirrors[$keys[$i]]['comment1']) > 0) print "<li>".$mirrors[$keys[$i]]['comment1']."</li>\n";
    if(strlen($mirrors[$keys[$i]]['comment2']) > 0) print "<li>".$mirrors[$keys[$i]]['comment2']."</li>\n";
    if(strlen($mirrors[$keys[$i]]['location']) > 0) print "<li>".$mirrors[$keys[$i]]['location']."</li>\n";
    print "</ul>\n";
    print "</li>\n";
}

?>
</ul>
<br />
