Exemplo n.º 1
0
if (!$_GET['not_json']) {
    header('Content-Type: application/x-json;charset=utf-8');
}
header("Access-Control-Allow-Origin: *");
/*
$_POST['c']='US';
$_POST['src']=0;
*/
$country_names = getCountryNames();
$other_flow = array();
if ($_POST['src']) {
    $flows = getFlowsFrom($_POST['c'], 10, "`qta` DESC");
    $index = 1;
    $other_flow = getFlowFromTo($_POST['c'], $_POST['o']);
} else {
    $flows = getFlowsTo($_POST['c'], 10, "`qta` DESC");
    $index = 0;
    $other_flow = getFlowFromTo($_POST['o'], $_POST['c']);
}
if ($_POST['o']) {
    //var_export($other_flow);
    //var_export($flows);
    if (!in_array($other_flow, $flows)) {
        array_push($flows, array($other_flow[0], $other_flow[1], $other_flow[2], 1));
    }
}
$population = getPopulation(2010, $_POST['c']);
$str .= "<h2><a href=\"#" . ($_POST['src'] ? 'f' : 't') . "_" . $_POST['c'] . "\" id=\"" . ($_POST['src'] ? 'from' : 'to') . "_" . $_POST['c'] . "\" title=\"" . $country_names[$_POST['c']] . "\">" . $country_names[$_POST['c']] . "</a></h2><h3>Population: <b>" . number_format($population[$_POST['c']], 0, "", ",") . "</b></h3><a href=\"#\" class=\"close\" rel=\"" . ($_POST['src'] ? 'from' : 'to') . "_" . $_POST['c'] . "\">hide</a>";
$migrants = $index ? getMigrationTotalFrom(null, $_POST['c']) : getMigrationTotalTo(null, $_POST['c']);
$perc = getSimplePercentageOnPopulation($migrants, $_POST['c']);
$str .= "<h3>" . ($index ? 'E' : 'Im') . "migrants: <b>" . number_format($migrants, 0, "", ",") . "</b></h3>";
Exemplo n.º 2
0
	//if(!$people[$row['src']])
	//	$people[$row['src']]=array();
	//$people[$row['src']][$row['dst']]=$row['qta'];
	array_push($people, array($row['src'],$row['dst'],round($row['qta'])));
}
//shuffle($people);

$money=array();

mysql_free_result($result);
mysql_close($link);

echo json_encode(array('people'=>$people,'money'=>$money));
*/
$max = 0;
$c = getFlowsTo('IT');
//var_export($c);
$new_flows = array();
foreach ($c as $flow) {
    $f = $flow[2];
    /*
    if(!$new_flows[$flow[0]])
    	$new_flows[$flow[0]]=array();
    array_push($new_flows[$flow[0]],array('f'=>$f,'to'=>$flow[1]));
    echo "adding $f from {$flow[0]} to {$flow[1]}\n";
    */
    $max = max($f, $max);
}
//var_export($new_flows);
$tm = array();
foreach ($c as $flow) {