stats.php 1019 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. function readNbUserPerChannel()
  3. {
  4. require_once("./.htconfig.php");
  5. $dblink = getlink();
  6. $result = array();
  7. $userCountPerChan = $dblink->query("SELECT anope_userstats_chan.channel, count(nickid) as nbuser FROM `anope_userstats_ison` inner join anope_userstats_chan on anope_userstats_chan. chanid=anope_userstats_ison.chanid inner join knacki_official ON knacki_official.channel = anope_userstats_chan.channel group by anope_userstats_chan.chanid order by channel");
  8. $userCountPerChan->setFetchMode(PDO::FETCH_OBJ);
  9. while ($i = $userCountPerChan->fetch())
  10. $result[$i->channel] = $i->nbuser;
  11. return $result;
  12. }
  13. function printNbUserPerChannelAsTable()
  14. {
  15. // FIXME catch error
  16. ?><table>
  17. <tr>
  18. <th>Channel</th>
  19. <th>Connected user</th>
  20. </tr>
  21. <?php foreach(readNbUserPerChannel() as $channel => $usercount){ ?>
  22. <tr>
  23. <td><?php echo $channel; ?></td>
  24. <td><?php echo $usercount; ?></td>
  25. </tr>
  26. <?php } ?>
  27. </table><?php
  28. }
  29. ?>