htdocs/index.php
author Dan
Sat, 15 Nov 2008 14:59:51 -0500
changeset 19 eb92dc5d9fb4
parent 15 5e2d1514ccd0
child 20 e2f6e3af9959
permissions -rw-r--r--
Can't believe I never put graphs.php in there.
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
require('../config.php');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
$channels = array_keys($stats_data['messages']);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
$first_channel = $channels[0];
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
$channel = ( isset($_REQUEST['channel']) && isset($stats_data['messages'][$_REQUEST['channel']]) ) ? $_REQUEST['channel'] : $first_channel;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
<html>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
  <head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
    <title><?php echo $nick; ?> - Statistics</title>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
    <style type="text/css">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
    div.footer {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
      font-size: smaller;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
      padding-top: 10px;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
      margin-top: 10px;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
      border-top: 1px solid #aaa;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
    </style>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
  </head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
  <body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
    <div style="float: right;">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
      <p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
        <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
        $tz_display = str_replace('_', ' ', str_replace('/', ': ', $tz));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
        echo 'Time zone: ' . $tz_display . ' [<a href="changetz.php">change</a>]<br />';
15
5e2d1514ccd0 Made stats use multiple files to reduce memory usage
Dan
parents: 11
diff changeset
    29
        echo '<small>The time now is ' . date('H:i:s') . '.<br />Statistics last written to disk at ' . date('H:i:s', stats_last_updated()) . '.</small>';
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
      </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
      <p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
        <big><b>Channels:</b></big><br />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
        <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
          foreach ( $channels as $i => $c )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
            $bold = ( $c == $channel );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
            echo $bold ? '<b>' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
            echo $bold ? '' : '<a href="index.php?channel=' . urlencode($c) . '">';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
            echo $c;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
            echo $bold ? '' : '</a>';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    42
            echo $bold ? '</b>' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    43
            echo $i == count($channels) - 1 ? '' : ' | ';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    44
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    45
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    46
      </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    47
    </div>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    48
    <h1>Active members</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    49
    <p>For the last 1, 5, and 15 minutes:
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    50
        <?php echo count(stats_activity_percent($channel, 1)) . ', ' .
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    51
                   count(stats_activity_percent($channel, 5)) . ', ' .
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    52
                   count(stats_activity_percent($channel, 15)) . ' (respectively)';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    53
        ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    54
        </p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    55
    <h1>Currently active members:</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    56
    <p>These people have posted in the last 3 minutes:</p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    57
    <ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    58
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    59
      $datum = stats_activity_percent($channel, 3);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    60
      $count = stats_message_count($channel, 3);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    61
      if ( empty($datum) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    62
        echo '<li>No recent posts.</li>';
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    63
      foreach ( $datum as $usernick => $pct )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    64
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    65
        $total = round($pct * $count);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    66
        $pct = round(100 * $pct, 1);
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    67
        echo "<li>$usernick - $pct% ($total)</li>\n";
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    68
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    69
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    70
    </ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    71
    <p>Last 20 minutes:</p>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    72
    <ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    73
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    74
      $datum = stats_activity_percent($channel, 20);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    75
      $count = stats_message_count($channel, 20);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    76
      if ( empty($datum) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    77
        echo '<li>No recent posts.</li>';
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    78
      foreach ( $datum as $usernick => $pct )
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    79
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    80
        $total = round($pct * $count);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    81
        $pct = round(100 * $pct, 1);
11
b3fec7467c05 Fixed $nick being overwritten in index
Dan
parents: 8
diff changeset
    82
        echo "<li>$usernick - $pct% ($total)</li>\n";
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    83
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    84
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    85
    </ul>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    86
    <h1>Last 24 hours</h1>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    87
    <img alt="Graph image" src="24hours.php?channel=<?php echo urlencode($channel); ?>" />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    88
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    89
    <div class="footer">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    90
    <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
    91
    </div>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    92
  </body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    93
</head>