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

title

Body

[close]

/ -> list_sorted.inc.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    
  10    function list_sorted( $text, $filename, $color , $item_width, $truncate, $sex )
  11    {
  12       global $stringlist;
  13  ?>
  14  
  15      <?php if ($truncate!="no") : ?>
  16  
  17      <table cellspacing="1" cellpadding="0" border="1" bgcolor="#E0E0E0" width="760">
  18        <tr width="760">
  19          <th width="760" colspan="4" bgcolor=<?php echo $color[3]; ?>>&nbsp;<?php echo $text; ?>&nbsp;</th>
  20        </tr>
  21        <?php
  22          if (is_file($filename))
  23          {
  24            $file = fopen( $filename, "r" );
  25            $t_table = array();
  26            $t_table_val = array();
  27            $t_table_count = 0;
  28            if ( flock($file, LOCK_SH))
  29            {
  30              while (!feof($file))
  31              {
  32                $line = fgetcsv( $file, 4096, "|" );
  33                if (($line!="")&&($line!="\r\n")&&($line!="\n")&&($line[0]!=""))
  34                {
  35                  if ($line[0]=="Unknown")
  36                  {
  37                    switch($sex)
  38                    {
  39                      case "he":  $line[0]=$stringlist["unknown_he"];  break;
  40                      case "she": $line[0]=$stringlist["unknown_she"]; break;
  41                      case "it":
  42                      default:    $line[0]=$stringlist["unknown_it"];
  43                                 break;
  44                    };
  45                  };
  46                  array_push( $t_table, $line[0] );
  47                  array_push( $t_table_val, (int)$line[1] );
  48                  $t_table_count += (int)$line[1];
  49                };
  50              };
  51              flock( $file, LOCK_UN );
  52            };
  53            fclose( $file );
  54            array_multisort( $t_table_val, SORT_DESC, SORT_NUMERIC, $t_table, SORT_STRING );
  55            switch ($truncate)
  56            {
  57              case "truncate": $how_many=count($t_table); break;
  58              default: $how_many=$truncate;
  59            };
  60            for( $i=0; $i<$how_many; $i++ )
  61            {
  62  //             echo "<colgroup>";

  63  //             echo "<col width=\"".(250+500-$item_width)."\"></col>";

  64  //             echo "<col width=\"50\"></col>";

  65  //             echo "<col width=\"".(10+$item_width)."\"></col>";

  66  //             echo "<col width=\"50\"></col>";

  67  //             echo "</colgroup>";

  68              $val_proc = round( $t_table_val[$i]*100.0/$t_table_count );
  69              if ( ($truncate=="truncate") && ((int)$val_proc<=0) ) break;
  70              echo "<tr width=\"760\">";
  71              echo "<td width=\"".(150+500-$item_width)."\" align=\"left\">&nbsp;$t_table[$i]&nbsp;</td>";
  72              echo "<td width=\"50\" align=\"right\">&nbsp;$t_table_val[$i]&nbsp;</td>";
  73              $val = round( $item_width*$t_table_val[$i]/$t_table_count );
  74              echo "<td width=\"".(10+$item_width)."\" align=\"left\">&nbsp;<img src=\"".$color[0]."\" width=\"".$val."\" height=\"12\" />&nbsp;</td>";
  75              echo "<td width=\"50\" align=\"right\">&nbsp;".$val_proc."%&nbsp;</td>";
  76              echo "</tr>";
  77            };
  78          };
  79        ?>
  80      </table>
  81              
  82        <?php endif; ?>
  83              
  84    <?php  
  85    };
  86  
  87  ?>


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