[ PHPXref.com ] [ Generated: Sun Jul 20 18:52:05 2008 ] [ mroovca stats 0.5.3 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> show_geolocalization.php (source)

   1  <?php
   2  // ************************************************************************

   3  // mroovca stats

   4  // version: 0.5.0 - 28 Feb 2006

   5  // author: przyjazn (MirekW)

   6  // licence: GNU GPL

   7  // ************************************************************************

   8  
   9      if (!$conf_access) { return; };
  10      include_once ( "t_connection.inc.php" );
  11      include_once ( "t_city.inc.php" );
  12  ?>
  13  <?php
  14      $item_width=700;
  15  ?>
  16  <?php
  17  // *****************************************************************

  18  		function getcountry($input)
  19          {
  20              global $stringlist_country;
  21              $output = "";
  22              $output = strrchr( $input, "." );
  23              if ($output === false) { return ""; };
  24              if ( array_key_exists( $output, $stringlist_country ) ) { return $output; }
  25                  else { return ""; };
  26              return "";
  27          }
  28          
  29  // *****************************************************************

  30  		function getsubdomen($input)
  31          {
  32                      $t_subdomen = explode( ".", $input );
  33                      $t_subdomen_count = 0;
  34                      $t_subdomen_count = count( $t_subdomen );
  35  
  36                      $output = "";
  37                      if ($t_subdomen_count>=2)
  38                      {
  39                          $output = ".".$t_subdomen[$t_subdomen_count-2].".".$t_subdomen[$t_subdomen_count-1];
  40                      };
  41                      return $output;
  42          }
  43          
  44  // *****************************************************************

  45  		function getcity($input)
  46          {
  47              global $t_city;
  48              $output = "";
  49                      foreach( $t_city as $value )
  50                      if( eregi( $value[0]."[\.\-]+", $input, $version) )
  51                      {
  52                          $output = $value[1];
  53               break;
  54                      };
  55               
  56                      # additional city recognition - in poland in SDI

  57               # city is written in host name !!

  58               # this same attention as in t_NNNN.php files - if in your country

  59               # is something like it - add it, and send me the php-code

  60                      if ($output=="")
  61                      {
  62                          if( eregi( "sdi\.tpnet\.pl", $input, $version)==TRUE )
  63                          {
  64                              $city_tmp = explode( ".", $input );
  65                              $output = ucwords($city_tmp[1]);
  66                          }
  67                          else $output = "";
  68               };
  69               return $output;
  70          }
  71  
  72  // *****************************************************************

  73  		function getconnection($input)
  74          {
  75              global $t_connection;
  76              $output = "";
  77                      foreach( $t_connection as $value )
  78                        if( eregi( $value[0], $input, $version) )
  79                        {
  80                            $output = $value[1];
  81                            break;
  82                        };
  83                        return $output;
  84          }
  85  
  86  // *****************************************************************

  87  ?>
  88  
  89  
  90          
  91  <?php
  92      // prepare data

  93  
  94      $q = "SELECT clientname, COUNT(*) as counter, clientip FROM ".$settings['dbprefix']."logdata";
  95      $q .= " WHERE id_configure=$conf_id_configure".$conf_q_excluded;
  96      if (!$conf_reload) { $q .= " AND reloaded=0"; };
  97      $q .= " GROUP BY clientname";
  98      $q .= " ORDER BY counter DESC;";
  99      $result = dblib_query( $dbh, $q, $settings["dbresult"] );
 100      $counter = 0;
 101      $max = 1;
 102      $sum = 0;
 103      unset($values);
 104      $values = array();
 105      if ( dblib_isset($result) )
 106      {
 107          while ($row = dblib_fetch_row($result))
 108          {
 109              $values[$counter][0] = $row[0];
 110              $values[$counter][1] = $row[1];
 111              
 112              if (strcmp($row[0],$row[2])!=0) { $values[$counter][2] = getcountry( $row[0] ); } else { $values[$counter][2]=""; };
 113              
 114              if (strcmp($row[0],$row[2])!=0) { $values[$counter][3] = getsubdomen( $row[0] ); } else { $values[$counter][3]=""; };
 115              if ($values[$counter][3]=="") { $values[$counter][3]=$stringlist["unknown_she"]; };
 116              
 117              $values[$counter][4] = getcity( $row[0] );
 118              if ($values[$counter][4]=="") { $values[$counter][4]=$stringlist["unknown_it"]; };
 119              
 120              $values[$counter][5] = getconnection( $row[0] );
 121              if ($values[$counter][5]=="") { $values[$counter][5]=$stringlist["unknown_it"]; };
 122              
 123              if ($row[1]>$max) { $max = $row[1]; };
 124              $sum += $row[1];
 125              ++$counter;
 126          };
 127      };
 128  ?>
 129  
 130  
 131  
 132  <!--
 133  // *************************************************************

 134  // * Countries                                                 *

 135  // *************************************************************

 136  -->
 137  <?php
 138      unset($values2);
 139      $values2 = array();
 140      $counter = 0;
 141      foreach( $values as $row )
 142      {
 143          $values2[$row[2]] += $row[1];
 144      };
 145      array_multisort( $values2, SORT_DESC );
 146  ?>
 147      <tr>
 148          <td align="center">
 149              <br />
 150              <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="<?= $table_width ?>">
 151              <tr>
 152              <th bgcolor=<?php echo $c_yellow[3]; ?> colspan="4">&nbsp;<?= $stringlist["countries"] ?>&nbsp;</th>
 153              </tr>
 154              <?php
 155                  foreach( $values2 as $key => $value )
 156                  {
 157                      $val_proc = round( $value*100.0/$sum, 0 );
 158                      $val = round( $item_width*$value/$sum );
 159                      if ( ($val_proc>0) )
 160                      {
 161                          echo '<tr width="1000">';
 162                          if ($key=="")
 163                          {
 164                              $show = $stringlist["unknown_he"];
 165                          }
 166                          else
 167                          {
 168                              if ( array_key_exists($key,$ht_country_flags) )
 169                              {
 170                                  $img = "<img src=\"gfx/flags_xs/".$ht_country_flags[$key].".gif\" width=\"20\" height=\"13\" alt=\"flag\" align=\"middle\" /> ";
 171                              }
 172                              else
 173                              {
 174                                  $img = "";
 175                              };
 176                              $show = $img."".$stringlist_country[$key]." (".$key.")";
 177                          }; 
 178                          echo '<td width="'.(1000-110-$item_width).'" align="left">&nbsp;'.$show.'&nbsp;</td>';
 179                          echo '<td width="50" align="right">&nbsp;'.$value.'&nbsp;</td>';
 180                          echo '<td width="50" align="right">&nbsp;'.$val_proc.'%&nbsp;</td>';
 181                          echo '<td width="'.(10+$item_width).'" align="left">&nbsp;<img src="'.$c_yellow[0].'" width="'.$val.'" height="12" />&nbsp;</td>';
 182                          echo '</tr>';
 183                      };
 184                  };
 185              ?>
 186              </table>
 187          </td>
 188      </tr>
 189  
 190  
 191  
 192  <!--
 193  // *************************************************************

 194  // * Subdomains                                                *

 195  // *************************************************************

 196  -->
 197  <?php
 198      // prepare data

 199      $values2 = array();
 200      $counter = 0;
 201      foreach( $values as $row )
 202      {
 203          $values2[$row[3]] += $row[1];
 204      };
 205  
 206      array_multisort( $values2, SORT_DESC );
 207  ?>
 208      <tr>
 209          <td align="center">
 210              <br />
 211              <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="<?= $table_width ?>">
 212              <tr>
 213              <th bgcolor=<?php echo $c_yellow[3]; ?> colspan="4">&nbsp;<?= $stringlist["subdomains"] ?>&nbsp;</th>
 214              </tr>
 215              <?php
 216                  foreach( $values2 as $key => $value )
 217                  {
 218                      $val_proc = round( $value*100.0/$sum, 0 );
 219                      $val = round( $item_width*$value/$sum );
 220                      if ( ($key!="") && ($val_proc>0) )
 221                      {
 222                              $country = strrchr( $key, "." );
 223                              if ( $country!="" && array_key_exists($country,$ht_country_flags) )
 224                              {
 225                                  $img = "<img src=\"gfx/flags_xs/".$ht_country_flags[$country].".gif\" width=\"20\" height=\"13\" alt=\"flag\" align=\"middle\" /> ";
 226                              }
 227                              else
 228                              {
 229                                  $img = "";
 230                              };
 231                              $show = $img."".$key;
 232                          echo '<tr width="1000">';
 233                          echo '<td width="'.(1000-110-$item_width).'" align="left">&nbsp;'.$show.'&nbsp;</td>';
 234                          echo '<td width="50" align="right">&nbsp;'.$value.'&nbsp;</td>';
 235                          echo '<td width="50" align="right">&nbsp;'.$val_proc.'%&nbsp;</td>';
 236                          echo '<td width="'.(10+$item_width).'" align="left">&nbsp;<img src="'.$c_yellow[0].'" width="'.$val.'" height="12" />&nbsp;</td>';
 237                          echo '</tr>';
 238                      };
 239                  };
 240              ?>
 241              </table>
 242          </td>
 243      </tr>
 244  
 245  
 246  
 247  <!--
 248  // *************************************************************

 249  // * Cities                                                    *

 250  // *************************************************************

 251  -->
 252  <?php
 253      // prepare data

 254      $values2 = array();
 255      $counter = 0;
 256      foreach( $values as $row )
 257      {
 258          $values2[$row[4]] += $row[1];
 259      };
 260  
 261      array_multisort( $values2, SORT_DESC );
 262  ?>
 263      <tr>
 264          <td align="center">
 265              <br />
 266              <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="<?= $table_width ?>">
 267              <tr>
 268              <th bgcolor=<?php echo $c_yellow[3]; ?> colspan="4">&nbsp;<?= $stringlist["towns"] ?>&nbsp;</th>
 269              </tr>
 270              <?php
 271                  $endloop = false;
 272                  foreach( $values2 as $key => $value )
 273                  {
 274                      $val_proc = round( $value*100.0/$sum, 0 );
 275                      $val = round( $item_width*$value/$sum );
 276                      if ( ($key!="") && ($val_proc>0) )
 277                      {
 278                          echo '<tr width="1000">';
 279                          echo '<td width="'.(1000-110-$item_width).'" align="left">&nbsp;'.$key.'&nbsp;</td>';
 280                          echo '<td width="50" align="right">&nbsp;'.$value.'&nbsp;</td>';
 281                          echo '<td width="50" align="right">&nbsp;'.$val_proc.'%&nbsp;</td>';
 282                          echo '<td width="'.(10+$item_width).'" align="left">&nbsp;<img src="'.$c_yellow[0].'" width="'.$val.'" height="12" />&nbsp;</td>';
 283                          echo '</tr>';
 284                      };
 285                  };
 286              ?>
 287              </table>
 288          </td>
 289      </tr>
 290  
 291  
 292  
 293  <!--
 294  // *************************************************************

 295  // * Connection                                                *

 296  // *************************************************************

 297  -->
 298  <?php
 299      // prepare data

 300      $values2 = array();
 301      $counter = 0;
 302      foreach( $values as $row )
 303      {
 304          $values2[$row[5]] += $row[1];
 305      };
 306  
 307      array_multisort( $values2, SORT_DESC );
 308  ?>
 309      <tr>
 310          <td align="center">
 311              <br />
 312              <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="<?= $table_width ?>">
 313              <tr>
 314              <th bgcolor=<?php echo $c_yellow[3]; ?> colspan="4">&nbsp;<?= $stringlist["connection_type"] ?>&nbsp;</th>
 315              </tr>
 316              <?php
 317                  foreach( $values2 as $key => $value )
 318                  {
 319                      $val_proc = round( $value*100.0/$sum, 0 );
 320                      $val = round( $item_width*$value/$sum );
 321                      if ( ($key!="") && ($val_proc>0) )
 322                      {
 323                          echo '<tr width="1000">';
 324                          echo '<td width="'.(1000-110-$item_width).'" align="left">&nbsp;'.$key.'&nbsp;</td>';
 325                          echo '<td width="50" align="right">&nbsp;'.$value.'&nbsp;</td>';
 326                          echo '<td width="50" align="right">&nbsp;'.$val_proc.'%&nbsp;</td>';
 327                          echo '<td width="'.(10+$item_width).'" align="left">&nbsp;<img src="'.$c_yellow[0].'" width="'.$val.'" height="12" />&nbsp;</td>';
 328                          echo '</tr>';
 329                      };
 330                  };
 331              ?>
 332              </table>
 333          </td>
 334      </tr>
 335  
 336  
 337  
 338  <!--
 339  // *************************************************************

 340  // * Hosts                                                     *

 341  // *************************************************************

 342  -->
 343      <tr>
 344          <td align="center">
 345              <br />
 346              <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="<?= $table_width ?>">
 347              <tr>
 348              <th bgcolor=<?php echo $c_yellow[3]; ?> colspan="4">&nbsp;<?= $stringlist["hosts"] ?>&nbsp;</th>
 349              </tr>
 350              <?php
 351                  $endloop = false;
 352                  $counter = 0;
 353                  foreach( $values as $row )
 354                  {
 355                      $key = $row[0];
 356                      $value = $row[1];
 357                      $val_proc = round( $value*100.0/$sum, 0 );
 358                      $val = round( $item_width*$value/$sum );
 359                      if ( ($key!="") && ($val_proc>0) )
 360                      {
 361                          echo '<tr width="1000">';
 362                          echo '<td width="'.(1000-110-$item_width).'" align="left">&nbsp;'.$key.'&nbsp;</td>';
 363                          echo '<td width="50" align="right">&nbsp;'.$value.'&nbsp;</td>';
 364                          echo '<td width="50" align="right">&nbsp;'.$val_proc.'%&nbsp;</td>';
 365                          echo '<td width="'.(10+$item_width).'" align="left">&nbsp;<img src="'.$c_yellow[0].'" width="'.$val.'" height="12" />&nbsp;</td>';
 366                          echo '</tr>';
 367                      };
 368                      $counter++;
 369                  };
 370              ?>
 371              </table>
 372          </td>
 373      </tr>
 374  
 375  


[ Powered by PHPXref - Served by Debian GNU/Linux ]