Location: PHPKode > projects > D4WStatsLittle - Web Stats System > d4wstatslittle-web-stats-system/Install Without Using Dreamweaver/d4wstatslittle/report/reportes/procedencia-paises.inc.php
<?php
/*
+--------------------------------------------------------------------------
|   D4WStatsLittle v1.1.2 - Developers4Web Web Stats Software
|   ==========================================================
|   by Developers4Web.com
|	D4WStatsLittle is a Trade Mark of Developers4Web
|   Copyright Developers4Web 2005 - 2006. All rights reserved.
|   English:
|       http://stats-service.developers4web.com
|   Español:
|       http://www.developers4web.com
|   ========================================
|   optimized by Trio Solutions
|   Dreamweaver Extensions and Web Development Components 
|   English:
|       http://components.developers4web.com
|   Español:
|       http://componentes.developers4web.com
|   ========================================
|   Web: http://www.d4wstats.com
|   Date: Tuesday, February 20, 2006
|   Email: info (at) developers4web (dot) com
|	License Type: D4WSTATSLITTLE is NOT Open Source Software and Limitations Apply 
|   Licence Info: /d4wstatslittle/license.txt
+--------------------------------------------------------------------------
*/
?>
<div>
<div style="margin-bottom: 2px;color: #666666;">
<h3><?php echo ST_MSG_PROCEDENCE; ?></h3>
</div>
<?php
 require "./menu.php";


 $report = readDatabaseII("report-countries.php");

 if ($report != '')
 {
  
 function cmp_vr ($a, $b) {
     if ($a["vr"] == $b["vr"]) return 0;
     return ($a["vr"] > $b["vr"]) ? -1 : 1;
 }
 function cmp_vs ($a, $b) {
     if ($a["vs"] == $b["vs"]) return 0;
     return ($a["vs"] > $b["vs"]) ? -1 : 1;
 }
 function cmp_h ($a, $b) {
     if ($a["h"] == $b["h"]) return 0;
     return ($a["h"] > $b["h"]) ? -1 : 1;
 }  

 $vr_day = $report["day"];
 $vr_month = $report["month"];
 $vr_total = $report["total"];

 $vs_day = $report["day"];
 $vs_month = $report["month"];
 $vs_total = $report["total"];
 
 $h_day = $report["day"];
 $h_month = $report["month"];
 $h_total = $report["total"];  

 uasort($vr_day, "cmp_vr");
 uasort($vr_month, "cmp_vr");
 uasort($vr_total, "cmp_vr");
  
 uasort($vs_day, "cmp_vs");
 uasort($vs_month, "cmp_vs");
 uasort($vs_total, "cmp_vs");
  
 uasort($h_day, "cmp_h");
 uasort($h_month, "cmp_h");
 uasort($h_total, "cmp_h");

 define ('MAX_PRINT_ROWS', 10);

 // para calculo del mes
 $total_visitas_d = 0;
 $total_visitantes_d = 0;
 $page_views_d = 0;
 foreach ($report["day"] as $item => $value)
 {
     $total_visitas_d += $value["vs"];
     $total_visitantes_d += $value["vr"];
     $page_views_d += $value["h"];
 }
 
 // para calculo del mes
 $total_visitas_m = 0;
 $total_visitantes_m = 0;
 $page_views_m = 0;
 foreach ($report["month"] as $item => $value)
 {
     $total_visitas_m += $value["vs"];
     $total_visitantes_m += $value["vr"];
     $page_views_m += $value["h"];
 }
 
 // para calculos totales
 $total_visitas = 0;
 $total_visitantes = 0;
 $page_views = 0;
 foreach ($report["total"] as $item => $value)
 {
     $total_visitas += $value["vs"];
     $total_visitantes += $value["vr"];
     $page_views += $value["h"];
 }

 
// more code....
$content = array();
$total = 0 ;
for ($i=0; $i<10;$i++)
{
    $content [$i]['name']='a';
    $content [$i]['value']=4*$i + 5;
    $content [$i]['color']='ff0000';//$color[($i-1) % 16][0];
    $total += $i;
}

for ($i=0; $i<10;$i++)
{
    $content [$i]['name']='a';
    $content [$i]['value']=round($i/$total*100,2);
    $content [$i]['color']=$color[($i-1) % 16][0];
}



?>
<table class="tableresume" width="600">
   <tr><td colspan="3" class="tdheadslow"><?php echo ST_MSG_ORIGEN_BY_COUNTRY_TODAY; ?></td></tr>
 <tr>
  <td>
   <table class="tableresume" width="199">
   <tr><td class="tdhead" colspan="2" nowrap><?php echo ST_MSG_COUNTRY_VISITORS; ?></td><td class="tdhead">#</td><td class="tdhead">%</td></tr>
   <?php
     $i = 0;
     $count = 0;
     $total = $total_visitantes_d/100;
     foreach ($vr_day as $item => $value)
     { 
         $i++;
         if ($i % 2 == 0)
             echo '<tr class="tr2">';
         else  
             echo '<tr class="tr1">';
         $count += $value["vr"];
         $percent = round($value["vr"]/$total,2);
         $content1 [$i-1]['name']= $countryname[$item];
         $content1 [$i-1]['value']= $percent;
         $content1 [$i-1]['color']= $color[($i-1) % 16][0];
         
         echo "<td width=\"1%\" bgcolor=\"#".$color[($i-1) % 16][0]."\">&nbsp;</td><td>".$countryname[$item]. "</td><td align=\"center\">".$value["vr"]."</td><td align=\"center\">".$percent."%</td></tr>";
         if ($i == MAX_PRINT_ROWS)
             break;
     }
     if ($i!=0)
     {
         echo "<tr class=\"tr1\"><td bgcolor=\"#dddddd\">&nbsp;</td><td>".ST_MSG_OTHERS2."</td><td align=\"center\">".(round((($total*100) - $count)))."</td><td align=\"center\">".round((($total*100) - $count)/$total,2)."%</td></tr>";
         echo "<tr ><td colspan=\"4\" class=\"tdhead\" >".ST_MSG_GRAPHIC."</td></tr>";
         echo "<tr class=\"tr1\"><td colspan=\"4\"  style=\"padding-left:30px;\">".ChartPie($content1, 100,'','','')."</td></tr>";
     }
   ?>
   </table>
  </td> 
  <td>
   <table class="tableresume" width="198">
   <tr><td class="tdhead" colspan="2"><?php echo ST_MSG_COUNTRY_VISITS; ?></td><td class="tdhead">#</td><td class="tdhead">%</td></tr>
   <?php
     $i = 0;
     $count = 0;
     $total = $total_visitas_d/100;
     foreach ($vs_day as $item => $value)
     { 
         $i++;
         if ($i % 2 == 0)
             echo '<tr class="tr2">';
         else  
             echo '<tr class="tr1">';
         $count += $value["vs"];
         $percent = round($value["vs"]/$total,2);
         $content1 [$i-1]['name']= $countryname[$item];
         $content1 [$i-1]['value']= $percent;
         $content1 [$i-1]['color']= $color[($i-1) % 16][0];
         
         echo "<td width=\"1%\" bgcolor=\"#".$color[($i-1) % 16][0]."\">&nbsp;</td><td>".$countryname[$item]. "</td><td align=\"center\">".$value["vs"]."</td><td align=\"center\">".$percent."%</td></tr>";
         if ($i == MAX_PRINT_ROWS)
             break;
     }
     if ($i!=0)
     {
         echo "<tr class=\"tr1\"><td bgcolor=\"#dddddd\">&nbsp;</td><td>".ST_MSG_OTHERS2."</td><td align=\"center\">".(round((($total*100) - $count)))."</td><td align=\"center\">".round((($total*100) - $count)/$total,2)."%</td></tr>";
         echo "<tr ><td colspan=\"4\" class=\"tdhead\" >".ST_MSG_GRAPHIC."</td></tr>";
         echo "<tr class=\"tr1\"><td colspan=\"4\"  style=\"padding-left:30px;\">".ChartPie($content1, 100,'','','')."</td></tr>";
     }
   ?>
   </table>
  </td>
  <td> 
   <table class="tableresume" width="199">
   <tr><td class="tdhead" colspan="2"><?php echo ST_MSG_COUNTRY_PAGES; ?></td><td class="tdhead">#</td><td class="tdhead">%</td></tr>
   <?php
     $i = 0;
     $count = 0;
     $total = $page_views_d/100;
     foreach ($h_day as $item => $value)
     { 
         $i++;
         if ($i % 2 == 0)
             echo '<tr class="tr2">';
         else  
             echo '<tr class="tr1">';
         $count += $value["h"];
         $percent = round($value["h"]/$total,2);
         $content1 [$i-1]['name']= $countryname[$item];
         $content1 [$i-1]['value']= $percent;
         $content1 [$i-1]['color']= $color[($i-1) % 16][0];
         
         echo "<td width=\"1%\" bgcolor=\"#".$color[($i-1) % 16][0]."\">&nbsp;</td><td>".$countryname[$item]. "</td><td align=\"center\">".$value["h"]."</td><td align=\"center\">".$percent."%</td></tr>";
         if ($i == MAX_PRINT_ROWS)
             break;
     }
     if ($i!=0)
     {
         echo "<tr class=\"tr1\"><td bgcolor=\"#dddddd\">&nbsp;</td><td>".ST_MSG_OTHERS2."</td><td align=\"center\">".(round((($total*100) - $count)))."</td><td align=\"center\">".round((($total*100) - $count)/$total,2)."%</td></tr>";
         echo "<tr ><td colspan=\"4\" class=\"tdhead\" >".ST_MSG_GRAPHIC."</td></tr>";
         echo "<tr class=\"tr1\"><td colspan=\"4\"  style=\"padding-left:30px;\">".ChartPie($content1, 100,'','','')."</td></tr>";
     }
   ?>
   </table>
  </td> 
 </tr>
 
 <tr><td colspan="3" class="tdheadslow"><?php echo ST_MSG_ORIGEN_BY_COUNTRY_MONTH; ?></td></tr>
 <tr>
  <td colspan="3">
   <?php echo VP_UPGRADE; ?>
  </td> 
 </tr> 
 
 <tr><td colspan="3" class="tdheadslow"><?php echo ST_MSG_ORIGEN_BY_COUNTRY_TOTALS; ?></td></tr>
 <tr>
  <td colspan="3">
   <?php echo VP_UPGRADE; ?>
  </td> 
 </tr>
 
 
  
</table>

<?php }  ?> 
</div>
Return current item: D4WStatsLittle - Web Stats System