aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--downloads.ini60
-rw-r--r--downloads.php80
-rw-r--r--downloads/index.php27
-rw-r--r--downloads_locales.php85
-rw-r--r--lib/Downloads.php267
-rw-r--r--lib/cached.list.php161
-rw-r--r--lib/maxmind/geoip/GeoIP.datbin0 -> 1151902 bytes
-rw-r--r--lib/maxmind/geoip/geoip.inc.php556
-rw-r--r--mirrors2.php73
9 files changed, 1309 insertions, 0 deletions
diff --git a/downloads.ini b/downloads.ini
new file mode 100644
index 000000000..2fb79bedf
--- /dev/null
+++ b/downloads.ini
@@ -0,0 +1,60 @@
+; Mageia downloads definition file
+
+[_global]
+name = Mageia 1 beta1
+prefix = mageia-1-beta1
+type = iso
+
+[dvd-i586]
+name = 32bit DVD
+size = 4GB
+lang = All supported
+md5 = md5-value
+sha1 = sha1-value
+path = iso/cauldron/mageia-dvd-1-Beta1-i586.iso
+
+[dvd-x86_64]
+name = 64bit DVD
+size = 4GB
+lang = All supported
+md5 = -
+sha1 = -
+path = iso/cauldron/mageia-dvd-1-Beta1-x86_64.iso
+
+;[live-kde-europa-cd-i586]
+;name = Live KDE CD
+;size = 700MB
+;lang = Europa set
+;langs = de|en|es|fr|it|pl|pt|ru
+;md5 =
+;sha1 =
+;path =
+;
+;[live-gnome-europa-cd-i586]
+;name = Live GNOME CD
+;size = 700MB
+;lang = Europa set
+;langs = de|en|es|fr|it|pl|pt|ru
+;md5 =
+;sha1 =
+;path =
+
+[cd-dualarch]
+name = Dual arch CD
+size = 700MB
+lang = All supported
+md5 = ?
+sha1 = ?
+path = iso/cauldron/mageia-dual-1-Beta1.iso
+
+[netboot-i586]
+name = boot.iso 32bit CD
+size = 60MB
+lang = English
+path = distrib/cauldron/i586/install/images/boot.iso
+
+[netboot-x86_64]
+name = boot.iso 64bit CD
+size = 60MB
+lang = English
+path = distrib/cauldron/x86_64/install/images/boot.iso
diff --git a/downloads.php b/downloads.php
new file mode 100644
index 000000000..f577e64e5
--- /dev/null
+++ b/downloads.php
@@ -0,0 +1,80 @@
+<?php
+/**
+*/
+
+$locale = explode('/', $_SERVER['REQUEST_URI']);
+$locale = $locale[1];
+
+include 'downloads_locales.php';
+
+$locale = 'fr';
+
+$_t = $_t[$locale];
+
+$prods = parse_ini_file('downloads.ini', true);
+$countries = array(
+ 'CH' => 'Switzerland',
+ 'CN' => 'China',
+ 'CZ' => 'Czechia',
+ 'DE' => 'Deutschland (Germany)',
+ 'FR' => 'France',
+ 'GR' => 'Greece',
+ 'NC' => 'New Caledonia',
+ 'NL' => 'Nederlands',
+ 'UK' => 'the UK',
+ 'US' => 'the USA',
+);
+
+$tmpl = <<<T
+<tr%s>
+<td class="name">%s</td>
+<td class="lang">%s</td>
+<td class="size">%s</td>
+<td class="link"><a href="%s" rel="nofollow">%s</a></td>
+
+</tr>
+T;
+//<td class="pop"><span class="pop_%s">%s</span></td>
+//<td class="link"><a href="%s" rel="nofollow">%s</a></td>
+
+$s = '';
+$glob = array_shift($prods);
+$i = 0;
+foreach ($prods as $k => $p) {
+
+ $iso = sprintf('%s-%s', $glob['prefix'], $k);
+
+ $dl_link = sprintf('/en/downloads/dl.php?product=%s', $iso);
+ $bt_link = sprintf('/en/downloads/dl.php?product=%s&torrent=1', $iso);
+ $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']);
+
+ $i++;
+}
+
+$dl_table = <<<T
+<table class="dlt2">
+ <thead>
+ <tr>
+ <th>{$_t['flavour']}</th>
+ <th>{$_t['language']}</th>
+ <th class="size">{$_t['size']}</th>
+ <th>{$_t['link']}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {$s}
+ </tbody>
+</table>
+<p class="dlinfo">All supported languages are: Deutsch, English, español, français, italiano, português.</p>
+<p class="dlinfo">Europa set of languages is: Deutsch, English, español, français, italiano, português.
+ More languages will be made available for the stable release.</p>
+T;
+
+
+
diff --git a/downloads/index.php b/downloads/index.php
new file mode 100644
index 000000000..1862360bf
--- /dev/null
+++ b/downloads/index.php
@@ -0,0 +1,27 @@
+<?php
+
+require_once '../langs.inc.php';
+
+$langs = array(
+// 'de' => 'Deutsch',
+// 'el' => 'Ελληνικά',
+ 'en' => 'English',
+// 'es' => 'Español',
+// 'et' => 'Eesti',
+// 'fi' => 'Suomeksi',
+// 'fr' => 'Français',
+// 'it' => 'Italiano',
+// 'lv' => 'Latviešu',
+// 'nb' => 'Bokmål',
+// 'nl' => 'Nederlands',
+// 'pl' => 'Polski',
+// 'pt' => 'Português',
+// 'ro' => 'Română',
+// 'ru' => 'Русский',
+// 'tr' => 'Türkçe',
+// 'sl' => 'Slovenščina',
+// 'zh-cn' => '简体中文',
+// 'zh-tw' => '正體中文'
+);
+
+relocate($langs, 'downloads/'); \ No newline at end of file
diff --git a/downloads_locales.php b/downloads_locales.php
new file mode 100644
index 000000000..723bea692
--- /dev/null
+++ b/downloads_locales.php
@@ -0,0 +1,85 @@
+<?php
+
+$_t = array(
+ 'en' => array(
+ 'download' => 'download',
+ 'page_title' => 'Download Mageia 1 beta1',
+ 'page_desc' => 'Where you can download Mageia installable and live ISO images.',
+ 'page_kw' => 'mageia, software, download, operating system, ISO, computer, torrent, ftp',
+ 'page_h1' => 'Download Mageia 1 <em class="tag">beta1</em>',
+ 'warn_1' => 'Be Careful!
+ This is NOT FOR: use, public review, personal or production evaluation.
+ This is FOR: developers and packagers testing.',
+ 'warn_2' => 'Whatever you may do with the provided ISO disc image
+ will be done at your own risk, with your own responsibility.',
+ 'title_ok' => 'You still want to download and test Mageia 1 beta1?',
+ 'dl_help' => 'Just pick the ISO image that is best for you; if you are not sure, you should pick among the first ones.',
+ 'changes_since_a2' => 'Changes since Alpha 2',
+ 'release_docs' => 'Release Documents',
+ 'whatismageia' => 'What is Mageia?',
+ 'size' => 'Size',
+ 'flavour' => 'Flavour',
+ 'language' => 'Language',
+ 'link' => 'Direct link',
+ 'dl_shld_start' => 'Your download of %s should start within a few seconds',
+ 'dl_size' => '(download size is about %s).',
+ 'alt_download' => 'If the download does not start, <a href="%s" rel="nofollow" title="%s">click here</a>.',
+ 'signs_check_1' => 'As soon as your download is complete, you should check that the signatures match:',
+ 'signs_check_2' => 'If signatures do not match, do not use this ISO. Double-check and try to download again.',
+ 'dl_mirror_loc' => 'This <a href="%s">%s</a> download mirror is located in %s (%s).',
+ 'dl_alt_mirrors' => 'If it does not work well for you, <a href="#om" id="other_mirrors_btn">check out these other mirrors</a>.',
+ 'whatdouthink?' => 'What do you think of it?',
+ 'give_feedback' => 'You are very welcome to give your impressions on Mageia 1 beta1, wherever you want:
+ on <a href="http://forums.mageia.org/">our forums</a>,
+ <a href="http://blog.mageia.org/">our blog</a>, on <em>your</em> blog,
+ on Twitter (<a href="http://twitter.com/mageia_org">@mageia_org</a>).
+ In any case, please link to <a href="http://mageia.org/">mageia.org</a>.',
+ 'report_bug' => 'If you encounter a bug, please <a href="">see how to report it</a>
+ in our bugs database so we can sort it out the best possible way.',
+ 'notify_web' => 'If you notice a problem with the download process/pages, please notify the Web team on
+<a href="irc://irc.freenode.net/#mageia-web">#mageia-web</a> Freenode IRC channel so we can sort it out as fast as possible.
+Note that translations are on their way.',
+ 'wanttohelp?' => 'Want to help? %sJoin Us!%s',
+ 'ucanhelp' => 'Yes you can! Mageia is the result of the will and collaboration of many happy fellow volunteers across the world.'
+ ),
+ 'fr' => array(
+ 'download' => 'télécharger',
+ 'page_title' => 'Télécharger Mageia 1 beta1',
+ 'page_desc' => 'Where you can download Mageia installable and live ISO images.',
+ 'page_kw' => 'mageia, software, download, télécharger, système, ordinateur, ISO, torrent, ftp',
+ 'page_h1' => 'Télécharger Mageia 1 <em class="tag">beta1</em>',
+ 'warn_1' => 'Attention&nbsp;!
+ Ce logiciel n’est PAS prévu pour un usage quotidien, une évaluation publique ou un environnement de production.
+ Ce logiciel est prévu pour des TESTS, par des développeurs ou empaqueteurs.',
+ 'warn_2' => 'Quelque soit l’usage que vous ferez des images ISO mises à votre disposition, cela sera fait en votre pleine conscience des risques encourus, avec vos propres responsabilités.',
+ 'title_ok' => 'Vous voulez toujours télécharger et tester Mageia 1 beta1?',
+ 'dl_help' => 'Choisissez l&rsquo;image qui vous convient&nbsp;; si vous n&rsquo;êtes pas sûr, prenez-en une parmi les premières.',
+ 'changes_since_a2' => 'Changes since Alpha 2',
+ 'release_docs' => 'Documents',
+ 'whatismageia' => 'Qu&rsquo;est-ce que Mageia&nbsp;?',
+ 'size' => 'Taille',
+ 'flavour' => 'Variante',
+ 'language' => 'Langue',
+ 'link' => 'Lien',
+ 'dl_shld_start' => 'Le téléchargement de %s va démarrer dans quelques secondes',
+ 'dl_size' => '(taille d&rsquo;environ %s).',
+ 'alt_download' => 'Si le téléchargement ne démarre pas, <a href="%s" rel="nofollow" title="%s">cliquez ici</a>.',
+ 'signs_check_1' => 'Dès que votre ISO est téléchargée, vous pouvez érifier que les signatures correspondent bien&nbsp;:',
+ 'signs_check_2' => 'Si elles ne correspondent pas, l&rsquo;image n&rsquo;est pas bonne.',
+ 'dl_mirror_loc' => 'Le mirroir de téléchargement <a href="%s">%s</a> est en %s (%s).',
+ 'dl_alt_mirrors' => 'S&rsquo;il ne fonctionne pas bien, vous pouvez aussi <a href="#om" id="other_mirrors_btn">essayer un autre miroir</a>.',
+ 'whatdouthink?' => 'Qu&rsquo;en pensez-vous&nbsp;?',
+ 'give_feedback' => 'Dites-nous vos impressions sur cette beta1, où vous voulez&nbsp;:
+ sur les <a href="http://forums.mageia.org/" hreflang="en">forums</a>,
+ sur <a href="http://blog.mageia.org/fr/">notre blog</a>, sur <em>votre</em> blog,
+ sur Twitter (<a href="http://twitter.com/mageia_org">@mageia_org</a>).
+ Dans tous les cas, n&rsquo;oubliez pas de pointer vers <a href="http://mageia.org/">mageia.org</a>.',
+ 'report_bug' => 'Si vous remarquez un bug, merci de <a href="">nous en informer</a> afin que nous puissions le corriger.',
+ 'notify_web' => 'Si vous rencontrez un problème pour télécharger cette beta,
+ merci d&rsquo;en informer l&rsquo;équipe Web sur le canal IRC Freenode
+ <a href="irc://irc.freenode.net/#mageia-web">#mageia-web</a>.',
+ 'wanttohelp?' => 'Vous voulez %sparticiper%s&nbsp;?',
+ 'ucanhelp' => 'Vous le pouvez&nbsp;! Mageia est le résultat des volontés et travaux de nombreux joyeux contributeurs à travers le monde.'
+
+ )
+); \ No newline at end of file
diff --git a/lib/Downloads.php b/lib/Downloads.php
new file mode 100644
index 000000000..eca318db4
--- /dev/null
+++ b/lib/Downloads.php
@@ -0,0 +1,267 @@
+<?php
+/**
+ * Class regrouping basic methods for download page.
+ *
+ * @copyright 2009-2011 Romain d'Alverny <rda>
+ * @license GPL-3+
+ *
+*/
+class Downloads
+{
+ /**
+ * @param string $country matches the URI base dir
+ * @param string $locale
+ */
+ function __construct($locale = 'en', $cache = null)
+ {
+ $this->_locale = $locale;
+ }
+ /**
+ * @param string $ua
+ *
+ * @return array
+ */
+ public static function get_platform($ua = null)
+ {
+ if ($ua == '')
+ return array(
+ 'arch' => 'i586',
+ 'system' => 'unknow',
+ 'locale' => 'en',
+ 'browser' => null
+ );
+
+ $locale = null;
+ if (preg_match_all('/([.^\(^\)]*) \((.*)\) (.*)/', $ua, $r))
+ {
+ $r = $r[2][0];
+ $r = explode(';', $r);
+ $r = explode(')', trim($r[3]));
+ if (strlen($r[0]) > 5)
+ $r = substr($r[0], 0, 5);
+ else
+ $r = $r[0];
+ $locale = $r;
+ }
+
+ $arch = 'i586';
+ if (strpos($ua, 'x86_64') !== false)
+ $arch = 'x86_64';
+
+ $sys = null;
+ if (strpos($ua, 'Windows') !== false)
+ $sys = 'win';
+ elseif (strpos($ua, 'Macintosh') !== false
+ || strpos($ua, 'Mac OS X') !== false)
+ $sys = 'mac';
+ elseif (strpos($ua, 'Linux') !== false)
+ $sys = 'linux';
+
+ $browser = null;
+ if (strpos($ua, 'Firefox') !== false)
+ $browser = 'firefox';
+ elseif (strpos($ua, 'MSIE') !== false)
+ $browser = 'msie';
+ elseif (strpos($ua, 'Safari') !== false)
+ $browser = 'safari';
+ elseif (strpos($ua, 'Opera') !== false)
+ $browser = 'opera';
+
+ return array(
+ 'arch' => $arch,
+ 'system' => $sys,
+ 'locale' => $locale,
+ 'browser' => $browser
+ );
+ }
+
+ /**
+ */
+ public static function get_all_mirrors()
+ {
+ $prod = true;
+ $cache_file = '../../lib/cached.list.php';
+
+ if ($prod) {
+ require $cache_file;
+ return $mirrors;
+ }
+
+ // @todo cache this!
+ $data = file('http://mirrors.mageia.org/api/foo.Cauldron.i586.list');
+ $mirrors3 = array();
+ foreach ($data as $line) {
+ $line = explode(',', trim($line));
+ foreach ($line as $val) {
+ $val = explode('=', trim($val));
+ $m[$val[0]] = $val[1];
+ }
+ $pu = parse_url($m['url']);
+ if (in_array($pu['scheme'], array('http', 'https', 'ftp')))
+ $mirrors3[$m['country']][] = array(
+ 'city' => $m['city'],
+ 'zone' => $m['zone'],
+ 'url' => str_replace('/distrib/cauldron/i586', '', $m['url'])
+ );
+ }
+
+ /*
+ file_put_contents($cache_file,
+ sprintf('<?php $mirrors = %s; ?>',
+ var_export($mirrors3, true)));
+ //*/
+
+ return $mirrors3;
+ }
+
+ /**
+ */
+ function get_mirror($country)
+ {
+ $mirs = self::get_all_mirrors();
+
+ if (array_key_exists($country, $mirs))
+ {
+ $mirs = $mirs[$country];
+ shuffle($mirs);
+ return array_shift($mirs);
+ }
+ else
+ {
+ shuffle($mirs);
+ $mirs = array_shift($mirs);
+ shuffle($mirs);
+ return array_shift($mirs);
+ }
+ }
+
+ /**
+ * Queries a GeoIP db for $ip to get the country.
+ *
+ * @param string $ip
+ *
+ * @return string
+ *
+ * If fail, use $country as a fallback to return.
+ * @see http://www.maxmind.com/app/php & http://www.maxmind.com/app/geoip_country
+ * It has limitations too & needs to be updated from time to time.
+ *
+ * @todo make a separate class for this.
+ * @todo unit tests for this!
+ */
+ function get_country($ip)
+ {
+ error_log(sprintf('in get_country with %s.', $ip));
+
+ if ($ip == '127.0.0.1' || $ip == '::1')
+ return null;
+
+ require_once '../../lib/maxmind/geoip/geoip.inc.php';
+ $gi = geoip_open(realpath('../../lib/maxmind/geoip/GeoIP.dat'),
+ GEOIP_STANDARD);
+ $loc = geoip_country_code_by_addr($gi, $ip);
+ geoip_close($gi);
+
+ if (trim($loc) == '' || is_null($loc))
+ return null;
+
+ error_log(sprintf('in get_country: %s', $loc));
+
+ return strtoupper($loc);
+ }
+
+ /**
+ * Setup session data about current visitor for downloads.
+ *
+ * @param string $version
+ * @param boolean $force
+ *
+ * @return array
+ */
+ function prepare_download($version, $force = false)
+ {
+ $fuzzy_mirror = false;
+
+ if (isset($_GET['country']))
+ {
+ $country = $_GET['country'];
+ $force = true;
+ }
+
+ if (!$force && isset($_SESSION['dl-data']))
+ {
+ error_log(sprintf('Got session data: %s', print_r($_SESSION['dl-data'], true)));
+ $system = $_SESSION['dl-data']['system'];
+ if (isset($_GET['mirror']))
+ {
+ $mirror = array('url' => $_GET['mirror']);
+ $mirror['purl'] = parse_url($mirror['url']);
+ $_SESSION['dl-data']['mirror'] = $mirror;
+ $country = '';
+ }
+ else
+ {
+ $country = $_SESSION['dl-data']['country'];
+ $mirror = $_SESSION['dl-data']['mirror'];
+ }
+ }
+ else
+ {
+ error_log('getting platform');
+ $system = self::get_platform($_SERVER['HTTP_USER_AGENT']);
+ if (isset($_GET['mirror']))
+ {
+ $mirror = array('url' => $_GET['mirror']);
+ $mirror['purl'] = parse_url($mirror['url']);
+ $country = '';
+ }
+ else
+ {
+ error_log('no mirror set yet');
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])
+ && $str = $_SERVER['HTTP_X_FORWARDED_FOR'])
+ {
+ $arr = explode(', ', $str);
+ $ip = $arr[0];
+ }
+ else
+ $ip = $_SERVER['REMOTE_ADDR'];
+
+ $_SESSION['ip'] = $ip;
+ if (isset($_GET['country']))
+ $country = $_GET['country'];
+ else
+ $country = self::get_country($ip);
+
+ $mirror = $this->get_mirror($country);
+ $fuzzy_mirror = is_null($country) ? true : false;
+
+ $mirror['purl'] = parse_url($mirror['url']);
+
+ // reassign country, as get_one_mirror() may have decided
+ // to return a mirror from another country than the one
+ // requested initially - @see get_one_mirror()
+ $country = $mirror['zone'];
+
+ if (is_null($mirror)) {
+ // @todo?
+ }
+ }
+ $_SESSION['dl-data'] = array(
+ 'system' => $system,
+ 'country' => $country,
+ 'mirror' => $mirror
+ );
+ //echo "<pre>Got NEW session data:", print_r($_SESSION['dl-data'], true), '</pre>';
+ }
+ //
+ return array(
+ 'arch' => $system['arch'],
+ 'mirror_host' => $mirror['purl']['host'],
+ 'mirror_scheme' => $mirror['purl']['scheme'],
+ 'mirror_url' => $mirror['url'],
+ 'country' => $country,
+ 'fuzzy_mirror' => $fuzzy_mirror
+ );
+ }
+} \ No newline at end of file
diff --git a/lib/cached.list.php b/lib/cached.list.php
new file mode 100644
index 000000000..945fc7128
--- /dev/null
+++ b/lib/cached.list.php
@@ -0,0 +1,161 @@
+<?php $mirrors = array (
+ 'FR' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Paris',
+ 'zone' => 'FR',
+ 'url' => 'https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Paris',
+ 'zone' => 'FR',
+ 'url' => 'http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia',
+ ),
+ 2 =>
+ array (
+ 'city' => 'Paris',
+ 'zone' => 'FR',
+ 'url' => 'ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia',
+ ),
+ ),
+ 'CH' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'geneva',
+ 'zone' => 'CH',
+ 'url' => 'http://mageia.unige.ch/mirror',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Lucern',
+ 'zone' => 'CH',
+ 'url' => 'ftp://ftp.LinuxCabal.org/pub/mirrors/Mageia',
+ ),
+ ),
+ 'DE' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Erlangen',
+ 'zone' => 'DE',
+ 'url' => 'ftp://ftp.uni-erlangen.de/mirrors/Mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Esslingen',
+ 'zone' => 'DE',
+ 'url' => 'http://ftp-stud.hs-esslingen.de/pub/Mirrors/Mageia',
+ ),
+ 2 =>
+ array (
+ 'city' => 'Erfurt',
+ 'zone' => 'DE',
+ 'url' => 'http://ftp.mandrivauser.de/mirrors/Mageia',
+ ),
+ 3 =>
+ array (
+ 'city' => 'Erlangen',
+ 'zone' => 'DE',
+ 'url' => 'http://ftp.uni-erlangen.de/mirrors/Mageia',
+ ),
+ 4 =>
+ array (
+ 'city' => 'Erfurt',
+ 'zone' => 'DE',
+ 'url' => 'ftp://ftp.mandrivauser.de/mirrors/Mageia',
+ ),
+ 5 =>
+ array (
+ 'city' => 'Esslingen',
+ 'zone' => 'DE',
+ 'url' => 'ftp://ftp-stud.hs-esslingen.de/pub/Mirrors/Mageia',
+ ),
+ ),
+ 'CZ' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Paris',
+ 'zone' => 'CZ',
+ 'url' => 'ftp://ftp.sh.cvut.cz/MIRRORS/mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Erlangen',
+ 'zone' => 'CZ',
+ 'url' => 'http://ftp.sh.cvut.cz/MIRRORS/mageia',
+ ),
+ 2 =>
+ array (
+ 'city' => 'Durham',
+ 'zone' => 'CZ',
+ 'url' => 'http://mageia.supp.name',
+ ),
+ ),
+ 'NL' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Amsterdam',
+ 'zone' => 'NL',
+ 'url' => 'http://ftp.nluug.nl/pub/os/Linux/distr/mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Amsterdam',
+ 'zone' => 'NL',
+ 'url' => 'ftp://ftp.nluug.nl/pub/os/Linux/distr/mageia',
+ ),
+ ),
+ 'GR' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Heraklion',
+ 'zone' => 'GR',
+ 'url' => 'ftp://ftp.cc.uoc.gr/mirrors/linux/mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Heraklion',
+ 'zone' => 'GR',
+ 'url' => 'http://ftp.cc.uoc.gr/mirrors/linux/mageia',
+ ),
+ ),
+ 'US' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Durham',
+ 'zone' => 'US',
+ 'url' => 'http://distro.ibiblio.org/pub/linux/distributions/mageia',
+ ),
+ 1 =>
+ array (
+ 'city' => 'Durham',
+ 'zone' => 'US',
+ 'url' => 'ftp://distro.ibiblio.org/pub/linux/distributions/mageia',
+ ),
+ ),
+ 'CN' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Beijing',
+ 'zone' => 'CN',
+ 'url' => 'http://fundawang.lcuc.org.cn/mageia',
+ ),
+ ),
+ 'NC' =>
+ array (
+ 0 =>
+ array (
+ 'city' => 'Nouméa',
+ 'zone' => 'NC',
+ 'url' => 'http://mageia.nautile.nc/mageia',
+ ),
+ ),
+); ?> \ No newline at end of file
diff --git a/lib/maxmind/geoip/GeoIP.dat b/lib/maxmind/geoip/GeoIP.dat
new file mode 100644
index 000000000..46ee3d806
--- /dev/null
+++ b/lib/maxmind/geoip/GeoIP.dat
Binary files differ
diff --git a/lib/maxmind/geoip/geoip.inc.php b/lib/maxmind/geoip/geoip.inc.php
new file mode 100644
index 000000000..e7de83947
--- /dev/null
+++ b/lib/maxmind/geoip/geoip.inc.php
@@ -0,0 +1,556 @@
+<?php
+
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* geoip.inc
+ *
+ * Copyright (C) 2007 MaxMind LLC
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+define("GEOIP_COUNTRY_BEGIN", 16776960);
+define("GEOIP_STATE_BEGIN_REV0", 16700000);
+define("GEOIP_STATE_BEGIN_REV1", 16000000);
+define("GEOIP_STANDARD", 0);
+define("GEOIP_MEMORY_CACHE", 1);
+define("GEOIP_SHARED_MEMORY", 2);
+define("STRUCTURE_INFO_MAX_SIZE", 20);
+define("DATABASE_INFO_MAX_SIZE", 100);
+define("GEOIP_COUNTRY_EDITION", 106);
+define("GEOIP_PROXY_EDITION", 8);
+define("GEOIP_ASNUM_EDITION", 9);
+define("GEOIP_NETSPEED_EDITION", 10);
+define("GEOIP_REGION_EDITION_REV0", 112);
+define("GEOIP_REGION_EDITION_REV1", 3);
+define("GEOIP_CITY_EDITION_REV0", 111);
+define("GEOIP_CITY_EDITION_REV1", 2);
+define("GEOIP_ORG_EDITION", 110);
+define("GEOIP_ISP_EDITION", 4);
+define("SEGMENT_RECORD_LENGTH", 3);
+define("STANDARD_RECORD_LENGTH", 3);
+define("ORG_RECORD_LENGTH", 4);
+define("MAX_RECORD_LENGTH", 4);
+define("MAX_ORG_RECORD_LENGTH", 300);
+define("GEOIP_SHM_KEY", 0x4f415401);
+define("US_OFFSET", 1);
+define("CANADA_OFFSET", 677);
+define("WORLD_OFFSET", 1353);
+define("FIPS_RANGE", 360);
+define("GEOIP_UNKNOWN_SPEED", 0);
+define("GEOIP_DIALUP_SPEED", 1);
+define("GEOIP_CABLEDSL_SPEED", 2);
+define("GEOIP_CORPORATE_SPEED", 3);
+define("GEOIP_DOMAIN_EDITION", 11);
+define("GEOIP_LOCATIONA_EDITION", 13);
+define("GEOIP_ACCURACYRADIUS_EDITION", 14);
+define("GEOIP_CITYCOMBINED_EDITION", 15);
+define("CITYCOMBINED_FIXED_RECORD", 7 );
+
+class GeoIP {
+ var $flags;
+ var $filehandle;
+ var $memory_buffer;
+ var $databaseType;
+ var $databaseSegments;
+ var $record_length;
+ var $shmid;
+ var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
+"" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
+"AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "AN" => 10, "AO" => 11,
+"AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
+"AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
+"BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
+"BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
+"BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
+"CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
+"CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
+"CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
+"DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
+"ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
+"FM" => 72, "FO" => 73, "FR" => 74, "FX" => 75, "GA" => 76, "GB" => 77,
+"GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
+"GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
+"GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
+"HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
+"IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
+"IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
+"KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
+"KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
+"LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
+"LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
+"MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
+"MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
+"MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
+"NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
+"NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
+"PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
+"PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
+"PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
+"RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
+"SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
+"SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
+"SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
+"TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
+"TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
+"UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
+"VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
+"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
+"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
+"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
+"MF" => 252
+);
+ var $GEOIP_COUNTRY_CODES = array(
+"", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ",
+"AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH",
+"BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA",
+"CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU",
+"CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG",
+"EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB",
+"GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT",
+"GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN",
+"IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM",
+"KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS",
+"LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN",
+"MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
+"NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA",
+"PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY",
+"QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI",
+"SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD",
+"TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
+"TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN",
+"VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1",
+"AX", "GG", "IM", "JE", "BL", "MF"
+);
+ var $GEOIP_COUNTRY_CODES3 = array(
+"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","ATA","ARG",
+"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
+"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK",
+"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
+"CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
+"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
+"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM","GUM",
+"GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IOT",
+"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
+"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
+"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
+"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
+"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
+"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
+"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
+"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF",
+"TGO","THA","TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN","TZA",
+"UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
+"WLF","WSM","YEM","MYT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1",
+"ALA","GGY","IMN","JEY","BLM","MAF"
+ );
+ var $GEOIP_COUNTRY_NAMES = array(
+"", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
+"Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
+"Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa",
+"Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina",
+"Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain",
+"Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil",
+"Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize",
+"Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the",
+"Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands",
+"Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde",
+"Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
+"Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
+"Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
+"Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands",
+"France", "France, Metropolitan", "Gabon", "United Kingdom",
+"Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland",
+"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands",
+"Guatemala", "Guam", "Guinea-Bissau",
+"Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras",
+"Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India",
+"British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of",
+"Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan",
+"Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of",
+"Korea, Republic of", "Kuwait", "Cayman Islands",
+"Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
+"Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
+"Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of",
+"Madagascar", "Marshall Islands", "Macedonia",
+"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
+"Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives",
+"Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia",
+"Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway",
+"Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia",
+"Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon",
+"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
+"Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania",
+"Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands",
+"Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia",
+"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal",
+"Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic",
+"Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories",
+"Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
+"Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu",
+"Taiwan", "Tanzania, United Republic of", "Ukraine",
+"Uganda", "United States Minor Outlying Islands", "United States", "Uruguay",
+"Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
+"Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
+"Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
+"Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe",
+"Anonymous Proxy","Satellite Provider","Other",
+"Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"
+);
+
+ var $GEOIP_CONTINENT_CODES = array(
+ "--", "AS", "EU", "EU", "AS", "AS", "NA", "NA", "EU", "AS",
+ "NA", "AF", "AN", "SA", "OC", "EU", "OC", "NA", "AS", "EU",
+ "NA", "AS", "EU", "AF", "EU", "AS", "AF", "AF", "NA", "AS",
+ "SA", "SA", "NA", "AS", "AN", "AF", "EU", "NA", "NA", "AS",
+ "AF", "AF", "AF", "EU", "AF", "OC", "SA", "AF", "AS", "SA",
+ "NA", "NA", "AF", "AS", "AS", "EU", "EU", "AF", "EU", "NA",
+ "NA", "AF", "SA", "EU", "AF", "AF", "AF", "EU", "AF", "EU",
+ "OC", "SA", "OC", "EU", "EU", "EU", "AF", "EU", "NA", "AS",
+ "SA", "AF", "EU", "NA", "AF", "AF", "NA", "AF", "EU", "AN",
+ "NA", "OC", "AF", "SA", "AS", "AN", "NA", "EU", "NA", "EU",
+ "AS", "EU", "AS", "AS", "AS", "AS", "AS", "EU", "EU", "NA",
+ "AS", "AS", "AF", "AS", "AS", "OC", "AF", "NA", "AS", "AS",
+ "AS", "NA", "AS", "AS", "AS", "NA", "EU", "AS", "AF", "AF",
+ "EU", "EU", "EU", "AF", "AF", "EU", "EU", "AF", "OC", "EU",
+ "AF", "AS", "AS", "AS", "OC", "NA", "AF", "NA", "EU", "AF",
+ "AS", "AF", "NA", "AS", "AF", "AF", "OC", "AF", "OC", "AF",
+ "NA", "EU", "EU", "AS", "OC", "OC", "OC", "AS", "NA", "SA",
+ "OC", "OC", "AS", "AS", "EU", "NA", "OC", "NA", "AS", "EU",
+ "OC", "SA", "AS", "AF", "EU", "EU", "AF", "AS", "OC", "AF",
+ "AF", "EU", "AS", "AF", "EU", "EU", "EU", "AF", "EU", "AF",
+ "AF", "SA", "AF", "NA", "AS", "AF", "NA", "AF", "AN", "AF",
+ "AS", "AS", "OC", "AS", "AF", "OC", "AS", "EU", "NA", "OC",
+ "AS", "AF", "EU", "AF", "OC", "NA", "SA", "AS", "EU", "NA",
+ "SA", "NA", "NA", "AS", "OC", "OC", "OC", "AS", "AF", "EU",
+ "AF", "AF", "EU", "AF", "--", "--", "--", "EU", "EU", "EU",
+ "EU", "NA", "NA"
+);
+
+}
+function geoip_load_shared_mem ($file) {
+
+ $fp = fopen($file, "rb");
+ if (!$fp) {
+ print "error opening $file: $php_errormsg\n";
+ exit;
+ }
+ $s_array = fstat($fp);
+ $size = $s_array['size'];
+ if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
+ shmop_delete ($shmid);
+ shmop_close ($shmid);
+ }
+ $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
+ shmop_write ($shmid, fread($fp, $size), 0);
+ shmop_close ($shmid);
+}
+
+function _setup_segments($gi){
+ $gi->databaseType = GEOIP_COUNTRY_EDITION;
+ $gi->record_length = STANDARD_RECORD_LENGTH;
+ if ($gi->flags & GEOIP_SHARED_MEMORY) {
+ $offset = @shmop_size ($gi->shmid) - 3;
+ for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
+ $delim = @shmop_read ($gi->shmid, $offset, 3);
+ $offset += 3;
+ if ($delim == (chr(255).chr(255).chr(255))) {
+ $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
+ $offset++;
+
+ if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
+ $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
+ } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
+ $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
+ } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
+ ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
+ || ($gi->databaseType == GEOIP_ORG_EDITION)
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
+ || ($gi->databaseType == GEOIP_ISP_EDITION)
+ || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
+ || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
+ $gi->databaseSegments = 0;
+ $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
+ for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
+ $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
+ }
+ if (($gi->databaseType == GEOIP_ORG_EDITION)
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
+ || ($gi->databaseType == GEOIP_ISP_EDITION)) {
+ $gi->record_length = ORG_RECORD_LENGTH;
+ }
+ }
+ break;
+ } else {
+ $offset -= 4;
+ }
+ }
+ if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
+ ($gi->databaseType == GEOIP_PROXY_EDITION)||
+ ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
+ $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
+ }
+ } else {
+ $filepos = ftell($gi->filehandle);
+ fseek($gi->filehandle, -3, SEEK_END);
+ for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
+ $delim = fread($gi->filehandle,3);
+ if ($delim == (chr(255).chr(255).chr(255))){
+ $gi->databaseType = ord(fread($gi->filehandle,1));
+ if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
+ $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
+ }
+ else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
+ $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
+ } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
+ || ($gi->databaseType == GEOIP_ORG_EDITION)
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
+ || ($gi->databaseType == GEOIP_ISP_EDITION)
+ || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
+ || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
+ $gi->databaseSegments = 0;
+ $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
+ for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
+ $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
+ }
+ if ( ( $gi->databaseType == GEOIP_ORG_EDITION )
+ || ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
+ || ( $gi->databaseType == GEOIP_ISP_EDITION ) ) {
+ $gi->record_length = ORG_RECORD_LENGTH;
+ }
+ }
+ break;
+ } else {
+ fseek($gi->filehandle, -4, SEEK_CUR);
+ }
+ }
+ if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
+ ($gi->databaseType == GEOIP_PROXY_EDITION)||
+ ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
+ $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
+ }
+ fseek($gi->filehandle,$filepos,SEEK_SET);
+ }
+ return $gi;
+}
+
+function geoip_open($filename, $flags) {
+ $gi = new GeoIP;
+ $gi->flags = $flags;
+ if ($gi->flags & GEOIP_SHARED_MEMORY) {
+ $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
+ } else {
+ $gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
+ if ($gi->flags & GEOIP_MEMORY_CACHE) {
+ $s_array = fstat($gi->filehandle);
+ $gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
+ }
+ }
+
+ $gi = _setup_segments($gi);
+ return $gi;
+}
+
+function geoip_close($gi) {
+ if ($gi->flags & GEOIP_SHARED_MEMORY) {
+ return true;
+ }
+
+ return fclose($gi->filehandle);
+}
+
+function geoip_country_id_by_name($gi, $name) {
+ $addr = gethostbyname($name);
+ if (!$addr || $addr == $name) {
+ return false;
+ }
+ return geoip_country_id_by_addr($gi, $addr);
+}
+
+function geoip_country_code_by_name($gi, $name) {
+ $country_id = geoip_country_id_by_name($gi,$name);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_CODES[$country_id];
+ }
+ return false;
+}
+
+function geoip_country_name_by_name($gi, $name) {
+ $country_id = geoip_country_id_by_name($gi,$name);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_NAMES[$country_id];
+ }
+ return false;
+}
+
+function geoip_country_id_by_addr($gi, $addr) {
+ $ipnum = ip2long($addr);
+ return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
+}
+
+function geoip_country_code_by_addr($gi, $addr) {
+ if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
+ $record = geoip_record_by_addr($gi,$addr);
+ if ( $record !== false ) {
+ return $record->country_code;
+ }
+ } else {
+ $country_id = geoip_country_id_by_addr($gi,$addr);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_CODES[$country_id];
+ }
+ }
+ return false;
+}
+
+function geoip_country_name_by_addr($gi, $addr) {
+ if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
+ $record = geoip_record_by_addr($gi,$addr);
+ return $record->country_name;
+ } else {
+ $country_id = geoip_country_id_by_addr($gi,$addr);
+ if ($country_id !== false) {
+ return $gi->GEOIP_COUNTRY_NAMES[$country_id];
+ }
+ }
+ return false;
+}
+
+function _geoip_seek_country($gi, $ipnum) {
+ $offset = 0;
+ for ($depth = 31; $depth >= 0; --$depth) {
+ if ($gi->flags & GEOIP_MEMORY_CACHE) {
+ // workaround php's broken substr, strpos, etc handling with
+ // mbstring.func_overload and mbstring.internal_encoding
+ $enc = mb_internal_encoding();
+ mb_internal_encoding('ISO-8859-1');
+
+ $buf = substr($gi->memory_buffer,
+ 2 * $gi->record_length * $offset,
+ 2 * $gi->record_length);
+
+ mb_internal_encoding($enc);
+ } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
+ $buf = @shmop_read ($gi->shmid,
+ 2 * $gi->record_length * $offset,
+ 2 * $gi->record_length );
+ } else {
+ fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
+ or die("fseek failed");
+ $buf = fread($gi->filehandle, 2 * $gi->record_length);
+ }
+ $x = array(0,0);
+ for ($i = 0; $i < 2; ++$i) {
+ for ($j = 0; $j < $gi->record_length; ++$j) {
+ $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
+ }
+ }
+ if ($ipnum & (1 << $depth)) {
+ if ($x[1] >= $gi->databaseSegments) {
+ return $x[1];
+ }
+ $offset = $x[1];
+ } else {
+ if ($x[0] >= $gi->databaseSegments) {
+ return $x[0];
+ }
+ $offset = $x[0];
+ }
+ }
+ trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
+ return false;
+}
+
+function _get_org($gi,$ipnum){
+ $seek_org = _geoip_seek_country($gi,$ipnum);
+ if ($seek_org == $gi->databaseSegments) {
+ return NULL;
+ }
+ $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
+ if ($gi->flags & GEOIP_SHARED_MEMORY) {
+ $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
+ } else {
+ fseek($gi->filehandle, $record_pointer, SEEK_SET);
+ $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
+ }
+ // workaround php's broken substr, strpos, etc handling with
+ // mbstring.func_overload and mbstring.internal_encoding
+ $enc = mb_internal_encoding();
+ mb_internal_encoding('ISO-8859-1');
+ $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
+ mb_internal_encoding($enc);
+ return $org_buf;
+}
+
+function geoip_org_by_addr ($gi,$addr) {
+ if ($addr == NULL) {
+ return 0;
+ }
+ $ipnum = ip2long($addr);
+ return _get_org($gi, $ipnum);
+}
+
+function _get_region($gi,$ipnum){
+ if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
+ $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
+ if ($seek_region >= 1000){
+ $country_code = "US";
+ $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
+ } else {
+ $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
+ $region = "";
+ }
+ return array ($country_code,$region);
+ } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
+ $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
+ //print $seek_region;
+ if ($seek_region < US_OFFSET){
+ $country_code = "";
+ $region = "";
+ } else if ($seek_region < CANADA_OFFSET) {
+ $country_code = "US";
+ $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
+ } else if ($seek_region < WORLD_OFFSET) {
+ $country_code = "CA";
+ $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
+ } else {
+ $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
+ $region = "";
+ }
+ return array ($country_code,$region);
+ }
+}
+
+function geoip_region_by_addr ($gi,$addr) {
+ if ($addr == NULL) {
+ return 0;
+ }
+ $ipnum = ip2long($addr);
+ return _get_region($gi, $ipnum);
+}
+
+function getdnsattributes ($l,$ip){
+ $r = new Net_DNS_Resolver();
+ $r->nameservers = array("ws1.maxmind.com");
+ $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
+ $str = is_object($p->answer[0])?$p->answer[0]->string():'';
+ ereg("\"(.*)\"",$str,$regs);
+ $str = $regs[1];
+ return $str;
+}
+
+?> \ No newline at end of file
diff --git a/mirrors2.php b/mirrors2.php
new file mode 100644
index 000000000..7eb6a94f8
--- /dev/null
+++ b/mirrors2.php
@@ -0,0 +1,73 @@
+<?php
+/**
+*/
+
+// update this list from mirrors.mageia.org
+/* @fixme note to self: brains! */
+$g_mirrors = array(
+ 'China' => array(
+ 'Beijing' => array(
+ 'http://fundawang.lcuc.org.cn/mageia/'
+ )
+ ),
+ 'Czechia' => array(
+ 'Praha' => array(
+ 'http://mageia.supp.name/'
+ ),
+ '?' => array(
+ 'ftp://ftp.sh.cvut.cz/MIRRORS/mageia/',
+ 'http://ftp.sh.cvut.cz/MIRRORS/mageia/'
+ )
+ ),
+ 'Deutschland' => array(
+ 'Erfurt' => array(
+ 'http://ftp.mandrivauser.de/mirrors/Mageia/',
+ 'ftp://ftp.mandrivauser.de/mirrors/Mageia/'
+ ),
+ 'Erlangen' => array(
+ 'http://ftp.uni-erlangen.de/mirrors/Mageia/',
+ 'ftp://ftp.uni-erlangen.de/mirrors/Mageia/'
+ ),
+ 'Esslingen' => array(
+ 'http://ftp-stud.hs-esslingen.de/pub/Mirrors/Mageia/',
+ 'ftp://ftp-stud.hs-esslingen.de/pub/Mirrors/Mageia/'
+ )
+ ),
+ 'France' => array(
+ 'Paris' => array(
+ 'http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/',
+ 'ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/'
+ )
+ ),
+ 'Ελλάδα' => array(
+ 'Ηράκλειον' => array(
+ 'http://ftp.cc.uoc.gr/mirrors/linux/mageia/',
+ 'ftp://ftp.cc.uoc.gr/mirrors/linux/mageia/'
+ )
+ ),
+ 'Schweitz' => array(
+ 'Geneva' => array(
+ 'http://mageia.unige.ch/mirror/'
+ ),
+ 'Lucern' => array(
+ 'ftp://ftp.LinuxCabal.org/pub/mirrors/Mageia/'
+ )
+ ),
+ 'Nederlands' => array(
+ 'Amsterdam' => array(
+ 'ftp://ftp.nluug.nl/pub/os/Linux/distr/mageia/',
+ 'http://ftp.nluug.nl/pub/os/Linux/distr/mageia/'
+ )
+ ),
+ 'Nouvelle Calédonie' => array(
+ 'Nouméa' => array(
+ 'http://mageia.nautile.nc/mageia/'
+ )
+ ),
+ 'USA' => array(
+ 'Durham' => array(
+ 'ftp://distro.ibiblio.org/pub/linux/distributions/mageia/',
+ 'http://distro.ibiblio.org/pub/linux/distributions/mageia/'
+ )
+ )
+);