$max_sum = $row[2]; $i = 1; #$sql=$sql1." and country!='EU' and country!='AP' ".$sql2; $sql = $sql1 . $sql2; $ret_p = ""; $ret_m = ""; $ret_t = ""; $res = $DB->Execute($sql); foreach ($res as $row) { if ($row['ccc'] == 'EU' || $row['ccc'] == 'AP') { continue; } # if( $plus==0 ) $plus=1; # if( $minus==0 ) $minus=1; // print $row[$field]."\n"; if (is_EU($row['ccc'])) { $plus += $eu_plus; $minus += $eu_minus; } // if( is_AP($row['country']) ) $count+=$eu; $plus = $row['plus'] > $max_plus ? $max_plus : $row['plus']; $minus = $row['minus'] > $max_minus ? $max_minus : $row['minus']; # if( $plus>$max_plus ) $plus=$max_plus; # if( $minus>$max_minus ) $minus=$max_minus; if ($type == "table") { print "{$i}\t{$date1}\t{$date2}\t\"reg-{$row['region']}\"\t\"{$row['ccc']}\"\t{$plus}\t{$minus}\t" . ($plus - $minus) . "\n"; } else { if ($plus == 0) { $plus = 1; } if ($minus == 0) {
$date = $argv[1]; //="count"; $row = $DB->GetRow("SELECT max(size),max(count) FROM\n\t\t\t(select sum(size) as size, sum(count) as count from ipv4_counts_country where on_date='2009-04-23' group by country) d"); $max_size = log($row[0], 2); $max_count = log($row[1], 2); $sql1 = "\nselect country,name,sum(count) as count ,sum(size) as size, sum(size)/sum(count) as ratio from ipv4_counts_country i\nright join countries c on i.country=c.code2\nwhere on_date='{$date}'\n"; $sql2 = "\ngroup by country,name\norder by size desc\n"; $sql = $sql1 . " and country='EU' " . $sql2; $res = $DB->Execute($sql); $row = $res->FetchRow(); $eu = array("count" => $row['count'], "size" => $row['size']); $ret_c = ""; $ret_s = ""; $sql = $sql1 . " and country!='EU' and country!='AP' " . $sql2; $res = $DB->Execute($sql); foreach ($res as $row) { $count = $row['count']; $size = $row['size']; if (is_EU($row['country'])) { $count += $eu['count']; $size += $eu['size']; } $ret_c .= "encodedPolygon_{$row['country']}.setFillStyle({color:'#" . hsb(240 - 240 * log($count, 2) / $max_count) . "',opacity:0.7});\n"; $ret_s .= "encodedPolygon_{$row['country']}.setFillStyle({color:'#" . hsb(240 - 240 * log($size, 2) / $max_size) . "',opacity:0.7});\n"; } print "function size" . str_replace("-", "_", $date) . "() {\n"; print $ret_s; print "}\n"; print "function count" . str_replace("-", "_", $date) . "() {\n"; print $ret_c; print "}\n";