isundil 6 years ago
parent
commit
6c04c99f73
4 changed files with 66 additions and 2 deletions
  1. 21 0
      .htconfig.php.sample
  2. 0 2
      README.md
  3. 13 0
      index.php
  4. 32 0
      stats.php

+ 21 - 0
.htconfig.php.sample

@@ -0,0 +1,21 @@
+<?php
+
+define("DB_HOST", "localhost");
+define("DB_PORT", 3306);
+define("DB_NAME", "irc_anope");
+define("DB_USER", "root");
+define("DB_PASS", "");
+
+// DO NOT EDIT BELOW
+
+$dblink = null;
+
+try {
+    global $dblink;
+    $dblink = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_PORT, DB_USER, DB_PASS);
+}
+catch (Exception $e) {
+    echo "Error: (" .$e->getCode() .") " .$e->getMessage();
+    exit();
+}
+?>

+ 0 - 2
README.md

@@ -1,2 +0,0 @@
-# www-irc
-

+ 13 - 0
index.php

@@ -0,0 +1,13 @@
+<?php require("./stats.php"); ?>
+<!DOCTYPE html5>
+<html>
+  <head>
+    <script>
+      <?php if (!isset($_GET["PRERELEASE"])) echo 'document.location.href="/kiwi/";'; ?>
+    </script>
+  </head>
+  <body>
+    <a href="/kiwi">Kiwi service</a>
+<?php printNbUserPerChannelAsTable(); ?>
+  </body>
+</html>

+ 32 - 0
stats.php

@@ -0,0 +1,32 @@
+<?php
+
+require("./.htconfig.php");
+
+function readNbUserPerChannel()
+{
+    global $dblink;
+    $result = array();
+    $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");
+    $userCountPerChan->setFetchMode(PDO::FETCH_OBJ);
+    while ($i = $userCountPerChan->fetch())
+	$result[$i->channel] = $i->nbuser;
+    return $result;
+}
+
+function printNbUserPerChannelAsTable()
+{
+  ?><table>
+      <tr>
+	<th>Channel</th>
+	<th>Connected user</th>
+      </tr>
+      <?php foreach(readNbUserPerChannel() as $channel => $usercount){ ?>
+        <tr>
+	  <td><?php echo $channel; ?></td>
+	  <td><?php echo $usercount; ?></td>
+	</td>
+      <?php } ?>
+      </table><?php
+}
+
+?>