stats.php 963 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require("./.htconfig.php");
  3. function readNbUserPerChannel()
  4. {
  5. global $dblink;
  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. ?><table>
  16. <tr>
  17. <th>Channel</th>
  18. <th>Connected user</th>
  19. </tr>
  20. <?php foreach(readNbUserPerChannel() as $channel => $usercount){ ?>
  21. <tr>
  22. <td><?php echo $channel; ?></td>
  23. <td><?php echo $usercount; ?></td>
  24. </tr>
  25. <?php } ?>
  26. </table><?php
  27. }
  28. ?>