<?php 
include('protector.php');
include('header.php');
?>
<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>


  <p align="center" class="style2" style="margin-left: 20">&nbsp;</p>
  <p align="center" class="style2" style="margin-left: 20"><font face="Arial" size="4">Provedores disponíveis</font></p>
  <table width="919"  border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="16"><img src="images/top_lef.gif" alt="f" width="16" height="16" /></td>
      <td height="16" background="images/top_mid.gif"><img src="images/top_mid.gif" alt="g" width="16" height="16" /></td>
      <td width="24"><img src="images/top_rig.gif" alt="h" width="24" height="16" /></td>
    </tr>
    <tr>
      <td width="16" background="images/cen_lef.gif"><img src="images/cen_lef.gif" alt="d" width="16" height="11" /></td>
      <td align="center" valign="middle" bgcolor="#FFFFFF"><font face="Arial" size="2" color="#000000">
  
  <table width="80%"  border="1" cellpadding="0" cellspacing="0" align="center">
  <tr bgcolor="#2c2f34">
    <td width="17%"><div align="center"><font color="#e2e2e2" size="2" face="Arial">ID</font></div></td>
    <td width="16%"><div align="center"><font color="#e2e2e2" size="2" face="Arial">CAID</font></div></td>
    <td width="53%"><div align="center"><font color="#e2e2e2" size="2" face="Arial">Nome</font></div></td>
    <td width="14%"><div align="center"><font color="#e2e2e2" size="2" face="Arial">Cartões</font></div></td>
  </tr>
<?php
if (file_exists($gbox_path.'share.info') && file_exists($gbox_path.'ident.info'))
{
   $cards = read2array($gbox_path.'share.info');
   unset($cards[count($cards)-1]);
   echo "<h4><div align=\"center\">".count($cards).' cartões online.</div></h4>';

   foreach($cards as $card){
     $elms = explode(' ',$card);
	 $provs[$elms[5]]['id'] = $elms[5];
	 $provs[$elms[5]]['cnt']=$provs[$elms[5]]['cnt']+1;
   }
   $ident = read2array($gbox_path.'ident.info');
   unset($ident[count($ident)-1]);
   foreach ($ident as $id){
     $names = explode(';',$id);
     $ids[$names[0]]['id'] = $names[0];
     $ids[$names[0]]['name'] = $names[1];
   }
   if (empty($provs)){
     echo "<tr><td colspan=4><div align=\"center\">Nenhum provedor encontrado.</div></td></tr>";
   }
   foreach($provs as $prov){
   //print_r($prov);
   echo "<tr>";
    echo "<td><div align=\"center\">".substr($prov['id'],4)."&nbsp;</div></td>";
    echo "<td><div align=\"center\">".substr($prov['id'],0,4)."&nbsp;</div></td>";
	if (isset($ids[$prov['id']]['name']))
    echo "<td><div align=\"center\">".$ids[$prov['id']]['name']."&nbsp;</div></td>";
	else
    echo "<td><div align=\"center\">&nbsp;</div></td>";
    echo "<td><div align=\"center\">".$prov['cnt']."&nbsp;</div></td>";
   echo "</tr>";

   }
}
else
  echo "<tr><td colspan=4><div align=\"center\">O ficheiro 'share.info' e/ou 'share.onl' não foi encontrado.</div></td></tr>";
  ?>
  </table>
  </font><br />
            </p></td><td width="24" background="images/cen_rig.gif"><img src="images/cen_rig.gif" alt="e" width="24" height="11" /></td>
    </tr>
    <tr>
      <td width="16" height="16"><img src="images/bot_lef.gif" alt="a" width="16" height="16" /></td>
      <td height="16" background="images/bot_mid.gif"><img src="images/bot_mid.gif" alt="b" width="16" height="16" /></td>
      <td width="24" height="16"><img src="images/bot_rig.gif" alt="c" width="24" height="16" /></td>
    </tr>
  </table>
  <p style="margin-left: 20">
  </p>

&nbsp;
&nbsp;
&nbsp;
&nbsp;
      
<?php 
include('footer.php'); 
?>