<?php

    include("config.php");
    
    $irpg_page_title = "Liste des joueurs";
    
    include("header.php");
    
    include("commonfunctions.php");

    $file = file($irpg_db);
    unset($file[0]);
    if (!$_GET['sort'] ||
        (($_GET['sort'] != "cmp_level_asc") &&
        ($_GET['sort'] != "cmp_level_desc") &&
        ($_GET['sort'] != "cmp_isadmin_asc") &&
        ($_GET['sort'] != "cmp_isadmin_desc") &&
        ($_GET['sort'] != "cmp_alignment_asc") &&
        ($_GET['sort'] != "cmp_alignment_desc") &&
        ($_GET['sort'] != "cmp_ttl_asc") &&
        ($_GET['sort'] != "cmp_ttl_desc") &&
        ($_GET['sort'] != "cmp_pen_asc") &&
        ($_GET['sort'] != "cmp_pen_desc") &&
        ($_GET['sort'] != "cmp_lastlogin_asc") &&
        ($_GET['sort'] != "cmp_lastlogin_desc") &&
        ($_GET['sort'] != "cmp_created_asc") &&
        ($_GET['sort'] != "cmp_created_desc") &&
        ($_GET['sort'] != "cmp_idled_asc") &&
        ($_GET['sort'] != "cmp_idled_desc") &&
        ($_GET['sort'] != "cmp_user_asc") &&
        ($_GET['sort'] != "cmp_user_desc") &&
        ($_GET['sort'] != "cmp_online_asc") &&
        ($_GET['sort'] != "cmp_online_desc") &&
        ($_GET['sort'] != "cmp_uhost_asc") &&
        ($_GET['sort'] != "cmp_uhost_desc") &&
        ($_GET['sort'] != "cmp_sum_asc") &&
        ($_GET['sort'] != "cmp_sum_desc"))) $_GET['sort'] = "cmp_level_desc";
    usort($file,$_GET['sort']);
?>
    <table border=1 cellpadding=2 cellspacing=2 cols="32" rows="<?php print count($file); ?>">
      <tr>
        <th NOWRAP>
          Pseudo
          (<a href="db.php?sort=cmp_user_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_user_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Niveau
          (<a href="db.php?sort=cmp_level_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_level_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Admin
          (<a href="db.php?sort=cmp_isadmin_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_isadmin_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>Profession</th>
        <th NOWRAP>
          Prochain Niv.
          (<a href="db.php?sort=cmp_ttl_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_ttl_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Nick!User@Host
          (<a href="db.php?sort=cmp_uhost_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_uhost_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          En ligne
          (<a href="db.php?sort=cmp_online_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_online_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Temps d'inactiv&eacute; total
          (<a href="db.php?sort=cmp_idled_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_idled_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>X Pos</th>
        <th NOWRAP>Y Pos</th>
        <th NOWRAP>P&eacute;n. Mesg</th>
        <th NOWRAP>P&eacute;n. Nick</th>
        <th NOWRAP>P&eacute;n. Part</th>
        <th NOWRAP>P&eacute;n. Kick</th>
        <th NOWRAP>P&eacute;n. Quit</th>
        <th NOWRAP>P&eacute;n. Qu&ecirc;te</th>
        <th NOWRAP>P&eacute;n. Logout</th>
        <th NOWRAP>
          Total Pen.
          (<a href="db.php?sort=cmp_pen_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_pen_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Date Cr&eacute;ation
          (<a href="db.php?sort=cmp_created_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_created_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Derni&egrave;re connex.
          (<a href="db.php?sort=cmp_lastlogin_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_lastlogin_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>Arme bourrin</th>
        <th NOWRAP>Arme sniper</th>
        <th NOWRAP>Rune Vie</th>
        <th NOWRAP>Rune For</th>
        <th NOWRAP>Rune Pre</th>
        <th NOWRAP>Rune Int</th>
        <th NOWRAP>V&eacute;hicule</th>
        <th NOWRAP>Bouffe</th>
        <th NOWRAP>Inutile</th>
        <th NOWRAP>Jouet</th>
        <th NOWRAP>
          Total
          (<a href="db.php?sort=cmp_sum_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_sum_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
        <th NOWRAP>
          Cot&eacute;
          (<a href="db.php?sort=cmp_alignment_asc">
             <img src="up.png" border="0">
           </a>
           /
          <a href="db.php?sort=cmp_alignment_desc">
             <img src="down.png" border="0">
          </a>)
        </th>
      </tr>
<?php
    foreach ($file as $line) {
      list($user,,$isadmin,$level,$class,$secs,,$uhost,$online,$idled,$x,$y,
           $pen['mesg'],
           $pen['nick'],
           $pen['part'],
           $pen['kick'],
           $pen['quit'],
           $pen['quest'],
           $pen['logout'],
           $created,
           $lastlogin,
           $item['amulet'],
           $item['charm'],
           $item['helm'],
           $item['boots'],
           $item['gloves'],
           $item['ring'],
           $item['leggings'],
           $item['shield'],
           $item['tunic'],
           $item['weapon'],
           $alignment,
          ) = explode("\t",trim($line));
      $class = str_replace("<","&lt;",$class);
      $user = str_replace("<","&lt;",$user);
      $class = str_replace(">","&gt;",$class);
      $user = str_replace(">","&gt;",$user);
      $sum = 0;
      foreach ($item as $k => $v) $sum += $v;
      $pentot = 0;
      foreach ($pen as $k => $v) $pentot += $v;
      echo "      <tr>\n".
           "        <td nowrap>$user</td>\n".
           "        <td>$level</td>\n".
           "        <td>".($isadmin?"Oui":"Non")."</td>\n".
           "        <td nowrap>$class</td>\n".
           "        <td nowrap>".duration($secs)."</td>\n".
           "        <td nowrap>$uhost</td>\n".
           "        <td>".(($online == 1) ? "Oui" : "Non")."</td>\n".
           "        <td nowrap>".duration($idled)."</td>\n".
           "        <td nowrap>$x</td>\n".
           "        <td nowrap>$y</td>\n".
           "        <td nowrap>".duration($pen['mesg'])."</td>\n".
           "        <td nowrap>".duration($pen['nick'])."</td>\n".
           "        <td nowrap>".duration($pen['part'])."</td>\n".
           "        <td nowrap>".duration($pen['kick'])."</td>\n".
           "        <td nowrap>".duration($pen['quit'])."</td>\n".
           "        <td nowrap>".duration($pen['quest'])."</td>\n".
           "        <td nowrap>".duration($pen['logout'])."</td>\n".
           "        <td nowrap>".duration($pentot)."</td>\n".
           "        <td nowrap>".strftime($dateformat,$created)."</td>\n".
           "        <td nowrap>".strftime($dateformat,$lastlogin)."</td>\n".
           "        <td>".$item['gloves']."</td>\n".
           "        <td>".$item['weapon']."</td>\n".
           "        <td>".$item['tunic']."</td>\n".
           "        <td>".$item['leggings']."</td>\n".
           "        <td>".$item['shield']."</td>\n".
           "        <td>".$item['helm']."</td>\n".
           "        <td>".$item['boots']."</td>\n".
           "        <td>".$item['charm']."</td>\n".
           "        <td>".$item['ring']."</td>\n".
           "        <td>".$item['amulet']."</td>\n".
           "        <td>$sum</td>\n".
           "        <td>".($alignment=='e'?"Sadique":($alignment=='n'?"Nain-d&eacute;ci":"Brave"))."</td>\n".
           "      </tr>\n";
    }

    echo('
    </table>
    ');
    include("footer.php");
?>
