Esempio n. 1
0
$connection = mysql_connect($host, $user, $pass);
if ($connection) {
    // the given languages
    $ulangs = $_GET['ulangs'];
    //$url_langs = explode(",", $ulangs);
    // get data from MySQL and save it to array:
    $query = "SELECT tlang, slang FROM `DB2139167`.`geodata`";
    $result = mysql_query($query);
    $data = array();
    $incomes = array();
    $colors = array();
    while ($row = mysql_fetch_object($result)) {
        $slang = $row->slang;
        $tlang = $row->tlang;
        //if($slang == $tlang || !(in_array($slang, $url_langs) && in_array($tlang, $url_langs))){
        if ($slang == $tlang || !link_match($ulangs, $slang, $tlang)) {
            continue;
        }
        // for each language pair exists one array entry:
        // array[AB] = (count(A->B), count(B->A))
        if (array_key_exists($slang . "|" . $tlang, $data)) {
            $data[$slang . "|" . $tlang]['num_ab'] += 1;
            $xtlang = $tlang;
        } elseif (array_key_exists($tlang . "|" . $slang, $data)) {
            $data[$tlang . "|" . $slang]['num_ba'] += 1;
            $xtlang = $slang;
        } else {
            $data[$slang . "|" . $tlang] = array();
            $data[$slang . "|" . $tlang]['seg_a_id'] = $slang;
            $data[$slang . "|" . $tlang]['seg_b_id'] = $tlang;
            $data[$slang . "|" . $tlang]['num_ab'] = 1;
Esempio n. 2
0
<?php

include_once "__dbdata.php";
include_once "langex.php";
$connection = mysql_connect($host, $user, $pass);
if ($connection) {
    $ulangs = $_GET['ulangs'];
    //$url_langs = explode(",", $ulangs);
    $query = "SELECT slang, tlang FROM `DB2139167`.`geodata`";
    $result = mysql_query($query);
    $lmap = array();
    while ($row = mysql_fetch_object($result)) {
        $sl = $row->slang;
        $tl = $row->tlang;
        //if($slang == $tlang || !(in_array($slang, $url_langs) && in_array($tlang, $url_langs))){
        if ($sl == $tl || !link_match($ulangs, $sl, $tl)) {
            continue;
        }
        if (!array_key_exists($sl . "|" . $tl, $lmap)) {
            $lmap[$sl . "|" . $tl] = 1;
        } else {
            ++$lmap[$sl . "|" . $tl];
        }
    }
    while ($l = current($lmap)) {
        $arr = explode("|", key($lmap));
        $lmap[key($lmap)] = $arr[0] . "|" . $arr[1] . "|" . $l . "|" . hashColor($arr[1]);
        next($lmap);
    }
    function sortIt($a, $b)
    {