htdocs/index.php
author Dan
Sun, 07 Dec 2008 17:54:29 -0500
changeset 33 c3179049f670
parent 20 e2f6e3af9959
child 34 a8daa2016cf1
permissions -rw-r--r--
Spacing typo. Nothing more.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     1
<?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     2
require('../stats-fe.php');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     3
require('../timezone.php');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
20
e2f6e3af9959 Stats now uses MySQL backend
Dan
parents: 15
diff changeset
     5
$channel_list = stats_channel_list();
e2f6e3af9959 Stats now uses MySQL backend
Dan
parents: 15
diff changeset
     6
$first_channel = $channel_list[0];
e2f6e3af9959 Stats now uses MySQL backend
Dan
parents: 15
diff changeset
     7
$channel = ( isset($_REQUEST['channel']) && in_array($_REQUEST['channel'], $channel_list) ) ? $_REQUEST['channel'] : $first_channel;
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
<html>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
  <head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
    <title><?php echo $nick; ?> - Statistics</title>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
    <style type="text/css">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
    div.footer {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
      font-size: smaller;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
      padding-top: 10px;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
      margin-top: 10px;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
      border-top: 1px solid #aaa;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
    </style>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
  </head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
  <body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
    <div style="float: right;">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
      <p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
        <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
        $tz_display = str_replace('_', ' ', str_replace('/', ': ', $tz));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
        echo 'Time zone: ' . $tz_display . ' [<a href="changetz.php">change</a>]<br />';
20
e2f6e3af9959 Stats now uses MySQL backend
Dan
parents: 15
diff changeset
    28
        echo '<small>The time now is ' . date('H:i:s') . '.<br />Statistics now updated constantly (see <a href="news.php">news</a>)</small>';
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
      </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
      <p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
        <big><b>Channels:</b></big><br />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
        <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
          foreach ( $channels as $i => $c )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
            $bold = ( $c == $channel );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
            echo $bold ? '<b>' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
            echo $bold ? '' : '<a href="index.php?channel=' . urlencode($c) . '">';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
            echo $c;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
            echo $bold ? '' : '</a>';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
            echo $bold ? '</b>' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    42
            echo $i == count($channels) - 1 ? '' : ' | ';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    43
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    44
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    45
      </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    46
    </div>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    47
    <h1>Active members</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    48
    <p>For the last 1, 5, and 15 minutes:
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    49
        <?php echo count(stats_activity_percent($channel, 1)) . ', ' .
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    50
                   count(stats_activity_percent($channel, 5)) . ', ' .
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    51
                   count(stats_activity_percent($channel, 15)) . ' (respectively)';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    52
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    53
        </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    54
    <h1>Currently active members:</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    55
    <p>These people have posted in the last 3 minutes:</p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    56
    <ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    57
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    58
      $datum = stats_activity_percent($channel, 3);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    59
      $count = stats_message_count($channel, 3);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    60
      if ( empty($datum) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    61
        echo '<li>No recent posts.</li>';
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    62
      foreach ( $datum as $usernick => $pct )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    63
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    64
        $total = round($pct * $count);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    65
        $pct = round(100 * $pct, 1);
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    66
        echo "<li>$usernick - $pct% ($total)</li>\n";
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    67
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    68
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    69
    </ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    70
    <p>Last 20 minutes:</p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    71
    <ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    72
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    73
      $datum = stats_activity_percent($channel, 20);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    74
      $count = stats_message_count($channel, 20);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    75
      if ( empty($datum) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    76
        echo '<li>No recent posts.</li>';
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    77
      foreach ( $datum as $usernick => $pct )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    78
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    79
        $total = round($pct * $count);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    80
        $pct = round(100 * $pct, 1);
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    81
        echo "<li>$usernick - $pct% ($total)</li>\n";
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    82
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    83
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    84
    </ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    85
    <h1>Last 24 hours</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    86
    <img alt="Graph image" src="24hours.php?channel=<?php echo urlencode($channel); ?>" />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    87
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    88
    <div class="footer">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    89
    <b><?php echo $nick; ?> is a privacy-respecting bot.</b> <a href="privacy.php">Read about what information <?php echo $nick; ?> collects</a>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    90
    </div>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    91
  </body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    92
</head>